29 lines
647 B
C#
29 lines
647 B
C#
using System;
|
|
using R3;
|
|
using UnityEngine;
|
|
|
|
namespace KitsuneCafe.Entity
|
|
{
|
|
public class Health : MonoBehaviour, IDamageable
|
|
{
|
|
[SerializeField]
|
|
private SerializableReactiveProperty<int> max;
|
|
|
|
public int Max => max.CurrentValue;
|
|
|
|
[SerializeField]
|
|
private SerializableReactiveProperty<int> current;
|
|
|
|
public int Current => current.CurrentValue;
|
|
|
|
public void Recover(int amount)
|
|
{
|
|
this.current.Value = Math.Clamp(this.Current + amount, 0, this.Max);
|
|
}
|
|
|
|
public void ReceiveDamage(IDamaging source, int amount)
|
|
{
|
|
this.current.Value = Math.Clamp(this.Current - amount, 0, this.Max);
|
|
}
|
|
}
|
|
}
|