주문 인터랙션 처리
This commit is contained in:
parent
c903c0c210
commit
bf253cd988
@ -141,11 +141,12 @@ MonoBehaviour:
|
|||||||
_executionParameters:
|
_executionParameters:
|
||||||
_holdTime: 0
|
_holdTime: 0
|
||||||
_displayParameters:
|
_displayParameters:
|
||||||
_messageKey:
|
<DefaultMessageKey>k__BackingField:
|
||||||
|
<ConditionalMessageKey>k__BackingField:
|
||||||
_interactionAvailableFlows: 2
|
_interactionAvailableFlows: 2
|
||||||
_aiInteractionPoints:
|
_aiInteractionPoints:
|
||||||
- {fileID: 1664322405549350652}
|
- {fileID: 1664322405549350652}
|
||||||
autoInitialize: 1
|
_autoInitialize: 1
|
||||||
--- !u!114 &4456475204957017828
|
--- !u!114 &4456475204957017828
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -221,7 +222,7 @@ MonoBehaviour:
|
|||||||
Data:
|
Data:
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 12
|
Entry: 12
|
||||||
Data: 2
|
Data: 1
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 7
|
Entry: 7
|
||||||
Data:
|
Data:
|
||||||
@ -234,18 +235,6 @@ MonoBehaviour:
|
|||||||
- Name:
|
- Name:
|
||||||
Entry: 8
|
Entry: 8
|
||||||
Data:
|
Data:
|
||||||
- Name:
|
|
||||||
Entry: 7
|
|
||||||
Data:
|
|
||||||
- Name: $k
|
|
||||||
Entry: 3
|
|
||||||
Data: 4
|
|
||||||
- Name: $v
|
|
||||||
Entry: 10
|
|
||||||
Data: 0
|
|
||||||
- Name:
|
|
||||||
Entry: 8
|
|
||||||
Data:
|
|
||||||
- Name:
|
- Name:
|
||||||
Entry: 13
|
Entry: 13
|
||||||
Data:
|
Data:
|
||||||
|
@ -10,13 +10,13 @@ public class StartRestaurantOrder : Action
|
|||||||
[SerializeField] private RestaurantOrderType _targetOrderType = RestaurantOrderType.Wait;
|
[SerializeField] private RestaurantOrderType _targetOrderType = RestaurantOrderType.Wait;
|
||||||
|
|
||||||
private IInteractor _interactor;
|
private IInteractor _interactor;
|
||||||
private bool _isGetInteractor;
|
private bool _isInteractorValid;
|
||||||
|
|
||||||
public override void OnStart()
|
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}");
|
Debug.LogError($"[{GetType().Name}] IInteractor를 찾을 수 없습니다: {gameObject.name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public override TaskStatus OnUpdate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 상호작용 수행: 액션이 붙은 에이전트를 Interactor로 사용
|
// 상호작용 수행: 액션이 붙은 에이전트를 Interactor로 사용
|
||||||
if (!_isGetInteractor)
|
if (!_isInteractorValid)
|
||||||
{
|
{
|
||||||
return TaskStatus.Failure;
|
return TaskStatus.Failure;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -37,6 +38,11 @@ public bool CanSolveInteractionType(InteractionType interactionType)
|
|||||||
return _interactionComponent.CanSolveInteractionType(interactionType);
|
return _interactionComponent.CanSolveInteractionType(interactionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FetchSolverTypeForInteraction(InteractionType type, out Type solverType)
|
||||||
|
{
|
||||||
|
return _interactionComponent.FetchSolverTypeForInteraction(type, out solverType);
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsInteractionHidden(IInteractable interactable)
|
public bool IsInteractionHidden(IInteractable interactable)
|
||||||
{
|
{
|
||||||
return _interactionComponent.IsInteractionHidden(interactable);
|
return _interactionComponent.IsInteractionHidden(interactable);
|
||||||
|
@ -14,14 +14,27 @@ public enum RestaurantOrderType : uint
|
|||||||
Dirty = 1u << 4,
|
Dirty = 1u << 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class RestaurantOrderObjectState
|
||||||
|
{
|
||||||
|
public GameObject Customer;
|
||||||
|
public GameObject Worker;
|
||||||
|
|
||||||
|
public string FoodId;
|
||||||
|
}
|
||||||
|
|
||||||
public interface IRestaurantOrderObject
|
public interface IRestaurantOrderObject
|
||||||
{
|
{
|
||||||
void TransitionToNextPhase();
|
void TransitionToNextPhase();
|
||||||
|
RestaurantOrderType GetCurrentOrderPhase();
|
||||||
|
RestaurantOrderObjectState GetOrderObjectState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO : 도중에 이탈할 경우, 순차적으로 다음 페이즈로 넘어가는 게 아니라 바로 Wait, Dirty로 전이시킬 필요가 있음
|
||||||
|
|
||||||
public class InteractionSubsystem_Order : MonoBehaviour, IInteractionSubsystemObject<RestaurantOrderType>, IRestaurantOrderObject
|
public class InteractionSubsystem_Order : MonoBehaviour, IInteractionSubsystemObject<RestaurantOrderType>, IRestaurantOrderObject
|
||||||
{
|
{
|
||||||
[SerializeField] private RestaurantOrderType _currentRestaurantOrderType = RestaurantOrderType.Wait;
|
[SerializeField] private RestaurantOrderType _currentRestaurantOrderType = RestaurantOrderType.Wait;
|
||||||
|
[SerializeField] private RestaurantOrderObjectState _orderObjectState = new();
|
||||||
|
|
||||||
public bool CanInteract()
|
public bool CanInteract()
|
||||||
{
|
{
|
||||||
@ -39,7 +52,17 @@ public void TransitionToNextPhase()
|
|||||||
var nextState = GetNextState(currentState);
|
var nextState = GetNextState(currentState);
|
||||||
SetInteractionSubsystemType(nextState);
|
SetInteractionSubsystemType(nextState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RestaurantOrderType GetCurrentOrderPhase()
|
||||||
|
{
|
||||||
|
return _currentRestaurantOrderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RestaurantOrderObjectState GetOrderObjectState()
|
||||||
|
{
|
||||||
|
return _orderObjectState;
|
||||||
|
}
|
||||||
|
|
||||||
public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
|
public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace DDD.Restaurant
|
namespace DDD.Restaurant
|
||||||
{
|
{
|
||||||
@ -27,7 +28,7 @@ public class RestaurantInteractionComponent : MonoBehaviour, IInteractable, IInt
|
|||||||
[SerializeField] protected InteractionDisplayParameters _displayParameters;
|
[SerializeField] protected InteractionDisplayParameters _displayParameters;
|
||||||
[SerializeField] protected GameFlowState _interactionAvailableFlows;
|
[SerializeField] protected GameFlowState _interactionAvailableFlows;
|
||||||
[SerializeField] private Transform[] _aiInteractionPoints;
|
[SerializeField] private Transform[] _aiInteractionPoints;
|
||||||
[SerializeField] private bool autoInitialize = true;
|
[FormerlySerializedAs("autoInitialize")] [SerializeField] private bool _autoInitialize = true;
|
||||||
private bool _isInitialized = false;
|
private bool _isInitialized = false;
|
||||||
|
|
||||||
private Dictionary<InteractionType, IInteractionSubsystemObject> _subsystems = new();
|
private Dictionary<InteractionType, IInteractionSubsystemObject> _subsystems = new();
|
||||||
@ -44,7 +45,7 @@ private void Start()
|
|||||||
var environmentState = RestaurantState.Instance?.EnvironmentState;
|
var environmentState = RestaurantState.Instance?.EnvironmentState;
|
||||||
environmentState?.RegisterInteractable(this);
|
environmentState?.RegisterInteractable(this);
|
||||||
|
|
||||||
if (autoInitialize && !_isInitialized)
|
if (_autoInitialize && !_isInitialized)
|
||||||
{
|
{
|
||||||
InitializeInteraction(_interactionType);
|
InitializeInteraction(_interactionType);
|
||||||
}
|
}
|
||||||
@ -70,7 +71,6 @@ public virtual bool CanInteract()
|
|||||||
|
|
||||||
public virtual bool IsInteractionAvailable()
|
public virtual bool IsInteractionAvailable()
|
||||||
{
|
{
|
||||||
|
|
||||||
var currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState;
|
var currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState;
|
||||||
var flowDisabled = (currentGameFlowState & _interactionAvailableFlows) == 0;
|
var flowDisabled = (currentGameFlowState & _interactionAvailableFlows) == 0;
|
||||||
if (flowDisabled)
|
if (flowDisabled)
|
||||||
|
@ -8,11 +8,11 @@ public virtual bool ExecuteInteractionSubsystem(IInteractor interactor, IInterac
|
|||||||
{
|
{
|
||||||
if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false)
|
if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false)
|
||||||
return false;
|
return false;
|
||||||
if (interactable is not IInteractionSubsystemOwner subsystemOwner)
|
|
||||||
return false;
|
if (GetRestaurantOrderObject(interactable) == null) return false;
|
||||||
if (!subsystemOwner.TryGetSubsystemObject<RestaurantOrderType>(out var subsystem))
|
|
||||||
return false;
|
var orderObject = GetRestaurantOrderObject(interactable);
|
||||||
if (subsystem is IRestaurantOrderObject orderObject)
|
if (orderObject != null)
|
||||||
{
|
{
|
||||||
orderObject.TransitionToNextPhase();
|
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);
|
public abstract bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null);
|
||||||
|
|
||||||
|
protected static IRestaurantOrderObject GetRestaurantOrderObject(IInteractable interactable)
|
||||||
|
{
|
||||||
|
var subsystemOwner = interactable.GetInteractableGameObject().GetComponent<IInteractionSubsystemOwner>();
|
||||||
|
IInteractionSubsystemObject<RestaurantOrderType> subsystemObject = null;
|
||||||
|
subsystemOwner?.TryGetSubsystemObject(out subsystemObject);
|
||||||
|
if (subsystemObject is IRestaurantOrderObject restaurantOrderObject)
|
||||||
|
{
|
||||||
|
return restaurantOrderObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -27,6 +27,13 @@ public override bool ExecuteInteractionSubsystem(IInteractor interactor, IIntera
|
|||||||
var highlightComponent = highlightObject?.GetComponent<IInteractionHighlight>();
|
var highlightComponent = highlightObject?.GetComponent<IInteractionHighlight>();
|
||||||
highlightComponent?.ClearHighlightProxy();
|
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
|
// Pick random menu from today's menu list
|
||||||
var foodCandidates = RestaurantState.Instance.ManagementState.GetTodayFoodMenus();
|
var foodCandidates = RestaurantState.Instance.ManagementState.GetTodayFoodMenus();
|
||||||
if (foodCandidates == null || foodCandidates.Count == 0)
|
if (foodCandidates == null || foodCandidates.Count == 0)
|
||||||
|
@ -11,7 +11,7 @@ public override bool ExecuteInteractionSubsystem(IInteractor interactor, IIntera
|
|||||||
|
|
||||||
public override bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
|
public override bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using Opsive.BehaviorDesigner.Runtime.Tasks;
|
using Opsive.BehaviorDesigner.Runtime.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace DDD.Restaurant
|
namespace DDD.Restaurant
|
||||||
{
|
{
|
||||||
@ -7,6 +8,12 @@ public class RestaurantOrderSolver_Wait : RestaurantOrderSolverBase
|
|||||||
{
|
{
|
||||||
public override bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
|
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);
|
return base.ExecuteInteractionSubsystem(interactor, interactable, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user