diff options
| author | tpart <tpart120@proton.me> | 2026-02-28 23:37:21 +0100 |
|---|---|---|
| committer | tpart <tpart120@proton.me> | 2026-02-28 23:37:21 +0100 |
| commit | 87a2dfefa605dfaac8008e6b7233e475d369c4b9 (patch) | |
| tree | 516837f71bb96aaf6937331207aee9bd007ad097 /client | |
| parent | bb76c2464d8bf475252f57a9b9686dba57500405 (diff) | |
| download | hurrycurry-87a2dfefa605dfaac8008e6b7233e475d369c4b9.tar hurrycurry-87a2dfefa605dfaac8008e6b7233e475d369c4b9.tar.bz2 hurrycurry-87a2dfefa605dfaac8008e6b7233e475d369c4b9.tar.zst | |
Add special case system for combinating tiles
Diffstat (limited to 'client')
| -rw-r--r-- | client/global.gd | 6 | ||||
| -rw-r--r-- | client/map/map.gd | 9 |
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: |