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