diff options
| author | tpart <tpart120@proton.me> | 2026-02-26 20:41:51 +0100 |
|---|---|---|
| committer | tpart <tpart120@proton.me> | 2026-02-26 20:49:58 +0100 |
| commit | cabc45cd02d2159d89bb37fc29bf83a23e89b8f0 (patch) | |
| tree | 9a6ac402a1dbe3f396468ab74f000a7b24c76d3f /client | |
| parent | 04dd47d13a8da9224e7f9ea8ccacf64129717ec1 (diff) | |
| download | hurrycurry-cabc45cd02d2159d89bb37fc29bf83a23e89b8f0.tar hurrycurry-cabc45cd02d2159d89bb37fc29bf83a23e89b8f0.tar.bz2 hurrycurry-cabc45cd02d2159d89bb37fc29bf83a23e89b8f0.tar.zst | |
Fix kitchen background not working
Diffstat (limited to 'client')
| -rw-r--r-- | client/game.gd | 8 | ||||
| -rw-r--r-- | client/gui/menus/main/background.gd | 3 | ||||
| -rw-r--r-- | client/map/kitchen_background.gd | 25 | ||||
| -rw-r--r-- | client/map/map.gd | 4 |
4 files changed, 21 insertions, 19 deletions
diff --git a/client/game.gd b/client/game.gd index ebcb688e..8d2a33a0 100644 --- a/client/game.gd +++ b/client/game.gd @@ -227,15 +227,13 @@ func handle_packet(p): pl.finish(h) pl.set_item(null, h) "update_map": - var pending_changes: Dictionary[Vector2i, Array] = {} # Dictionary[Vector2i, Array[String]] + var changes: Dictionary[Vector2i, Array] = {} # Dictionary[Vector2i, Array[String]] for change in p["changes"]: var pos := Vector2i(change[0][0], change[0][1]) var tiles: Array = change[1].map(func(x): return tile_names[int(x)] if x != null else null) # : Array[String] - pending_changes[pos] = tiles - - for pos: Vector2i in pending_changes: - map.set_tiles(pos, pending_changes[pos], pending_changes) + changes[pos] = tiles + map.set_all_tiles(changes) map.flush() "communicate": # TODO: use MessageParser diff --git a/client/gui/menus/main/background.gd b/client/gui/menus/main/background.gd index 6bf31ef9..e45fdaaa 100644 --- a/client/gui/menus/main/background.gd +++ b/client/gui/menus/main/background.gd @@ -40,8 +40,7 @@ func _ready(): tiles[Vector2i(x,y)] = [tile] if tile == "counter" and randf() > 0.5 and w > 0.45: item_counters.push_back(Vector2i(x, y)) - for pos: Vector2i in tiles: - map.set_tiles(Vector2i(pos.x, pos.y), tiles[pos], tiles) + map.set_all_tiles(tiles) map.flush() for v: Vector2i in item_counters: 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() diff --git a/client/map/map.gd b/client/map/map.gd index afac0a1b..acf7c1a4 100644 --- a/client/map/map.gd +++ b/client/map/map.gd @@ -41,6 +41,10 @@ func get_tile_instance(pos: Vector2i) -> Tile: if e != null: return e.tile else: return null +func set_all_tiles(changes: Dictionary[Vector2i, Array]): + for pos: Vector2i in changes: + set_tiles(Vector2i(pos.x, pos.y), changes[pos], changes) + func set_tiles(pos: Vector2i, tiles: Array = [], pending_changes: Dictionary[Vector2i, Array] = {}): # tiles: Array[String] var inst = get_tile_instance(pos) if inst != null and not tiles.is_empty(): |