]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/resources.qh
1140b0576eca9f05d43faad42f6cfc85f46aca63
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / resources.qh
1 #pragma once
2
3 /// \file
4 /// \brief Header file that describes the resource system.
5 /// \copyright GNU GPLv2 or any later version.
6
7 #include <common/resources.qh>
8
9 // ============================ Public API ====================================
10
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);
16
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);
23
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);
30
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);
38
39 // ===================== Legacy and/or internal API ===========================
40
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);
45
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);
50
51 /// \brief Legacy fields for the resources. To be removed.
52 .float health;
53 .float armorvalue;