Made a curative component really quick.
This commit is contained in:
parent
d6916b675e
commit
ee304c30e3
3 changed files with 24 additions and 0 deletions
|
@ -59,5 +59,17 @@
|
|||
{"type": "Tile", "config": {"chr": "\u077e"}},
|
||||
{"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;
|
||||
};
|
||||
|
||||
struct Curative {
|
||||
int hp = 10;
|
||||
};
|
||||
|
||||
inline void configure(DinkyECS::World &world, DinkyECS::Entity entity, json& entity_data) {
|
||||
for(auto &comp : entity_data["components"]) {
|
||||
json& config = comp["config"];
|
||||
|
@ -69,6 +73,8 @@ namespace components {
|
|||
world.set<EnemyConfig>(entity, {config["hearing_distance"]});
|
||||
} else if(comp["type"] == "Combat") {
|
||||
world.set<Combat>(entity, {config["hp"], config["damage"]});
|
||||
} else if(comp["type"] == "Curative") {
|
||||
world.set<Curative>(entity, {config["hp"]});
|
||||
} else if(comp["type"] == "Motion") {
|
||||
world.set<Motion>(entity, {config["dx"], config["dy"], config["random"]});
|
||||
} else {
|
||||
|
|
|
@ -165,6 +165,12 @@ void System::collision(DinkyECS::World &world, Player &player) {
|
|||
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);
|
||||
world.remove<Tile>(entity);
|
||||
world.remove<InventoryItem>(entity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue