Skip to content

Commit

Permalink
resource category and description
Browse files Browse the repository at this point in the history
  • Loading branch information
Piglit committed Jul 13, 2024
1 parent ee60def commit bb1dc7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/spaceObjects/shipTemplateBasedObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ REGISTER_SCRIPT_SUBCLASS_NO_CREATE(ShipTemplateBasedObject, SpaceObject)
/// Returns true, if the operation was sucessfull; false otherwise.
/// Example: stbo:tryTransferResource("trade item", 1, otherShip)
REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplateBasedObject, tryTransferResource);
/// Sets a category for a resource for this ship
/// Example: stbo:setResourceCategory("empty cargo space", "Cargo")
REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplateBasedObject, setResourceCategory);
/// Sets a description for a resource for this ship
/// Example: stbo:setResourceCategory("empty cargo space", "Can be filled with cargo")
REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplateBasedObject, setResourceDescription);
/// [DEPRECATED]
/// Use ShipTemplateBasedObject:getShieldLevel() with an index value.
REGISTER_SCRIPT_CLASS_FUNCTION(ShipTemplateBasedObject, getFrontShield);
Expand Down
4 changes: 4 additions & 0 deletions src/spaceObjects/shipTemplateBasedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class ShipTemplateBasedObject : public SpaceObject, public Updatable
EPlayerShipType player_ship_type;
ERestockMissileBehaviour restocks_missiles_docked;
std::map<string, int> resources;
std::map<string, string> resource_categories;
std::map<string, string> resource_descriptions;

ScriptSimpleCallback on_destruction;
ScriptSimpleCallback on_taking_damage;
Expand Down Expand Up @@ -134,6 +136,8 @@ class ShipTemplateBasedObject : public SpaceObject, public Updatable
bool tryTransformResource(string resource_name_from, int amount_from, string resource_name_to, int amount_to);
void transferResource(string resource_name, int amount, P<ShipTemplateBasedObject> other);
bool tryTransferResource(string resource_name, int amount, P<ShipTemplateBasedObject> other);
void setResourceCategory(string resource_name, string resource_category) { resource_categories[resource_name] = resource_category; }
void setResourceDescription(string resource_name, string resource_description) { resource_descriptions[resource_name] = resource_description; }
};

#endif//SHIP_TEMPLATE_BASED_OBJECT_H

0 comments on commit bb1dc7a

Please sign in to comment.