4 /// \brief Header file that describes the resource system.
6 /// \copyright GNU GPLv2 or any later version.
8 #include <common/resources.qh>
10 // ============================ Public API ====================================
12 /// \brief Returns the maximum amount of the given resource.
13 /// \param[in] e Entity to check.
14 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
15 /// \return Maximum amount of the given resource.
16 float GetResourceLimit(entity e, int resource_type);
18 /// \brief Returns the current amount of resource the given entity has.
19 /// \param[in] e Entity to check.
20 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
21 /// \return Current amount of resource the given entity has.
22 float GetResourceAmount(entity e, int resource_type);
24 /// \brief Sets the current amount of resource the given entity will have.
25 /// \param[in,out] e Entity to adjust.
26 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
27 /// \param[in] amount Amount of resource to set.
28 /// \return No return.
29 void SetResourceAmount(entity e, int resource_type, float amount);
31 /// \brief Gives an entity some resource.
32 /// \param[in,out] receiver Entity to give resource to.
33 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
34 /// \param[in] amount Amount of resource to give.
35 /// \return No return.
36 void GiveResource(entity receiver, int resource_type, float amount);
38 /// \brief Gives an entity some resource but not more than a limit.
39 /// \param[in,out] receiver Entity to give resource to.
40 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
41 /// \param[in] amount Amount of resource to give.
42 /// \param[in] limit Limit of resources to give.
43 /// \return No return.
44 void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
47 /// \brief Takes an entity some resource.
48 /// \param[in,out] receiver Entity to take resource from.
49 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
50 /// \param[in] amount Amount of resource to take.
51 /// \return No return.
52 void TakeResource(entity receiver, int resource_type, float amount);
54 /// \brief Takes an entity some resource but not less than a limit.
55 /// \param[in,out] receiver Entity to take resource from.
56 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
57 /// \param[in] amount Amount of resource to take.
58 /// \param[in] limit Limit of resources to take.
59 /// \return No return.
60 void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
63 /// \brief Gives to or takes from an entity resource.
64 /// \param[in,out] receiver Entity to give or take resource.
65 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
66 /// \param[in] amount Amount of resource to give or take.
67 /// \return No return.
68 void GiveOrTakeResource(entity receiver, int resource_type, float amount);
70 /// \brief Gives to or takes from an entity resource but not more/less than a limit.
71 /// \param[in,out] receiver Entity to give or take resource.
72 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
73 /// \param[in] amount Amount of resource to give or take.
74 /// \param[in] limit Limit of resources to give or take.
75 /// \return No return.
76 void GiveOrTakeResourceWithLimit(entity receiver, int resource_type, float amount,
79 // ===================== Legacy and/or internal API ===========================
81 /// \brief Converts an entity field to resource type.
82 /// \param[in] resource_field Entity field to convert.
83 /// \return Resource type (a RESOURCE_* constant).
84 int GetResourceType(.float resource_field);
86 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
87 /// \param[in] resource_type Type of the resource.
88 /// \return Entity field for that resource.
89 .float GetResourceField(int resource_type);