Godot Version
4.2.1
Question
So im working on a game and I have each tile in a tilemap with their own modulate. Occasionally, this modulate needs to change so I wrote some code so that only the tiles that need updates are updated. However, it appears the tiles arent saving their colors if they arent updated. Can anyone help?
World.gd:
# Tile Data
func _use_tile_data_runtime_update(layer: int, coords: Vector2i) -> bool:
if (generationDone):
return provinces[coords.x][coords.y].colorUpdateNeeded
else:
return true
func _tile_data_runtime_update(layer: int, coords: Vector2i, tile_data: TileData) -> void:
#var currentProvince = provinces[coords.x][coords.y]
tile_data.modulate = provinces[coords.x][coords.y].color
func updateGridColor():
notify_runtime_tile_data_update(0)
if (!generationDone):
generationDone = true
Province.gd
func colorTile():
colorUpdateNeeded = true
if (!controller):
colorBiome()
else:
color = controller.color
if (!game.mapChanged):
game.mapChanged = true
#colorUpdate.emit()
func update():
colorUpdateNeeded = false
if (passable && !fullyUnclaimed):
neutralConquest()
Game.gd
func updateTime():
mapChanged = false
updateDay()
updateEnd.emit()
if (mapChanged):
tilemapUpdate.emit()
# Tilemap update is connected to updateGridColor
Result:
If you need any more code just ask!
Thanks!