using System.Collections; using System.Collections.Generic; using BITKit.Entities; using UnityEngine; namespace BITKit { public class AutoRespawnComponent : EntityComponent,IHealthCallback,IAction { [SerializeField] private IntervalUpdate respawnInterval; private bool requestRespawn; public override void OnAwake() { entity.RegisterCallback(this); } public override void OnUpdate(float deltaTime) { if (requestRespawn && respawnInterval.AllowUpdate) { requestRespawn = false; Execute(); } } public void OnSetAlive(bool alive) { if (alive) { requestRespawn = false; } else { respawnInterval.Reset(); requestRespawn = true; } } public void OnSetHP(int hp) { } public void Execute() { if (TryGetComponent(out var health)) { health.HealthPoint = 100; } } } }