duncgibbs a9352d337d
Some checks failed
linting & formatting / build (push) Failing after 24s
way too many changes; multiplayer version, like, 0.6 or 0.7
2026-04-20 13:03:39 -05:00

52 lines
1.0 KiB
GDScript

class_name Spawn extends Tile
enum Size { SMALL, MEDIUM, LARGE }
const CITIZEN_SCENE = preload("uid://bwx0lqtkd2jd7")
@export var spawn_size: Size = Size.SMALL
@export var direction: Board.Direction = Board.Direction.UP
var spawn_time: float = 0.5
var spawn_left: int
var current_time: float = 0
var paused: bool = true
@onready var icon: ColorRect = %Icon
func _ready() -> void:
match spawn_size:
Size.SMALL:
spawn_left = 1
func pause() -> void:
paused = true
func unpause() -> void:
paused = false
func handle_post_turn_actions() -> void:
match spawn_size:
Size.SMALL:
spawn_left = 10
func _physics_process(delta: float) -> void:
#print(paused)
if paused:
return
current_time += delta
if current_time >= spawn_time and spawn_left > 0:
spawn_left -= 1
current_time = 0
var citizen: Citizen = CITIZEN_SCENE.instantiate()
add_sibling(citizen)
citizen.add_to_group("Pausable")
citizen.position = position
citizen.set_offset(Vector2(randf_range(-40, 40), randf_range(-40, 40)))
citizen.direction = direction