상호작용 메세지 로직 수정
This commit is contained in:
parent
aa628edf1b
commit
b9e31ce74d
@ -29,12 +29,12 @@ public InteractionExecutionParameters(float holdTime = 0f)
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public struct InteractionDisplayParameters
|
public struct InteractionDisplayParameters
|
||||||
{
|
{
|
||||||
[field: SerializeField] public string SuccessMessageKey { get; private set; }
|
[field: SerializeField] public string DefaultMessageKey { get; private set; }
|
||||||
[field: SerializeField] public string FailureMessageKey { get; private set; }
|
[field: SerializeField] public string ConditionalMessageKey { get; private set; }
|
||||||
public InteractionDisplayParameters(string successMessageKey = "", string failureMessageKey = "")
|
public InteractionDisplayParameters(string defaultMessageKey, string conditionalMessageKey = null)
|
||||||
{
|
{
|
||||||
SuccessMessageKey = successMessageKey;
|
DefaultMessageKey = defaultMessageKey ?? string.Empty;
|
||||||
FailureMessageKey = failureMessageKey;
|
ConditionalMessageKey = conditionalMessageKey ?? DefaultMessageKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ public interface IInteractionSubsystemObject
|
|||||||
void InitializeSubsystem();
|
void InitializeSubsystem();
|
||||||
bool CanInteract();
|
bool CanInteract();
|
||||||
bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null);
|
bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null);
|
||||||
|
string GetCurrentSubsystemTypeName();
|
||||||
}
|
}
|
||||||
public interface IInteractionSubsystemObject<T> : IInteractionSubsystemObject where T : Enum
|
public interface IInteractionSubsystemObject<T> : IInteractionSubsystemObject where T : Enum
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// <auto-generated> File: CookwareDataAsset.cs
|
// <auto-generated> File: CookwareDataAsset.cs
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -8,17 +10,13 @@ namespace DDD
|
|||||||
[CreateAssetMenu(fileName = "InteractionDataAsset", menuName = "GoogleSheet/InteractionDataAsset")]
|
[CreateAssetMenu(fileName = "InteractionDataAsset", menuName = "GoogleSheet/InteractionDataAsset")]
|
||||||
public class InteractionDataAsset : DataAsset<InteractionDataEntry>
|
public class InteractionDataAsset : DataAsset<InteractionDataEntry>
|
||||||
{
|
{
|
||||||
public void InteractionTypeParsing(string unparsedInteractionType)
|
public bool TryGetValueByTypeName(string interactionTypeName, string subsystemTypeName, out InteractionDataEntry interactionDataEntry)
|
||||||
{
|
{
|
||||||
var split = unparsedInteractionType.Split('.');
|
var targetString = $"{interactionTypeName}.{subsystemTypeName}";
|
||||||
var interactionType = split[0];
|
interactionDataEntry = _datas.FirstOrDefault(entry =>
|
||||||
var interactionSubsystemType = split[1];
|
string.Equals(entry.UnparsedInteractionType, targetString, StringComparison.Ordinal));
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(interactionType) || string.IsNullOrWhiteSpace(interactionSubsystemType))
|
return interactionDataEntry != null;
|
||||||
{
|
|
||||||
Debug.LogError($"{unparsedInteractionType} 파싱 오류");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,14 +17,14 @@ public class InteractionDataEntry : IId
|
|||||||
[field: SerializeField]
|
[field: SerializeField]
|
||||||
public string UnparsedInteractionType;
|
public string UnparsedInteractionType;
|
||||||
|
|
||||||
/// <summary>상호작용 성공 현지화 키 값</summary>
|
/// <summary>상호작용 기본 현지화 키 값</summary>
|
||||||
[Tooltip("상호작용 성공 현지화 키 값")]
|
[Tooltip("상호작용 기본 현지화 키 값")]
|
||||||
[field: SerializeField]
|
[field: SerializeField]
|
||||||
public string SuccessMessageKey;
|
public string DefaultMessageKey;
|
||||||
|
|
||||||
/// <summary>상호작용 실패 현지화 키 값</summary>
|
/// <summary>상호작용 예외처리 현지화 키 값</summary>
|
||||||
[Tooltip("상호작용 실패 현지화 키 값")]
|
[Tooltip("상호작용 예외처리 현지화 키 값")]
|
||||||
[field: SerializeField]
|
[field: SerializeField]
|
||||||
public string FailureMessageKey;
|
public string ConditionalMessageKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,9 +155,10 @@ protected override void OnInteractionCompleted()
|
|||||||
|
|
||||||
private void BroadcastShowUi(IInteractable interactable, bool canInteract, float ratio)
|
private void BroadcastShowUi(IInteractable interactable, bool canInteract, float ratio)
|
||||||
{
|
{
|
||||||
|
var displayParameters = interactable.GetDisplayParameters();
|
||||||
var evt = GameEvents.ShowInteractionUiEvent;
|
var evt = GameEvents.ShowInteractionUiEvent;
|
||||||
evt.CanInteract = canInteract;
|
evt.CanInteract = canInteract;
|
||||||
evt.TextKey = interactable.GetDisplayParameters().SuccessMessageKey;
|
evt.TextKey = canInteract ? displayParameters.DefaultMessageKey : displayParameters.ConditionalMessageKey;
|
||||||
evt.HoldProgress = ratio;
|
evt.HoldProgress = ratio;
|
||||||
EventBus.Broadcast(evt);
|
EventBus.Broadcast(evt);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,11 @@ public virtual bool OnInteracted(IInteractor interactor, ScriptableObject payloa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetCurrentSubsystemTypeName()
|
||||||
|
{
|
||||||
|
return nameof(_cookType);
|
||||||
|
}
|
||||||
|
|
||||||
public ScriptableObject GetPayload()
|
public ScriptableObject GetPayload()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -39,6 +39,11 @@ public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = nu
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetCurrentSubsystemTypeName()
|
||||||
|
{
|
||||||
|
return nameof(_managementType);
|
||||||
|
}
|
||||||
|
|
||||||
public ScriptableObject GetPayload()
|
public ScriptableObject GetPayload()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -47,6 +47,11 @@ public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = nu
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetCurrentSubsystemTypeName()
|
||||||
|
{
|
||||||
|
return nameof(_currentRestaurantMealType);
|
||||||
|
}
|
||||||
|
|
||||||
public ScriptableObject GetPayload()
|
public ScriptableObject GetPayload()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -45,6 +45,11 @@ public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = nu
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetCurrentSubsystemTypeName()
|
||||||
|
{
|
||||||
|
return nameof(_currentRestaurantOrderType);
|
||||||
|
}
|
||||||
|
|
||||||
public ScriptableObject GetPayload()
|
public ScriptableObject GetPayload()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -23,8 +23,8 @@ public class RestaurantInteractionComponent : MonoBehaviour, IInteractable, IInt
|
|||||||
// Single interaction type
|
// Single interaction type
|
||||||
[ValueDropdown("GetAllInteractionTypes")]
|
[ValueDropdown("GetAllInteractionTypes")]
|
||||||
[SerializeField] protected InteractionType _interactionType = InteractionType.None;
|
[SerializeField] protected InteractionType _interactionType = InteractionType.None;
|
||||||
[SerializeField] protected InteractionExecutionParameters _executionParameters = new InteractionExecutionParameters(1f);
|
[SerializeField] protected InteractionExecutionParameters _executionParameters = new(1f);
|
||||||
[SerializeField] protected InteractionDisplayParameters _displayParameters = new InteractionDisplayParameters("");
|
[SerializeField] protected InteractionDisplayParameters _displayParameters;
|
||||||
[SerializeField] protected GameFlowState _interactionAvailableFlows;
|
[SerializeField] protected GameFlowState _interactionAvailableFlows;
|
||||||
[SerializeField] private Transform[] _aiInteractionPoints;
|
[SerializeField] private Transform[] _aiInteractionPoints;
|
||||||
[SerializeField] private bool autoInitialize = true;
|
[SerializeField] private bool autoInitialize = true;
|
||||||
@ -102,7 +102,7 @@ public virtual void InitializeInteraction(InteractionType interactionType)
|
|||||||
_isInitialized = true;
|
_isInitialized = true;
|
||||||
|
|
||||||
InitializeSubsystems();
|
InitializeSubsystems();
|
||||||
|
SetDisplayParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeSubsystems()
|
private void InitializeSubsystems()
|
||||||
@ -143,7 +143,13 @@ public virtual InteractionExecutionParameters GetExecutionParameters()
|
|||||||
|
|
||||||
private void SetDisplayParameters()
|
private void SetDisplayParameters()
|
||||||
{
|
{
|
||||||
|
if (DataManager.Instance.GetDataSo<InteractionDataAsset>().TryGetValueByTypeName(nameof(_interactionType),
|
||||||
|
_subsystems[_interactionType].GetCurrentSubsystemTypeName(), out var interactionDataEntry) == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_displayParameters = new InteractionDisplayParameters(interactionDataEntry.DefaultMessageKey, interactionDataEntry.ConditionalMessageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual InteractionDisplayParameters GetDisplayParameters()
|
public virtual InteractionDisplayParameters GetDisplayParameters()
|
||||||
@ -159,7 +165,7 @@ public float GetRequiredHoldTime()
|
|||||||
|
|
||||||
public string GetInteractionMessageKey()
|
public string GetInteractionMessageKey()
|
||||||
{
|
{
|
||||||
return _displayParameters.SuccessMessageKey;
|
return _displayParameters.DefaultMessageKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3[] GetInteractionPoints()
|
public Vector3[] GetInteractionPoints()
|
||||||
|
Loading…
Reference in New Issue
Block a user