Can now go down a level.

This commit is contained in:
Zed A. Shaw 2026-03-31 11:43:44 -04:00
parent 360402cb3c
commit 44e474b023
3 changed files with 19 additions and 6 deletions

View file

@ -190,11 +190,17 @@ void WorldBuilder::place_doors(DinkyECS::World& world, GameConfig& config) {
} }
void WorldBuilder::place_stairs(DinkyECS::World& world, GameConfig& config) { void WorldBuilder::place_stairs(DinkyECS::World& world, GameConfig& config) {
auto player = world.get_the<Player>();
auto player_pos = world.get<Position>(player.entity);
auto& device_config = config.devices.json(); auto& device_config = config.devices.json();
auto entity_data = device_config["STAIRS_DOWN"]; auto entity_data = device_config["STAIRS_DOWN"];
auto at_end = $map.$dead_ends.back(); // auto at_end = $map.$dead_ends.back();
configure_entity_in_map(world, entity_data, at_end); configure_entity_in_map(world, entity_data, {
player_pos.location.x+1,
player_pos.location.y
});
} }
void WorldBuilder::configure_starting_items(DinkyECS::World &world) { void WorldBuilder::configure_starting_items(DinkyECS::World &world) {
@ -203,11 +209,11 @@ void WorldBuilder::configure_starting_items(DinkyECS::World &world) {
auto healing = System::spawn_item(world, "REPAIR_KIT"); auto healing = System::spawn_item(world, "REPAIR_KIT");
inventory.add("inv0", healing); inventory.add("inv0", healing);
world.make_constant(healing);
auto sword = System::spawn_item(world, "SWORD_1"); auto sword = System::spawn_item(world, "SWORD_1");
inventory.add("hand_main", sword); inventory.add("hand_main", sword);
world.make_constant(sword);
world.make_constant(healing);
} }
void WorldBuilder::place_entities(DinkyECS::World &world) { void WorldBuilder::place_entities(DinkyECS::World &world) {

View file

@ -431,7 +431,8 @@ namespace gui {
event(Event::ATTACK, data); event(Event::ATTACK, data);
break; break;
case eGUI::STAIRS_DOWN: case eGUI::STAIRS_DOWN:
dbc::sentinel("make me!"); next_level();
state(State::IDLE);
break; break;
case eGUI::DEATH: { case eGUI::DEATH: {
$status_ui.update(); $status_ui.update();

View file

@ -66,16 +66,22 @@ namespace gui {
$body_ui.update(); $body_ui.update();
for(const auto& [slot, cell] : $gui.cells()) { for(const auto& [slot, cell] : $gui.cells()) {
if(inventory.has(slot)) { if(inventory.has(slot)) {
auto gui_id = $gui.entity(slot); auto gui_id = $gui.entity(slot);
auto world_entity = inventory.get(slot); auto world_entity = inventory.get(slot);
dbc::check(world->has<components::Sprite>(world_entity),
fmt::format("inventory {} has missing sprite", slot));
auto& sprite = world->get<components::Sprite>(world_entity); auto& sprite = world->get<components::Sprite>(world_entity);
$gui.set_init<guecs::Icon>(gui_id, {sprite.name}); $gui.set_init<guecs::Icon>(gui_id, {sprite.name});
guecs::GrabSource grabber{ world_entity, guecs::GrabSource grabber{ world_entity,
[&, gui_id]() { return remove_slot(gui_id); }}; [&, gui_id]() { return remove_slot(gui_id); }};
grabber.setSprite($gui, gui_id); grabber.setSprite($gui, gui_id);
$gui.set<guecs::GrabSource>(gui_id, grabber); $gui.set<guecs::GrabSource>(gui_id, grabber);
} else { } else {
auto gui_id = $gui.entity(slot); auto gui_id = $gui.entity(slot);