Made a curative component really quick.

main
Zed A. Shaw 2 weeks ago
parent d6916b675e
commit ee304c30e3
  1. 12
      assets/items.json
  2. 6
      components.hpp
  3. 6
      systems.cpp

@ -59,5 +59,17 @@
{"type": "Tile", "config": {"chr": "\u077e"}}, {"type": "Tile", "config": {"chr": "\u077e"}},
{"type": "LightSource", "config": {"strength": 60, "radius": 1.8}} {"type": "LightSource", "config": {"strength": 60, "radius": 1.8}}
] ]
},
"POTION_HEALING_SMALL": {
"id": "POTION_HEALING_SMALL",
"name": "Small Healing Potion",
"foreground": [24, 205, 189],
"background": [24, 205, 189],
"description": "A small healing potion.",
"inventory_count": 1,
"components": [
{"type": "Tile", "config": {"chr": "\u03eb"}},
{"type": "Curative", "config": {"hp": 20}}
]
} }
} }

@ -53,6 +53,10 @@ namespace components {
int damage = 0; int damage = 0;
}; };
struct Curative {
int hp = 10;
};
inline void configure(DinkyECS::World &world, DinkyECS::Entity entity, json& entity_data) { inline void configure(DinkyECS::World &world, DinkyECS::Entity entity, json& entity_data) {
for(auto &comp : entity_data["components"]) { for(auto &comp : entity_data["components"]) {
json& config = comp["config"]; json& config = comp["config"];
@ -69,6 +73,8 @@ namespace components {
world.set<EnemyConfig>(entity, {config["hearing_distance"]}); world.set<EnemyConfig>(entity, {config["hearing_distance"]});
} else if(comp["type"] == "Combat") { } else if(comp["type"] == "Combat") {
world.set<Combat>(entity, {config["hp"], config["damage"]}); world.set<Combat>(entity, {config["hp"], config["damage"]});
} else if(comp["type"] == "Curative") {
world.set<Curative>(entity, {config["hp"]});
} else if(comp["type"] == "Motion") { } else if(comp["type"] == "Motion") {
world.set<Motion>(entity, {config["dx"], config["dy"], config["random"]}); world.set<Motion>(entity, {config["dx"], config["dy"], config["random"]});
} else { } else {

@ -165,6 +165,12 @@ void System::collision(DinkyECS::World &world, Player &player) {
world.remove<Loot>(entity); world.remove<Loot>(entity);
} }
if(world.has<Curative>(entity)) {
auto& cure = world.get<Curative>(entity);
player_combat.hp += cure.hp;
world.remove<Curative>(entity);
}
collider.remove(item_pos.location); collider.remove(item_pos.location);
world.remove<Tile>(entity); world.remove<Tile>(entity);
world.remove<InventoryItem>(entity); world.remove<InventoryItem>(entity);

Loading…
Cancel
Save