ProjectDDD/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionComponent.cs

61 lines
1.8 KiB
C#
Raw Normal View History

using UnityEngine;
namespace DDD
{
public class RestaurantInteractionComponent : MonoBehaviour, IInteractable
{
[SerializeField] private InteractionType _interactionType = InteractionType.None;
[SerializeField] private float _holdTime = 1f;
2025-08-05 10:46:36 +00:00
[SerializeField] private string _interactionMessageKey = "";
[SerializeField] protected GameFlowState _interactionAvailableFlows;
public bool CanInteract()
{
return !IsInteractionHidden();
}
public bool IsInteractionHidden()
{
var currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState;
var flowDisabled = (currentGameFlowState & _interactionAvailableFlows) == 0;
return flowDisabled;
}
public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
{
if (CanInteract() == false)
{
return false;
}
bool interactionResult = RestaurantInteractionEvents.RestaurantInteraction.RequestInteraction(interactor.GetInteractorGameObject(),
GetInteractableGameObject(), GetInteractionType(), payloadSo, true);
return interactionResult;
}
public InteractionType GetInteractionType()
{
return _interactionType;
}
public GameObject GetInteractableGameObject()
{
return gameObject;
}
public void InitializeInteraction(InteractionType interactionType)
{
_interactionType = interactionType;
}
public float GetRequiredHoldTime()
{
return _holdTime;
}
2025-08-05 10:46:36 +00:00
public string GetInteractionMessageKey()
{
return _interactionMessageKey;
}
}
}