diff --git a/Assets/_DDD/_Scripts/Game/GameEvent/IInteractable.cs b/Assets/_DDD/_Scripts/Game/GameEvent/IInteractable.cs index f8a20466a..684924323 100644 --- a/Assets/_DDD/_Scripts/Game/GameEvent/IInteractable.cs +++ b/Assets/_DDD/_Scripts/Game/GameEvent/IInteractable.cs @@ -29,12 +29,12 @@ public InteractionExecutionParameters(float holdTime = 0f) [System.Serializable] public struct InteractionDisplayParameters { - [field: SerializeField] public string SuccessMessageKey { get; private set; } - [field: SerializeField] public string FailureMessageKey { get; private set; } - public InteractionDisplayParameters(string successMessageKey = "", string failureMessageKey = "") + [field: SerializeField] public string DefaultMessageKey { get; private set; } + [field: SerializeField] public string ConditionalMessageKey { get; private set; } + public InteractionDisplayParameters(string defaultMessageKey, string conditionalMessageKey = null) { - SuccessMessageKey = successMessageKey; - FailureMessageKey = failureMessageKey; + DefaultMessageKey = defaultMessageKey ?? string.Empty; + ConditionalMessageKey = conditionalMessageKey ?? DefaultMessageKey; } } diff --git a/Assets/_DDD/_Scripts/Game/GameEvent/InteractionSubsystem.cs b/Assets/_DDD/_Scripts/Game/GameEvent/InteractionSubsystem.cs index d3165af45..ba44ed3ff 100644 --- a/Assets/_DDD/_Scripts/Game/GameEvent/InteractionSubsystem.cs +++ b/Assets/_DDD/_Scripts/Game/GameEvent/InteractionSubsystem.cs @@ -8,6 +8,7 @@ public interface IInteractionSubsystemObject void InitializeSubsystem(); bool CanInteract(); bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null); + string GetCurrentSubsystemTypeName(); } public interface IInteractionSubsystemObject : IInteractionSubsystemObject where T : Enum { diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/InteractionDataAsset.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/InteractionDataAsset.cs index 16f3f02c7..0250661ec 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/InteractionDataAsset.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/InteractionDataAsset.cs @@ -1,4 +1,6 @@ // File: CookwareDataAsset.cs + +using System; using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -8,17 +10,13 @@ namespace DDD [CreateAssetMenu(fileName = "InteractionDataAsset", menuName = "GoogleSheet/InteractionDataAsset")] public class InteractionDataAsset : DataAsset { - public void InteractionTypeParsing(string unparsedInteractionType) + public bool TryGetValueByTypeName(string interactionTypeName, string subsystemTypeName, out InteractionDataEntry interactionDataEntry) { - var split = unparsedInteractionType.Split('.'); - var interactionType = split[0]; - var interactionSubsystemType = split[1]; - - if (string.IsNullOrWhiteSpace(interactionType) || string.IsNullOrWhiteSpace(interactionSubsystemType)) - { - Debug.LogError($"{unparsedInteractionType} 파싱 오류"); - return; - } + var targetString = $"{interactionTypeName}.{subsystemTypeName}"; + interactionDataEntry = _datas.FirstOrDefault(entry => + string.Equals(entry.UnparsedInteractionType, targetString, StringComparison.Ordinal)); + + return interactionDataEntry != null; } } } \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/InteractionDataEntry.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/InteractionDataEntry.cs index 8107665f3..468893100 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/InteractionDataEntry.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/InteractionDataEntry.cs @@ -17,14 +17,14 @@ public class InteractionDataEntry : IId [field: SerializeField] public string UnparsedInteractionType; - /// 상호작용 성공 현지화 키 값 - [Tooltip("상호작용 성공 현지화 키 값")] + /// 상호작용 기본 현지화 키 값 + [Tooltip("상호작용 기본 현지화 키 값")] [field: SerializeField] - public string SuccessMessageKey; + public string DefaultMessageKey; - /// 상호작용 실패 현지화 키 값 - [Tooltip("상호작용 실패 현지화 키 값")] + /// 상호작용 예외처리 현지화 키 값 + [Tooltip("상호작용 예외처리 현지화 키 값")] [field: SerializeField] - public string FailureMessageKey; + public string ConditionalMessageKey; } } diff --git a/Assets/_DDD/_Scripts/Restaurant/Character/Player/PlayerInteraction.cs b/Assets/_DDD/_Scripts/Restaurant/Character/Player/PlayerInteraction.cs index 996c79caf..b22e70148 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Character/Player/PlayerInteraction.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Character/Player/PlayerInteraction.cs @@ -155,9 +155,10 @@ protected override void OnInteractionCompleted() private void BroadcastShowUi(IInteractable interactable, bool canInteract, float ratio) { + var displayParameters = interactable.GetDisplayParameters(); var evt = GameEvents.ShowInteractionUiEvent; evt.CanInteract = canInteract; - evt.TextKey = interactable.GetDisplayParameters().SuccessMessageKey; + evt.TextKey = canInteract ? displayParameters.DefaultMessageKey : displayParameters.ConditionalMessageKey; evt.HoldProgress = ratio; EventBus.Broadcast(evt); } diff --git a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Cook.cs b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Cook.cs index c599b2af8..7a40d307f 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Cook.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Cook.cs @@ -38,6 +38,11 @@ public virtual bool OnInteracted(IInteractor interactor, ScriptableObject payloa return true; } + public string GetCurrentSubsystemTypeName() + { + return nameof(_cookType); + } + public ScriptableObject GetPayload() { return null; diff --git a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Management.cs b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Management.cs index f96e57e14..9f2a60c12 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Management.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Management.cs @@ -39,6 +39,11 @@ public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = nu return true; } + public string GetCurrentSubsystemTypeName() + { + return nameof(_managementType); + } + public ScriptableObject GetPayload() { return null; diff --git a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Meal.cs b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Meal.cs index 48b1b410d..bdcba7f73 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Meal.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Meal.cs @@ -47,6 +47,11 @@ public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = nu return true; } + public string GetCurrentSubsystemTypeName() + { + return nameof(_currentRestaurantMealType); + } + public ScriptableObject GetPayload() { return null; diff --git a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Order.cs b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Order.cs index 968306869..3cc452449 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Order.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Environment/Interactions/InteractionSubsystem_Order.cs @@ -45,6 +45,11 @@ public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = nu return true; } + public string GetCurrentSubsystemTypeName() + { + return nameof(_currentRestaurantOrderType); + } + public ScriptableObject GetPayload() { return null; diff --git a/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs b/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs index 70c5fe79d..65ace3af7 100644 --- a/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs +++ b/Assets/_DDD/_Scripts/Restaurant/Event/RestaurantInteractionComponent.cs @@ -23,8 +23,8 @@ public class RestaurantInteractionComponent : MonoBehaviour, IInteractable, IInt // Single interaction type [ValueDropdown("GetAllInteractionTypes")] [SerializeField] protected InteractionType _interactionType = InteractionType.None; - [SerializeField] protected InteractionExecutionParameters _executionParameters = new InteractionExecutionParameters(1f); - [SerializeField] protected InteractionDisplayParameters _displayParameters = new InteractionDisplayParameters(""); + [SerializeField] protected InteractionExecutionParameters _executionParameters = new(1f); + [SerializeField] protected InteractionDisplayParameters _displayParameters; [SerializeField] protected GameFlowState _interactionAvailableFlows; [SerializeField] private Transform[] _aiInteractionPoints; [SerializeField] private bool autoInitialize = true; @@ -102,7 +102,7 @@ public virtual void InitializeInteraction(InteractionType interactionType) _isInitialized = true; InitializeSubsystems(); - + SetDisplayParameters(); } private void InitializeSubsystems() @@ -143,7 +143,13 @@ public virtual InteractionExecutionParameters GetExecutionParameters() private void SetDisplayParameters() { - + if (DataManager.Instance.GetDataSo().TryGetValueByTypeName(nameof(_interactionType), + _subsystems[_interactionType].GetCurrentSubsystemTypeName(), out var interactionDataEntry) == false) + { + return; + } + + _displayParameters = new InteractionDisplayParameters(interactionDataEntry.DefaultMessageKey, interactionDataEntry.ConditionalMessageKey); } public virtual InteractionDisplayParameters GetDisplayParameters() @@ -159,7 +165,7 @@ public float GetRequiredHoldTime() public string GetInteractionMessageKey() { - return _displayParameters.SuccessMessageKey; + return _displayParameters.DefaultMessageKey; } public Vector3[] GetInteractionPoints()