4 /// \brief Header file that describes the resource system.
5 /// \copyright GNU GPLv2 or any later version.
7 #include <common/resources.qh>
9 // ============================ Public API ====================================
11 /// \brief Returns the current amount of resource the given entity has.
12 /// \param[in] e Entity to check.
13 /// \param[in] res_type Type of the resource (a RES_* constant).
14 /// \return Current amount of resource the given entity has.
15 float GetResource(entity e, int res_type);
17 /// \brief Sets the resource amount of an entity without calling any hooks.
18 /// \param[in,out] e Entity to adjust.
19 /// \param[in] res_type Type of the resource (a RES_* constant).
20 /// \param[in] amount Amount of resource to set.
21 /// \return Boolean for whether the ammo amount was changed
22 bool SetResourceExplicit(entity e, int res_type, float amount);
24 /// \brief Sets the current amount of resource the given entity will have.
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 No return.
29 void SetResource(entity e, int res_type, float amount);
31 /// \brief Takes an entity some resource.
32 /// \param[in,out] receiver Entity to take resource from.
33 /// \param[in] res_type Type of the resource (a RES_* constant).
34 /// \param[in] amount Amount of resource to take.
35 /// \return No return.
36 void TakeResource(entity receiver, int res_type, float amount);
38 /// \brief Takes an entity some resource but not less than a limit.
39 /// \param[in,out] receiver Entity to take resource from.
40 /// \param[in] res_type Type of the resource (a RES_* constant).
41 /// \param[in] amount Amount of resource to take.
42 /// \param[in] limit Limit of resources to take.
43 /// \return No return.
44 void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit);
46 // ===================== Legacy and/or internal API ===========================
48 /// \brief Converts an entity field to resource type.
49 /// \param[in] res_field Entity field to convert.
50 /// \return Resource type (a RES_* constant).
51 int GetResourceType(.float res_field);
53 /// \brief Converts resource type (a RES_* constant) to entity field.
54 /// \param[in] res_type Type of the resource.
55 /// \return Entity field for that resource.
56 .float GetResourceField(int res_type);
58 /// \brief Legacy fields for the resources. To be removed.