From bfcc99be3843531e373c4d6ce0635290f8434a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=82=B0?= Date: Wed, 27 Aug 2025 11:45:27 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_Addressables/Prefabs/CustomerNpc.prefab | 23 ------ .../Common/Actions/MoveToInteractionTarget.cs | 3 +- .../AI/Common/Decorator/TimeLimiter.cs | 2 +- .../Customer/Actions/StartRestaurantOrder.cs | 1 + .../Actions/WaitForPlayerInteraction.cs | 70 ++++++------------- .../RestaurantCustomerBlackboardComponent.cs | 1 + .../RestaurantMealInteractionSubsystem.cs | 4 ++ 7 files changed, 30 insertions(+), 74 deletions(-) diff --git a/Assets/_DDD/_Addressables/Prefabs/CustomerNpc.prefab b/Assets/_DDD/_Addressables/Prefabs/CustomerNpc.prefab index 80cdc789c..d16acedec 100644 --- a/Assets/_DDD/_Addressables/Prefabs/CustomerNpc.prefab +++ b/Assets/_DDD/_Addressables/Prefabs/CustomerNpc.prefab @@ -1210,9 +1210,6 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 7462519206451630147, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} insertIndex: -1 addedObject: {fileID: 3825874317044733320} - - targetCorrespondingSourceObject: {fileID: 7462519206451630147, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} - insertIndex: -1 - addedObject: {fileID: 1122074513716966771} m_SourcePrefab: {fileID: 100100000, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} --- !u!1 &4266090516809920735 stripped GameObject: @@ -1255,23 +1252,3 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: af69e82818254bfa9cabb2dbf9430850, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &1122074513716966771 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4266090516809920735} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 201f9e6d7ca7404baa9945950292a392, type: 3} - m_Name: - m_EditorClassIdentifier: - _interactionType: 4 - _executionParameters: - _holdTime: 0 - _displayParameters: - _messageKey: - _interactionAvailableFlows: 2 - _aiInteractionPoints: [] - autoInitialize: 1 diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Common/Actions/MoveToInteractionTarget.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Common/Actions/MoveToInteractionTarget.cs index 828782504..4e284809c 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Common/Actions/MoveToInteractionTarget.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Common/Actions/MoveToInteractionTarget.cs @@ -1,5 +1,6 @@ using Opsive.BehaviorDesigner.Runtime.Tasks; using Opsive.BehaviorDesigner.Runtime.Tasks.Actions; +using Opsive.BehaviorDesigner.Runtime.Tasks.Events; using UnityEngine; namespace DDD @@ -29,6 +30,7 @@ public class MoveToInteractionTarget : Action public override void OnStart() { + Debug.Log($"[{gameObject.GetHashCode()}, {GetType().Name}] OnStart"); if (cachedTarget != null) return; movement = gameObject.GetComponentInParent(); repathTimer = 0f; @@ -44,7 +46,6 @@ public override TaskStatus OnUpdate() var target = GetTarget(); if (target == null) return failIfNoTarget ? TaskStatus.Failure : TaskStatus.Success; - Debug.Log(target.name); if (ShouldUpdateDestination()) { diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Common/Decorator/TimeLimiter.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Common/Decorator/TimeLimiter.cs index ec725c587..15c13cd29 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Common/Decorator/TimeLimiter.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Common/Decorator/TimeLimiter.cs @@ -188,7 +188,7 @@ public void Execute(ref DynamicBuffer branchComponents, branchComponents[taskComponent.BranchIndex] = branchComponent; continue; } - else if (taskComponent.Status != TaskStatus.Running) + if (taskComponent.Status != TaskStatus.Running) { continue; } diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/StartRestaurantOrder.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/StartRestaurantOrder.cs index 7fa600a90..f0997393f 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/StartRestaurantOrder.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/StartRestaurantOrder.cs @@ -19,6 +19,7 @@ public class StartRestaurantOrder : Action public override void OnStart() { _isGetInteractor = gameObject.TryGetComponent(out _interactor); + if (!_isGetInteractor) Debug.LogError($"[{GetType().Name}] IInteractor를 찾을 수 없습니다: {gameObject.name}"); } diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/WaitForPlayerInteraction.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/WaitForPlayerInteraction.cs index 220788be6..ec90190a9 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/WaitForPlayerInteraction.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/WaitForPlayerInteraction.cs @@ -17,55 +17,27 @@ public class WaitForPlayerInteraction : Action public override void OnStart() { // 의자가 복합 상태를 가지게 될 경우 - // GameObject interactionTarget = null; - // var shared = gameObject.GetComponentInChildren(); - // if (shared != null) - // { - // interactionTarget = shared.GetCurrentInteractionTarget(); - // } - // else - // { - // // 하위 호환: 고객 전용 블랙보드 지원 - // var customerBb = gameObject.GetComponentInParent(); - // interactionTarget = customerBb?.GetCurrentInteractionTarget(); - // } - // - // if (interactionTarget == null) - // { - // Debug.LogError($"[{GetType().Name}] interactionTarget을 찾을 수 없습니다: {gameObject.name}"); - // return; - // } - // - // if (!interactionTarget.TryGetComponent(out var interactionComponent)) - // Debug.LogError($"[{interactionTarget.name}] {nameof(interactionComponent)}를 찾을 수 없습니다: {gameObject.name}"); - // if (interactionComponent is IInteractionSubsystemOwner subsystemOwner) - // { - // if (!subsystemOwner.TryGetSubsystemObject(out var subsystem)) - // { - // Debug.LogError($"[{GetType().Name}] {nameof(_targetOrderType)}의 Subsystem을 찾을 수 없습니다: {gameObject.name}"); - // _isGetInteractionSubsystem = false; - // return; - // } - // - // _isGetInteractionSubsystem = true; - // subsystem.SetInteractionSubsystemType(_targetOrderType); - // - // if (!gameObject.TryGetComponent(out var interactor)) - // { - // Debug.LogError($"[{GetType().Name}] IInteractor를 찾을 수 없습니다: {gameObject.name}"); - // return; - // } - // - // interactor.CanInteractTo(interactionComponent); - // - // _interactionSubsystem = subsystem; - // } - - if (!gameObject.TryGetComponent(out var interactionComponent)) - { - Debug.LogError($"[{GetType().Name}]에서 interactionComponent를 찾을 수 없습니다: {gameObject.name}"); - return; - } + GameObject interactionTarget = null; + var shared = gameObject.GetComponentInChildren(); + if (shared != null) + { + interactionTarget = shared.GetCurrentInteractionTarget(); + } + else + { + // 하위 호환: 고객 전용 블랙보드 지원 + var customerBb = gameObject.GetComponentInParent(); + interactionTarget = customerBb?.GetCurrentInteractionTarget(); + } + + if (interactionTarget == null) + { + Debug.LogError($"[{GetType().Name}] interactionTarget을 찾을 수 없습니다: {gameObject.name}"); + return; + } + + if (!interactionTarget.TryGetComponent(out var interactionComponent)) + Debug.LogError($"[{interactionTarget.name}] {nameof(interactionComponent)}를 찾을 수 없습니다: {gameObject.name}"); if (interactionComponent is not IInteractionSubsystemOwner subsystemOwner) { diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/RestaurantCustomerBlackboardComponent.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/RestaurantCustomerBlackboardComponent.cs index 98112000e..efef15e5b 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/RestaurantCustomerBlackboardComponent.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/RestaurantCustomerBlackboardComponent.cs @@ -28,6 +28,7 @@ public void SetCurrentInteractionTarget(GameObject targetGameObject) _currentInteractionTarget = targetGameObject; if (_subtree == null) return; _subtree.SetVariableValue(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget), targetGameObject); + } public GameObject GetCurrentInteractionTarget() diff --git a/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantMealInteractionSubsystem.cs b/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantMealInteractionSubsystem.cs index d018dc86b..ffaceb0d6 100644 --- a/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantMealInteractionSubsystem.cs +++ b/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantMealInteractionSubsystem.cs @@ -1,4 +1,5 @@ using System; +using Unity.VisualScripting; using UnityEngine; namespace DDD @@ -23,11 +24,13 @@ public RestaurantMealType GetInteractionSubsystemType() public void SetInteractionSubsystemType(RestaurantMealType inValue) { + Debug.Log($"[{gameObject.GetHashCode()}, {GetType().Name}] SetInteractionSubsystemType {inValue.ToString()}"); _currentRestaurantMealType = inValue; } public void InitializeSubsystem() { + Debug.Log($"[{gameObject.GetHashCode()}, {GetType().Name}] InitializeSubsystem"); _currentRestaurantMealType = RestaurantMealType.None; } @@ -38,6 +41,7 @@ public bool CanInteract() public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null) { + Debug.Log($"[{gameObject.GetHashCode()}, {GetType().Name}] OnInteracted"); var prev = _currentRestaurantMealType; _currentRestaurantMealType = GetNextState(prev); return true; From b4e001f03f34baab7d5bacca1a58bd5462b68c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=82=B0?= Date: Thu, 28 Aug 2025 10:49:44 +0900 Subject: [PATCH 2/5] Refactor: Simplify interaction target retrieval in `WaitForPlayerInteraction` using `TryGetComponent` and shared blackboard. --- .../AI/Customer/Actions/WaitForPlayerInteraction.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) 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 8f2f3f801..6c5dd2230 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/WaitForPlayerInteraction.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/WaitForPlayerInteraction.cs @@ -18,17 +18,8 @@ public override void OnStart() { // 의자가 복합 상태를 가지게 될 경우 GameObject interactionTarget = null; - var shared = gameObject.GetComponentInChildren(); - if (shared != null) - { - interactionTarget = shared.GetCurrentInteractionTarget(); - } - else - { - // 하위 호환: 고객 전용 블랙보드 지원 - var customerBb = gameObject.GetComponentInParent(); - interactionTarget = customerBb?.GetCurrentInteractionTarget(); - } + if(!gameObject.TryGetComponent(out var sharedBlackboard)) return; + interactionTarget = sharedBlackboard.GetBlackboardGameObject(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget)); if (interactionTarget == null) { 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 3/5] =?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() From 60d0c80ad3cff2317fb65b325773ade2feb49864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=82=B0?= Date: Thu, 28 Aug 2025 12:55:21 +0900 Subject: [PATCH 4/5] =?UTF-8?q?Blackboard=20Customer=20data=20Id=EB=A7=8C?= =?UTF-8?q?=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AI/Customer/Subtree/CustomerDefault.asset | 4 +- .../Actions/WaitForPlayerInteraction.cs | 38 ++++++++++--------- .../AI/Customer/CustomerAiComponent.cs | 2 +- .../Customer/CustomerBlackboardComponent.cs | 4 +- .../Interfaces/ICustomerBlackboard.cs | 4 +- .../Restaurant/Ui/PropUiDisplayComponent.cs | 9 +++++ .../Ui/PropUiDisplayComponent.cs.meta | 3 ++ 7 files changed, 40 insertions(+), 24 deletions(-) create mode 100644 Assets/_DDD/_Scripts/Restaurant/Ui/PropUiDisplayComponent.cs create mode 100644 Assets/_DDD/_Scripts/Restaurant/Ui/PropUiDisplayComponent.cs.meta diff --git a/Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset b/Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset index b4c023f9c..94df842de 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:03d01d4c1d7746e711e9ef21cafbfa8e0ffd13f6f6ad4fbacea3f7464426ba16 -size 67915 +oid sha256:11145b67edd52b3f90fcfa0bfa2cde8d4547c8a8a6edc28c2f9922a5e7211ebb +size 68048 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 46579e1ce..30feb0826 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/WaitForPlayerInteraction.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/Actions/WaitForPlayerInteraction.cs @@ -14,32 +14,36 @@ public class WaitForPlayerInteraction : Action public override void OnStart() { - GameObject interactionTarget = null; - if(!gameObject.TryGetComponent(out var sharedBlackboard)) return; - interactionTarget = sharedBlackboard.GetBlackboardGameObject(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget)); - - if (interactionTarget == null) - { - Debug.LogError($"[{GetType().Name}] interactionTarget을 찾을 수 없습니다: {gameObject.name}"); - return; - } - - if (!interactionTarget.TryGetComponent(out var interactionComponent)) - Debug.LogError($"[{interactionTarget.name}] {nameof(interactionComponent)}를 찾을 수 없습니다: {gameObject.name}"); + GameObject interactionTarget = null; + if (!gameObject.TryGetComponent(out var sharedBlackboard)) return; + interactionTarget = + sharedBlackboard.GetBlackboardGameObject( + nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget)); + + if (interactionTarget == null) + { + Debug.LogError($"[{GetType().Name}] interactionTarget을 찾을 수 없습니다: {gameObject.name}"); + return; + } + + if (!interactionTarget.TryGetComponent(out var interactionComponent)) + Debug.LogError( + $"[{interactionTarget.name}] {nameof(interactionComponent)}를 찾을 수 없습니다: {gameObject.name}"); if (interactionComponent is not IInteractionSubsystemOwner subsystemOwner) { - Debug.LogError($"[{GetType().Name}]에서 {nameof(IInteractionSubsystemOwner)}를 찾을 수 없습니다: {gameObject.name}"); + Debug.LogError( + $"[{GetType().Name}]에서 {nameof(IInteractionSubsystemOwner)}를 찾을 수 없습니다: {gameObject.name}"); return; } if (!subsystemOwner.TryGetSubsystemObject(out _interactionSubsystem)) { - Debug.LogError($"[{GetType().Name}]에서 {nameof(IInteractionSubsystemObject)}를 찾을 수 없습니다: {gameObject.name}"); + Debug.LogError( + $"[{GetType().Name}]에서 {nameof(IInteractionSubsystemObject)}를 찾을 수 없습니다: {gameObject.name}"); return; } - - _interactionSubsystem.SetInteractionSubsystemType(_targetOrderType); + _isGetInteractionSubsystem = true; } @@ -51,7 +55,7 @@ public override TaskStatus OnUpdate() if (result == TaskStatus.Success) Debug.Log($"[{GetType().Name}] Success"); return result; } - + private TaskStatus CheckToSubsystemStatus() { return _interactionSubsystem.GetInteractionSubsystemType() == _targetOrderType diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/CustomerAiComponent.cs b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/CustomerAiComponent.cs index fa61ee462..a0ba7d4ea 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/CustomerAiComponent.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/CustomerAiComponent.cs @@ -48,7 +48,7 @@ private async Task InitializeAiInternal(CustomerData inCustomerData) _behaviorTree.Subgraph = subtree; _blackboardComponent.InitializeWithBehaviorTree(_behaviorTree); - _blackboardComponent.SetCustomerData(inCustomerData); + _blackboardComponent.SetCustomerData(inCustomerData.Id); // TODO : 1. Subtree - Action, Condition // TODO : 2. Blackboard _behaviorTree.StartBehavior(); diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/CustomerBlackboardComponent.cs b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/CustomerBlackboardComponent.cs index f56cd6b2b..41aee0f18 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/CustomerBlackboardComponent.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/AI/Customer/CustomerBlackboardComponent.cs @@ -17,10 +17,10 @@ public void InitializeWithBehaviorTree(BehaviorTree inBehaviorTree) } } - public void SetCustomerData(CustomerData inCustomerData) + public void SetCustomerData(string inCustomerDataId) { if (!_behaviorTree) return; - _behaviorTree.SetVariableValue(nameof(RestaurantCustomerBlackboardKey.CustomerData), inCustomerData); + _behaviorTree.SetVariableValue(nameof(RestaurantCustomerBlackboardKey.CustomerDataId), inCustomerDataId); } public void SetBlackboardGameObject(string key, GameObject inGameObject) diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/Interfaces/ICustomerBlackboard.cs b/Assets/_DDD/_Scripts/Restaurant/Character/Interfaces/ICustomerBlackboard.cs index 31c03ad24..8754ec832 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/Interfaces/ICustomerBlackboard.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/Interfaces/ICustomerBlackboard.cs @@ -5,12 +5,12 @@ namespace DDD public enum RestaurantCustomerBlackboardKey { SelfGameObject, - CustomerData, + CustomerDataId, CurrentInteractionTarget, } public interface ICustomerBlackboard { - void SetCustomerData(CustomerData inCustomerData); + void SetCustomerData(string inCustomerDataId); } } \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/Restaurant/Ui/PropUiDisplayComponent.cs b/Assets/_DDD/_Scripts/Restaurant/Ui/PropUiDisplayComponent.cs new file mode 100644 index 000000000..817d2635c --- /dev/null +++ b/Assets/_DDD/_Scripts/Restaurant/Ui/PropUiDisplayComponent.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace DDD.Restaurant +{ + public class PropUiDisplayComponent : MonoBehaviour + { + + } +} \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/Restaurant/Ui/PropUiDisplayComponent.cs.meta b/Assets/_DDD/_Scripts/Restaurant/Ui/PropUiDisplayComponent.cs.meta new file mode 100644 index 000000000..2b5b6d8ec --- /dev/null +++ b/Assets/_DDD/_Scripts/Restaurant/Ui/PropUiDisplayComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 37e749c7ec5440d587f83c715f29ca8f +timeCreated: 1756353198 \ No newline at end of file From 45c6f03cc9941fdfd824938d29f4ada4c151c03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=82=B0?= Date: Thu, 28 Aug 2025 12:56:09 +0900 Subject: [PATCH 5/5] =?UTF-8?q?BehaviorTree=EC=97=90=20=EA=B3=B5=EC=9C=A0?= =?UTF-8?q?=EB=B3=80=EC=88=98=EB=A5=BC=20CustomerData=EB=A5=BC=20CustomerD?= =?UTF-8?q?ataId=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_Addressables/AI/Customer/Subtree/CustomerDefault.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset b/Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset index 94df842de..a793b242d 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:11145b67edd52b3f90fcfa0bfa2cde8d4547c8a8a6edc28c2f9922a5e7211ebb +oid sha256:277f8b3b25cfe078e4838cab1222b85e5dae0bc036cb39e5f84b6e3b3fce1cd0 size 68048