Compare commits

...

2 Commits

Author SHA1 Message Date
Stedd 813d034fc5 Added debug message is runtime set does not exist 2024-10-05 17:11:50 +02:00
Stedd c81a750f2f Added simple death mechanic 2024-10-05 17:05:49 +02:00
2 changed files with 12 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Events;
namespace GameDev.CoreSystems namespace GameDev.CoreSystems
{ {
@ -14,6 +15,8 @@ namespace GameDev.CoreSystems
[field: Header("Modifiers")] [field: Header("Modifiers")]
[field: SerializeField] public bool IsInvulnerable { get; private set; } [field: SerializeField] public bool IsInvulnerable { get; private set; }
public UnityEvent DeathEvent;
private void OnEnable() private void OnEnable()
{ {
_activeDamageableRuntimeSet.Add(this); _activeDamageableRuntimeSet.Add(this);
@ -35,6 +38,7 @@ namespace GameDev.CoreSystems
if (CurrentHealth >= 0) return; if (CurrentHealth >= 0) return;
print($"{transform.parent.parent.name} died"); print($"{transform.parent.parent.name} died");
DeathEvent.Invoke();
} }
#endregion #endregion

View File

@ -19,7 +19,14 @@ namespace GameDev.CoreSystems
private void OnEnable() private void OnEnable()
{ {
_activeTargetableRuntimeSet.Add(this); if (_activeTargetableRuntimeSet != null)
{
_activeTargetableRuntimeSet.Add(this);
}
else
{
Debug.LogError("TargetableRuntimeSet does not exist");
}
} }
private void OnDisable() private void OnDisable()