generated from krampus/template-godot4
33 lines
820 B
GDScript
33 lines
820 B
GDScript
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
|
|
Game.manager.raise_alert(ALERT_DELTA)
|
|
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 - pct_damage()
|
|
material.albedo_color = Color(value, value, value)
|
|
|
|
|
|
func _on_animation_finished(anim_name: StringName) -> void:
|
|
if anim_name == "trigger":
|
|
_busy = false
|