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 GetResourceAmount(entity e, int res_type);
17 /// \brief Sets the current amount of resource the given entity will have.
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 No return.
22 void SetResourceAmount(entity e, int res_type, float amount);
24 /// \brief Takes an entity some resource.
25 /// \param[in,out] receiver Entity to take resource from.
26 /// \param[in] res_type Type of the resource (a RES_* constant).
27 /// \param[in] amount Amount of resource to take.
28 /// \return No return.
29 void TakeResource(entity receiver, int res_type, float amount);
31 /// \brief Takes an entity some resource but not less than a limit.
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 /// \param[in] limit Limit of resources to take.
36 /// \return No return.
37 void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit);
39 // ===================== Legacy and/or internal API ===========================
41 /// \brief Converts an entity field to resource type.
42 /// \param[in] res_field Entity field to convert.
43 /// \return Resource type (a RES_* constant).
44 int GetResourceType(.float res_field);
46 /// \brief Converts resource type (a RES_* constant) to entity field.
47 /// \param[in] res_type Type of the resource.
48 /// \return Entity field for that resource.
49 .float GetResourceField(int res_type);
51 /// \brief Legacy fields for the resources. To be removed.