]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/resources.qh
Reduce name space of resource constants and variables (RESOURCE_* --> RES_*, resour...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / resources.qh
1 #pragma once
2
3 /// \file
4 /// \brief Header file that describes the resource system.
5 /// \author Lyberta
6 /// \copyright GNU GPLv2 or any later version.
7
8 #include <common/resources.qh>
9
10 // ============================ Public API ====================================
11
12 /// \brief Returns the maximum amount of the given resource.
13 /// \param[in] e Entity to check.
14 /// \param[in] res_type Type of the resource (a RES_* constant).
15 /// \return Maximum amount of the given resource.
16 float GetResourceLimit(entity e, int res_type);
17
18 /// \brief Returns the current amount of resource the given entity has.
19 /// \param[in] e Entity to check.
20 /// \param[in] res_type Type of the resource (a RES_* constant).
21 /// \return Current amount of resource the given entity has.
22 float GetResourceAmount(entity e, int res_type);
23
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 SetResourceAmount(entity e, int res_type, float amount);
30
31 /// \brief Gives an entity some resource.
32 /// \param[in,out] receiver Entity to give resource to.
33 /// \param[in] res_type Type of the resource (a RES_* constant).
34 /// \param[in] amount Amount of resource to give.
35 /// \return No return.
36 void GiveResource(entity receiver, int res_type, float amount);
37
38 /// \brief Gives an entity some resource but not more than a limit.
39 /// \param[in,out] receiver Entity to give resource to.
40 /// \param[in] res_type Type of the resource (a RES_* constant).
41 /// \param[in] amount Amount of resource to give.
42 /// \param[in] limit Limit of resources to give.
43 /// \return No return.
44 void GiveResourceWithLimit(entity receiver, int res_type, float amount, float limit);
45
46 /// \brief Takes an entity some resource.
47 /// \param[in,out] receiver Entity to take resource from.
48 /// \param[in] res_type Type of the resource (a RES_* constant).
49 /// \param[in] amount Amount of resource to take.
50 /// \return No return.
51 void TakeResource(entity receiver, int res_type, float amount);
52
53 /// \brief Takes an entity some resource but not less than a limit.
54 /// \param[in,out] receiver Entity to take resource from.
55 /// \param[in] res_type Type of the resource (a RES_* constant).
56 /// \param[in] amount Amount of resource to take.
57 /// \param[in] limit Limit of resources to take.
58 /// \return No return.
59 void TakeResourceWithLimit(entity receiver, int res_type, float amount, float limit);
60
61 /// \brief Gives to or takes from an entity resource.
62 /// \param[in,out] receiver Entity to give or take resource.
63 /// \param[in] res_type Type of the resource (a RES_* constant).
64 /// \param[in] amount Amount of resource to give or take.
65 /// \return No return.
66 void GiveOrTakeResource(entity receiver, int res_type, float amount);
67
68 /// \brief Gives to or takes from an entity resource but not more/less than a limit.
69 /// \param[in,out] receiver Entity to give or take resource.
70 /// \param[in] res_type Type of the resource (a RES_* constant).
71 /// \param[in] amount Amount of resource to give or take.
72 /// \param[in] limit Limit of resources to give or take.
73 /// \return No return.
74 void GiveOrTakeResourceWithLimit(entity receiver, int res_type, float amount, float limit);
75
76 // ===================== Legacy and/or internal API ===========================
77
78 /// \brief Converts an entity field to resource type.
79 /// \param[in] res_field Entity field to convert.
80 /// \return Resource type (a RES_* constant).
81 int GetResourceType(.float res_field);
82
83 /// \brief Converts resource type (a RES_* constant) to entity field.
84 /// \param[in] res_type Type of the resource.
85 /// \return Entity field for that resource.
86 .float GetResourceField(int res_type);