public static void Parse() { var dir = "data/xml/"; var dc = DCT.GetDataCenter(); foreach (var group in DCT.DataCenter.Root.Children.GroupBy(x => x.Name)) { string dir2, format; if (group.Count() > 1) { dir2 = dir + group.Key + "/"; format = "{0}-{1}.xml"; } else { dir2 = dir; format = "{0}.xml"; } Directory.CreateDirectory(dir2); int i = 0; foreach (var mainObject in group) { var element = ConvertToXElement(mainObject); element.Save(dir2 + string.Format(format, mainObject.Name, i)); i++; } } }
public static void Parse() { var dir = "data/json/"; var dc = DCT.GetDataCenter(); foreach (var group in DCT.DataCenter.Root.Children.GroupBy(x => x.Name)) { string dir2, format; if (group.Count() > 1) { dir2 = dir + group.Key + "/"; format = "{0}-{1}.json"; } else { dir2 = dir; format = "{0}.json"; } Directory.CreateDirectory(dir2); int i = 0; foreach (var mainObject in group) { var values = dc.GetValues(mainObject, x => x.Value); var json = JsonConvert.SerializeObject(values, Formatting.Indented); File.WriteAllText(dir2 + string.Format(format, mainObject.Name, i), json); i++; } } }
public static async Task Parse(IProgress <ParseProgress> progress) { var outDir = ((App.Current.MainWindow as MainWindow).DataContext as MainVM).OutPath; var groups = DCT.DataCenter.Root.Children.GroupBy(x => x.Name); var count = groups.Count(); var g = 0; var dc = DCT.GetDataCenter(); foreach (var group in groups) { await Task.Run(async() => { var pi = new ParseProgress(); pi.CurrentGroup = group.Key; string dir2, format; if (group.Count() > 1) { dir2 = outDir + "/" + group.Key + "/"; format = "{0}-{1}.json"; } else { dir2 = outDir + "/"; format = "{0}.json"; } g++; pi.OverallProgress = g / (float)count; var i = 0; var objectsCount = group.Count(); foreach (var mainObject in group) { await Task.Run(async() => { var values = dc.GetValues(mainObject, x => x.Value); var json = JsonConvert.SerializeObject(values, Formatting.Indented); var fName = string.Format(format, mainObject.Name, i); var path = Utils.GetOutput(dir2 + fName); File.WriteAllText(path, json); i++; pi.CurrentFile = fName; pi.GroupProgress = i / (float)objectsCount; progress.Report(pi); }); } }); } }
public async static Task Parse(IProgress <ParseProgress> progress) { var dc = DCT.GetDataCenter(); var groups = DCT.DataCenter.Root.Children.GroupBy(x => x.Name); var count = groups.Count(); var g = 0; var outDir = ((App.Current.MainWindow as MainWindow).DataContext as MainVM).OutPath; foreach (var group in groups) { await Task.Run(async() => { var pi = new ParseProgress(); pi.CurrentGroup = group.Key; string dir2, format; if (group.Count() > 1) { dir2 = outDir + "/" + group.Key + "/"; format = "{0}-{1}.xml"; } else { dir2 = outDir + "/"; format = "{0}.xml"; } g++; pi.OverallProgress = g / (float)count; Directory.CreateDirectory(dir2); int i = 0; var objectsCount = group.Count(); foreach (var mainObject in group) { await Task.Run(() => { var element = ConvertToXElement(mainObject); var fName = string.Format(format, mainObject.Name, i); var path = dir2 + fName; element.Save(path); i++; pi.CurrentFile = fName; pi.GroupProgress = i / (float)objectsCount; progress.Report(pi); //Console.WriteLine($"[{i / (float)group.Count():P2}]\tCurrent: {fName}"); }); } }); } }
private static void ParseNpcShapes() { Shapes = new Dictionary <int, NpcShape>(); DataCenter dc = DCT.GetDataCenter(); foreach (var dcObject in dc.GetMainObjectsByName("NpcShape")) { var values = dc.GetValues(dcObject); if (!values.ContainsKey("Shape")) { continue; } foreach (var data in (List <Dictionary <string, object> >)values["Shape"]) { NpcShape shape = new NpcShape(); int id = int.Parse(data["id"].ToString()); if (data.ContainsKey("baseRunSpeed")) { shape.RunSpeed = float.Parse(data["baseRunSpeed"].ToString()); } if (data.ContainsKey("baseTurnSpeed")) { shape.TurnSpeed = float.Parse(data["baseTurnSpeed"].ToString()); } if (data.ContainsKey("baseWalkSpeed")) { shape.WalkSpeed = float.Parse(data["baseWalkSpeed"].ToString()); } if (!Shapes.ContainsKey(id)) { Shapes.Add(id, shape); } else { Console.WriteLine("Dublicate npc shape {0}", id); } } } Console.WriteLine("Loaded {0} npc shapes...", Shapes.Count); }
private static void ParseNpcNames() { NpcNames = new Dictionary <int, Dictionary <int, KeyValuePair <string, string> > >(); DataCenter dc = DCT.GetDataCenter(); int count = 0; var objects = dc.GetObjectsByName("StrSheet_Creature"); foreach (var dcObject in objects) { var strings = (Dictionary <string, object>)dc.GetValues(dcObject); var huntingZones = (List <Dictionary <string, object> >)strings["HuntingZone"]; foreach (var zoneData in huntingZones) { int huntingZoneId = int.Parse(zoneData["id"].ToString()); if (huntingZoneId == 0) { continue; } NpcNames.Add(huntingZoneId, new Dictionary <int, KeyValuePair <string, string> >()); foreach (var data in (List <Dictionary <string, object> >)zoneData["String"]) { int id = int.Parse(data["templateId"].ToString()); string name = null; if (data.ContainsKey("name")) { name = data["name"].ToString(); } string title = null; if (data.ContainsKey("title") && data["title"].ToString().Length > 0) { title = data["title"].ToString(); } NpcNames[huntingZoneId].Add(id, new KeyValuePair <string, string>(name, title)); count++; } } } Console.WriteLine("Loaded {0} npc names...", count); }
private static void ParseSpawn() { Spawn = new Dictionary <int, List <SpawnTemplate> >(); DataCenter dc = DCT.GetDataCenter(); int count = 0; foreach (var dcObject in dc.GetMainObjectsByName("StrSheet_NpcLoc")) { count += ParseSpawnData(dc.GetValues(dcObject)); } foreach (var dcObject in dc.GetMainObjectsByName("StrSheet_NpcLocManual")) { count += ParseSpawnData(dc.GetValues(dcObject)); } Console.WriteLine("Loaded {0} spawn templates...", count); }
private static void ParseNpcTemplates() { NpcTemplates = new Dictionary <int, Dictionary <int, NpcTemplate> >(); DataCenter dc = DCT.GetDataCenter(); int count = 0; foreach (var dcObject in dc.GetMainObjectsByName("NpcData")) { var zoneData = dc.GetValues(dcObject); int huntingZoneId = int.Parse(zoneData["huntingZoneId"].ToString()); NpcTemplates.Add(huntingZoneId, new Dictionary <int, NpcTemplate>()); foreach (var data in (List <Dictionary <string, object> >)zoneData["Template"]) { NpcTemplate template = new NpcTemplate(); template.HuntingZoneId = huntingZoneId; template.Id = int.Parse(data["id"].ToString()); template.Scale = data.ContainsKey("scale") ? float.Parse(data["scale"].ToString()) : 1f; if (data.ContainsKey("size") && data["size"].ToString().Length > 0) { template.Size = ParseEnum <NpcSize>(data["size"]); } else { template.Size = NpcSize.Medium; } int shapeId = int.Parse(data["shapeId"].ToString()); template.Shape = Shapes[shapeId]; try { template.Level = int.Parse(((List <Dictionary <string, object> >)data["Stat"])[0]["level"].ToString()); } catch { template.Level = 1; } template.Name = null; template.Title = null; if (NpcNames.ContainsKey(huntingZoneId) && NpcNames[huntingZoneId].ContainsKey(template.Id)) { template.Name = NpcNames[huntingZoneId][template.Id].Key; template.Title = NpcNames[huntingZoneId][template.Id].Value; } //resourceSize //resourceType //class if (data.ContainsKey("gender") && data["gender"].ToString().Length > 0) { try { template.Gender = ParseEnum <Gender>(data["gender"]); } catch { //Nothing } } if (data.ContainsKey("race") && data["race"].ToString().Length > 0) { template.Race = data["race"].ToString(); } else { template.Race = null; } if (data.ContainsKey("parentId")) { template.ParentId = int.Parse(data["parentId"].ToString()); } //despawnScriptId //basicActionId if (data.ContainsKey("collideOnMove")) { template.CollideOnMove = bool.Parse(data["collideOnMove"].ToString()); } if (data.ContainsKey("cameraPenetratable")) { template.CameraPenetratable = bool.Parse(data["cameraPenetratable"].ToString()); } if (data.ContainsKey("isHomunculus")) { template.IsHomunculus = bool.Parse(data["isHomunculus"].ToString()); } //deathShapeId if (data.ContainsKey("dontTurn")) { template.DontTurn = bool.Parse(data["dontTurn"].ToString()); } if (data.ContainsKey("villager")) { template.IsVillager = bool.Parse(data["villager"].ToString()); } if (data.ContainsKey("isObjectNpc")) { template.IsObject = bool.Parse(data["isObjectNpc"].ToString()); } if (data.ContainsKey("elite")) { template.IsElite = bool.Parse(data["elite"].ToString()); } if (data.ContainsKey("unionElite")) { template.IsUnionElite = bool.Parse(data["unionElite"].ToString()); } if (data.ContainsKey("isFreeNamed")) { template.IsFreeNamed = bool.Parse(data["isFreeNamed"].ToString()); } if (data.ContainsKey("showAggroTarget")) { template.ShowAggroTarget = bool.Parse(data["showAggroTarget"].ToString()); } //spawnScriptId if (data.ContainsKey("isSpirit")) { template.IsSpirit = bool.Parse(data["isSpirit"].ToString()); } if (data.ContainsKey("isWideBroadcaster")) { template.IsWideBroadcaster = bool.Parse(data["isWideBroadcaster"].ToString()); } //villagerVolumeActiveRange //villagerVolumeHalfHeight //villagerVolumeInteractionDist //villagerVolumeOffset if (data.ContainsKey("showShorttermTarget")) { template.ShowShorttermTarget = bool.Parse(data["showShorttermTarget"].ToString()); } //__value__ //cannotPassThrough //vehicleEx //NamePlate //VehicleType //SeatList //Shader //DeathEffect //Stat (Level) //AltAnimation //Emoticon if (!NpcTemplates[huntingZoneId].ContainsKey(template.Id)) { NpcTemplates[huntingZoneId].Add(template.Id, template); } else { Console.WriteLine("Dublicate NPC template: {0},{1}", huntingZoneId, template.Id); } count++; } } Console.WriteLine("Loaded {0} npc templates...", count); }