refactor(store): improve ChangeVariables() logic

This commit is contained in:
2025-11-30 22:27:47 +09:00
parent fcc9d7a78b
commit 2a832f18af
2 changed files with 5 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using UnityEngine;
using System.Text.RegularExpressions;
public class Store
{
@@ -54,20 +55,17 @@ public class Store
{
Debug.LogWarning($"VariableManager :: Cannot add {valueStr} to {name} (Type: {current.GetType()})");
}
Debug.Log($"VariableManager :: Add {name} += {valueStr} -> {_variables[name]}");
}
public string ReplaceVariables(string text)
{
if (string.IsNullOrEmpty(text) || !text.Contains("{")) return text;
foreach (var kvp in _variables)
return Regex.Replace(text, @"\{([^}]+)\}", match =>
{
text = text.Replace($"{{{kvp.Key}}}", kvp.Value.ToString());
}
return text;
string key = match.Groups[1].Value;
return _variables.ContainsKey(key) ? _variables[key].ToString() : match.Value;
});
}
}

View File

@@ -62,7 +62,6 @@ public class VNManager : MonoBehaviour
NextStep();
}
void Update()
{
DisplayEffects(dialogueText);