인터렉션 충돌 머지
This commit is contained in:
parent
65f2f17752
commit
a119382330
@ -24,30 +24,30 @@ public class RestaurantInteractionEvent : RestaurantEventBase<InteractionType>
|
|||||||
protected override bool EventSolve(GameObject causer, GameObject target, InteractionType interactionType,
|
protected override bool EventSolve(GameObject causer, GameObject target, InteractionType interactionType,
|
||||||
ScriptableObject payload)
|
ScriptableObject payload)
|
||||||
{
|
{
|
||||||
if (!RestaurantInteractionEventSolvers.TypeToSolver.TryGetValue(interactionType, out var solverType))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Component solverComponent = causer.GetComponent(solverType);
|
|
||||||
IInteractionSolver solver = solverComponent as IInteractionSolver;
|
|
||||||
IInteractor interactor = causer.GetComponent<IInteractor>();
|
IInteractor interactor = causer.GetComponent<IInteractor>();
|
||||||
IInteractable interactable = target.GetComponent<IInteractable>();
|
if (interactor != null && interactor.CanSolveInteractionType(interactionType))
|
||||||
|
|
||||||
// Cast solverComponent to IInteractable
|
|
||||||
if (solver is not null && interactor is not null)
|
|
||||||
{
|
{
|
||||||
bool canExecute = solver.CanExecuteInteraction(interactor, interactable, payload);
|
if (interactor.FetchSolverTypeForInteraction(interactionType, out var solverType))
|
||||||
if (canExecute)
|
|
||||||
{
|
{
|
||||||
return solver.ExecuteInteraction(interactor, interactable, payload);
|
// Solve event directly. 이벤트 처리는 여기서 하고, 이벤트 호출로는 이런 이벤트가 호출되었고 결과가 어떻다는 거 전파하는 식으로.
|
||||||
|
if (solverType != null)
|
||||||
|
{
|
||||||
|
IInteractionSolver solver = causer.GetComponent(solverType) as IInteractionSolver;
|
||||||
|
IInteractable interactable = target.GetComponent<IInteractable>();
|
||||||
|
if (solver is not null)
|
||||||
|
{
|
||||||
|
bool canExecute = solver.CanExecuteInteraction(interactor, interactable, payload);
|
||||||
|
return canExecute && solver.ExecuteInteraction(interactor, interactable, payload);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Should not reach here!
|
||||||
|
Debug.Assert(false, "Solver Component or Interactor is null");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should not reach here!
|
|
||||||
Debug.Assert(false, "Solver Component or Interactor is null");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user