feat(equipment): persist mech loadouts and recover ejection safe case loot

This commit is contained in:
2026-11-12 18:02:26 +08:00
parent 0857e291d5
commit e1d38c5a6d
23 changed files with 1371 additions and 204 deletions
@@ -7,7 +7,11 @@ namespace Ironspore
{
public static class GameLocalization
{
#if UNITY_EDITOR
public static string PreferenceKey => "settings.locale." + Hash128.Compute(Application.dataPath);
#else
public const string PreferenceKey = "settings.locale";
#endif
public const string FallbackCode = "en";
public static event Action Changed;
public static string CurrentCode { get; private set; } = FallbackCode;
@@ -40,6 +44,7 @@ namespace Ironspore
tables.Add(locale.code, ReadTable(locale.table));
if (!tables.ContainsKey(FallbackCode))
throw new InvalidOperationException("English fallback table is missing.");
if (catalog.uiFont) PrepareGlyphs(catalog);
string system = CultureInfo.CurrentUICulture.Name;
if (Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional || Application.systemLanguage == SystemLanguage.Chinese)
system = "zh-Hans";
@@ -48,6 +53,23 @@ namespace Ironspore
CurrentCode = FallbackCode;
}
static void PrepareGlyphs(LocalizationCatalog catalog)
{
// A clean import can start with an empty dynamic atlas.
var missingGlyphs = new SortedSet<char>();
foreach (var table in tables.Values)
foreach (string value in table.Values)
foreach (char glyph in value)
if (!char.IsControl(glyph) && !catalog.uiFont.HasCharacter(glyph)) missingGlyphs.Add(glyph);
if (missingGlyphs.Count > 0)
{
var glyphs = new char[missingGlyphs.Count];
missingGlyphs.CopyTo(glyphs);
catalog.uiFont.TryAddCharacters(new string(glyphs), out string absent);
if (!string.IsNullOrEmpty(absent)) Debug.LogWarning("Missing UI font glyphs: " + absent);
}
}
public static Dictionary<string, string> ReadTable(TextAsset source)
{
if (!source)