//ctor to populate lists. public MainTabWindow_Numbers() { optionsMaker = new OptionsMaker(this); MethodInfo statsToDraw = typeof(StatsReportUtility).GetMethod("StatsToDraw", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod, null, new[] { typeof(Thing) }, null); Pawn tmpPawn = PawnGenerator.GeneratePawn(PawnKindDefOf.AncientSoldier, Faction.OfPlayerSilentFail); if (statsToDraw != null) { pawnHumanlikeStatDef = ((IEnumerable <StatDrawEntry>)statsToDraw.Invoke(null, new[] { tmpPawn })) .Concat(tmpPawn.def.SpecialDisplayStats(StatRequest.For(tmpPawn))) .Where(s => s.stat != null && s.ShouldDisplay && s.stat.Worker != null) .Select(s => s.stat) .OrderBy(stat => stat.LabelCap); tmpPawn.Destroy(); tmpPawn = PawnGenerator.GeneratePawn(PawnKindDefOf.Thrumbo); pawnAnimalNeedDef = tmpPawn.needs.AllNeeds.Where(x => x.def.showOnNeedList).Select(x => x.def); pawnAnimalStatDef = ((IEnumerable <StatDrawEntry>)statsToDraw.Invoke(null, new[] { tmpPawn })) .Where(s => s.stat != null && s.ShouldDisplay && s.stat.Worker != null) .Select(s => s.stat) .OrderBy(stat => stat.LabelCap); Corpse corpse = (Corpse)ThingMaker.MakeThing(tmpPawn.RaceProps.corpseDef); corpse.InnerPawn = tmpPawn; corpseStatDef = ((IEnumerable <StatDrawEntry>)statsToDraw.Invoke(null, new[] { corpse })) .Concat(tmpPawn.def.SpecialDisplayStats(StatRequest.For(tmpPawn))) .Where(s => s.stat != null && s.ShouldDisplay && s.stat.Worker != null) .Select(s => s.stat) .OrderBy(stat => stat.LabelCap); tmpPawn.Destroy(); } else { Log.Error("ReflectionTypeLoadException in Numbers: statsToDraw was null. Please contact mod author."); } pawnHumanlikeNeedDef = DefDatabase <NeedDef> .AllDefsListForReading; PawnTableDef defaultTable = WorldComponent_Numbers.PrimaryFilter.First().Key; if (Find.World.GetComponent <WorldComponent_Numbers>().sessionTable.TryGetValue(defaultTable, out List <PawnColumnDef> list)) { pawnTableDef.columns = list; } UpdateFilter(); }
//ctor to populate lists. public MainTabWindow_Numbers() { optionsMaker = new OptionsMaker(this); StatsToDraw = typeof(StatsReportUtility).GetMethod("StatsToDraw", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod, null, new[] { typeof(Thing) }, null); if (StatsToDraw == null) { Log.Error("ReflectionTypeLoadException in Numbers: statsToDraw was null. Please contact mod author."); } if (pawnHumanlikeNeedDef == null) { pawnHumanlikeNeedDef = GetHumanLikeNeedDef(); } if (pawnHumanlikeStatDef == null) { pawnHumanlikeStatDef = GetHumanLikeStatDefs(); } if (pawnAnimalNeedDef == null || pawnAnimalStatDef == null || corpseStatDef == null) { var statDefs = PopulateLists(); pawnAnimalStatDef = statDefs.pawnAnimalStatDef; pawnAnimalNeedDef = statDefs.pawnAnimalNeedDef; corpseStatDef = statDefs.corpseStatDef; } PawnTableDef defaultTable = WorldComponent_Numbers.PrimaryFilter.First().Key; if (Find.World.GetComponent <WorldComponent_Numbers>().sessionTable.TryGetValue(defaultTable, out List <PawnColumnDef> list)) { pawnTableDef.columns = list; } UpdateFilter(); }