]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/resources.qh
Merge branch 'master' into Lyberta/URS3
[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 current amount of resource the given entity will have.
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 No return.
32 void SetResourceAmount(entity e, int resource_type, float amount);
33
34 /// \brief Gives an entity some resource.
35 /// \param[in,out] receiver Entity to give resource to.
36 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
37 /// \param[in] amount Amount of resource to give.
38 /// \return No return.
39 void GiveResource(entity receiver, int resource_type, float amount);
40
41 /// \brief Gives an entity some resource but not more than a limit.
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 /// \param[in] limit Limit of resources to give.
46 /// \return No return.
47 void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
48         float limit);
49
50 // ===================== Legacy and/or internal API ===========================
51
52 /// \brief Converts an entity field to resource type.
53 /// \param[in] resource_field Entity field to convert.
54 /// \return Resource type (a RESOURCE_* constant).
55 int GetResourceType(.float resource_field);
56
57 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
58 /// \param[in] resource_type Type of the resource.
59 /// \return Entity field for that resource.
60 .float GetResourceField(int resource_type);