aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/global.gd6
-rw-r--r--client/map/map.gd9
2 files changed, 15 insertions, 0 deletions
diff --git a/client/global.gd b/client/global.gd
index 478c9d93..c9db6be6 100644
--- a/client/global.gd
+++ b/client/global.gd
@@ -185,3 +185,9 @@ static func has_one(arr: Array, items: Array):
if arr.has(item):
return true
return false
+
+static func has_all(arr: Array, items: Array):
+ for item in items:
+ if not arr.has(item):
+ return false
+ return true
diff --git a/client/map/map.gd b/client/map/map.gd
index d2467fd6..eb1e13bb 100644
--- a/client/map/map.gd
+++ b/client/map/map.gd
@@ -26,6 +26,9 @@ class TileInfo:
var interact_tile: Tile
const NEIGHBOR_OFFSETS: Array[Vector2i] = [Vector2i.UP, Vector2i.LEFT, Vector2i.DOWN, Vector2i.RIGHT]
+const TILE_COMBINATOR: Dictionary[Array, Array] = {
+ ["counter", "sink"]: ["sink"]
+ } # : Dictionary[Array[String], Array[String]]
var tile_by_pos: Dictionary[Vector2i, TileInfo] = {}
var autoflush = false
@@ -62,6 +65,12 @@ func set_tiles(pos: Vector2i, tiles: Array = [], pending_changes: Dictionary[Vec
if autoflush: flush()
func _add_tiles(pos: Vector2i, tiles: Array, pending_changes: Dictionary[Vector2i, Array] = {}) -> void:
+ # Combinate tiles
+ for k in TILE_COMBINATOR:
+ if G.has_all(tiles, k):
+ for item: String in k: tiles.erase(item)
+ tiles.append_array(TILE_COMBINATOR[k])
+
# Find neighbor tile names
var neighbors: Array[Array] = [] # Array[Array[String]]
for offset: Vector2i in NEIGHBOR_OFFSETS: