Implemented configurable randomization in the world builder, and then got the beginning of devices to work for the next part of going down a level through stairs.
This commit is contained in:
parent
7acbd0379f
commit
d2162910f6
10 changed files with 73 additions and 36 deletions
23
systems.cpp
23
systems.cpp
|
@ -56,15 +56,16 @@ void System::init_positions(DinkyECS::World &world) {
|
|||
|
||||
// BUG: instead of separate things maybe just one
|
||||
// BUG: Collision component that references what is collide
|
||||
world.query<Position, Combat>([&](const auto &ent, auto &pos, auto &combat) {
|
||||
if(!combat.dead) {
|
||||
world.query<Position>([&](const auto &ent, auto &pos) {
|
||||
if(world.has<Combat>(ent)) {
|
||||
const auto& combat = world.get<Combat>(ent);
|
||||
if(!combat.dead) {
|
||||
collider.insert(pos.location, ent);
|
||||
}
|
||||
} else {
|
||||
collider.insert(pos.location, ent);
|
||||
}
|
||||
});
|
||||
|
||||
world.query<Position>([&](const auto &ent, auto &pos) {
|
||||
collider.insert(pos.location, ent);
|
||||
});
|
||||
}
|
||||
|
||||
inline void move_entity(SpatialMap &collider, Map &game_map, Position &position, Motion &motion, DinkyECS::Entity ent) {
|
||||
|
@ -175,6 +176,8 @@ void System::collision(DinkyECS::World &world, Player &player) {
|
|||
world.remove<Tile>(entity);
|
||||
world.remove<InventoryItem>(entity);
|
||||
world.send<Events::GUI>(Events::GUI::LOOT, entity, item);
|
||||
} else if(world.has<Device>(entity)) {
|
||||
System::device(world, player.entity, entity);
|
||||
} else {
|
||||
println("UNKNOWN COLLISION TYPE {}", entity);
|
||||
}
|
||||
|
@ -211,3 +214,11 @@ void System::pickup(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::En
|
|||
|
||||
inventory.add(invitem);
|
||||
}
|
||||
|
||||
void System::device(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::Entity item) {
|
||||
auto& device = world.get<Device>(item);
|
||||
if(device.active) {
|
||||
println("entity {} INTERACTED WITH DEVICE {}", actor, item);
|
||||
device.active = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue