From 22047aeb8b5e1f3758864aa92df7459c436351b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=82=B0?= Date: Wed, 20 Aug 2025 15:30:08 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B8=ED=84=B0=EB=9E=99=EC=85=98=20?= =?UTF-8?q?=EC=B4=88=EA=B8=B0=ED=99=94=20=EB=A1=9C=EC=A7=81=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20CustomerNpc=20=ED=94=84=EB=A6=AC?= =?UTF-8?q?=ED=8C=B9=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/RestaurantOrder.prefab | 3 +- .../_Addressables/Prefabs/CustomerNpc.prefab | 34 +++++++++++++++++++ .../Customer/Actions/StartRestaurantOrder.cs | 4 +-- .../Core/RestaurantCharacter.cs | 9 ++--- .../RestaurantInteractionComponent.cs | 9 ++++- .../Solvers/RestaurantSubsystemSolver.cs | 2 +- 6 files changed, 52 insertions(+), 9 deletions(-) diff --git a/Assets/_DDD/Restaurant/Environments/Interactables/Common/RestaurantOrder.prefab b/Assets/_DDD/Restaurant/Environments/Interactables/Common/RestaurantOrder.prefab index 24036b0a6..546d96553 100644 --- a/Assets/_DDD/Restaurant/Environments/Interactables/Common/RestaurantOrder.prefab +++ b/Assets/_DDD/Restaurant/Environments/Interactables/Common/RestaurantOrder.prefab @@ -133,7 +133,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 201f9e6d7ca7404baa9945950292a392, type: 3} m_Name: m_EditorClassIdentifier: - _interactionType: 4 + _interactionType: 2 _executionParameters: _holdTime: 0 _displayParameters: @@ -141,6 +141,7 @@ MonoBehaviour: _interactionAvailableFlows: 2 _aiInteractionPoints: - {fileID: 1664322405549350652} + autoInitialize: 1 --- !u!114 &4456475204957017828 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/_DDD/_Addressables/Prefabs/CustomerNpc.prefab b/Assets/_DDD/_Addressables/Prefabs/CustomerNpc.prefab index 4091378b7..e8667b395 100644 --- a/Assets/_DDD/_Addressables/Prefabs/CustomerNpc.prefab +++ b/Assets/_DDD/_Addressables/Prefabs/CustomerNpc.prefab @@ -1100,6 +1100,10 @@ PrefabInstance: propertyPath: skeletonDataAsset value: objectReference: {fileID: 11400000, guid: 90ef4d2128c770b4cb83806c33867a79, type: 2} + - target: {fileID: 5108021082109611361, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} + propertyPath: _availableInteractions + value: 2 + objectReference: {fileID: 0} - target: {fileID: 6336425934484470474, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} propertyPath: m_Materials.Array.size value: 4 @@ -1148,6 +1152,12 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 7462519206451630147, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} insertIndex: -1 addedObject: {fileID: 6054843938321605399} + - targetCorrespondingSourceObject: {fileID: 7462519206451630147, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} + insertIndex: -1 + addedObject: {fileID: 3924055170972325225} + - targetCorrespondingSourceObject: {fileID: 7462519206451630147, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} + insertIndex: -1 + addedObject: {fileID: 3825874317044733320} m_SourcePrefab: {fileID: 100100000, guid: ceeea618d8ee23642a0e56b3f963448c, type: 3} --- !u!1 &4266090516809920735 stripped GameObject: @@ -1166,3 +1176,27 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b242c4f65b2734841840c89dfab1500b, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &3924055170972325225 +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: 784c770c13244dc0a0804056065eaf92, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &3825874317044733320 +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: af69e82818254bfa9cabb2dbf9430850, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/StartRestaurantOrder.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/StartRestaurantOrder.cs index 004f9111b..336001e00 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/StartRestaurantOrder.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/AI/Customer/Actions/StartRestaurantOrder.cs @@ -26,8 +26,8 @@ public override TaskStatus OnUpdate() // TODO : 아래 상호작용 수행 로직이 우리 프로젝트의 권장하는 방식이 아님. 플레이어가 오브젝트에 인터랙션하는 것과 비슷한 흐름으로 NPC가 오브젝트에 인터랙션하게 만들 것. // 상호작용 수행: 액션이 붙은 에이전트를 Interactor로 사용 - var interactor = gameObject.GetComponentInParent(); - if (interactor == null) + var isGetInteractor = gameObject.TryGetComponent(out var interactor); + if (!isGetInteractor || !interactor.CanInteractTo(outInteractable)) { return TaskStatus.Failure; } diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/Core/RestaurantCharacter.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/Core/RestaurantCharacter.cs index 45c56de5d..892a2bbfe 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/Core/RestaurantCharacter.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/Core/RestaurantCharacter.cs @@ -14,10 +14,6 @@ protected virtual void Awake() { _interactionComponent = GetComponent(); _spineController = GetComponent(); - } - - protected virtual void Start() - { foreach (var typeToSolver in RestaurantInteractionEventSolvers.TypeToSolver) { var flag = typeToSolver.Key; @@ -32,6 +28,11 @@ protected virtual void Start() } } + protected virtual void Start() + { + + } + public GameObject GetInteractorGameObject() { return _interactionComponent.GetInteractorGameObject(); diff --git a/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionComponent.cs b/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionComponent.cs index 7921054b4..92f7c8a4d 100644 --- a/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionComponent.cs +++ b/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionComponent.cs @@ -27,6 +27,7 @@ public class RestaurantInteractionComponent : MonoBehaviour, IInteractable, IInt [SerializeField] protected GameFlowState _interactionAvailableFlows; [SerializeField] private Transform[] _aiInteractionPoints; [SerializeField] private bool autoInitialize = true; + private bool _isInitialized = false; private Dictionary _subsystems = new(); @@ -36,7 +37,7 @@ private void OnEnable() var environmentState = RestaurantState.Instance?.EnvironmentState; environmentState?.RegisterInteractable(this); - if (autoInitialize) + if (autoInitialize && !_isInitialized) { InitializeInteraction(_interactionType); } @@ -53,6 +54,11 @@ private void Start() // 보수적으로 Start에서도 등록 시도 (OnEnable 시점에 EnvironmentState가 없었을 경우 대비) var environmentState = RestaurantState.Instance?.EnvironmentState; environmentState?.RegisterInteractable(this); + + if (autoInitialize && !_isInitialized) + { + InitializeInteraction(_interactionType); + } } private static IEnumerable GetAllInteractionTypes() @@ -108,6 +114,7 @@ public GameObject GetInteractableGameObject() public virtual void InitializeInteraction(InteractionType interactionType) { _interactionType = interactionType; + _isInitialized = true; InitializeSubsystems(); } diff --git a/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantSubsystemSolver.cs b/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantSubsystemSolver.cs index 6edbf5102..d5814a100 100644 --- a/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantSubsystemSolver.cs +++ b/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantSubsystemSolver.cs @@ -10,7 +10,7 @@ public abstract class RestaurantSubsystemSolver : MonoBehaviour, IInteraction protected abstract Dictionary GetSubsystemSolverTypeMappings(); - private void Start() + private void Awake() { foreach (var subsystemSolverType in GetSubsystemSolverTypeMappings()) {