]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/resources.qh
4f57a2f3c01524fb13595f9a0818720bc17877d1
[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 current amount of resource the given entity will have.
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 No return.
22 void SetResourceAmount(entity e, int resource_type, float amount);
23
24 /// \brief Takes an entity some resource.
25 /// \param[in,out] receiver Entity to take resource from.
26 /// \param[in] resource_type Type of the resource (a RESOURCE_* constant).
27 /// \param[in] amount Amount of resource to take.
28 /// \return No return.
29 void TakeResource(entity receiver, int resource_type, float amount);
30
31 /// \brief Takes an entity some resource but not less than a limit.
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 /// \param[in] limit Limit of resources to take.
36 /// \return No return.
37 void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
38         float limit);
39
40 // ===================== Legacy and/or internal API ===========================
41
42 /// \brief Converts an entity field to resource type.
43 /// \param[in] resource_field Entity field to convert.
44 /// \return Resource type (a RESOURCE_* constant).
45 int GetResourceType(.float resource_field);
46
47 /// \brief Converts resource type (a RESOURCE_* constant) to entity field.
48 /// \param[in] resource_type Type of the resource.
49 /// \return Entity field for that resource.
50 .float GetResourceField(int resource_type);
51
52 /// \brief Legacy fields for the resources. To be removed.
53 .float health;
54 .float armorvalue;