4 /// \brief Header file that describes the resource system.
6 /// \copyright GNU GPLv2 or any later version.
8 #include <common/resources.qh>
10 /// \brief Unconditional maximum amount of resources the entity can have.
11 const int RESOURCE_AMOUNT_HARD_LIMIT = 999;
13 // ============================ Public API ====================================
15 /// \brief Returns the maximum amount of the given resource.
16 /// \param[in] e Entity to check.
17 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
18 /// \return Maximum amount of the given resource.
19 float GetResourceLimit(entity e, int resource_type);
21 /// \brief Returns the current amount of resource the given entity has.
22 /// \param[in] e Entity to check.
23 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
24 /// \return Current amount of resource the given entity has.
25 float GetResourceAmount(entity e, int resource_type);
27 /// \brief Sets the current amount of resource the given entity will have.
28 /// \param[in,out] e Entity to adjust.
29 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
30 /// \param[in] amount Amount of resource to set.
31 /// \return No return.
32 void SetResourceAmount(entity e, int resource_type, float amount);
34 /// \brief Gives an entity some resource.
35 /// \param[in,out] receiver Entity to give resource to.
36 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
37 /// \param[in] amount Amount of resource to give.
38 /// \return No return.
39 void GiveResource(entity receiver, int resource_type, float amount);
41 /// \brief Gives an entity some resource but not more than a limit.
42 /// \param[in,out] receiver Entity to give resource to.
43 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
44 /// \param[in] amount Amount of resource to give.
45 /// \param[in] limit Limit of resources to give.
46 /// \return No return.
47 void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
50 // ===================== Legacy and/or internal API ===========================
52 /// \brief Converts an entity field to resource type.
53 /// \param[in] resource_field Entity field to convert.
54 /// \return Resource type (a RESOURCE_* constant).
55 int GetResourceType(.float resource_field);
57 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
58 /// \param[in] resource_type Type of the resource.
59 /// \return Entity field for that resource.
60 .float GetResourceField(int resource_type);