Inventory system basically works now but is in a alpha hack stage. Time to refactor.
This commit is contained in:
parent
b7f49aa719
commit
e0e7a1027c
11 changed files with 92 additions and 33 deletions
|
@ -189,7 +189,6 @@ void System::collision(GameLevel &level) {
|
|||
auto player = world.get_the<Player>();
|
||||
|
||||
const auto& player_position = world.get<Position>(player.entity);
|
||||
auto& player_combat = world.get<Combat>(player.entity);
|
||||
|
||||
// this is guaranteed to not return the given position
|
||||
auto [found, nearby] = collider.neighbors(player_position.location);
|
||||
|
@ -210,16 +209,11 @@ void System::collision(GameLevel &level) {
|
|||
|
||||
if(world.has<LightSource>(entity)) {
|
||||
inventory.add(item);
|
||||
auto &new_light = world.get<LightSource>(entity);
|
||||
world.set<LightSource>(player.entity, new_light);
|
||||
inventory.light = new_light;
|
||||
world.remove<LightSource>(entity);
|
||||
}
|
||||
|
||||
if(world.has<Weapon>(entity)) {
|
||||
inventory.add(item);
|
||||
auto &weapon = world.get<Weapon>(entity);
|
||||
player_combat.damage = weapon.damage;
|
||||
world.remove<Weapon>(entity);
|
||||
}
|
||||
|
||||
|
@ -230,8 +224,7 @@ void System::collision(GameLevel &level) {
|
|||
}
|
||||
|
||||
if(world.has<Curative>(entity)) {
|
||||
auto& cure = world.get<Curative>(entity);
|
||||
player_combat.hp = std::min(player_combat.hp + cure.hp, player_combat.max_hp);
|
||||
inventory.add(item);
|
||||
world.remove<Curative>(entity);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue