]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/resources/resources.qh
Update default video settings
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / resources / resources.qh
1 #pragma once
2
3 #ifdef SVQC
4         #include <common/stats.qh>
5 #endif
6
7 #ifdef CSQC
8 /// \brief Legacy fields for the resources. To be removed.
9 .float health;
10 .float armorvalue;
11 #endif
12
13 #if 1
14 .int ammo_none;
15 .int ammo_shells;
16 .int ammo_nails;
17 .int ammo_rockets;
18 .int ammo_cells;
19 #ifdef SVQC
20 const .int ammo_plasma = _STAT(PLASMA);
21 const .int ammo_fuel = _STAT(FUEL);
22 #else
23 .int ammo_plasma;
24 .int ammo_fuel;
25 #endif
26 #endif
27
28 CLASS(Resource, Object)
29         ATTRIB(Resource, netname, string, "");
30 #ifdef GAMEQC
31         ATTRIB(Resource, m_field, .float, health);
32 #endif
33 ENDCLASS(Resource)
34
35 #define REGISTER_RESOURCE(id, inst) REGISTER(Resources, RES, id, m_id, inst)
36 REGISTRY(Resources, BITS(4));
37 REGISTER_REGISTRY(Resources)
38 REGISTRY_SORT(Resources);
39 REGISTRY_CHECK(Resources);
40
41 REGISTRY_DEFINE_GET(Resources, NULL)
42 STATIC_INIT(Resources_renumber) { FOREACH(Resources, true, it.m_id = i); }
43
44 /// \brief Unconditional maximum amount of resources the entity can have.
45 const int RES_AMOUNT_HARD_LIMIT = 999;
46 const int RES_LIMIT_NONE = -1;
47
48 /// \brief Describes the available resource types.
49 REGISTER_RESOURCE(NONE, NEW(Resource)); ///< Indicates the lack of resource. Use with caution.
50
51 #include "all.inc"
52
53 #ifdef GAMEQC
54 // ===================== Legacy and/or internal API ===========================
55
56 /// \brief Converts an entity field to resource type.
57 /// \param[in] res_field Entity field to convert.
58 /// \return Resource type (a RES_* constant).
59 Resource GetResourceType(.float res_field);
60
61 /// \brief Converts resource type (a RES_* constant) to entity field.
62 /// \param[in] res_type Type of the resource.
63 /// \return Entity field for that resource.
64 .float GetResourceField(Resource res_type);
65 #endif