From 61fd509c96cec3452287bba4e454399383cf15ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=82=B0?= Date: Thu, 28 Aug 2025 12:43:32 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A4=91=EC=B2=A9=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=ED=94=8C=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=96=B4-=EC=86=90=EB=8B=98=20OrderSolver=20=EB=B6=84=EB=B0=B0?= =?UTF-8?q?,=20=EC=B4=88=EA=B8=B0=ED=99=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AI/Customer/Subtree/CustomerDefault.asset | 4 ++-- .../AI/Customer/Subtree/OrderSubtree.asset | 4 ++-- .../Prefabs/RestaurantPlayer.prefab | 2 +- .../_Scripts/Game/GameEvent/IInteractable.cs | 1 - .../Common/Actions/LookAtInteractionTarget.cs | 13 ++++------- .../Actions/WaitForPlayerInteraction.cs | 7 ++---- .../Character/Core/CharacterInteraction.cs | 23 +++++++++++++++++++ .../Character/Core/RestaurantCharacter.cs | 13 +---------- .../Character/Player/PlayerInteraction.cs | 14 +++++++++++ .../Event/RestaurantInteractionComponent.cs | 1 - .../Event/RestaurantInteractionEvents.cs | 5 +++- .../RestaurantOrders/RestaurantOrderSolver.cs | 12 +++++++++- 12 files changed, 64 insertions(+), 35 deletions(-) diff --git a/Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset b/Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset index 193d9ef96..b4c023f9c 100644 --- a/Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset +++ b/Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:27a3a40bb3be1c167778bdc35a0ec6db10f288f1dde2c666105b98ffad079bdc -size 67663 +oid sha256:03d01d4c1d7746e711e9ef21cafbfa8e0ffd13f6f6ad4fbacea3f7464426ba16 +size 67915 diff --git a/Assets/_DDD/_Addressables/AI/Customer/Subtree/OrderSubtree.asset b/Assets/_DDD/_Addressables/AI/Customer/Subtree/OrderSubtree.asset index 8e6a2bf26..7e7bb95e0 100644 --- a/Assets/_DDD/_Addressables/AI/Customer/Subtree/OrderSubtree.asset +++ b/Assets/_DDD/_Addressables/AI/Customer/Subtree/OrderSubtree.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e863335f3752df069447ebc0fee597d6f366d88edd12d70db68b45923a4f87c -size 20475 +oid sha256:6da8678bc90f664244b89aa26dc5c6b01c51567387ea3414b916fb27082f752b +size 16520 diff --git a/Assets/_DDD/_Addressables/Prefabs/RestaurantPlayer.prefab b/Assets/_DDD/_Addressables/Prefabs/RestaurantPlayer.prefab index f842662b8..bb8720305 100644 --- a/Assets/_DDD/_Addressables/Prefabs/RestaurantPlayer.prefab +++ b/Assets/_DDD/_Addressables/Prefabs/RestaurantPlayer.prefab @@ -426,7 +426,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 81e01dd8c1cc3404d805400eba1bb4ae, type: 3} m_Name: m_EditorClassIdentifier: - _availableInteractions: 5 + _availableInteractions: 7 _nearColliders: - {fileID: 0} - {fileID: 0} diff --git a/Assets/_DDD/_Scripts/Game/GameEvent/IInteractable.cs b/Assets/_DDD/_Scripts/Game/GameEvent/IInteractable.cs index c386e8e2a..72831c1fd 100644 --- a/Assets/_DDD/_Scripts/Game/GameEvent/IInteractable.cs +++ b/Assets/_DDD/_Scripts/Game/GameEvent/IInteractable.cs @@ -10,7 +10,6 @@ public enum InteractionType : uint None = 0u, RestaurantManagement = 1u << 0, RestaurantOrder = 1u << 1, - RestaurantMeal = 1u << 2, RestaurantCook = 1u << 3, All = 0xFFFFFFFFu } diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Common/Actions/LookAtInteractionTarget.cs b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Common/Actions/LookAtInteractionTarget.cs index 1c0938cbe..68058dfd2 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Common/Actions/LookAtInteractionTarget.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Common/Actions/LookAtInteractionTarget.cs @@ -12,11 +12,7 @@ public class LookAtInteractionTarget : Action { [Header("Target Settings")] [Tooltip("InteractionPoints를 사용해 가장 적절한 지점을 바라봄")] - [SerializeField] private bool useInteractionPoints = true; - - [Header("Update Settings")] - [Tooltip("프레임마다 갱신하여 지속적으로 바라볼지 (Running 반환) 여부. 비활성화 시 1회만 시도하고 성공 처리")] - [SerializeField] private bool continuousUpdate = true; + [SerializeField] private bool _useInteractionPoints = true; // Visual 전용 컴포넌트(나중 구현)를 위한 최소 인터페이스 // 실제 구현은 Spine/애니메이션 제어 컴포넌트에서 이 인터페이스를 구현하세요. @@ -68,9 +64,8 @@ public override TaskStatus OnUpdate() { _visual?.UpdateLookAt(_currentLookPosition); } - - // 연속 업데이트면 Running, 아니면 1회만 시도 후 Success 반환 - return continuousUpdate ? TaskStatus.Running : TaskStatus.Success; + + return TaskStatus.Success; } public override void OnEnd() @@ -87,7 +82,7 @@ public override void OnEnd() private Vector3 CalculateLookPosition(GameObject target) { - if (!useInteractionPoints) + if (!_useInteractionPoints) return target.transform.position; if (target.TryGetComponent(out var ric)) diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/WaitForPlayerInteraction.cs b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/WaitForPlayerInteraction.cs index 6c5dd2230..46579e1ce 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/WaitForPlayerInteraction.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/WaitForPlayerInteraction.cs @@ -8,15 +8,12 @@ namespace DDD.Restaurant //차후 제네릭으로 변경 가능성 있음 public class WaitForPlayerInteraction : Action { - [Tooltip("기다릴 상호작용 타입")] - [SerializeField] private RestaurantMealType _targetOrderType = RestaurantMealType.WaitForOrder; - - private IInteractionSubsystemObject _interactionSubsystem; + [SerializeField] private RestaurantOrderType _targetOrderType; + private IInteractionSubsystemObject _interactionSubsystem; private bool _isGetInteractionSubsystem; public override void OnStart() { - // 의자가 복합 상태를 가지게 될 경우 GameObject interactionTarget = null; if(!gameObject.TryGetComponent(out var sharedBlackboard)) return; interactionTarget = sharedBlackboard.GetBlackboardGameObject(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget)); diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/Core/CharacterInteraction.cs b/Assets/_DDD/_Scripts/Restaurant/Character/Core/CharacterInteraction.cs index d6b1530a5..5ec7c67ac 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/Core/CharacterInteraction.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/Core/CharacterInteraction.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Sirenix.OdinInspector; using UnityEngine; @@ -99,5 +100,27 @@ public bool CanInteractTo(IInteractable interactable, ScriptableObject payloadSo if (TryGetSolverFor(interactable, out var solver) == false) return false; return solver.CanExecuteInteraction(this, interactable, payloadSo); } + + public virtual void InitializeSolvers() + { + var typesToSolver = RestaurantInteractionEventSolvers.TypeToSolver; + InitializeInteractionSolvers(typesToSolver); + } + + protected void InitializeInteractionSolvers(Dictionary typesToSolver) + { + foreach (var typeToSolver in typesToSolver) + { + var flag = typeToSolver.Key; + if (flag == InteractionType.None) continue; + + if ((AvailableInteractions & flag) == 0) continue; + + if (!TryGetComponent(typeToSolver.Value, out _)) + { + gameObject.AddComponent(typeToSolver.Value); + } + } + } } } diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/Core/RestaurantCharacter.cs b/Assets/_DDD/_Scripts/Restaurant/Character/Core/RestaurantCharacter.cs index 42105fd49..f3a32003e 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/Core/RestaurantCharacter.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/Core/RestaurantCharacter.cs @@ -13,19 +13,8 @@ public class RestaurantCharacter : MonoBehaviour, IGameCharacter, IInteractor protected virtual void Awake() { _interactionComponent = GetComponent(); + _interactionComponent.InitializeSolvers(); _spineController = GetComponent(); - foreach (var typeToSolver in RestaurantInteractionEventSolvers.TypeToSolver) - { - var flag = typeToSolver.Key; - if (flag == InteractionType.None) continue; - - if ((_interactionComponent.AvailableInteractions & flag) == 0) continue; - - if (!TryGetComponent(typeToSolver.Value, out _)) - { - gameObject.AddComponent(typeToSolver.Value); - } - } } protected virtual void Start() diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/Player/PlayerInteraction.cs b/Assets/_DDD/_Scripts/Restaurant/Character/Player/PlayerInteraction.cs index 4162945a1..21832e1ea 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/Player/PlayerInteraction.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/Player/PlayerInteraction.cs @@ -1,3 +1,5 @@ +using System; +using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.InputSystem; @@ -35,6 +37,18 @@ private Task Initialize() return Task.CompletedTask; } + public override void InitializeSolvers() + { + var typesToSolver = RestaurantInteractionEventSolvers.TypeToSolver; + var playerSolver = RestaurantInteractionEventSolvers.TypeToPlayerSolver; + foreach(var pair in playerSolver) + { + typesToSolver.Remove(pair.Key); + } + InitializeInteractionSolvers(typesToSolver); + InitializeInteractionSolvers(playerSolver); + } + protected override void OnDestroy() { base.OnDestroy(); diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs b/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs index 34bb0a1c3..422daa866 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs @@ -13,7 +13,6 @@ public static class RestaurantInteractionSubsystems { {InteractionType.RestaurantOrder, typeof(InteractionSubsystem_Order)}, {InteractionType.RestaurantManagement, typeof(InteractionSubsystem_Management)}, - {InteractionType.RestaurantMeal, typeof(InteractionSubsystem_Meal)} }; } diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionEvents.cs b/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionEvents.cs index 9fe0c5cef..f006c3e85 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionEvents.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionEvents.cs @@ -10,9 +10,12 @@ public static class RestaurantInteractionEventSolvers { {InteractionType.RestaurantManagement, typeof(RestaurantManagementSolver)}, {InteractionType.RestaurantOrder, typeof(RestaurantOrderSolver)}, - {InteractionType.RestaurantMeal, typeof(RestaurantMealSolver)}, {InteractionType.RestaurantCook, typeof(RestaurantCookSolver)} }; + public static Dictionary TypeToPlayerSolver = new() + { + {InteractionType.RestaurantOrder, typeof(RestaurantOrderPlayerSolver)}, + }; } public class RestaurantInteractionEvent : IEvent diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver.cs b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver.cs index a0f2bab02..b752ebdda 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/Solvers/RestaurantOrders/RestaurantOrderSolver.cs @@ -10,9 +10,19 @@ public class RestaurantOrderSolver : RestaurantSubsystemSolver GetSubsystemSolverTypeMappings() + { + return _typeToOrderSolver; + } + } + public class RestaurantOrderPlayerSolver : RestaurantSubsystemSolver + { + private Dictionary _typeToOrderSolver = new() + { { RestaurantOrderType.Order, typeof(RestaurantOrderSolver_Order) }, { RestaurantOrderType.Serve, typeof(RestaurantOrderSolver_Serve) }, - { RestaurantOrderType.Busy, typeof(RestaurantOrderSolver_Busy) }, { RestaurantOrderType.Dirty, typeof(RestaurantOrderSolver_Dirty) } }; protected override Dictionary GetSubsystemSolverTypeMappings()