public static void CanWearTogether_Postfix(ThingDef A, ThingDef B, BodyDef body, ref bool __result) { if (A.apparel.bodyPartGroups.NullOrEmpty() || A.defName.Contains("OG") && A.defName.Contains("_Wargear_")) { bool flag1 = (!A.apparel.tags.Contains("OGEnergyShield") || !B.apparel.tags.Contains("OGEnergyShield")); __result = A != B && flag1; } ApparelRestrictionDefExtension extA = A.GetModExtensionFast <ApparelRestrictionDefExtension>(); ApparelRestrictionDefExtension extB = A.GetModExtensionFast <ApparelRestrictionDefExtension>(); bool restricted = extA != null || extB != null; if (restricted) { if (extA != null) { } if (extB != null) { } } }
public static void Post_(Pawn p, ThingDef apparel, ref bool __result) { if (apparel.HasModExtension <ApparelRestrictionDefExtension>()) { __result = false; ApparelRestrictionDefExtension defExtension = apparel.GetModExtension <ApparelRestrictionDefExtension>(); if (defExtension != null) { if (!defExtension.RaceDefs.NullOrEmpty()) { __result = defExtension.RaceDefs.Contains(p.def); } if (!defExtension.HediffDefs.NullOrEmpty()) { __result = p.health.hediffSet.hediffs.Any(x => defExtension.HediffDefs.Contains(x.def)); } if (!defExtension.TraitDefs.NullOrEmpty()) { __result = p.story.traits.allTraits.Any(x => defExtension.TraitDefs.Contains(x.def)); } } } }
public static void Postfix(Thing thing, Pawn pawn, ref string cantReason, ref bool __result) { if (__result) { if (thing.def.IsApparel) { if (thing.def.HasModExtension <ApparelRestrictionDefExtension>()) { ApparelRestrictionDefExtension defExtension = thing.def.GetModExtension <ApparelRestrictionDefExtension>(); if (defExtension != null) { bool gender = defExtension.gender == Gender.None || pawn.gender == defExtension.gender; bool race = defExtension.RaceDefs.NullOrEmpty(); bool apparel = defExtension.ApparelDefs.NullOrEmpty(); bool hediff = defExtension.HediffDefs.NullOrEmpty(); bool trait = defExtension.TraitDefs.NullOrEmpty(); if (!defExtension.RaceDefs.NullOrEmpty()) { race = defExtension.RaceDefs.Contains(pawn.def); if (race && defExtension.Any) { __result = true; return; } cantReason = "Wrong Race"; } if (!defExtension.ApparelDefs.NullOrEmpty()) { if (pawn.apparel?.WornApparelCount > 0) { foreach (var item in defExtension.ApparelDefs) { apparel = pawn.apparel.WornApparel.Any(x => x.def == item); if (apparel) { break; } } if (apparel && defExtension.Any) { __result = true; return; } } cantReason = "Missing required Apparel"; } if (!defExtension.HediffDefs.NullOrEmpty()) { hediff = pawn.health.hediffSet.hediffs.Any(x => defExtension.HediffDefs.Contains(x.def)); if (hediff && defExtension.Any) { __result = true; return; } cantReason = "Missing required Implant"; } if (!defExtension.TraitDefs.NullOrEmpty()) { trait = pawn.story.traits.allTraits.Any(x => defExtension.TraitDefs.Contains(x.def)); if (trait && defExtension.Any) { __result = true; return; } cantReason = "Missing required Train"; } __result = gender && (race && hediff && trait && apparel); if (!__result) { cantReason = $"{pawn.NameShortColored} " + cantReason; return; } } } } } }