using UnityEngine;
public class OneUseHealthSource : MonoBehaviour, IHealthSource
{
public GameObject i_source { get => m_source;
set => m_source = value; }
public float i_health { get => m_healingAmount;
set => m_healingAmount = value; }
private GameObject m_source;
[SerializeField]
private float m_healingAmount;
private void Awake()
{
m_source = gameObject;
}
public void InflictHealth(IHarmable target)
{
target.Heal(m_healingAmount);
}
private void OnCollisionEnter(Collision collision)
{
IHarmable other = collision.gameObject.GetComponent<IHarmable>();
if (other != null)
{
InflictHealth(other);
Destroy(gameObject);
}
}
}