]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/resources.qh
Merge branch 'master' into Lyberta/TeamplayOverhaul
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / resources.qh
1 #pragma once
2
3 /// \file
4 /// \brief Header file that describes the resource system.
5 /// \copyright GNU GPLv2 or any later version.
6
7 #include <common/resources.qh>
8
9 // ============================ Public API ====================================
10
11 /// \brief Returns the current amount of resource the given entity has.
12 /// \param[in] e Entity to check.
13 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
14 /// \return Current amount of resource the given entity has.
15 float GetResourceAmount(entity e, int resource_type);
16
17 /// \brief Sets the resource amount of an entity without calling any hooks.
18 /// \param[in,out] e Entity to adjust.
19 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
20 /// \param[in] amount Amount of resource to set.
21 /// \return Boolean for whether the ammo amount was changed
22 bool SetResourceAmountExplicit(entity e, int resource_type, float amount);
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] resource_type Type of the resource (a RESOURCE_* constant).
27 /// \param[in] amount Amount of resource to set.
28 /// \return No return.
29 void SetResourceAmount(entity e, int resource_type, float amount);
30
31 /// \brief Takes an entity some resource.
32 /// \param[in,out] receiver Entity to take resource from.
33 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
34 /// \param[in] amount Amount of resource to take.
35 /// \return No return.
36 void TakeResource(entity receiver, int resource_type, float amount);
37
38 /// \brief Takes an entity some resource but not less than a limit.
39 /// \param[in,out] receiver Entity to take resource from.
40 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
41 /// \param[in] amount Amount of resource to take.
42 /// \param[in] limit Limit of resources to take.
43 /// \return No return.
44 void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
45         float limit);
46
47 // ===================== Legacy and/or internal API ===========================
48
49 /// \brief Converts an entity field to resource type.
50 /// \param[in] resource_field Entity field to convert.
51 /// \return Resource type (a RESOURCE_* constant).
52 int GetResourceType(.float resource_field);
53
54 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
55 /// \param[in] resource_type Type of the resource.
56 /// \return Entity field for that resource.
57 .float GetResourceField(int resource_type);
58
59 /// \brief Legacy fields for the resources. To be removed.
60 .float health;
61 .float armorvalue;