Basic prototype of showing a different door to match the walls. Need to generalize though.

This commit is contained in:
Zed A. Shaw 2026-03-17 12:31:35 -04:00
parent 349656589b
commit f57d202f5c
2 changed files with 24 additions and 4 deletions

View file

@ -12,6 +12,7 @@
"texture": "assets/textures/wall_plain.png",
"display": 9608,
"light": 0,
"door": "door_plain",
"foreground": "tiles/fg:wall_plain",
"background": "tiles/bg:wall_plain",
"id": 1
@ -20,6 +21,7 @@
"texture": "assets/textures/glowing_moss_wall.png",
"display": 9256,
"light": 20,
"door": "door_wall_moss",
"foreground": "tiles/fg:wall_moss",
"background": "tiles/bg:wall_moss",
"id": 2

View file

@ -173,12 +173,30 @@ void WorldBuilder::place_doors(DinkyECS::World& world, GameConfig& config) {
auto& device_config = config.devices.json();
auto entity_data = device_config["DOOR_PLAIN"];
auto& tiles = $map.tiles();
size_t door_id = textures::get_id("door_moss_wall");
auto& walls = $map.walls();
for(auto [door_at, _] : $map.$doors) {
$map.$walls[door_at.y][door_at.x] = WALL_VALUE;
tiles[door_at.y][door_at.x] = door_id;
// note, we set this to WALL_VALUE so it renders as a wall but map.iswall will check if its a door for collision
walls[door_at.y][door_at.x] = WALL_VALUE;
size_t moss_wall_id = textures::get_id("wall_moss");
size_t plain_door_id = textures::get_id("door_plain");
size_t moss_door_id = textures::get_id("door_moss_wall");
for(matrix::compass it{tiles, door_at.x, door_at.y}; it.next();) {
if(walls[it.y][it.x] == WALL_VALUE) {
// found a wall near the door, and since doors always have n/s/e/w walls it should be the one to use
size_t wall_id = tiles[it.y][it.x]; // this is wall to use
// change this to texture::door_for_wall(wall_id);
if(wall_id == moss_wall_id) {
tiles[door_at.y][door_at.x] = moss_door_id;
} else {
tiles[door_at.y][door_at.x] = plain_door_id;
}
break;
}
}
}
}