Example #1
0
        public static void Postfix(ref IEnumerable <Pawn> __result, IIncidentTarget target)
        {
            var newList = __result.ToList();

            newList.RemoveAll(pawn => PeacekeeperUtility.IsPeacekeeper(pawn));
            __result = newList;
        }
Example #2
0
 public static void Postfix(ref Thought_Memory __result, Corpse __instance)
 {
     if (__result != null && PeacekeeperUtility.IsPeacekeeper(__instance.InnerPawn))
     {
         __result = null;
     }
 }
Example #3
0
        public static bool Prefix(Need_Rest __instance, Pawn ___pawn, ref int ___ticksAtZero)
        {
            if (!PeacekeeperUtility.IsPeacekeeper(___pawn))
            {
                return(true);
            }

            // todo add class to hediff that removes the hediff when energy is available
            var isFrozen  = (bool)Traverse.Create(__instance).Property("IsFrozen").GetValue <bool>();
            var malnutInt = MalnutritionSeverityPerInterval(___pawn);

            if (!isFrozen)
            {
                __instance.CurLevel -= __instance.RestFallPerTick * 150f;
            }
            if (__instance.CurLevel < 0.0001f)
            {
                ___ticksAtZero += 150;
            }
            else
            {
                ___ticksAtZero = 0;
            }
            if (___ticksAtZero > 1000)
            {
                HealthUtility.AdjustSeverity(___pawn, RSDefOf.RSEnergyShortage, malnutInt * ModSettings.energyShortageSeverityMult);
            }
            else
            {
                HealthUtility.AdjustSeverity(___pawn, RSDefOf.RSEnergyShortage, -malnutInt);
            }

            return(false);
        }
Example #4
0
 public static void Postfix(ref string __result, Need __instance, Pawn ___pawn)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(___pawn))
     {
         return;
     }
     if (__instance.def.defName == "Rest")
     {
         __result = string.Concat(new string[]
         {
             __instance.LabelCap,
             ": ",
             __instance.CurLevelPercentage.ToStringPercent(),
             " (",
             __instance.CurLevel.ToString("0.##"),
             " / ",
             __instance.MaxLevel.ToString("0.##"),
             ")\n",
             "RSEnergyDesc".Translate()
         }
                                  );
     }
     else if ((new string[] { "Joy", "Comfort", "Beauty", "Outdoors", "Mood" }).Contains(__instance.def.defName))
     {
         __result = string.Empty;
     }
 }
Example #5
0
        public static void Postfix(ref Job __result, Pawn pawn, float ___radius)
        {
            if (__result != null)
            {
                return;
            }
            Predicate <Thing> validator = delegate(Thing t)
            {
                Pawn pawn3 = (Pawn)t;
                return(pawn3.Downed && pawn3.Faction == pawn.Faction && !pawn3.InBed() && pawn.CanReserve(pawn3, 1, -1, null, false) && !pawn3.IsForbidden(pawn) && !GenAI.EnemyIsNear(pawn3, 25f));
            };
            Pawn pawn2 = (Pawn)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), ___radius, validator, null, 0, -1, false, RegionType.Set_Passable, false);

            if (pawn2 == null)
            {
                return;
            }
            if (!PeacekeeperUtility.IsPeacekeeper(pawn2) || PeacekeeperUtility.IsInChargeStation(pawn2))
            {
                return;
            }

            var building_Bed = PeacekeeperUtility.GetEmptyChargeStation(pawn2);

            if (building_Bed == null || !pawn2.CanReserve(building_Bed, 1, -1, null, false) || building_Bed.IsForbidden(pawn))
            {
                return;
            }
            Job job = JobMaker.MakeJob(RSDefOf.RSRescueToChargeStation, pawn2, building_Bed);

            job.count = 1;
            __result  = job;
        }
Example #6
0
 public static bool Prefix(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtToAddToAll> outAllColonistsThoughts)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(victim))
     {
         return(true);
     }
     return(false);
 }
Example #7
0
 public static void Postfix(Pawn pawn, Caravan ___caravan)
 {
     if (pawn.Dead || !PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     PeacekeeperUtility.RefuelPawnOnCaravan(pawn, ___caravan);
 }
Example #8
0
 public static bool Prefix(Pawn ___pawn)
 {
     if (PeacekeeperUtility.IsPeacekeeper(___pawn))
     {
         return(false);
     }
     return(true);
 }
Example #9
0
 public static void JobGiver_Bedtime_TryGiveJob_Postfix(ref Job __result, Pawn pawn)
 {
     if (__result == null || !PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     __result = null;
 }
Example #10
0
 public static void guardNeedBladder_Postfix(ref bool __result, Pawn pawn)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     __result = false;
 }
Example #11
0
 public static void ShipInteriorMod2_hasSpaceSuit_Postfix(ref bool __result, Pawn pawn)
 {
     if (__result == true || !PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     __result = true;
 }
Example #12
0
 public static bool Need_Treatment_NeedInterval_Prefix(Pawn ___pawn)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(___pawn))
     {
         return(true);
     }
     return(false);
 }
Example #13
0
 public static bool Prefix(ref bool __result, Pawn p)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(p))
     {
         return(true);
     }
     __result = false;
     return(false);
 }
Example #14
0
 public static bool JobGiver_Labor_TryIssueJobPackage_Prefix(ref ThinkResult __result, Pawn pawn)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return(true);
     }
     __result = ThinkResult.NoJob;
     return(false);
 }
Example #15
0
 public static void Postfix(ref string __result, Need __instance, Pawn ___pawn)
 {
     if (__instance.def.defName == "Rest" && PeacekeeperUtility.IsPeacekeeper(___pawn))
     {
         __result = "RSEnergyLabel".Translate();
     }
     else if ((new string[] { "Joy", "Comfort", "Beauty", "Outdoors", "Mood" }).Contains(__instance.def.defName) && PeacekeeperUtility.IsPeacekeeper(___pawn))
     {
         __result = string.Empty;
     }
 }
Example #16
0
 public static void Postfix(ref Job __result, Pawn pawn)
 {
     if (__result == null)
     {
         return;
     }
     if (PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         __result = null;
     }
 }
Example #17
0
 public static void Postfix(ref bool __result, Pawn pawn, InteractionDef interactionDef = null)
 {
     if (!__result)
     {
         return;
     }
     if (PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         __result = false;
     }
 }
Example #18
0
 public static void Postfix(ref bool __result, Pawn p)
 {
     if (!__result)
     {
         return;
     }
     if (PeacekeeperUtility.IsPeacekeeper(p))
     {
         __result = false;
     }
 }
Example #19
0
 public static void Postfix(ref ThoughtState __result, Pawn p, Pawn otherPawn)
 {
     if (!ModSettings.removeIdeologyImpact || __result.StageIndex == ThoughtState.Inactive.StageIndex)
     {
         return;
     }
     if (PeacekeeperUtility.IsPeacekeeper(p) || PeacekeeperUtility.IsPeacekeeper(otherPawn))
     {
         __result = false;
     }
 }
Example #20
0
        //public static bool JobGiver_Labor__TryIssueJobPackage_Postfix(ref ThinkResult __result, Pawn pawn)
        //{
        //    if (!PeacekeeperUtility.IsPeacekeeper(pawn)) return true;
        //    __result = ThinkResult.NoJob;
        //    return false;
        //}

        public static bool WorkSettings_InitWorkSettings_Prefix(Pawn pawn)
        {
            if (!PeacekeeperUtility.IsPeacekeeper(pawn))
            {
                return(true);
            }
            if (pawn?.playerSettings?.AreaRestriction != null)
            {
                pawn.playerSettings.AreaRestriction = null;
            }
            return(false);
        }
Example #21
0
        public static void Postfix(ref bool __result, Pawn pawn, Thing t, bool forced = false)
        {
            if (!__result)
            {
                return;
            }
            Pawn pawn2 = t as Pawn;

            if (!PeacekeeperUtility.IsPeacekeeper(pawn2))
            {
                return;
            }
            __result = false;
        }
Example #22
0
 public static void Postfix(ref string __result, PawnCapacityDef __instance, Pawn pawn)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     if (__instance == PawnCapacityDefOf.BloodFiltration)
     {
         __result = "RSCoolantFiltration".Translate();
     }
     if (__instance == PawnCapacityDefOf.BloodPumping)
     {
         __result = "RSCoolantCirculation".Translate();
     }
 }
Example #23
0
 // todo - may need some revision
 public static void Postfix(ref bool __result, Thing bedThing, Pawn sleeper)
 {
     if (PeacekeeperUtility.IsPeacekeeper(sleeper) && bedThing.def == RSDefOf.RSChargeStation)
     {
         __result = true;
     }
     else if (PeacekeeperUtility.IsPeacekeeper(sleeper) && bedThing.def != RSDefOf.RSChargeStation)
     {
         __result = false;
     }
     else if (bedThing.def == RSDefOf.RSChargeStation)
     {
         __result = false;
     }
 }
Example #24
0
        public static void Postfix(ref bool __result, Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (!PeacekeeperUtility.IsPeacekeeper(pawn2))
            {
                return;
            }
            if (!pawn2.Downed || pawn2.Faction != Faction.OfPlayer || PeacekeeperUtility.IsInChargeStation(pawn2) || !pawn.CanReserve(pawn2) || GenAI.EnemyIsNear(pawn2, 40f))
            {
                __result = false;
                return;
            }
            var chargeStation = PeacekeeperUtility.GetEmptyChargeStation(pawn2);

            __result = chargeStation != null && pawn2.CanReserve(chargeStation, 1, -1, null, false);
        }
Example #25
0
        public static void Postfix(ref Job __result, Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (!PeacekeeperUtility.IsPeacekeeper(pawn2) || PeacekeeperUtility.IsInChargeStation(pawn2) || !pawn.CanReserve(t))
            {
                return;
            }

            Thing t2 = PeacekeeperUtility.GetEmptyChargeStation(pawn2);

            if (t2 == null)
            {
                return;
            }
            Job job = JobMaker.MakeJob(RSDefOf.RSRescueToChargeStation, pawn2, t2);

            job.count = 1;
            __result  = job;
        }
Example #26
0
        public static void Pawn_NeedsTracker_ShouldHaveNeed_Postfix(Pawn_NeedsTracker __instance, ref bool __result, Pawn ___pawn, NeedDef nd)
        {
            if (!__result)
            {
                return;
            }
            if (!PeacekeeperUtility.IsPeacekeeper(___pawn))
            {
                return;
            }

            var t             = PatchesCompatibility.hygieneAssembly.GetType("DubsBadHygiene.NeedsUtil");
            var checkInfo     = t.GetMethod("IsHygieneNeed", new[] { typeof(NeedDef) });
            var isHygieneNeed = (bool)checkInfo.Invoke(null, new object[] { nd });

            if (!isHygieneNeed)
            {
                return;
            }
            __result = false;
        }
Example #27
0
        public static void StorytellerUtilityPopulation_AdjustedPopulation_get_Postfix(ref float __result)
        {
            var robotCount = PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists?.Where(colonist => PeacekeeperUtility.IsPeacekeeper(colonist))?.Count();

            if (robotCount == null)
            {
                return;
            }
            __result -= (int)robotCount;
        }
Example #28
0
 public static void ColonistBar_CheckRecacheEntries_Postfix(List <ColonistBar.Entry> ___cachedEntries)
 {
     ___cachedEntries.RemoveAll(entry => PeacekeeperUtility.IsPeacekeeper(entry.pawn));
 }
Example #29
0
        public static void Postfix(ref bool __result, Caravan __instance)
        {
            if (!__result)
            {
                return;
            }
            var peaceKeeperCount = __instance.pawns.InnerListForReading.Where(pawn => PeacekeeperUtility.IsPeacekeeper(pawn)).Count();

            if (peaceKeeperCount == __instance.pawns.Count)
            {
                __result = false;
            }
        }
Example #30
0
 public static void Postfix(Pawn __instance, Pawn butcher, float efficiency)
 {
     ModSettings.butcheredPeacekeeper = PeacekeeperUtility.IsPeacekeeper(__instance);
 }