4 #include <common/stats.qh>
8 /// \brief Legacy fields for the resources. To be removed.
20 const .int ammo_plasma = _STAT(PLASMA);
21 const .int ammo_fuel = _STAT(FUEL);
28 CLASS(Resource, Object)
29 ATTRIB(Resource, netname, string, "");
31 ATTRIB(Resource, m_field, .float, health);
35 #define REGISTER_RESOURCE(id, inst) REGISTER(Resources, RES, id, m_id, inst)
36 REGISTRY(Resources, BITS(4));
37 REGISTER_REGISTRY(Resources)
40 // Copy Resources registry here before it gets sorted alphabetically by REGISTRY_SORT
41 // so we can keep resources sorted by categories (as they appear in the code)
42 IntrusiveList default_order_resources;
43 STATIC_INIT(default_order_resources)
45 default_order_resources = IL_NEW();
46 FOREACH(Resources, true, {
47 IL_PUSH(default_order_resources, it);
52 REGISTRY_SORT(Resources)
53 REGISTRY_CHECK(Resources)
55 REGISTRY_DEFINE_GET(Resources, NULL)
56 STATIC_INIT(Resources_renumber) { FOREACH(Resources, true, it.m_id = i); }
58 /// \brief Unconditional maximum amount of resources the entity can have.
59 const int RES_AMOUNT_HARD_LIMIT = 999;
60 const int RES_LIMIT_NONE = -1;
62 /// \brief Describes the available resource types.
63 REGISTER_RESOURCE(NONE, NEW(Resource)); ///< Indicates the lack of resource. Use with caution.
68 // ===================== Legacy and/or internal API ===========================
70 /// \brief Converts an entity field to resource type.
71 /// \param[in] res_field Entity field to convert.
72 /// \return Resource type (a RES_* constant).
73 Resource GetResourceType(.float res_field);
75 /// \brief Converts resource type (a RES_* constant) to entity field.
76 /// \param[in] res_type Type of the resource.
77 /// \return Entity field for that resource.
78 .float GetResourceField(Resource res_type);