28 lines
794 B
C#
28 lines
794 B
C#
using UnityEngine;
|
|
|
|
namespace OnlyScove.Scripts
|
|
{
|
|
public class HealthInteractable : BaseInteractable
|
|
{
|
|
[SerializeField] private float healAmount = 25f;
|
|
[SerializeField] private bool destroyOnInteract = true;
|
|
|
|
protected override void PerformInteraction(PlayerStateMachine player)
|
|
{
|
|
if (player.TryGetComponent(out Health health))
|
|
{
|
|
health.Heal(healAmount);
|
|
Debug.Log($"[Healing] Restored {healAmount} health.");
|
|
|
|
if (destroyOnInteract)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning("[Healing] Player has no Health component!");
|
|
}
|
|
}
|
|
}
|
|
} |