|
|
|
@ -206,7 +206,7 @@ void System::death(GameLevel &level) { |
|
|
|
|
sound::play(snd->death); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto entity_data = config.items["GRAVE_STONE"]; |
|
|
|
|
auto entity_data = config.devices["GRAVE_STONE"]; |
|
|
|
|
components::configure_entity(world, ent, entity_data["components"]); |
|
|
|
|
if(entity_data["inventory_count"] > 0) { |
|
|
|
|
System::distribute_loot(world, ent, entity_data); |
|
|
|
@ -306,40 +306,21 @@ void System::collision(GameLevel &level) { |
|
|
|
|
// call into that to work it, rather than this hard coded crap
|
|
|
|
|
auto item = world.get<InventoryItem>(entity); |
|
|
|
|
auto& item_pos = world.get<Position>(entity); |
|
|
|
|
dbc::log("REWRITE ME!"); |
|
|
|
|
|
|
|
|
|
if(world.has<LightSource>(entity)) { |
|
|
|
|
// inventory.add(item);
|
|
|
|
|
world.remove<LightSource>(entity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(world.has<ritual::JunkPile>(entity)) { |
|
|
|
|
auto& pile = world.get<ritual::JunkPile>(entity); |
|
|
|
|
auto& blanket = world.get_the<ritual::Blanket>(); |
|
|
|
|
|
|
|
|
|
for(auto& junk : pile.contents) { |
|
|
|
|
fmt::println("adding {} to blanket", junk); |
|
|
|
|
blanket.add(junk); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(world.has<Weapon>(entity)) { |
|
|
|
|
// inventory.add(item);
|
|
|
|
|
world.remove<Weapon>(entity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(world.has<Curative>(entity)) { |
|
|
|
|
// inventory.add(item);
|
|
|
|
|
world.remove<Curative>(entity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(auto snd = world.get_if<Sound>(entity)) { |
|
|
|
|
sound::play(snd->attack); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
collider.remove(item_pos.location); |
|
|
|
|
world.remove<Tile>(entity); |
|
|
|
|
world.remove<InventoryItem>(entity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt::println("LOOT EVENT, picking up {}", int(entity)); |
|
|
|
|
world.send<Events::GUI>(Events::GUI::LOOT, entity, item); |
|
|
|
|
} else if(world.has<Device>(entity)) { |
|
|
|
|
System::device(world, player.entity, entity); |
|
|
|
@ -357,18 +338,23 @@ void System::collision(GameLevel &level) { |
|
|
|
|
|
|
|
|
|
void System::device(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::Entity item) { |
|
|
|
|
auto& device = world.get<Device>(item); |
|
|
|
|
dbc::log(fmt::format("entity {} INTERACTED WITH DEVICE {}", actor, item)); |
|
|
|
|
|
|
|
|
|
for(auto event : device.events) { |
|
|
|
|
dbc::log(fmt::format("Device event received {}", event)); |
|
|
|
|
|
|
|
|
|
if(event == "Events::GUI::STAIRS_DOWN") { |
|
|
|
|
if(event == "STAIRS_DOWN") { |
|
|
|
|
world.send<Events::GUI>(Events::GUI::STAIRS_DOWN, actor, device); |
|
|
|
|
} else if(event == "STAIRS_UP") { |
|
|
|
|
world.send<Events::GUI>(Events::GUI::STAIRS_UP, actor, device); |
|
|
|
|
} else if(event == "TRAP") { |
|
|
|
|
world.send<Events::GUI>(Events::GUI::TRAP, actor, device); |
|
|
|
|
} else if(event == "LOOT_OPEN") { |
|
|
|
|
world.send<Events::GUI>(Events::GUI::LOOT, actor, device); |
|
|
|
|
} else { |
|
|
|
|
dbc::log(fmt::format("EVENT IGNORED {}", event)); |
|
|
|
|
dbc::log(fmt::format( |
|
|
|
|
"INVALID EVENT {} for device {}", |
|
|
|
|
event, (std::string)device.config["name"])); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dbc::log(fmt::format("entity {} INTERACTED WITH DEVICE {}", actor, item)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void System::plan_motion(DinkyECS::World& world, Point move_to) { |
|
|
|
|