sort of fix

This commit is contained in:
Gabriel Ksawery Skowron-Rodriguez 2022-05-23 14:15:06 +02:00
parent 42452e6e64
commit 28f7e76c0b
2 changed files with 19 additions and 18 deletions

View File

@ -21,7 +21,6 @@ public class Entity : MonoBehaviour
[HideInInspector] public UnityEvent<Entity> OnDeath = new UnityEvent<Entity>();
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()
{

View File

@ -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<Action> queueToHandle = ref interrupts;
if (interrupts.Count < 1) // if no interrupt actions to do, handle regular queue
queueToHandle = actions;