grunk/src/world/mechanics/alarm/gunk_alarm.gd

33 lines
859 B
GDScript3
Raw Normal View History

2025-03-13 13:34:35 -06:00
class_name GunkAlarm extends GunkNode
## Raises the grunk alert when triggered.
const ALERT_DELTA := 1
var _busy := false
@onready var mesh_instance_3d: MeshInstance3D = %MeshInstance3D
@onready var animation_player: AnimationPlayer = %AnimationPlayer
## Trigger this alarm.
##
## Will not trigger if this alarm is busy (e.g. on cooldown)
func trigger() -> void:
if not _busy:
_busy = true
2025-03-13 14:50:59 -06:00
Game.manager.raise_alert(ALERT_DELTA)
2025-03-13 13:34:35 -06:00
animation_player.play("trigger")
func _process(delta: float) -> void:
super._process(delta)
# TODO actual model & animation
var material: StandardMaterial3D = mesh_instance_3d.mesh.surface_get_material(0)
var value := 1.0 - _sustained_damage / durability
material.albedo_color = Color(value, value, value)
func _on_animation_finished(anim_name: StringName) -> void:
if anim_name == "trigger":
_busy = false