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] res_type Type of the resource (a RES_* constant).
15 /// \return Maximum amount of the given resource.
16 float GetResourceLimit(entity e, int res_type);
18 /// \brief Returns the current amount of resource the given entity has.
19 /// \param[in] e Entity to check.
20 /// \param[in] res_type Type of the resource (a RES_* constant).
21 /// \return Current amount of resource the given entity has.
22 float GetResource(entity e, int res_type);
24 /// \brief Sets the resource amount of an entity without calling any hooks.
25 /// \param[in,out] e Entity to adjust.
26 /// \param[in] res_type Type of the resource (a RES_* constant).
27 /// \param[in] amount Amount of resource to set.
28 /// \return Boolean for whether the ammo amount was changed
29 bool SetResourceExplicit(entity e, int res_type, float amount);
31 /// \brief Sets the current amount of resource the given entity will have
32 /// but limited to the max amount allowed for the resource type.
33 /// \param[in,out] e Entity to adjust.
34 /// \param[in] res_type Type of the resource (a RES_* constant).
35 /// \param[in] amount Amount of resource to set.
36 /// \return No return.
37 void SetResource(entity e, int res_type, float amount);
39 /// \brief Gives an entity some resource.
40 /// \param[in,out] receiver Entity to give resource to.
41 /// \param[in] res_type Type of the resource (a RES_* constant).
42 /// \param[in] amount Amount of resource to give.
43 /// \return No return.
44 void GiveResource(entity receiver, int res_type, float amount);
46 /// \brief Gives an entity some resource but not more than a limit.
47 /// \param[in,out] receiver Entity to give resource to.
48 /// \param[in] res_type Type of the resource (a RES_* constant).
49 /// \param[in] amount Amount of resource to give.
50 /// \param[in] limit Limit of resources to give.
51 /// \return No return.
52 void GiveResourceWithLimit(entity receiver, int res_type, float amount, float limit);
54 /// \brief Takes an entity some resource.
55 /// \param[in,out] receiver Entity to take resource from.
56 /// \param[in] res_type Type of the resource (a RES_* constant).
57 /// \param[in] amount Amount of resource to take.
58 /// \return No return.
59 void TakeResource(entity receiver, int res_type, float amount);
61 /// \brief Takes an entity some resource but not less than a limit.
62 /// \param[in,out] receiver Entity to take resource from.
63 /// \param[in] res_type Type of the resource (a RES_* constant).
64 /// \param[in] amount Amount of resource to take.
65 /// \param[in] limit Limit of resources to take.
66 /// \return No return.
67 void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit);
69 // ===================== Legacy and/or internal API ===========================
71 /// \brief Converts an entity field to resource type.
72 /// \param[in] res_field Entity field to convert.
73 /// \return Resource type (a RES_* constant).
74 int GetResourceType(.float res_field);
76 /// \brief Converts resource type (a RES_* constant) to entity field.
77 /// \param[in] res_type Type of the resource.
78 /// \return Entity field for that resource.
79 .float GetResourceField(int res_type);