mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
34 lines
1.1 KiB
GDScript
34 lines
1.1 KiB
GDScript
extends Node
|
|
|
|
var Tilemap = preload("res://world/Tilemap.tscn")
|
|
var tilemaps = []
|
|
|
|
func _ready():
|
|
StateServer.connect("changed_tiletypes", self, "_on_StateServer_changed_tiletypes")
|
|
StateServer.connect("request_init", self, "_on_StateServer_request_init")
|
|
|
|
func respawn_tilemaps():
|
|
tilemaps = []
|
|
for i in range(0, StateServer.get_world_size().z):
|
|
var map = Tilemap.instance()
|
|
map.position.y -= i * map.cell_size.y
|
|
map.z_index = i
|
|
add_child(map)
|
|
tilemaps.push_back(map)
|
|
|
|
func get_tile_at(pos: Vector3) -> String:
|
|
return StateServer.get_tile_at(int(pos.x), int(pos.y), int(pos.z))
|
|
|
|
func update_tiles(tile_positions: PoolVector3Array):
|
|
for tile in tile_positions:
|
|
if !StateServer.is_tile_hidden(int(tile.x), int(tile.y), int(tile.z)):
|
|
tilemaps[tile.z].set_tile_graphics(Vector2(tile.x, tile.y),
|
|
get_tile_at(tile))
|
|
for map in tilemaps:
|
|
map.update_dirty_quadrants()
|
|
|
|
func _on_StateServer_request_init():
|
|
call_deferred("respawn_tilemaps")
|
|
|
|
func _on_StateServer_changed_tiletypes(tile_positions: PoolVector3Array):
|
|
call_deferred("update_tiles", tile_positions)
|