인터렉션 충돌 머지
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,
|
||||
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>();
|
||||
IInteractable interactable = target.GetComponent<IInteractable>();
|
||||
|
||||
// Cast solverComponent to IInteractable
|
||||
if (solver is not null && interactor is not null)
|
||||
if (interactor != null && interactor.CanSolveInteractionType(interactionType))
|
||||
{
|
||||
bool canExecute = solver.CanExecuteInteraction(interactor, interactable, payload);
|
||||
if (canExecute)
|
||||
if (interactor.FetchSolverTypeForInteraction(interactionType, out var solverType))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user