diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index deb5b201..f663f9e5 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/Source/WulaFallenEmpire/EventSystem/AI/Tools/Tool_SpawnResources.cs b/Source/WulaFallenEmpire/EventSystem/AI/Tools/Tool_SpawnResources.cs index 9b81d90b..bac154e6 100644 --- a/Source/WulaFallenEmpire/EventSystem/AI/Tools/Tool_SpawnResources.cs +++ b/Source/WulaFallenEmpire/EventSystem/AI/Tools/Tool_SpawnResources.cs @@ -169,9 +169,10 @@ namespace WulaFallenEmpire.EventSystem.AI.Tools } Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("Wula_PIA_Legion_Faction")); - string letterText = faction != null - ? "Wula_ResourceDrop".Translate(faction.def.defName.Named("FACTION_name")) - : "Wula_ResourceDrop".Translate("Unknown".Named("FACTION_name")); + // Avoid unresolved named placeholders if the translation system doesn't pick up NamedArguments as expected. + string template = "Wula_ResourceDrop".Translate(); + string factionName = faction?.Name ?? "Unknown"; + string letterText = template.Replace("{FACTION_name}", factionName); Messages.Message(letterText, new LookTargets(dropSpot, map), MessageTypeDefOf.PositiveEvent); resultLog.Length -= 2; // Remove trailing comma diff --git a/Source/WulaFallenEmpire/EventSystem/AI/Utils/ThingDefSearcher.cs b/Source/WulaFallenEmpire/EventSystem/AI/Utils/ThingDefSearcher.cs index a34d8fe7..a2b71747 100644 --- a/Source/WulaFallenEmpire/EventSystem/AI/Utils/ThingDefSearcher.cs +++ b/Source/WulaFallenEmpire/EventSystem/AI/Utils/ThingDefSearcher.cs @@ -178,6 +178,10 @@ namespace WulaFallenEmpire.EventSystem.AI.Utils string cleaned = Regex.Replace(token, @"[^\p{L}\p{N}]+", ""); if (string.IsNullOrWhiteSpace(cleaned)) continue; tokens.Add(cleaned); + + // CJK queries often have no spaces; add bigrams for better partial matching + // (e.g. "乌拉能源核心" should match "乌拉帝国能源核心"). + AddCjkBigrams(cleaned, tokens); } // For queries like "fine meal" also consider the normalized concatenation for matching "MealFine". @@ -189,6 +193,59 @@ namespace WulaFallenEmpire.EventSystem.AI.Utils return tokens.Distinct().ToList(); } + private static void AddCjkBigrams(string token, List tokens) + { + if (string.IsNullOrEmpty(token) || token.Length < 2) return; + + int runStart = -1; + for (int i = 0; i < token.Length; i++) + { + bool isCjk = IsCjkChar(token[i]); + if (isCjk) + { + if (runStart == -1) runStart = i; + } + else + { + if (runStart != -1) + { + AddBigramsForRun(token, runStart, i - 1, tokens); + runStart = -1; + } + } + } + + if (runStart != -1) + { + AddBigramsForRun(token, runStart, token.Length - 1, tokens); + } + } + + private static void AddBigramsForRun(string token, int start, int end, List tokens) + { + int len = end - start + 1; + if (len < 2) return; + + // cap to avoid generating too many tokens for long Chinese sentences + int maxBigrams = 32; + int added = 0; + + for (int i = start; i < end; i++) + { + tokens.Add(token.Substring(i, 2)); + added++; + if (added >= maxBigrams) break; + } + } + + private static bool IsCjkChar(char c) + { + // Basic CJK ranges commonly used in Chinese/Japanese/Korean text. + return (c >= '\u4E00' && c <= '\u9FFF') || + (c >= '\u3400' && c <= '\u4DBF') || + (c >= '\uF900' && c <= '\uFAFF'); + } + private static string NormalizeKey(string s) { if (string.IsNullOrEmpty(s)) return "";