37 lines
750 B
GDScript
37 lines
750 B
GDScript
class_name Spawner extends Area3D
|
|||
|
|
|
||
|
|
|
||
|
|
@export var faction: Globals.Faction = Globals.Faction.NEUTRAL
|
||
|
|
|
||
|
|
var is_available: bool = true
|
||
|
|
var delay_timer: Timer = null
|
||
|
|
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
pass
|
||
|
|
|
||
|
|
func _on_area_body_entered(_body: Jet) -> void:
|
||
|
|
if delay_timer:
|
||
|
|
delay_timer.stop()
|
||
|
|
|
||
|
|
delay_timer = null
|
||
|
|
|
||
|
|
func _on_area_body_exited(_body: Jet) -> void:
|
||
|
|
delay_timer = Timer.new()
|
||
|
|
delay_timer.one_shot = true
|
||
|
|
delay_timer.timeout.connect(can_spawn)
|
||
|
|
|
||
|
|
|
||
|
|
func set_can_spawn(availablity: bool = true) -> void:
|
||
|
|
is_available = availablity
|
||
|
|
|
||
|
|
func can_spawn() -> void:
|
||
|
|
is_available = true
|
||
|
|
|
||
|
|
func cannot_spawn() -> void:
|
||
|
|
is_available = false
|
||
|
|
|
||
|
|
func align_to_position(jet: Jet) -> void:
|
||
|
|
jet.global_position = global_position
|
||
|
|
jet.rotation = rotation
|