public static void LoadData() { Defs.Initialize(); if (!hasLoaded) { try { try { if (File.Exists(GetStatsPath())) { File.Delete(GetStatsPath()); } } catch { Log.Message("Unable to delete stats.xml"); } StringBuilder sb = new StringBuilder("InGameDefEditor".Translate() + ": Loading Def Settings\n"); if (Load("AutoApplyDefs", out RootAutoApplyDefs raad)) { Log.Message($"Auto-Apply Settings to:"); raad?.autoApplyDefs.ForEach(s => { if (!Defs.ApplyStatsAutoDefs.Add(s)) { Log.Warning($"unable to auto-apply stats to {s} as the def/backstory was not found"); } }); raad?.autoApplyDefsV2.ForEach(s => { if (!Defs.ApplyStatsAutoDefs.AddDef(s)) { Log.Warning($"unable to auto-apply stats to {s} as the def was not found"); } }); raad?.autoApplyBackstories.ForEach(s => { if (!Defs.ApplyStatsAutoDefs.AddBackstory(s)) { Log.Warning($"unable to auto-apply stats to {s} as the backstory was not found"); } }); } if (Load(DefType.Apparel, out RootApparel ra)) { ra?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Weapon, out RootWeapons rw)) { rw?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Projectile, out RootProjectiles rp)) { rp?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Biome, out RootBiomes rb)) { rb?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Recipe, out RootRecipe rr)) { rr?.recipes.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Trait, out RootTraits rtr)) { rtr?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Thought, out RootThoughts rth)) { rth?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.StoryTeller, out RootStoryTeller rst)) { rst?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Difficulty, out RootDifficulty dif)) { dif?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Hediff, out RootHediffs hed)) { hed?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Ingestible, out RootIngestible ing)) { ing?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Mineable, out RootMineable min)) { min?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Backstory, out RootBackstory back)) { back?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Building, out RootBuilding building)) { building?.stats.ForEach((d) => Initialize(d, sb)); } if (Load(DefType.Resource, out RootResource resource)) { resource?.stats.ForEach((d) => Initialize(d, sb)); } // Do Last sb.AppendLine("Disabling the following defs:"); if (Load("DisabledDefs", out RootDisabledDefs rdd)) { rdd?.disabledThingDefs.ForEach(s => { if (!Defs.DisabledDefs.Add(s)) { Log.Warning($"failed to disable def {s} as the def was not found"); } else { sb.AppendLine($"- {s}"); } }); rdd?.disabledDefsV2.ForEach(s => { if (!Defs.DisabledDefs.AddDef(s)) { Log.Warning($"failed to disable def {s} as the def was not found"); } else { sb.AppendLine($"- {s}"); } }); rdd?.disabledBackstories.ForEach(s => { if (!Defs.DisabledDefs.AddBackstory(s)) { Log.Warning($"failed to disable def {s} as the def was not found"); } else { sb.AppendLine($"- {s}"); } }); Defs.DisabledDefs.Backstories.ForEach(b => DatabaseUtil.Remove(b)); Defs.DisabledDefs.Defs.ForEach(d => DatabaseUtil.Remove(d)); } Log.Message(sb.ToString()); } catch (Exception e) { Log.Warning("InGameDefEditor".Translate() + ": encountered an error on load - " + e.Message); } finally { hasLoaded = true; DefLookupUtil.ClearDefDic(); } } }