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)
38 REGISTRY_SORT(Resources);
39 REGISTRY_CHECK(Resources);
41 REGISTRY_DEFINE_GET(Resources, NULL)
42 STATIC_INIT(Resources_renumber) { FOREACH(Resources, true, it.m_id = i); }
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;
48 /// \brief Describes the available resource types.
49 REGISTER_RESOURCE(NONE, NEW(Resource)); ///< Indicates the lack of resource. Use with caution.
54 // ===================== Legacy and/or internal API ===========================
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);
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);