]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/resources.qh
Merge branch 'Lyberta/URS3' into Lyberta/RandomStartWeapons
[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 /// \brief Unconditional maximum amount of resources the entity can have.
9 const int RESOURCE_AMOUNT_HARD_LIMIT = 999;
10
11 // ============================ Public API ====================================
12
13 /// \brief Returns the maximum amount of the given resource.
14 /// \param[in] e Entity to check.
15 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
16 /// \return Maximum amount of the given resource.
17 float GetResourceLimit(entity e, int resource_type);
18
19 /// \brief Returns the current amount of resource the given entity has.
20 /// \param[in] e Entity to check.
21 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
22 /// \return Current amount of resource the given entity has.
23 float GetResourceAmount(entity e, int resource_type);
24
25 /// \brief Sets the current amount of resource the given entity will have.
26 /// \param[in,out] e Entity to adjust.
27 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
28 /// \param[in] amount Amount of resource to set.
29 /// \return No return.
30 void SetResourceAmount(entity e, int resource_type, float amount);
31
32 /// \brief Gives an entity some resource.
33 /// \param[in,out] receiver Entity to give resource to.
34 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
35 /// \param[in] amount Amount of resource to give.
36 /// \return No return.
37 void GiveResource(entity receiver, int resource_type, float amount);
38
39 /// \brief Gives an entity some resource but not more than a limit.
40 /// \param[in,out] receiver Entity to give resource to.
41 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
42 /// \param[in] amount Amount of resource to give.
43 /// \param[in] limit Limit of resources to give.
44 /// \return No return.
45 void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
46         float limit);
47
48 // ===================== Legacy and/or internal API ===========================
49
50 /// \brief Converts an entity field to resource type.
51 /// \param[in] resource_field Entity field to convert.
52 /// \return Resource type (a RESOURCE_* constant).
53 int GetResourceType(.float resource_field);
54
55 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
56 /// \param[in] resource_type Type of the resource.
57 /// \return Entity field for that resource.
58 .float GetResourceField(int resource_type);