Files

36 lines
1.0 KiB
C#

using Drawing;
using Reset.Core;
using Unity.Netcode;
using UnityEngine;
namespace Reset.Units{
public interface IKillable : IDamageable{
public void Kill();
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 <b>{((MonoBehaviour)this).name}</b>. Setting to 10000.");
currentHealth = 10000f;
} else {
currentHealth = maxHealth;
}
}
[Rpc(SendTo.Everyone)]
void SetHealthRpc(float health);
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);
}
}
}
}