27 lines
652 B
GDScript
27 lines
652 B
GDScript
## SecuritySystem.gd
|
|
## The shared objective the team must protect.
|
|
class_name SecuritySystem
|
|
extends Node2D
|
|
|
|
@export var max_hp: int = 20
|
|
var _hp: int = 20
|
|
|
|
func _ready() -> void:
|
|
_hp = max_hp
|
|
EventBus.creep_reached_exit.connect(_on_creep_reached_exit)
|
|
|
|
func _on_creep_reached_exit(_creep: Node, hp_damage: int) -> void:
|
|
take_damage(hp_damage)
|
|
|
|
func take_damage(amount: int) -> void:
|
|
_hp = max(0, _hp - amount)
|
|
EventBus.security_system_damaged.emit(amount, _hp)
|
|
if _hp <= 0:
|
|
EventBus.security_system_destroyed.emit()
|
|
GameState.set_phase(GameState.Phase.GAME_OVER)
|
|
|
|
func get_hp() -> int:
|
|
return _hp
|
|
|
|
func get_max_hp() -> int:
|
|
return max_hp
|