Added visibility component

This commit is contained in:
2024-02-13 20:38:17 +01:00
parent 5caf5f6c71
commit 7937645028
12 changed files with 124 additions and 107 deletions

View File

@ -25,19 +25,19 @@ func drop_loot():
loot.global_position = owner.global_position + loot.position
func die():
set_alive(false)
DeathComponent.set_physics(owner, false)
hud.visible = false
animation.play("slime_death")
func revive():
health.restore()
set_alive(true)
DeathComponent.set_physics(owner, true)
hud.visible = true
(owner as Node3D).transform = Transform3D.IDENTITY
owner.global_position = respawn_position
animation.play("slime_idle")
func set_alive(alive: bool):
owner.propagate_call("set_process", [alive])
owner.propagate_call("set_physics_process", [alive])
owner.get_node("Collision").call_deferred("set_disabled", !alive)
hud.visible = alive
static func set_physics(obj: Node3D, alive: bool):
obj.propagate_call("set_process", [alive])
obj.propagate_call("set_physics_process", [alive])
obj.get_node("Collision").call_deferred("set_disabled", !alive)