class_name SurfaceGenerator extends RefCounted const GridMapStateType = preload("res://scripts/domain/grid_map_state.gd") const FloorStateType = preload("res://scripts/domain/world/floor_state.gd") const ActorStateType = preload("res://scripts/domain/actor_state.gd") # Floor zero deliberately remains an authored tutorial surface. Its geometry is # not derived from the run seed; RunState supplies persistence by caching it. static func generate(_seed: String = "") -> FloorState: var map := GridMapStateType.new(Vector2i(30, 20), GridMapStateType.CellKind.WALL) _carve_room(map, Rect2i(2, 12, 6, 5)) _carve_room(map, Rect2i(2, 4, 7, 7)) _carve_room(map, Rect2i(10, 2, 10, 6)) _carve_room(map, Rect2i(21, 5, 7, 8)) _carve_vertical_corridor(map, 4, 10, 12) _carve_horizontal_corridor(map, 8, 10, 6) _carve_horizontal_corridor(map, 18, 21, 6) _carve_vertical_corridor(map, 18, 4, 6) map.set_cell(Vector2i(4, 11), GridMapStateType.CellKind.CLOSED_DOOR) map.set_cell(Vector2i(4, 7), GridMapStateType.CellKind.CHEST) map.set_cell(Vector2i(18, 4), GridMapStateType.CellKind.STAIRS) var floor := FloorStateType.new(map, 0, 0) floor.entrance = Vector2i(4, 12) floor.exit = Vector2i(18, 4) floor.enemies[&"goblin"] = ActorStateType.new(&"goblin", Vector2i(24, 8), 6, 2) floor.chests[Vector2i(4, 7)] = {"opened": false} floor.metadata = {"hand_authored": true, "theme": "surface"} return floor static func _carve_room(map: GridMapState, room: Rect2i) -> void: for y in range(room.position.y, room.end.y): for x in range(room.position.x, room.end.x): map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR) static func _carve_horizontal_corridor(map: GridMapState, from_x: int, to_x: int, y: int) -> void: for x in range(from_x, to_x + 1): map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR) static func _carve_vertical_corridor(map: GridMapState, x: int, from_y: int, to_y: int) -> void: for y in range(from_y, to_y + 1): map.set_cell(Vector2i(x, y), GridMapStateType.CellKind.FLOOR)