payload 롤백

This commit is contained in:
NTG 2025-08-27 13:18:44 +09:00
parent 62a916392d
commit a1c33cdaf5
18 changed files with 50 additions and 73 deletions

View File

@ -48,7 +48,6 @@ public interface IInteractable
InteractionExecutionParameters GetExecutionParameters(); InteractionExecutionParameters GetExecutionParameters();
InteractionDisplayParameters GetDisplayParameters(); InteractionDisplayParameters GetDisplayParameters();
Vector3[] GetInteractionPoints(); Vector3[] GetInteractionPoints();
ScriptableObject GetPayload();
} }
public interface IInteractor public interface IInteractor
@ -62,7 +61,7 @@ bool CanInteractTo(IInteractable interactable,
public interface IInteractionSolver public interface IInteractionSolver
{ {
bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null); bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null);
bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null); bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null);
} }
} }

View File

@ -8,7 +8,6 @@ public interface IInteractionSubsystemObject
void InitializeSubsystem(); void InitializeSubsystem();
bool CanInteract(); bool CanInteract();
bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null); bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null);
ScriptableObject GetPayload();
} }
public interface IInteractionSubsystemObject<T> : IInteractionSubsystemObject where T : Enum public interface IInteractionSubsystemObject<T> : IInteractionSubsystemObject where T : Enum
{ {
@ -21,7 +20,7 @@ public interface IInteractionSubsystemSolver
} }
public interface IInteractionSubsystemSolver<T> : IInteractionSubsystemSolver where T : Enum public interface IInteractionSubsystemSolver<T> : IInteractionSubsystemSolver where T : Enum
{ {
bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null); bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null);
bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null); bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null);
} }
} }

View File

@ -18,6 +18,11 @@ public RestaurantCookType GetInteractionSubsystemType()
return _cookType; return _cookType;
} }
public void SetInteractionSubsystemType(RestaurantCookType inValue)
{
}
public virtual void InitializeSubsystem() public virtual void InitializeSubsystem()
{ {

View File

@ -31,19 +31,7 @@ public class RestaurantInteractionComponent : MonoBehaviour, IInteractable, IInt
private bool _isInitialized = false; private bool _isInitialized = false;
private Dictionary<InteractionType, IInteractionSubsystemObject> _subsystems = new(); private Dictionary<InteractionType, IInteractionSubsystemObject> _subsystems = new();
private void OnEnable()
{
// Register this interactable to environment state
var environmentState = RestaurantState.Instance?.EnvironmentState;
environmentState?.RegisterInteractable(this);
if (autoInitialize && !_isInitialized)
{
InitializeInteraction(_interactionType);
}
}
private void OnDisable() private void OnDisable()
{ {
var environmentState = RestaurantState.Instance?.EnvironmentState; var environmentState = RestaurantState.Instance?.EnvironmentState;
@ -87,7 +75,7 @@ public virtual bool IsInteractionHidden()
return flowDisabled; return flowDisabled;
} }
public virtual bool OnInteracted(IInteractor interactor, ScriptableObject causerPayload = null) public virtual bool OnInteracted(IInteractor interactor, ScriptableObject payload = null)
{ {
if (CanInteract() == false) if (CanInteract() == false)
{ {
@ -95,10 +83,10 @@ public virtual bool OnInteracted(IInteractor interactor, ScriptableObject causer
} }
bool interactionResult = RestaurantInteractionEvents.RestaurantInteraction.RequestInteraction(interactor.GetInteractorGameObject(), bool interactionResult = RestaurantInteractionEvents.RestaurantInteraction.RequestInteraction(interactor.GetInteractorGameObject(),
GetInteractableGameObject(), GetInteractionType(), causerPayload, GetPayload(), true); GetInteractableGameObject(), GetInteractionType(), payload, true);
if (HasSubsystem(_interactionType)) if (HasSubsystem(_interactionType))
{ {
interactionResult &= GetSubsystem(_interactionType).OnInteracted(interactor, causerPayload); interactionResult &= GetSubsystem(_interactionType).OnInteracted(interactor, payload);
} }
return interactionResult; return interactionResult;
} }
@ -195,11 +183,6 @@ public Vector3[] GetInteractionPoints()
return positions; return positions;
} }
public ScriptableObject GetPayload()
{
return TryGetSubsystem(_interactionType, out var subsystem) ? subsystem.GetPayload() : null;
}
public bool TryGetSubsystemObject<T>(out IInteractionSubsystemObject<T> subsystemObject) where T : Enum public bool TryGetSubsystemObject<T>(out IInteractionSubsystemObject<T> subsystemObject) where T : Enum
{ {
foreach (var interactionSubsystemObject in _subsystems.Values) foreach (var interactionSubsystemObject in _subsystems.Values)

View File

@ -25,30 +25,28 @@ public class RestaurantInteractionEvent : IEvent
public GameObject Causer; public GameObject Causer;
public GameObject Target; public GameObject Target;
public InteractionType InteractionType; public InteractionType InteractionType;
public ScriptableObject CauserPayload; public ScriptableObject Payload;
public ScriptableObject TargetPayload;
public bool EventResult = false; public bool EventResult = false;
public RestaurantInteractionEvent MakeInteractionEvent(GameObject causer, GameObject target, InteractionType interactionType, public RestaurantInteractionEvent MakeInteractionEvent(GameObject causer, GameObject target, InteractionType interactionType,
ScriptableObject causerPayload, ScriptableObject targetPayload) ScriptableObject payload = null)
{ {
Causer = causer; Causer = causer;
Target = target; Target = target;
InteractionType = interactionType; InteractionType = interactionType;
CauserPayload = causerPayload; Payload = payload;
TargetPayload = targetPayload;
return this; return this;
} }
public bool RequestInteraction(GameObject causer, GameObject target, InteractionType interactionType, public bool RequestInteraction(GameObject causer, GameObject target, InteractionType interactionType,
ScriptableObject causerPayload = null, ScriptableObject targetPayload = null, bool shouldBroadcastAfterSolve = true) ScriptableObject payload = null, bool shouldBroadcastAfterSolve = true)
{ {
if (interactionType == InteractionType.None) if (interactionType == InteractionType.None)
{ {
return false; return false;
} }
var evt = MakeInteractionEvent(causer, target, interactionType, causerPayload, targetPayload); var evt = MakeInteractionEvent(causer, target, interactionType, payload);
evt.EventResult = false; evt.EventResult = false;
// Solve event directly. 이벤트 처리는 여기서 하고, 이벤트 호출로는 이런 이벤트가 호출되었고 결과가 어떻다는 거 전파하는 식으로. // Solve event directly. 이벤트 처리는 여기서 하고, 이벤트 호출로는 이런 이벤트가 호출되었고 결과가 어떻다는 거 전파하는 식으로.
if (RestaurantInteractionEventSolvers.TypeToSolver.TryGetValue(interactionType, out var solverType)) if (RestaurantInteractionEventSolvers.TypeToSolver.TryGetValue(interactionType, out var solverType))
@ -61,7 +59,7 @@ public bool RequestInteraction(GameObject causer, GameObject target, Interaction
// Cast solverComponent to IInteractable // Cast solverComponent to IInteractable
if (solver is not null && interactor is not null) if (solver is not null && interactor is not null)
{ {
evt.EventResult = solver.ExecuteInteraction(interactor, interactable, causerPayload, targetPayload); evt.EventResult = solver.ExecuteInteraction(interactor, interactable, payload);
} }
else else
{ {

View File

@ -4,10 +4,9 @@ namespace DDD
{ {
public class RestaurantCookSolver_OpenCookUi : MonoBehaviour, IInteractionSubsystemSolver<RestaurantCookType> public class RestaurantCookSolver_OpenCookUi : MonoBehaviour, IInteractionSubsystemSolver<RestaurantCookType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null)
{ {
if (CanExecuteInteractionSubsystem(interactor, interactable, causerPayload, targetPayloadSo) == false) return false; if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false) return false;
var evt = GameEvents.OpenPopupUiEvent; var evt = GameEvents.OpenPopupUiEvent;
evt.UiType = typeof(CookUi); evt.UiType = typeof(CookUi);
@ -16,8 +15,7 @@ public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable in
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null)
{ {
GameFlowState currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState; GameFlowState currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState;
return currentGameFlowState == GameFlowState.RunRestaurant; return currentGameFlowState == GameFlowState.RunRestaurant;

View File

@ -4,9 +4,9 @@ namespace DDD
{ {
public class RestaurantManagementSolver_Menu : MonoBehaviour, IInteractionSubsystemSolver<RestaurantManagementType> public class RestaurantManagementSolver_Menu : MonoBehaviour, IInteractionSubsystemSolver<RestaurantManagementType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
if (CanExecuteInteractionSubsystem(interactor, interactable, causerPayload, targetPayloadSo) == false) return false; if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false) return false;
var evt = GameEvents.OpenPopupUiEvent; var evt = GameEvents.OpenPopupUiEvent;
evt.UiType = typeof(RestaurantManagementUi); evt.UiType = typeof(RestaurantManagementUi);
@ -14,7 +14,7 @@ public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable in
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{ {
GameFlowState currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState; GameFlowState currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState;
return currentGameFlowState == GameFlowState.ReadyForRestaurant; return currentGameFlowState == GameFlowState.ReadyForRestaurant;

View File

@ -10,15 +10,15 @@ private RestaurantManagementState GetManagementState()
return RestaurantState.Instance.ManagementState; return RestaurantState.Instance.ManagementState;
} }
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
if (CanExecuteInteractionSubsystem(interactor, interactable, causerPayload, targetPayloadSo) == false) return false; if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false) return false;
_ = GameFlowManager.Instance.ChangeFlow(GameFlowState.RunRestaurant); _ = GameFlowManager.Instance.ChangeFlow(GameFlowState.RunRestaurant);
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{ {
GameFlowState currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState; GameFlowState currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState;

View File

@ -4,13 +4,12 @@ namespace DDD
{ {
public class RestaurantMealSolver_WaitForOrder : MonoBehaviour, IInteractionSubsystemSolver<RestaurantMealType> public class RestaurantMealSolver_WaitForOrder : MonoBehaviour, IInteractionSubsystemSolver<RestaurantMealType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null)
{ {
return true; return true;

View File

@ -4,13 +4,12 @@ namespace DDD
{ {
public class RestaurantMealSolver_WaitForServe : MonoBehaviour, IInteractionSubsystemSolver<RestaurantMealType> public class RestaurantMealSolver_WaitForServe : MonoBehaviour, IInteractionSubsystemSolver<RestaurantMealType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null)
{ {
return true; return true;
} }

View File

@ -4,15 +4,13 @@ namespace DDD.RestaurantOrders
{ {
public class RestaurantOrderSolver_Busy : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType> public class RestaurantOrderSolver_Busy : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null)
{ {
// TODO : DO SOMETHING!!! // TODO : DO SOMETHING!!!
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null)
{ {
// TODO : DO SOMETHING!!! // TODO : DO SOMETHING!!!
return true; return true;

View File

@ -4,14 +4,13 @@ namespace DDD.RestaurantOrders
{ {
public class RestaurantOrderSolver_Dirty : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType> public class RestaurantOrderSolver_Dirty : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
// TODO : DO SOMETHING!!! // TODO : DO SOMETHING!!!
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null)
{ {
return true; return true;
} }

View File

@ -4,13 +4,13 @@ namespace DDD.RestaurantOrders
{ {
public class RestaurantOrderSolver_Order : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType> public class RestaurantOrderSolver_Order : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
// TODO : DO SOMETHING!!! // TODO : DO SOMETHING!!!
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{ {
return true; return true;
} }

View File

@ -4,13 +4,13 @@ namespace DDD.RestaurantOrders
{ {
public class RestaurantOrderSolver_Reserved : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType> public class RestaurantOrderSolver_Reserved : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
// TODO : DO SOMETHING!!! // TODO : DO SOMETHING!!!
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{ {
// Interactable's CurrentInteractor is me? => Can execute // Interactable's CurrentInteractor is me? => Can execute
return false; return false;

View File

@ -4,13 +4,13 @@ namespace DDD.RestaurantOrders
{ {
public class RestaurantOrderSolver_Serve : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType> public class RestaurantOrderSolver_Serve : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
// TODO : DO SOMETHING!!! // TODO : DO SOMETHING!!!
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{ {
return true; return true;
} }

View File

@ -5,9 +5,9 @@ namespace DDD.RestaurantOrders
{ {
public class RestaurantOrderSolver_Wait : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType> public class RestaurantOrderSolver_Wait : MonoBehaviour, IInteractionSubsystemSolver<RestaurantOrderType>
{ {
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
if (CanExecuteInteractionSubsystem(interactor, interactable, causerPayload, targetPayloadSo) == false) return false; if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false) return false;
// TODO : DO SOMETHING!!! // TODO : DO SOMETHING!!!
/* TODO /* TODO
* OnInteracted에서 , , ? CanInteractTo에서 ? * OnInteracted에서 , , ? CanInteractTo에서 ?
@ -16,7 +16,7 @@ public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable in
return true; return true;
} }
public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{ {
return true; return true;
} }

View File

@ -18,16 +18,16 @@ private void Awake()
_solvers.Add(subsystemSolverType.Key, solver); _solvers.Add(subsystemSolverType.Key, solver);
} }
} }
public bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
{ {
return TryGetSolver(interactable, out var solver) && return TryGetSolver(interactable, out var solver) &&
solver.ExecuteInteractionSubsystem(interactor, interactable, causerPayload, targetPayloadSo); solver.ExecuteInteractionSubsystem(interactor, interactable, payload);
} }
public bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null) public bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{ {
return TryGetSolver(interactable, out var solver) && return TryGetSolver(interactable, out var solver) &&
solver.CanExecuteInteractionSubsystem(interactor, interactable, causerPayload, targetPayloadSo); solver.CanExecuteInteractionSubsystem(interactor, interactable, payload);
} }
// Solver를 가져오는 공통 로직 // Solver를 가져오는 공통 로직

BIN
ProjectSettings/EditorBuildSettings.asset (Stored with Git LFS)

Binary file not shown.