public static void Postfix(ThingDef __instance, ref IEnumerable <StatDrawEntry> __result) { if (__instance.GetModExtension <AnimalStatExtension>() != null && !__instance.IsCorpse) { AnimalStatExtension extension = __instance.GetModExtension <AnimalStatExtension>(); foreach (string stat in extension.statToAdd) { __result = __result.AddItem(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, stat.Translate(), extension.statValues[extension.statToAdd.IndexOf(stat)].Translate(), extension.statDescriptions[extension.statToAdd.IndexOf(stat)].Translate() , 1)); } } }
public static bool Prefix(Rect cardRect, Dialog_InfoCard __instance, Thing ___thing) { Pawn pawn = ___thing as Pawn; rect = cardRect; bool result; if (pawn == null) { result = true; } else { if (pawn.def.GetModExtension <AnimalStatExtension>() != null) { extension = pawn.def.GetModExtension <AnimalStatExtension>(); if (extension.showImageInInfoCard) { Type typ = typeof(Dialog_InfoCard); FieldInfo type = typ.GetField("tab", BindingFlags.Instance | BindingFlags.NonPublic); Dialog_InfoCard.InfoCardTab tab = (Dialog_InfoCard.InfoCardTab)type.GetValue(__instance); if (tab == Dialog_InfoCard.InfoCardTab.Stats) { Texture2D texture = ContentFinder <Texture2D> .Get(extension.ImageToShowInInfoCard, false); Rect position = rect.AtZero(); position.width = 384f; position.height = 576f; position.x = rect.width * 0.75f - position.width / 2f + 18f; position.y = rect.center.y - position.height / 2f + 120; GUI.DrawTexture(position, texture, ScaleMode.ScaleToFit, true); } } } result = true; } return(result); }
public static bool Prefix(Rect cardRect, Dialog_InfoCard __instance, Thing ___thing, Dialog_InfoCard.InfoCardTab ___tab) { Thing thing = ___thing as Thing; rect = cardRect; bool result; if (thing == null) { result = true; } else { if (thing.def.GetModExtension <AnimalStatExtension>() != null) { extension = thing.def.GetModExtension <AnimalStatExtension>(); if (extension.showImageInInfoCard) { if (___tab == Dialog_InfoCard.InfoCardTab.Stats) { Texture2D texture = ContentFinder <Texture2D> .Get(extension.ImageToShowInInfoCard, false); Rect position = rect.AtZero(); position.width = 384f; position.height = 576f; position.x = rect.width * 0.75f - position.width / 2f + 18f; position.y = rect.center.y - position.height / 2f + 120; GUI.DrawTexture(position, texture, ScaleMode.ScaleToFit, true); } } } result = true; } return(result); }