Exemplo n.º 1
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.Drafted)
            {
                return(null);
            }
            if (pawn.needs.rest.CurLevel > (minEnergyRechargePercentage / 100f))
            {
                return(null);
            }
            var emptyChargeStation = PeacekeeperUtility.GetEmptyChargeStation(pawn);

            if (emptyChargeStation == null || emptyChargeStation.IsForbidden(pawn))
            {
                if (pawn.needs.rest.CurLevel < (minEnergyPowercellPercentage / 100f))
                {
                    var fuel = PeacekeeperUtility.FindBestFuel(pawn);
                    if (fuel != null)
                    {
                        return(JobMaker.MakeJob(RSDefOf.RSFuelRobot, pawn, fuel));
                    }
                }
                return(JobMaker.MakeJob(JobDefOf.Wait, 120, true));
            }
            return(JobMaker.MakeJob(RSDefOf.RSRecharge, emptyChargeStation));
        }
Exemplo n.º 2
0
 public static void JobGiver_Bedtime_TryGiveJob_Postfix(ref Job __result, Pawn pawn)
 {
     if (__result == null || !PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     __result = null;
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 public static void guardNeedBladder_Postfix(ref bool __result, Pawn pawn)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     __result = false;
 }
Exemplo n.º 5
0
 public static void ShipInteriorMod2_hasSpaceSuit_Postfix(ref bool __result, Pawn pawn)
 {
     if (__result == true || !PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     __result = true;
 }
Exemplo n.º 6
0
 public static bool Need_Treatment_NeedInterval_Prefix(Pawn ___pawn)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(___pawn))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 7
0
 public static void Postfix(Pawn pawn, Caravan ___caravan)
 {
     if (pawn.Dead || !PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return;
     }
     PeacekeeperUtility.RefuelPawnOnCaravan(pawn, ___caravan);
 }
Exemplo n.º 8
0
 static CustomPatches()
 {
     PeacekeeperUtility.RunSavely(PatchRobotNoFoodAndRecipes);
     PeacekeeperUtility.RunSavely(PatchStorytellers);
     PeacekeeperUtility.RunSavely(PatchRemoveRottingFromCorpses);
     PeacekeeperUtility.RunSavely(PatchFuelConsumption);
     PeacekeeperUtility.RunSavely(PatchRobotClothing);
 }
Exemplo n.º 9
0
 public static bool Prefix(Pawn ___pawn)
 {
     if (PeacekeeperUtility.IsPeacekeeper(___pawn))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 10
0
 public static bool Prefix(ref bool __result, Pawn p)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(p))
     {
         return(true);
     }
     __result = false;
     return(false);
 }
Exemplo n.º 11
0
 public static bool JobGiver_Labor_TryIssueJobPackage_Prefix(ref ThinkResult __result, Pawn pawn)
 {
     if (!PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         return(true);
     }
     __result = ThinkResult.NoJob;
     return(false);
 }
Exemplo n.º 12
0
 public static void Postfix(ref Job __result, Pawn pawn)
 {
     if (__result == null)
     {
         return;
     }
     if (PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         __result = null;
     }
 }
Exemplo n.º 13
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;
     }
 }
Exemplo n.º 14
0
 public static void Postfix(ref bool __result, Pawn pawn, InteractionDef interactionDef = null)
 {
     if (!__result)
     {
         return;
     }
     if (PeacekeeperUtility.IsPeacekeeper(pawn))
     {
         __result = false;
     }
 }
Exemplo n.º 15
0
        public override void CompTick()
        {
            var robot      = PeacekeeperUtility.GeneratePeacekeeper(Props.pawnKind, this.parent.Tile);
            var spawnedBot = GenSpawn.Spawn(robot, this.parent.Position, this.parent.Map, Rot4.South) as Pawn;
            var gun        = ThingMaker.MakeThing(Props.weaponDef) as ThingWithComps;

            spawnedBot.equipment.MakeRoomFor(gun);
            spawnedBot.equipment.AddEquipment(gun);
            //AddCape(spawnedBot);
            this.parent.Destroy();
        }
Exemplo n.º 16
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;
     }
 }
Exemplo n.º 17
0
 public static void Postfix(ref bool __result, Pawn p)
 {
     if (!__result)
     {
         return;
     }
     if (PeacekeeperUtility.IsPeacekeeper(p))
     {
         __result = false;
     }
 }
Exemplo n.º 18
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);
        }
        public static Pawn GeneratePeacekeeper(PawnKindDef pawnKind, int tile)
        {
            var robot = PawnGenerator.GeneratePawn(new PawnGenerationRequest()
            {
                KindDef                  = pawnKind,
                Faction                  = Faction.OfPlayer,
                Context                  = PawnGenerationContext.NonPlayer,
                Tile                     = tile,
                FixedBiologicalAge       = 0,
                FixedGender              = Gender.Male,
                AllowAddictions          = false,
                FixedMelanin             = 0,
                CanGeneratePawnRelations = false,
                FixedIdeo                = null,
                ForceNoIdeo              = true
            });

            robot.Name = new NameSingle(robot.Name.ToStringShort + " #" + ModSettings.peacekeeperNumber++);
            var hediff = HediffMaker.MakeHediff(RSDefOf.RSRobotConsciousness, robot);

            if (robot != null && !robot.health.hediffSet.HasHediff(RSDefOf.RSRobotConsciousness))
            {
                robot.health.AddHediff(hediff, robot.health.hediffSet.GetBrain(), null, null);
            }

            var robotModExt   = robot.def.GetModExtension <RSPeacekeeperModExt>();
            var batteryHediff = HediffMaker.MakeHediff(RSDefOf.RSPeacekeeperBattery, robot);

            robot.health.AddHediff(batteryHediff, PeacekeeperUtility.GetTorso(robot), null, null);
            batteryHediff.Severity = robotModExt.batterySeverity;
            var allowedTraits = (robot.def as ThingDef_AlienRace)?.alienRace?.generalSettings?.forcedRaceTraitEntries?.Select(entry => entry.defName)?.ToList();

            if (allowedTraits != null && allowedTraits.Count != 0)
            {
                foreach (var trait in robot.story.traits.allTraits.Reverse <Trait>())
                {
                    robot.story.traits.allTraits.Remove(trait);
                }
                foreach (var trait in allowedTraits)
                {
                    robot.story.traits.GainTrait(new Trait(trait));
                }
            }

            robot.playerSettings.hostilityResponse = HostilityResponseMode.Attack;

            robot.skills.skills.FirstOrDefault(x => x.def == SkillDefOf.Shooting).Level = robotModExt.shootingSkill;
            robot.skills.skills.FirstOrDefault(x => x.def == SkillDefOf.Melee).Level    = robotModExt.meleeSkill;

            robot.guest.joinStatus = JoinStatus.JoinAsColonist;

            return(robot);
        }
Exemplo n.º 20
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;
        }
Exemplo n.º 21
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();
     }
 }
Exemplo n.º 22
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;
     }
 }
        private void CheckTerrain()
        {
            var selTrait = this.parent.pawn.story.traits.allTraits.FirstOrDefault(trait => trait.def == RSDefOf.RSTraitWinter || trait.def == RSDefOf.RSTraitDesert || trait.def == RSDefOf.RSTraitForest);

            if (selTrait == null)
            {
                return;
            }
            var apply      = false;
            var selTerrain = selTrait.def == RSDefOf.RSTraitWinter ? allowedTerrain : allowedTerrainSand;
            var selBiomes  = selTrait.def == RSDefOf.RSTraitWinter ? allowedBiomes : allowedBiomesSand;

            if (selTrait.def == RSDefOf.RSTraitForest)
            {
                if (this.parent.pawn.Map == null && allowedBiomesForest.Contains(Find.WorldGrid.tiles[this.parent.pawn.Tile].biome) ||
                    (this.parent.pawn.Map != null && allowedBiomesForest.Contains(Find.WorldGrid.tiles[this.parent.pawn.Tile].biome) &&
                     (allowedTerrainForest.Contains(this.parent.pawn.Position.GetTerrain(this.parent.pawn.Map)))))
                {
                    apply = true;
                }
            }
            else if (this.parent.pawn.Map == null && selBiomes.Contains(Find.WorldGrid.tiles[this.parent.pawn.Tile].biome) ||
                     (this.parent.pawn.Map != null && (selTerrain.Contains(this.parent.pawn.Position.GetTerrain(this.parent.pawn.Map)) ||
                                                       (selTrait.def == RSDefOf.RSTraitWinter && parent.pawn.Map.snowGrid.TotalDepth > 100f))))
            {
                apply = true;
            }

            if (apply)
            {
                if (!this.parent.pawn.health.hediffSet.HasHediff(RSDefOf.RSTerrainAdvantage))
                {
                    foreach (var leg in PeacekeeperUtility.GetLegs(parent.pawn))
                    {
                        var hediff = HediffMaker.MakeHediff(RSDefOf.RSTerrainAdvantage, parent.pawn);
                        this.parent.pawn.health.AddHediff(hediff, leg);
                    }
                }
            }
            else
            {
                if (this.parent.pawn.health.hediffSet.HasHediff(RSDefOf.RSTerrainAdvantage))
                {
                    this.parent.pawn.health.hediffSet.hediffs.RemoveAll(hediff => hediff.def == RSDefOf.RSTerrainAdvantage);
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 28
0
 public static void ColonistBar_CheckRecacheEntries_Postfix(List <ColonistBar.Entry> ___cachedEntries)
 {
     ___cachedEntries.RemoveAll(entry => PeacekeeperUtility.IsPeacekeeper(entry.pawn));
 }
Exemplo n.º 29
0
 public static void Postfix(Pawn __instance, Pawn butcher, float efficiency)
 {
     ModSettings.butcheredPeacekeeper = PeacekeeperUtility.IsPeacekeeper(__instance);
 }
Exemplo n.º 30
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;
            }
        }