public override void QueryStart(object parameter) { // 这个线程正在被使用,禁止再继续调用这个线程 if (_qeuryCorp) { return; } if (_corpQueryed) { QueryLpGroup(); return; } _qeuryCorp = true; var threadQueryCorpTab = new Thread(new ThreadStart(ThreadQueryCorpTab)); _corp = parameter as NewNpcCorporations; if (_corp != null && !querying) { threadQueryCorpTab.Start(); } else { _qeuryCorp = false; } }
/// <summary> ///根据本地文件解析出能使用的NPC公司数据 /// </summary> public static void ReadAndParseNpcCorpGroup() { var @default = YamlTools.Read <Dictionary <int, NpcCorporations> >("Resources/npcCorporations.yaml"); //YamlFilter.NpcCorporations(@default, out var @new); FPS.FileReader.Read("Resources/npcCorporations.txt", out string contents); // 反转字典,用于反向构造映射关系 Dictionary <string, int> @neww = new Dictionary <string, int>(); foreach (var n in @default) { if ([email protected](n.Value.nameID.zh)) { @neww.Add(n.Value.nameID.zh, n.Key); } } var strs = contents.Split('\n'); Dictionary <int, NewNpcCorporations> tmncc = new Dictionary <int, NewNpcCorporations>(); List <TmpNc> tmncs = new List <TmpNc>(); // nc用来存txt解析出来的数据 // ncc用来构造新模板实例 bool title = true; int tmncsIndex = 0; for (int i = 0; i < strs.Length; i++) { var name = strs[i].Replace("\r", ""); if (title) { title = false; tmncs.Add(new TmpNc(name)); continue; } if (name.Contains("//")) { title = true; tmncsIndex++; continue; } tmncs[tmncsIndex].AddSub(name, 0); } int tmnccIndex = 0; foreach (var n in tmncs) { var tmnc = new NewNpcCorporations(tmnccIndex, n.name); tmncc.Add(tmnccIndex, tmnc); foreach (var n1 in n.subs) { @neww.TryGetValue(n1.Key, out int id); tmnc.AddSub(new NewNpcCorporations(id, n1.Key)); } tmnccIndex++; } YamlTools.Write(tmncc, "Resources/newNpcCorporations.yaml"); }