diff --git a/Assets/_DDD/Restaurant/Environments/Interactables/Common/RestaurantOrder.prefab b/Assets/_DDD/Restaurant/Environments/Interactables/Common/RestaurantOrder.prefab index 416b52c32..c6b9273d8 100644 --- a/Assets/_DDD/Restaurant/Environments/Interactables/Common/RestaurantOrder.prefab +++ b/Assets/_DDD/Restaurant/Environments/Interactables/Common/RestaurantOrder.prefab @@ -141,11 +141,12 @@ MonoBehaviour: _executionParameters: _holdTime: 0 _displayParameters: - _messageKey: + k__BackingField: + k__BackingField: _interactionAvailableFlows: 2 _aiInteractionPoints: - {fileID: 1664322405549350652} - autoInitialize: 1 + _autoInitialize: 1 --- !u!114 &4456475204957017828 MonoBehaviour: m_ObjectHideFlags: 0 @@ -221,7 +222,7 @@ MonoBehaviour: Data: - Name: Entry: 12 - Data: 2 + Data: 1 - Name: Entry: 7 Data: @@ -234,18 +235,6 @@ MonoBehaviour: - Name: Entry: 8 Data: - - Name: - Entry: 7 - Data: - - Name: $k - Entry: 3 - Data: 4 - - Name: $v - Entry: 10 - Data: 0 - - Name: - Entry: 8 - Data: - Name: Entry: 13 Data: diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/StartRestaurantOrder.cs b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/StartRestaurantOrder.cs index ba29130bd..045256e15 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/StartRestaurantOrder.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/StartRestaurantOrder.cs @@ -10,13 +10,13 @@ public class StartRestaurantOrder : Action [SerializeField] private RestaurantOrderType _targetOrderType = RestaurantOrderType.Wait; private IInteractor _interactor; - private bool _isGetInteractor; + private bool _isInteractorValid; public override void OnStart() { - _isGetInteractor = gameObject.TryGetComponent(out _interactor); + _isInteractorValid = gameObject.TryGetComponent(out _interactor); - if (!_isGetInteractor) + if (!_isInteractorValid) Debug.LogError($"[{GetType().Name}] IInteractor를 찾을 수 없습니다: {gameObject.name}"); } @@ -61,7 +61,7 @@ public override TaskStatus OnUpdate() } // 상호작용 수행: 액션이 붙은 에이전트를 Interactor로 사용 - if (!_isGetInteractor) + if (!_isInteractorValid) { return TaskStatus.Failure; } diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/Core/RestaurantCharacter.cs b/Assets/_DDD/_Scripts/Restaurant/Character/Core/RestaurantCharacter.cs index 5599e61ac..b5142beef 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/Core/RestaurantCharacter.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/Core/RestaurantCharacter.cs @@ -1,3 +1,4 @@ +using System; using Sirenix.OdinInspector; using UnityEngine; @@ -37,6 +38,11 @@ public bool CanSolveInteractionType(InteractionType interactionType) return _interactionComponent.CanSolveInteractionType(interactionType); } + public bool FetchSolverTypeForInteraction(InteractionType type, out Type solverType) + { + return _interactionComponent.FetchSolverTypeForInteraction(type, out solverType); + } + public bool IsInteractionHidden(IInteractable interactable) { return _interactionComponent.IsInteractionHidden(interactable); diff --git a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Order.cs b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Order.cs index 4d2bb9848..6b8a4ad8d 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Order.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Order.cs @@ -14,14 +14,27 @@ public enum RestaurantOrderType : uint Dirty = 1u << 4, } + public class RestaurantOrderObjectState + { + public GameObject Customer; + public GameObject Worker; + + public string FoodId; + } + public interface IRestaurantOrderObject { void TransitionToNextPhase(); + RestaurantOrderType GetCurrentOrderPhase(); + RestaurantOrderObjectState GetOrderObjectState(); } + // TODO : 도중에 이탈할 경우, 순차적으로 다음 페이즈로 넘어가는 게 아니라 바로 Wait, Dirty로 전이시킬 필요가 있음 + public class InteractionSubsystem_Order : MonoBehaviour, IInteractionSubsystemObject, IRestaurantOrderObject { [SerializeField] private RestaurantOrderType _currentRestaurantOrderType = RestaurantOrderType.Wait; + [SerializeField] private RestaurantOrderObjectState _orderObjectState = new(); public bool CanInteract() { @@ -39,7 +52,17 @@ public void TransitionToNextPhase() var nextState = GetNextState(currentState); SetInteractionSubsystemType(nextState); } - + + public RestaurantOrderType GetCurrentOrderPhase() + { + return _currentRestaurantOrderType; + } + + public RestaurantOrderObjectState GetOrderObjectState() + { + return _orderObjectState; + } + public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null) { return true; diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs b/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs index 8568b690e..25b408a71 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs @@ -4,6 +4,7 @@ using System.Linq; using UnityEngine; using Sirenix.OdinInspector; +using UnityEngine.Serialization; namespace DDD.Restaurant { @@ -27,7 +28,7 @@ public class RestaurantInteractionComponent : MonoBehaviour, IInteractable, IInt [SerializeField] protected InteractionDisplayParameters _displayParameters; [SerializeField] protected GameFlowState _interactionAvailableFlows; [SerializeField] private Transform[] _aiInteractionPoints; - [SerializeField] private bool autoInitialize = true; + [FormerlySerializedAs("autoInitialize")] [SerializeField] private bool _autoInitialize = true; private bool _isInitialized = false; private Dictionary _subsystems = new(); @@ -44,7 +45,7 @@ private void Start() var environmentState = RestaurantState.Instance?.EnvironmentState; environmentState?.RegisterInteractable(this); - if (autoInitialize && !_isInitialized) + if (_autoInitialize && !_isInitialized) { InitializeInteraction(_interactionType); } @@ -70,7 +71,6 @@ public virtual bool CanInteract() public virtual bool IsInteractionAvailable() { - var currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState; var flowDisabled = (currentGameFlowState & _interactionAvailableFlows) == 0; if (flowDisabled) diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolverBase.cs b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolverBase.cs index 63c0a89e3..de1562422 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolverBase.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolverBase.cs @@ -8,11 +8,11 @@ public virtual bool ExecuteInteractionSubsystem(IInteractor interactor, IInterac { if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false) return false; - if (interactable is not IInteractionSubsystemOwner subsystemOwner) - return false; - if (!subsystemOwner.TryGetSubsystemObject(out var subsystem)) - return false; - if (subsystem is IRestaurantOrderObject orderObject) + + if (GetRestaurantOrderObject(interactable) == null) return false; + + var orderObject = GetRestaurantOrderObject(interactable); + if (orderObject != null) { orderObject.TransitionToNextPhase(); } @@ -20,6 +20,19 @@ public virtual bool ExecuteInteractionSubsystem(IInteractor interactor, IInterac } public abstract bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null); + + protected static IRestaurantOrderObject GetRestaurantOrderObject(IInteractable interactable) + { + var subsystemOwner = interactable.GetInteractableGameObject().GetComponent(); + IInteractionSubsystemObject subsystemObject = null; + subsystemOwner?.TryGetSubsystemObject(out subsystemObject); + if (subsystemObject is IRestaurantOrderObject restaurantOrderObject) + { + return restaurantOrderObject; + } + + return null; + } } } \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Order.cs b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Order.cs index 483ded96b..67e8b8344 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Order.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Order.cs @@ -27,6 +27,13 @@ public override bool ExecuteInteractionSubsystem(IInteractor interactor, IIntera var highlightComponent = highlightObject?.GetComponent(); highlightComponent?.ClearHighlightProxy(); + // Worker takes the order + var orderObject = GetRestaurantOrderObject(interactable); + if (orderObject != null) + { + orderObject.GetOrderObjectState().Worker = interactor.GetInteractorGameObject(); + } + // Pick random menu from today's menu list var foodCandidates = RestaurantState.Instance.ManagementState.GetTodayFoodMenus(); if (foodCandidates == null || foodCandidates.Count == 0) diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Serve.cs b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Serve.cs index 8a524e274..d4718a97d 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Serve.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Serve.cs @@ -11,7 +11,7 @@ public override bool ExecuteInteractionSubsystem(IInteractor interactor, IIntera public override bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null) { - return true; + return false; } } } \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Wait.cs b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Wait.cs index c76745736..2a4a374f9 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Wait.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver_Wait.cs @@ -1,5 +1,6 @@ using Opsive.BehaviorDesigner.Runtime.Tasks; using UnityEngine; +using UnityEngine.UIElements; namespace DDD.Restaurant { @@ -7,6 +8,12 @@ public class RestaurantOrderSolver_Wait : RestaurantOrderSolverBase { public override bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null) { + var orderObject = GetRestaurantOrderObject(interactable); + if (orderObject != null) + { + orderObject.GetOrderObjectState().Customer = interactor.GetInteractorGameObject(); + } + return base.ExecuteInteractionSubsystem(interactor, interactable, payload); }