24 lines
813 B
GDScript
24 lines
813 B
GDScript
extends Node2D
|
|
class_name Base
|
|
|
|
@export var world_grid: TileMap
|
|
var grid_loc
|
|
var i = 1
|
|
|
|
const curruption_directions := [Vector2i.LEFT, Vector2i.RIGHT, Vector2i.UP, Vector2i.DOWN]
|
|
var corruption_tiles: Array[Vector2i] = []
|
|
|
|
func _ready():
|
|
grid_loc = world_grid.local_to_map(position)
|
|
corruption_tiles.append(grid_loc)
|
|
world_grid.set_cell(Constants.TilemapLayers.BUILDINGS, grid_loc, 0, Vector2i(17,7))
|
|
|
|
|
|
func _on_expand_timer_timeout():
|
|
var corrupt_tile = corruption_tiles.pick_random() + self.curruption_directions.pick_random()
|
|
while corruption_tiles.has(corrupt_tile):
|
|
corrupt_tile = corruption_tiles.pick_random() + self.curruption_directions.pick_random()
|
|
corruption_tiles.append(corrupt_tile)
|
|
world_grid.set_cells_terrain_connect(Constants.TilemapLayers.ENVIRONMENT, corruption_tiles, 0, 0)
|
|
i += 1
|