canto/Assets/Scripts/Interaction/Interactable.cs
2025-07-14 22:22:25 -04:00

36 lines
872 B
C#

using KitsuneCafe.System;
using UnityEngine;
using UnityEngine.Events;
namespace KitsuneCafe.Interaction
{
public class Interactable : MonoBehaviour, IInteractable
{
[SerializeField]
private bool oneTimeUse = false;
[SerializeField]
private UnityEvent<IInteractor> onInteracted = default;
private bool isInteractable = true;
public bool IsInteractable => isInteractable;
public IResult<Unit, InteractionError> Interact(IInteractor interactor)
{
onInteracted.Invoke(interactor);
if (oneTimeUse)
{
isInteractable = false;
}
return Result.Ok<Unit, InteractionError>(default);
}
public void SetInteractable(bool interactable = true)
{
isInteractable = interactable;
}
}
}