]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/resources.qh
Update the weapon ammo notification to point people to the developers
[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] resource_type Type of the resource (a RESOURCE_* constant).
15 /// \return Maximum amount of the given resource.
16 float GetResourceLimit(entity e, int resource_type);
17
18 /// \brief Returns the current amount of resource the given entity has.
19 /// \param[in] e Entity to check.
20 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
21 /// \return Current amount of resource the given entity has.
22 float GetResourceAmount(entity e, int resource_type);
23
24 /// \brief Sets the resource amount of an entity without calling any hooks.
25 /// \param[in,out] e Entity to adjust.
26 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
27 /// \param[in] amount Amount of resource to set.
28 /// \return Boolean for whether the ammo amount was changed
29 bool SetResourceAmountExplicit(entity e, int resource_type, float amount);
30
31 /// \brief Sets the current amount of resource the given entity will have.
32 /// \param[in,out] e Entity to adjust.
33 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
34 /// \param[in] amount Amount of resource to set.
35 /// \return No return.
36 void SetResourceAmount(entity e, int resource_type, float amount);
37
38 /// \brief Gives an entity some resource.
39 /// \param[in,out] receiver Entity to give resource to.
40 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
41 /// \param[in] amount Amount of resource to give.
42 /// \return No return.
43 void GiveResource(entity receiver, int resource_type, float amount);
44
45 /// \brief Gives an entity some resource but not more than a limit.
46 /// \param[in,out] receiver Entity to give resource to.
47 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
48 /// \param[in] amount Amount of resource to give.
49 /// \param[in] limit Limit of resources to give.
50 /// \return No return.
51 void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
52         float limit);
53
54 /// \brief Takes an entity some resource.
55 /// \param[in,out] receiver Entity to take resource from.
56 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
57 /// \param[in] amount Amount of resource to take.
58 /// \return No return.
59 void TakeResource(entity receiver, int resource_type, float amount);
60
61 /// \brief Takes an entity some resource but not less than a limit.
62 /// \param[in,out] receiver Entity to take resource from.
63 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
64 /// \param[in] amount Amount of resource to take.
65 /// \param[in] limit Limit of resources to take.
66 /// \return No return.
67 void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
68         float limit);
69
70 /// \brief Gives to or takes from an entity resource.
71 /// \param[in,out] receiver Entity to give or take resource.
72 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
73 /// \param[in] amount Amount of resource to give or take.
74 /// \return No return.
75 void GiveOrTakeResource(entity receiver, int resource_type, float amount);
76
77 /// \brief Gives to or takes from an entity resource but not more/less than a limit.
78 /// \param[in,out] receiver Entity to give or take resource.
79 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
80 /// \param[in] amount Amount of resource to give or take.
81 /// \param[in] limit Limit of resources to give or take.
82 /// \return No return.
83 void GiveOrTakeResourceWithLimit(entity receiver, int resource_type, float amount,
84         float limit);
85
86 // ===================== Legacy and/or internal API ===========================
87
88 /// \brief Converts an entity field to resource type.
89 /// \param[in] resource_field Entity field to convert.
90 /// \return Resource type (a RESOURCE_* constant).
91 int GetResourceType(.float resource_field);
92
93 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
94 /// \param[in] resource_type Type of the resource.
95 /// \return Entity field for that resource.
96 .float GetResourceField(int resource_type);