fixed customer interaction flow

This commit is contained in:
Jeonghyeon Ha 2025-08-27 19:15:21 +09:00
parent fbe0f26562
commit 18a9d9fef0
4 changed files with 35 additions and 18 deletions

View File

@ -39,9 +39,7 @@ public override TaskStatus OnUpdate()
return TaskStatus.Failure;
}
// TODO : 아래 상호작용 수행 로직이 우리 프로젝트의 권장하는 방식이 아님. 플레이어가 오브젝트에 인터랙션하는 것과 비슷한 흐름으로 NPC가 오브젝트에 인터랙션하게 만들 것.
// TODO : 이벤트 통해서 인터랙션. 직접 호출하지 말 것!
outInteractable.OnInteracted(_interactor);
RestaurantEvents.InteractionEvent.RequestInteraction(_interactor.GetInteractorGameObject(), outInteractable.gameObject, outInteractable.GetInteractionType());
if (_registerOnBlackboard)
{

View File

@ -53,8 +53,7 @@ public static TaskStatus FindAvailableOrderInteractable<T>(bool checkCanInteract
if (outInteractable == null) continue;
if (!outInteractable.TryGetSubsystemObject<T>(out var subsystem)) continue;
if (EqualityComparer<T>.Default.Equals(subsystem.GetInteractionSubsystemType(), targetOrderType)
)
if (EqualityComparer<T>.Default.Equals(subsystem.GetInteractionSubsystemType(), targetOrderType))
{
// CheckCanInteract이 false면 타입만 맞으면 성공
if (!checkCanInteract)

View File

@ -14,7 +14,12 @@ public enum RestaurantOrderType : uint
Dirty = 1u << 4,
}
public class InteractionSubsystem_Order : MonoBehaviour, IInteractionSubsystemObject<RestaurantOrderType>
public interface IRestaurantOrderObject
{
void TransitionToNextPhase();
}
public class InteractionSubsystem_Order : MonoBehaviour, IInteractionSubsystemObject<RestaurantOrderType>, IRestaurantOrderObject
{
[FormerlySerializedAs("orderType")] [SerializeField] protected RestaurantOrderType _orderType = RestaurantOrderType.Wait;
private RestaurantOrderType _currentRestaurantOrderType;
@ -26,18 +31,23 @@ private void Start()
public bool CanInteract()
{
//if (GetInteractionSubsystemType() == RestaurantOrderType.Wait)
//{
// return true;
//}
if (GetInteractionSubsystemType() == RestaurantOrderType.Wait)
{
return CanTransitionToNextPhase();
}
return true;
}
public void TransitionToNextPhase()
{
// 간단한 상태 전이: 현재 상태에서 다음 상태로 이동
var currentState = GetInteractionSubsystemType();
var nextState = GetNextState(currentState);
SetInteractionSubsystemType(nextState);
}
public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
{
// 간단한 상태 전이: 현재 상태에서 다음 상태로 이동
var prev = _currentRestaurantOrderType;
_currentRestaurantOrderType = GetNextState(prev);
return true;
}
@ -74,5 +84,10 @@ private RestaurantOrderType GetNextState(RestaurantOrderType state)
default: return RestaurantOrderType.Wait;
}
}
public bool CanTransitionToNextPhase()
{
return true;
}
}
}

View File

@ -8,11 +8,16 @@ public class RestaurantOrderSolver_Wait : MonoBehaviour, IInteractionSubsystemSo
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{
if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false) return false;
// TODO : DO SOMETHING!!!
/* TODO
* OnInteracted에서 , , ? CanInteractTo에서 ?
* IInteractable CurrentInteractor를 ?
*/
if (interactable is not IInteractionSubsystemOwner subsystemOwner)
return false;
if (!subsystemOwner.TryGetSubsystemObject<RestaurantOrderType>(out var subsystem))
return false;
if (subsystem is IRestaurantOrderObject orderObject)
{
orderObject.TransitionToNextPhase();
}
return true;
}