using System; using System.Collections.Generic; using JetBrains.Annotations; using UnityEngine; namespace DDD.Restaurant { public static class RestaurantInteractionEventSolvers { public static readonly Dictionary TypeToSolver = new() { {InteractionType.RestaurantManagement, typeof(RestaurantManagementSolver)}, {InteractionType.RestaurantOrder, typeof(RestaurantOrderSolver)}, {InteractionType.RestaurantCook, typeof(RestaurantCookSolver)} }; public static readonly Dictionary TypeToPlayerSolver = new() { {InteractionType.RestaurantOrder, typeof(RestaurantOrderPlayerSolver)}, }; } public class RestaurantInteractionEvent : RestaurantEventBase { protected override bool EventSolve(GameObject causer, GameObject target, InteractionType interactionType, ScriptableObject payload) { var interactor = causer.GetComponent(); if (interactor == null || !interactor.CanSolveInteractionType(interactionType)) return false; if (!interactor.FetchSolverTypeForInteraction(interactionType, out var solverType)) return false; // Solve event directly. 이벤트 처리는 여기서 하고, 이벤트 호출로는 이런 이벤트가 호출되었고 결과가 어떻다는 거 전파하는 식으로. if (solverType == null) return false; var solver = causer.GetComponent(solverType) as IInteractionSolver; var interactable = target.GetComponent(); if (solver is not null) { bool canExecute = solver.CanExecuteInteraction(interactor, interactable, payload); return canExecute && solver.ExecuteInteraction(interactor, interactable, payload); } Debug.Assert(false, "Solver Component or Interactor is null"); return false; } } }