2025-07-22 11:15:20 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
2025-08-05 08:09:14 +00:00
|
|
|
namespace DDD
|
2025-07-22 11:15:20 +00:00
|
|
|
{
|
|
|
|
public class RestaurantInteractionComponent : MonoBehaviour, IInteractable
|
|
|
|
{
|
2025-08-05 08:09:14 +00:00
|
|
|
[SerializeField] private InteractionType _interactionType = InteractionType.None;
|
|
|
|
[SerializeField] private float _holdTime = 1f;
|
2025-08-05 10:46:36 +00:00
|
|
|
[SerializeField] private string _interactionMessageKey = "";
|
2025-08-05 08:09:14 +00:00
|
|
|
|
2025-08-14 05:30:14 +00:00
|
|
|
[SerializeField] protected GameFlowState _interactionAvailableFlows;
|
2025-08-19 11:13:29 +00:00
|
|
|
[SerializeField] private Transform[] _aiInteractionPoints;
|
2025-08-14 05:30:14 +00:00
|
|
|
|
2025-07-22 11:15:20 +00:00
|
|
|
public bool CanInteract()
|
|
|
|
{
|
2025-08-14 05:30:14 +00:00
|
|
|
return !IsInteractionHidden();
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsInteractionHidden()
|
|
|
|
{
|
|
|
|
var currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState;
|
|
|
|
var flowDisabled = (currentGameFlowState & _interactionAvailableFlows) == 0;
|
|
|
|
return flowDisabled;
|
2025-07-22 11:15:20 +00:00
|
|
|
}
|
|
|
|
|
2025-08-14 04:46:36 +00:00
|
|
|
public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
|
2025-07-22 11:15:20 +00:00
|
|
|
{
|
|
|
|
if (CanInteract() == false)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2025-08-05 08:09:14 +00:00
|
|
|
bool interactionResult = RestaurantInteractionEvents.RestaurantInteraction.RequestInteraction(interactor.GetInteractorGameObject(),
|
2025-08-14 04:46:36 +00:00
|
|
|
GetInteractableGameObject(), GetInteractionType(), payloadSo, true);
|
2025-07-22 11:15:20 +00:00
|
|
|
return interactionResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
public InteractionType GetInteractionType()
|
|
|
|
{
|
2025-08-05 08:09:14 +00:00
|
|
|
return _interactionType;
|
2025-07-22 11:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public GameObject GetInteractableGameObject()
|
|
|
|
{
|
2025-08-05 08:09:14 +00:00
|
|
|
return gameObject;
|
2025-07-22 11:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void InitializeInteraction(InteractionType interactionType)
|
|
|
|
{
|
2025-08-05 08:09:14 +00:00
|
|
|
_interactionType = interactionType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float GetRequiredHoldTime()
|
|
|
|
{
|
|
|
|
return _holdTime;
|
2025-07-22 11:15:20 +00:00
|
|
|
}
|
2025-08-05 10:46:36 +00:00
|
|
|
|
|
|
|
public string GetInteractionMessageKey()
|
|
|
|
{
|
|
|
|
return _interactionMessageKey;
|
|
|
|
}
|
2025-08-19 11:13:29 +00:00
|
|
|
|
|
|
|
public Vector3[] GetInteractionPoints()
|
|
|
|
{
|
|
|
|
if (_aiInteractionPoints == null || _aiInteractionPoints.Length == 0)
|
|
|
|
{
|
|
|
|
// AI 상호작용 포인트가 설정되지 않은 경우 오브젝트의 위치를 기본값으로 반환
|
|
|
|
return new Vector3[] { transform.position };
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3[] positions = new Vector3[_aiInteractionPoints.Length];
|
|
|
|
for (int i = 0; i < _aiInteractionPoints.Length; i++)
|
|
|
|
{
|
|
|
|
if (_aiInteractionPoints[i] != null)
|
|
|
|
{
|
|
|
|
positions[i] = _aiInteractionPoints[i].position;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
positions[i] = transform.position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return positions;
|
|
|
|
}
|
2025-07-22 11:15:20 +00:00
|
|
|
}
|
|
|
|
}
|