]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/resources.qh
Clear out most references to the .ammo_* fields
[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 /// \brief Unconditional maximum amount of resources the entity can have.
11 const int RESOURCE_AMOUNT_HARD_LIMIT = 999;
12
13 // ============================ Public API ====================================
14
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);
20
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);
26
27 /// \brief Sets the resource amount of an entity without calling any hooks.
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 Boolean for whether the ammo amount was changed
32 bool SetResourceAmountExplicit(entity e, int resource_type, float amount);
33
34 /// \brief Sets the current amount of resource the given entity will have.
35 /// \param[in,out] e Entity to adjust.
36 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
37 /// \param[in] amount Amount of resource to set.
38 /// \return No return.
39 void SetResourceAmount(entity e, int resource_type, float amount);
40
41 /// \brief Gives an entity some resource.
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 /// \return No return.
46 void GiveResource(entity receiver, int resource_type, float amount);
47
48 /// \brief Gives an entity some resource but not more than a limit.
49 /// \param[in,out] receiver Entity to give resource to.
50 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
51 /// \param[in] amount Amount of resource to give.
52 /// \param[in] limit Limit of resources to give.
53 /// \return No return.
54 void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
55         float limit);
56
57 // ===================== Legacy and/or internal API ===========================
58
59 /// \brief Converts an entity field to resource type.
60 /// \param[in] resource_field Entity field to convert.
61 /// \return Resource type (a RESOURCE_* constant).
62 int GetResourceType(.float resource_field);
63
64 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
65 /// \param[in] resource_type Type of the resource.
66 /// \return Entity field for that resource.
67 .float GetResourceField(int resource_type);