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();
InteractionDisplayParameters GetDisplayParameters();
Vector3[] GetInteractionPoints();
ScriptableObject GetPayload();
}
public interface IInteractor
@ -62,7 +61,7 @@ bool CanInteractTo(IInteractable interactable,
public interface IInteractionSolver
{
bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null);
bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject causerPayload = null, ScriptableObject targetPayloadSo = null);
bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null);
bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null);
}
}

View File

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

View File

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

View File

@ -32,18 +32,6 @@ public class RestaurantInteractionComponent : MonoBehaviour, IInteractable, IInt
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()
{
var environmentState = RestaurantState.Instance?.EnvironmentState;
@ -87,7 +75,7 @@ public virtual bool IsInteractionHidden()
return flowDisabled;
}
public virtual bool OnInteracted(IInteractor interactor, ScriptableObject causerPayload = null)
public virtual bool OnInteracted(IInteractor interactor, ScriptableObject payload = null)
{
if (CanInteract() == false)
{
@ -95,10 +83,10 @@ public virtual bool OnInteracted(IInteractor interactor, ScriptableObject causer
}
bool interactionResult = RestaurantInteractionEvents.RestaurantInteraction.RequestInteraction(interactor.GetInteractorGameObject(),
GetInteractableGameObject(), GetInteractionType(), causerPayload, GetPayload(), true);
GetInteractableGameObject(), GetInteractionType(), payload, true);
if (HasSubsystem(_interactionType))
{
interactionResult &= GetSubsystem(_interactionType).OnInteracted(interactor, causerPayload);
interactionResult &= GetSubsystem(_interactionType).OnInteracted(interactor, payload);
}
return interactionResult;
}
@ -195,11 +183,6 @@ public Vector3[] GetInteractionPoints()
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
{
foreach (var interactionSubsystemObject in _subsystems.Values)

View File

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

View File

@ -4,10 +4,9 @@ namespace DDD
{
public class RestaurantCookSolver_OpenCookUi : MonoBehaviour, IInteractionSubsystemSolver<RestaurantCookType>
{
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;
evt.UiType = typeof(CookUi);
@ -16,8 +15,7 @@ public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable in
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;
return currentGameFlowState == GameFlowState.RunRestaurant;

View File

@ -4,9 +4,9 @@ namespace DDD
{
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;
evt.UiType = typeof(RestaurantManagementUi);
@ -14,7 +14,7 @@ public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable in
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;
return currentGameFlowState == GameFlowState.ReadyForRestaurant;

View File

@ -10,15 +10,15 @@ private RestaurantManagementState GetManagementState()
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);
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;

View File

@ -4,13 +4,12 @@ namespace DDD
{
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;
}
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;

View File

@ -4,13 +4,12 @@ namespace DDD
{
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;
}
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;
}

View File

@ -4,15 +4,13 @@ namespace DDD.RestaurantOrders
{
public class RestaurantOrderSolver_Busy : 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!!!
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)
{
// TODO : DO SOMETHING!!!
return true;

View File

@ -4,14 +4,13 @@ namespace DDD.RestaurantOrders
{
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!!!
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;
}

View File

@ -4,13 +4,13 @@ namespace DDD.RestaurantOrders
{
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!!!
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;
}

View File

@ -4,13 +4,13 @@ namespace DDD.RestaurantOrders
{
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!!!
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
return false;

View File

@ -4,13 +4,13 @@ namespace DDD.RestaurantOrders
{
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!!!
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;
}

View File

@ -5,9 +5,9 @@ namespace DDD.RestaurantOrders
{
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
* OnInteracted에서 , , ? CanInteractTo에서 ?
@ -16,7 +16,7 @@ public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable in
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;
}

View File

@ -18,16 +18,16 @@ private void Awake()
_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) &&
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) &&
solver.CanExecuteInteractionSubsystem(interactor, interactable, causerPayload, targetPayloadSo);
solver.CanExecuteInteractionSubsystem(interactor, interactable, payload);
}
// Solver를 가져오는 공통 로직

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

Binary file not shown.