69 lines
1.4 KiB
GDScript3
Raw Permalink Normal View History

class_name Spawn extends Building
2026-04-13 11:34:00 -05:00
enum Size { SMALL, MEDIUM, LARGE }
const CITIZEN_SCENE = preload("uid://bwx0lqtkd2jd7")
2026-04-13 11:34:00 -05:00
@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
2026-04-13 11:34:00 -05:00
func _ready() -> void:
match spawn_size:
Size.SMALL:
2026-04-20 13:33:56 -05:00
spawn_left = 10
2026-04-13 11:34:00 -05:00
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
2026-04-13 11:34:00 -05:00
current_time += delta
if current_time >= spawn_time and spawn_left > 0:
spawn_left -= 1
current_time = 0
var citizen: Citizen = CITIZEN_SCENE.instantiate()
2026-04-13 11:34:00 -05:00
add_sibling(citizen)
citizen.add_to_group("Pausable")
citizen.position = position
2026-04-13 11:34:00 -05:00
citizen.set_offset(Vector2(randf_range(-40, 40), randf_range(-40, 40)))
citizen.direction = direction
2026-04-20 13:33:56 -05:00
citizen.handle_tile_area_exited(null)
func activate(_citizen: Citizen) -> void:
pass
func can_citizen_enter(_coord: Vector2i, _direction: Board.Direction) -> bool:
return true
func get_direction_queue(_citizen: Citizen) -> Array[Board.Direction]:
return []
func get_tile_coords() -> Array[Vector2i]:
return [starting_coord]