ProjectDDD/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs
Jeonghyeon Ha e0e0f3564f 인터랙션 파라미터 구조체 작성
InteractionExecutionParameters, InteractionDisplayParamaters
2025-08-20 12:59:29 +09:00

73 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace DDD
{
/* TODO : BitFlag 제거해야할듯.
인터랙션 개수가 엄청나게 많아질것으로 예상됨.
혹은 인터랙션 타입을 여기서 추가하면 안 되고 여기는 몇가지 정적인 타입만 두고 RestaurantInteraction 같은 식으로 확장해서 사용해야함.
확장성을 생각하면 RestaurantInteractionSolver에서 RestaurantInteractionType을 리졸브해서 또 다른 Solver로 포워딩하는 식으로.
편하게 하려면 그냥 여기서 비트연산자 없애고 인터랙션타입을 무한정 늘리기.
*/
[Flags]
public enum InteractionType : ulong
{
None = 0u,
RestaurantManagementUi = 1u << 0,
OpenRestaurant = 1u << 1,
All = 0xFFFFFFFFu
}
[System.Serializable]
public struct InteractionExecutionParameters
{
[SerializeField] private float _holdTime;
public float HoldTime => _holdTime;
public InteractionExecutionParameters(float holdTime = 1f)
{
_holdTime = holdTime;
}
}
[System.Serializable]
public struct InteractionDisplayParameters
{
[SerializeField] private string _messageKey;
public string MessageKey => _messageKey;
public InteractionDisplayParameters(string messageKey = "")
{
_messageKey = messageKey;
}
}
public interface IInteractable
{
bool CanInteract();
bool IsInteractionHidden();
bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null);
InteractionType GetInteractionType();
GameObject GetInteractableGameObject();
void InitializeInteraction(InteractionType interactionType);
InteractionExecutionParameters GetExecutionParameters();
InteractionDisplayParameters GetDisplayParameters();
Vector3[] GetInteractionPoints();
}
public interface IInteractor
{
GameObject GetInteractorGameObject();
IInteractable GetFocusedInteractable();
bool CanSolveInteractionType(InteractionType interactionType);
bool CanInteractTo(IInteractable interactable,
ScriptableObject payloadSo = null);
}
public interface IInteractionSolver
{
bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject payloadSo = null);
bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null,
ScriptableObject payloadSo = null);
}
}