From cabc45cd02d2159d89bb37fc29bf83a23e89b8f0 Mon Sep 17 00:00:00 2001 From: tpart Date: Thu, 26 Feb 2026 20:41:51 +0100 Subject: Fix kitchen background not working --- client/map/kitchen_background.gd | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'client/map/kitchen_background.gd') diff --git a/client/map/kitchen_background.gd b/client/map/kitchen_background.gd index 4b728a94..a638ad5f 100644 --- a/client/map/kitchen_background.gd +++ b/client/map/kitchen_background.gd @@ -22,13 +22,13 @@ func _ready() -> void: func init_map(): var map_tile = func (t): match t: - ".": return "floor" - "=": return "counter" - "s": return "stove" - "c": return "chair" - "t": return "table" - "o": return "oven" - "#": return "wall" + ".": return ["floor"] + "=": return ["counter"] + "s": return ["stove"] + "c": return ["chair"] + "t": return ["table"] + "o": return ["oven"] + "#": return ["wall"] _: push_error("unknown tile: ", t) var tiles = [ "...............", @@ -39,9 +39,10 @@ func init_map(): ".............=#", ".............=#" ].map(func (l): return Array(l.split("")).map(map_tile)) - var gt = func (e): return null if e[1] >= tiles.size() else null if e[0] >= tiles[e[1]].size() else tiles[e[1]][e[0]] - var co = Vector2i(floor(tiles[0].size() / 2), floor(tiles.size() - 2)) - for y in tiles.size(): - for x in tiles[y].size(): - map.set_tile(Vector2i(x,y) - co, gt.call([x,y]), [[x,y-1],[x-1,y],[x,y+1],[x+1,y]].map(gt)) + var offset = Vector2i(floor(tiles[0].size() / 2), floor(tiles.size() - 2)) + var pos_to_tile: Dictionary[Vector2i, Array] = {} # : Dictionary[Vector2i, Array[String]] + for y in range(tiles.size()): + for x in range(tiles[y].size()): + pos_to_tile[Vector2i(x,y) - offset] = tiles[y][x] + map.set_all_tiles(pos_to_tile) map.flush() -- cgit v1.3