class_name GridMapState extends RefCounted const TILE_SIZE := Vector2i(32, 32) enum CellKind { FLOOR, WALL, CLOSED_DOOR, CHEST, STAIRS } var size: Vector2i var _cells: Dictionary[Vector2i, CellKind] = {} func _init(new_size: Vector2i, fill: CellKind = CellKind.FLOOR) -> void: size = new_size for y in range(size.y): for x in range(size.x): _cells[Vector2i(x, y)] = fill func set_cell(cell: Vector2i, kind: CellKind) -> void: if is_inside(cell): _cells[cell] = kind func get_cell(cell: Vector2i) -> CellKind: return _cells.get(cell, CellKind.WALL) func is_inside(cell: Vector2i) -> bool: return cell.x >= 0 and cell.y >= 0 and cell.x < size.x and cell.y < size.y func is_walkable(cell: Vector2i) -> bool: var kind := get_cell(cell) return kind == CellKind.FLOOR or kind == CellKind.STAIRS func is_opaque(cell: Vector2i) -> bool: var kind := get_cell(cell) return kind == CellKind.WALL or kind == CellKind.CLOSED_DOOR or kind == CellKind.CHEST