A dungeon delver roguelike using Pathfinder 2nd edition rules

Adding code to display doors where applicable

+37 -5
+7 -5
dungeonGenerator/dungeon.gd
··· 7 7 @export var height: int = 6 8 8 @export var entrance: int = -1 9 9 @export var init: bool = false 10 + @export var currentRoom: int = -1 10 11 11 12 const BitUsedRoom: int = 0x01 12 13 const BitEntrance: int = 0x02 ··· 24 25 func _ready() -> void: 25 26 if init: 26 27 generate() 28 + currentRoom = entrance 27 29 var nextScene: Node3D = preload("res://dungeonRoom/dungeonRoom.tscn").instantiate() 28 30 get_node("/root/Main").call_deferred("add_child", nextScene) 29 31 ··· 92 94 93 95 door <<= 1 94 96 95 - func getNeighborRoomIndex(currentRoom: int, direction: int) -> int: 97 + func getNeighborRoomIndex(currRoom: int, direction: int) -> int: 96 98 var neighborRoom: int 97 99 98 100 if direction == BitDoorNorth: 99 - neighborRoom = currentRoom - width 101 + neighborRoom = currRoom - width 100 102 elif direction == BitDoorEast: 101 - neighborRoom = currentRoom + 1 103 + neighborRoom = currRoom + 1 102 104 elif direction == BitDoorSouth: 103 - neighborRoom = currentRoom + width 105 + neighborRoom = currRoom + width 104 106 elif direction == BitDoorWest: 105 - neighborRoom = currentRoom - 1 107 + neighborRoom = currRoom - 1 106 108 107 109 if ((direction == BitDoorNorth) and (neighborRoom >= 0)) or ((direction == BitDoorSouth) and (neighborRoom < (width * height))) or ((direction == BitDoorEast) and ((neighborRoom % width) > 0)) or ((direction == BitDoorWest) and ((neighborRoom % width) < (width - 1))): 108 110 return neighborRoom
+30
dungeonRoom/dungeonRoom.gd
··· 1 1 extends Node3D 2 + 3 + func updateRoom() -> void: 4 + var dungeon: Dungeon = get_node("/root/Main/Dungeon") 5 + var currentRoomData: int = dungeon.grid[dungeon.currentRoom] 6 + 7 + if currentRoomData & dungeon.BitDoorNorth: 8 + setDoor("north") 9 + 10 + if currentRoomData & dungeon.BitDoorSouth: 11 + setDoor("south") 12 + 13 + if currentRoomData & dungeon.BitDoorEast: 14 + setDoor("east") 15 + 16 + if currentRoomData & dungeon.BitDoorWest: 17 + setDoor("west") 18 + 19 + if currentRoomData & dungeon.BitStairBelow: 20 + (get_node("/root/Main/DungeonRoom/stair-down") as Node3D).visible = true 21 + (get_node("/root/Main/DungeonRoom/no-stair-down") as Node3D).visible = false 22 + 23 + if currentRoomData & dungeon.BitStairUp: 24 + (get_node("/root/Main/DungeonRoom/stair-up") as Node3D).visible = true 25 + 26 + func setDoor(doorName: String) -> void: 27 + (get_node("/root/Main/DungeonRoom/" + doorName + "-door") as Node3D).visible = true 28 + (get_node("/root/Main/DungeonRoom/no-" + doorName + "-door") as Node3D).visible = false 29 + 30 + func _ready() -> void: 31 + updateRoom()