@@ -1,10 +1,12 @@
|
||||
extends Node2D
|
||||
class_name Base
|
||||
|
||||
@export var corruption_pattern: ExpansionBase
|
||||
@export var world: World
|
||||
|
||||
@onready var expand_timer: Timer = $ExpandTimer
|
||||
var grid_loc: Vector2i
|
||||
|
||||
const curruption_directions := [Vector2i.LEFT, Vector2i.RIGHT, Vector2i.UP, Vector2i.DOWN]
|
||||
var corruption_tiles: Array[Vector2i] = []
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -14,8 +16,10 @@ func _ready() -> void:
|
||||
world.corrupt_location(grid_loc)
|
||||
|
||||
func _on_expand_timer_timeout() -> void:
|
||||
var corrupt_tile: Vector2i = 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.corrupt_location(corrupt_tile)
|
||||
var corrupt_tile: Vector2i = corruption_pattern.expand_next_tile() + grid_loc
|
||||
if corrupt_tile:
|
||||
corruption_tiles.append(corrupt_tile)
|
||||
world.corrupt_location(corrupt_tile)
|
||||
|
||||
func on_corruption_finished() -> void:
|
||||
expand_timer.stop()
|
||||
|
||||
Reference in New Issue
Block a user