상호작용 메세지 로직 수정
This commit is contained in:
parent
aa628edf1b
commit
b9e31ce74d
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ public interface IInteractionSubsystemObject
|
||||
void InitializeSubsystem();
|
||||
bool CanInteract();
|
||||
bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null);
|
||||
string GetCurrentSubsystemTypeName();
|
||||
}
|
||||
public interface IInteractionSubsystemObject<T> : IInteractionSubsystemObject where T : Enum
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
// <auto-generated> 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<InteractionDataEntry>
|
||||
{
|
||||
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];
|
||||
var targetString = $"{interactionTypeName}.{subsystemTypeName}";
|
||||
interactionDataEntry = _datas.FirstOrDefault(entry =>
|
||||
string.Equals(entry.UnparsedInteractionType, targetString, StringComparison.Ordinal));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(interactionType) || string.IsNullOrWhiteSpace(interactionSubsystemType))
|
||||
{
|
||||
Debug.LogError($"{unparsedInteractionType} 파싱 오류");
|
||||
return;
|
||||
}
|
||||
return interactionDataEntry != null;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,14 +17,14 @@ public class InteractionDataEntry : IId
|
||||
[field: SerializeField]
|
||||
public string UnparsedInteractionType;
|
||||
|
||||
/// <summary>상호작용 성공 현지화 키 값</summary>
|
||||
[Tooltip("상호작용 성공 현지화 키 값")]
|
||||
/// <summary>상호작용 기본 현지화 키 값</summary>
|
||||
[Tooltip("상호작용 기본 현지화 키 값")]
|
||||
[field: SerializeField]
|
||||
public string SuccessMessageKey;
|
||||
public string DefaultMessageKey;
|
||||
|
||||
/// <summary>상호작용 실패 현지화 키 값</summary>
|
||||
[Tooltip("상호작용 실패 현지화 키 값")]
|
||||
/// <summary>상호작용 예외처리 현지화 키 값</summary>
|
||||
[Tooltip("상호작용 예외처리 현지화 키 값")]
|
||||
[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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<InteractionDataAsset>().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()
|
||||
|
Loading…
Reference in New Issue
Block a user