diff --git a/theProject/Assets/Scripts/Entities/Entity.cs b/theProject/Assets/Scripts/Entities/Entity.cs index 74e64ec5..2441bf8c 100644 --- a/theProject/Assets/Scripts/Entities/Entity.cs +++ b/theProject/Assets/Scripts/Entities/Entity.cs @@ -21,7 +21,6 @@ public class Entity : MonoBehaviour [HideInInspector] public UnityEvent OnDeath = new UnityEvent(); - public Team GetOwnTeam() { return myTeam; @@ -51,6 +50,18 @@ public class Entity : MonoBehaviour } } + protected virtual void Awake() + { + TickSystem.OnTick += HandleTick; + } + + protected virtual void Die() + { + TickSystem.OnTick -= HandleTick; + OnDeath.Invoke(this); + Destroy(gameObject); + } + public void SetOwnTeam(Team type) { myTeam = type; @@ -61,17 +72,16 @@ public class Entity : MonoBehaviour healthPoints -= damage; if (healthPoints <= 0) - Destroy(gameObject); + Die(); UpdateHPDisplay(); Debug.Log("I took damage, my HP is now: " + healthPoints + " noooo!!!!", gameObject); } - protected virtual void Die() - { - OnDeath.Invoke(this); - Destroy(gameObject); - } + protected virtual void HandleTick(TickSystem.OnTickEventArgs tickEventArgs) + { + + } private void OnDestroy() { diff --git a/theProject/Assets/Scripts/Entities/Soldier.cs b/theProject/Assets/Scripts/Entities/Soldier.cs index d609d74c..b43c7af4 100644 --- a/theProject/Assets/Scripts/Entities/Soldier.cs +++ b/theProject/Assets/Scripts/Entities/Soldier.cs @@ -66,19 +66,10 @@ public class Soldier : Entity else enemyType = Team.Ally; } - void Awake() - { - TickSystem.OnTick += HandleTick; - } - - protected override void Die() + protected override void HandleTick(TickSystem.OnTickEventArgs tickEventArgs) { - TickSystem.OnTick -= HandleTick; - base.Die(); - } + // base.HandleTick(tickEventArgs); - private void HandleTick(TickSystem.OnTickEventArgs tickEventArgs) - { ref Queue queueToHandle = ref interrupts; if (interrupts.Count < 1) // if no interrupt actions to do, handle regular queue queueToHandle = actions;