Fixes to worldbuilder to prevent door placement of items and enemies.

This commit is contained in:
Zed A. Shaw 2026-05-26 11:25:24 -04:00
parent d1d7bf8d94
commit d86617aa3a

View file

@ -118,6 +118,10 @@ DinkyECS::Entity WorldBuilder::configure_entity_in_room(DinkyECS::World &world,
Point pos_out;
bool placed = $map.place_entity(in_room, pos_out);
dbc::check(placed, "failed to randomly place item in room");
// don't place anything inside a door
if($map.$doors.contains(pos_out)) return DinkyECS::NONE;
auto entity = configure_entity_in_map(world, entity_data, pos_out);
return entity;
}
@ -208,6 +212,7 @@ void WorldBuilder::configure_starting_items(DinkyECS::World &world) {
blanket.add(name);
};
// BUG: Starting items should be configured
auto torch_id = System::spawn_item(world, "TORCH_BAD");
auto &inventory = world.get<inventory::Model>(player.entity);
@ -239,6 +244,7 @@ void WorldBuilder::place_entities(DinkyECS::World &world) {
} else {
auto player_data = config.enemies["PLAYER_TILE"];
auto player_ent = configure_entity_in_room(world, player_data, 0);
dbc::check(player_ent != DinkyECS::NONE, "placed the player in a door!");
player_pos = world.get<Position>(player_ent);