Very simple items system to get into the inventory work.
This commit is contained in:
parent
1962b0c24e
commit
3d461bce6d
15 changed files with 94 additions and 32 deletions
24
systems.cpp
24
systems.cpp
|
@ -138,14 +138,25 @@ void System::collision(DinkyECS::World &world, Player &player) {
|
|||
auto loot = world.get<Loot>(entity);
|
||||
auto &loot_pos = world.get<Position>(entity);
|
||||
auto &inventory = world.get<Inventory>(player.entity);
|
||||
// BUG: this should go away and be a part of inventory
|
||||
auto &light = world.get<LightSource>(player.entity);
|
||||
|
||||
world.send<Events::GUI>(Events::GUI::LOOT, entity, loot);
|
||||
inventory.gold += loot.amount;
|
||||
light.strength = 70;
|
||||
light.radius = 2;
|
||||
if(world.has<LightSource>(entity)) {
|
||||
auto &new_light = world.get<LightSource>(entity);
|
||||
world.set<LightSource>(player.entity, new_light);
|
||||
inventory.light = new_light;
|
||||
world.remove<LightSource>(entity);
|
||||
} else if(world.has<Weapon>(entity)) {
|
||||
auto &weapon = world.get<Weapon>(entity);
|
||||
player_combat.damage = weapon.damage;
|
||||
world.remove<Weapon>(entity);
|
||||
} else {
|
||||
// it's just gold
|
||||
inventory.gold += loot.amount;
|
||||
}
|
||||
|
||||
collider.remove(loot_pos.location);
|
||||
world.remove<Tile>(entity);
|
||||
world.remove<Loot>(entity);
|
||||
world.send<Events::GUI>(Events::GUI::LOOT, entity, loot);
|
||||
} else {
|
||||
println("UNKNOWN COLLISION TYPE {}", entity);
|
||||
}
|
||||
|
@ -153,7 +164,6 @@ void System::collision(DinkyECS::World &world, Player &player) {
|
|||
}
|
||||
}
|
||||
|
||||
// BUG: this is kind of massive, need to maybe rethink how systems are designed. I mean...can each system be a callable class instead?
|
||||
void System::draw_entities(DinkyECS::World &world, Map &game_map, const Matrix &lighting, ftxui::Canvas &canvas, const Point &cam_orig, size_t view_x, size_t view_y) {
|
||||
auto &tiles = game_map.tiles();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue