maint: moving around methods to work better with Unit/Player/Enemy classes
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Reset.Core;
|
||||
using Drawing;
|
||||
using Reset.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units{
|
||||
public interface IKillable : IDamageable{
|
||||
@@ -6,5 +8,29 @@ namespace Reset.Units{
|
||||
|
||||
public float maxHealth{ get; set; }
|
||||
public float currentHealth{ get; set; }
|
||||
|
||||
void IKillableInitialize(){
|
||||
SetMaxHealth();
|
||||
}
|
||||
|
||||
private void SetMaxHealth(){
|
||||
if (maxHealth == 0f) {
|
||||
Debug.LogError($"Max health is not set for type of <b>{((object)this)}</b>. Setting to 10000.");
|
||||
currentHealth = 10000f;
|
||||
} else {
|
||||
currentHealth = maxHealth;
|
||||
}
|
||||
}
|
||||
|
||||
internal void DrawHealthDebug(){
|
||||
using (Draw.WithColor(Color.blue)) {
|
||||
Draw.ingame.Label2D(((MonoBehaviour)this).transform.position + Vector3.up * 2.2f, ((IKillable)this).currentHealth.ToString(),
|
||||
Color.blue);
|
||||
}
|
||||
}
|
||||
|
||||
private void InternalUpdate(){
|
||||
Debug.Log("is this possible");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user