예제 #1
0
 public override bool ActivateOn(Lord lord, TriggerSignal signal)
 {
     if (signal.type == TriggerSignalType.Tick)
     {
         for (int i = 0; i < lord.ownedPawns.Count; i++)
         {
             if (GenAI.EnemyIsNear(lord.ownedPawns[i], 10f))
             {
                 return(false);
             }
             Need_Rest rest = lord.ownedPawns[i].needs.rest;
             if (rest != null)
             {
                 if (rest.CurLevelPercentage < 0.14f + this.extraRestThreshOffset && !lord.ownedPawns[i].Awake())
                 {
                     return(true);
                 }
             }
             Need_Food food = lord.ownedPawns[i].needs.food;
             if (food != null)
             {
                 if (food.CurCategory == HungerCategory.Starving)
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
     return(false);
 }
        protected override Job TryGiveJob(Pawn pawn)
        {
            Predicate <Thing> validator = delegate(Thing t)
            {
                Pawn pawn3 = (Pawn)t;
                return((pawn3.Downed && pawn3.Faction == pawn.Faction &&
                        !pawn3.InBed() && pawn.CanReserve(pawn3) && !pawn3.IsForbidden(pawn) &&
                        !GenAI.EnemyIsNear(pawn3, 25f)) ? true : false);
            };
            Pawn pawn2 = (Pawn)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(pawn),
                                                                radius, validator);

            if (pawn2 == null)
            {
                return(null);
            }
            Building_Bed building_Bed = RestUtility.FindBedFor(pawn2, pawn, pawn2.HostFaction == pawn.Faction, checkSocialProperness: false);

            if (building_Bed == null || !pawn2.CanReserve(building_Bed))
            {
                return(null);
            }
            Job job = JobMaker.MakeJob(JobDefOf.Rescue, pawn2, building_Bed);

            job.count = 1;
            return(job);
        }
예제 #3
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 != null && pawn2.Downed && pawn2.Faction == pawn.Faction && !pawn2.InBed())
            {
                LocalTargetInfo target = pawn2;
                if (pawn.CanReserve(target, 1, -1, null, forced) && !GenAI.EnemyIsNear(pawn2, 40f))
                {
                    Thing thing = base.FindBed(pawn, pawn2);
                    return(thing != null && pawn2.CanReserve(thing, 1, -1, null, false));
                }
            }
            return(false);
        }
예제 #4
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_EntertainingHD"), false) && comp.nextEntertainTick < Find.TickManager.TicksGame)
            {
                if (pawn2 != null && pawn2 != pawn && pawn2.RaceProps.Humanlike && pawn2.IsColonist && pawn2.Awake() && !pawn2.Drafted && !pawn.Drafted && !pawn2.Downed && pawn2.CanCasuallyInteractNow())
                {
                    if ((pawn.Position - pawn2.Position).LengthHorizontal < 50f && !GenAI.EnemyIsNear(pawn2, 40f))
                    {
                        IEnumerable <Pawn> breakingPawnsExtreme = BreakRiskAlertUtility.PawnsAtRiskExtreme;
                        foreach (Pawn current in breakingPawnsExtreme)
                        {
                            if (current == pawn2)
                            {
                                bool                  flag          = true;
                                LocalTargetInfo       target        = pawn2;
                                List <Thought_Memory> pawn2Memories = pawn.needs.mood.thoughts.memories.Memories;
                                for (int i = 0; i < pawn2Memories.Count; i++)
                                {
                                    if (pawn2Memories[i].def.defName == "TM_EntertainedTD" && pawn2Memories[i].MoodOffset() > 11f)
                                    {
                                        flag = false;
                                    }
                                }
                                if (flag && pawn.CanReserve(target, 1, -1, null, forced))
                                {
                                    return(true);
                                }
                                return(false);
                            }
                        }
                        IEnumerable <Pawn> breakingPawnsMajor = BreakRiskAlertUtility.PawnsAtRiskMajor;
                        foreach (Pawn current in breakingPawnsMajor)
                        {
                            if (current == pawn2)
                            {
                                bool flag = true;
                                List <Thought_Memory> pawn2Memories = pawn.needs.mood.thoughts.memories.Memories;
                                for (int i = 0; i < pawn2Memories.Count; i++)
                                {
                                    if (pawn2Memories[i].def.defName == "TM_EntertainedTD")
                                    {
                                        flag = false;
                                    }
                                }
                                if (flag)
                                {
                                    return(true);
                                }
                                return(false);
                            }
                        }
                        IEnumerable <Pawn> breakingPawnsMinor = BreakRiskAlertUtility.PawnsAtRiskMinor;
                        foreach (Pawn current in breakingPawnsMinor)
                        {
                            if (current == pawn2)
                            {
                                bool flag = true;
                                List <Thought_Memory> pawn2Memories = pawn.needs.mood.thoughts.memories.Memories;
                                for (int i = 0; i < pawn2Memories.Count; i++)
                                {
                                    if (pawn2Memories[i].def.defName == "TM_EntertainedTD")
                                    {
                                        flag = false;
                                    }
                                }
                                if (flag)
                                {
                                    return(true);
                                }
                                return(false);
                            }
                        }
                    }
                }
            }
            return(false);
        }
예제 #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;
        }
예제 #6
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);
        }
예제 #7
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;
            CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>();

            if (pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_CommanderAuraHD, false))
            {
                HediffComp_CommanderAura hdComp = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_CommanderAuraHD).TryGetComp <HediffComp_CommanderAura>();
                if (hdComp != null && hdComp.nextSpeechTick < Find.TickManager.TicksGame)
                {
                    if (pawn2 != null && pawn2 != pawn && pawn2.RaceProps.Humanlike && pawn2.IsColonist && pawn2.Awake() && !pawn2.Drafted && !pawn.Drafted && !pawn2.Downed)
                    {
                        if (pawn2.InMentalState && (pawn.Position - pawn2.Position).LengthHorizontal < 50f && !GenAI.EnemyIsNear(pawn2, 20f))
                        {
                            hdComp.nextSpeechTick = Find.TickManager.TicksGame + 100;
                            LocalTargetInfo target = pawn2;
                            if (pawn.CanReserveAndReach(target, PathEndMode.Touch, Danger.Deadly, 1, -1, null, true))
                            {
                                hdComp.nextSpeechTick = Find.TickManager.TicksGame + (Rand.Range(12000, 15000) - (1200 * hdComp.pwrVal));
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
예제 #8
0
        public override void CompTick()
        {
            base.CompTick();
            if (IsMounted)
            {
                if (!Driver.Spawned)
                {
                    parent.DeSpawn();
                    return;
                }

                if (Driver.Dead || Driver.Downed || Driver.health.InPainShock ||
                    Driver.MentalStateDef == MentalStateDefOf.WanderPsychotic ||
                    (parent.IsForbidden(Faction.OfPlayer) && Driver.Faction == Faction.OfPlayer))
                {
                    if (!Driver.Position.InBounds())
                    {
                        DismountAt(Driver.Position);
                        return;
                    }

                    DismountAt(Driver.Position - parent.def.interactionCellOffset.RotatedBy(Driver.Rotation));
                    Driver.Position = Driver.Position.RandomAdjacentCell8Way();
                    return;
                }


                if (Find.TickManager.TicksGame - tickCheck >= tickCooldown)
                {
                    if (Driver.Faction == Faction.OfPlayer && Driver.CurJob != null)
                    {
                        if (Driver.CurJob.def.playerInterruptible && (
                                Driver.CurJob.def == JobDefOf.GotoWander ||
                                Driver.CurJob.def == JobDefOf.Open ||
                                Driver.CurJob.def == JobDefOf.ManTurret ||
                                Driver.CurJob.def == JobDefOf.EnterCryptosleepCasket ||
                                Driver.CurJob.def == JobDefOf.UseNeurotrainer ||
                                Driver.CurJob.def == JobDefOf.UseArtifact ||
                                Driver.CurJob.def == JobDefOf.DoBill ||
                                Driver.CurJob.def == JobDefOf.Research ||
                                Driver.CurJob.def == JobDefOf.OperateDeepDrill ||
                                Driver.CurJob.def == JobDefOf.Repair ||
                                Driver.CurJob.def == JobDefOf.FixBrokenDownBuilding ||
                                Driver.CurJob.def == JobDefOf.UseCommsConsole ||
                                Driver.CurJob.def == JobDefOf.BuryCorpse ||
                                Driver.CurJob.def == JobDefOf.TradeWithPawn ||
                                Driver.CurJob.def == JobDefOf.Lovin ||
                                Driver.CurJob.def == JobDefOf.SocialFight ||
                                Driver.CurJob.def == JobDefOf.Maintain ||
                                Driver.CurJob.def == JobDefOf.MarryAdjacentPawn ||
                                Driver.CurJob.def == JobDefOf.SpectateCeremony ||
                                Driver.CurJob.def == JobDefOf.StandAndBeSociallyActive ||
                                Driver.CurJob.def == JobDefOf.LayDown ||
                                Driver.CurJob.def == JobDefOf.Ingest ||
                                Driver.CurJob.def == JobDefOf.SocialRelax ||
                                Driver.CurJob.def == JobDefOf.Refuel ||
                                Driver.CurJob.def == JobDefOf.FillFermentingBarrel ||
                                Driver.CurJob.def == JobDefOf.TakeBeerOutOfFermentingBarrel ||
                                Driver.CurJob.def == JobDefOf.TakeWoundedPrisonerToBed ||
                                Driver.CurJob.def == JobDefOf.TakeToBedToOperate ||
                                Driver.CurJob.def == JobDefOf.EscortPrisonerToBed ||
                                Driver.CurJob.def == JobDefOf.CarryToCryptosleepCasket ||
                                Driver.CurJob.def == JobDefOf.ReleasePrisoner ||
                                Driver.CurJob.def == JobDefOf.PrisonerAttemptRecruit ||
                                Driver.CurJob.def == JobDefOf.PrisonerFriendlyChat ||
                                Driver.CurJob.def == JobDefOf.PrisonerExecution ||
                                Driver.CurJob.def == JobDefOf.FeedPatient ||
                                Driver.CurJob.def == JobDefOf.TendPatient ||
                                Driver.CurJob.def == JobDefOf.VisitSickPawn ||
                                Driver.CurJob.def == JobDefOf.Slaughter ||
                                Driver.CurJob.def == JobDefOf.Milk ||
                                Driver.CurJob.def == JobDefOf.Shear ||
                                Driver.CurJob.def == JobDefOf.Train ||
                                Driver.CurJob.def == JobDefOf.Mate ||
                                Driver.health.NeedsMedicalRest ||
                                Driver.health.PrefersMedicalRest
                                ) && Driver.Position.Roofed())
                        {
                            parent.Position = Position.ToIntVec3();
                            parent.Rotation = Driver.Rotation;
                            if (!Driver.Position.InBounds())
                            {
                                DismountAt(Driver.Position);
                                return;
                            }
                            DismountAt(Driver.Position - InteractionOffset.ToIntVec3());
                            Driver.Position = Driver.Position.RandomAdjacentCell8Way();
                            return;
                        }
                    }
                    tickCheck    = Find.TickManager.TicksGame;
                    tickCooldown = Rand.RangeInclusive(60, 180);

                    CompVehicle vehicleComp = parent.TryGetComp <CompVehicle>();

                    if (!vehicleComp.MotorizedWithoutFuel())
                    {
                        CompRefuelable refuelableComp = parent.TryGetComp <CompRefuelable>();
                        Job            jobNew         = ToolsForHaulUtility.DismountInBase(Driver, MapComponent_ToolsForHaul.currentVehicle[Driver]);

                        if (Driver.Faction == Faction.OfPlayer)
                        {
                            if (!GenAI.EnemyIsNear(Driver, 40f))
                            {
                                if (parent.HitPoints / parent.MaxHitPoints < 0.65f ||
                                    (Driver.CurJob != null && Driver.jobs.curDriver.asleep) ||
                                    vehicleComp.tankLeaking ||
                                    !refuelableComp.HasFuel)
                                {
                                    Driver.jobs.StartJob(jobNew, JobCondition.InterruptForced);
                                }
                            }
                        }

                        else if (!refuelableComp.HasFuel)
                        {
                            Dismount();
                            FireUtility.TryStartFireIn(Position.ToIntVec3(), 0.1f);
                        }
                    }
                }
                if (Find.TickManager.TicksGame - tickLastDoorCheck >= 96 &&
                    (Driver.Position.GetEdifice() is Building_Door || parent.Position.GetEdifice() is Building_Door))
                {
                    lastPassedDoor =
                        (Driver.Position.GetEdifice() is Building_Door
                            ? Driver.Position.GetEdifice()
                            : parent.Position.GetEdifice()) as Building_Door;
                    lastPassedDoor.StartManualOpenBy(Driver);
                    tickLastDoorCheck = Find.TickManager.TicksGame;
                }
                else if (Find.TickManager.TicksGame - tickLastDoorCheck >= 96 && lastPassedDoor != null)
                {
                    lastPassedDoor.StartManualCloseBy(Driver);
                    lastPassedDoor = null;
                }
                if (Driver.pather.Moving && Driver.Position != (Driver.pather.Destination.Cell))
                {
                    lastDrawAsAngle = Driver.Rotation.AsAngle;
                    parent.Position = (Position.ToIntVec3());
                    parent.Rotation = (Driver.Rotation);
                }
            }
        }
            internal bool <> m__0(Thing t)
            {
                Pawn pawn = (Pawn)t;

                return(pawn.Downed && pawn.Faction == this.pawn.Faction && !pawn.InBed() && this.pawn.CanReserve(pawn, 1, -1, null, false) && !pawn.IsForbidden(this.pawn) && !GenAI.EnemyIsNear(pawn, 25f));
            }
        protected override Job TryGiveJob(Pawn pawn)
        {
            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), this.radius, validator, null, 0, -1, false, RegionType.Set_Passable, false);
            Job  result;

            if (pawn2 == null)
            {
                result = null;
            }
            else
            {
                Building_Bed building_Bed = RestUtility.FindBedFor(pawn2, pawn, pawn2.HostFaction == pawn.Faction, false, false);
                if (building_Bed == null || !pawn2.CanReserve(building_Bed, 1, -1, null, false))
                {
                    result = null;
                }
                else
                {
                    result = new Job(JobDefOf.Rescue, pawn2, building_Bed)
                    {
                        count = 1
                    };
                }
            }
            return(result);
        }
예제 #11
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 != null && pawn2.Downed && pawn2.Faction == pawn.Faction && !pawn2.InBed())
            {
                LocalTargetInfo target = pawn2;
                bool            ignoreOtherReservations = forced;
                if (pawn.CanReserve(target, 1, -1, null, ignoreOtherReservations) && !GenAI.EnemyIsNear(pawn2, 40f))
                {
                    Thing thing = FindBed(pawn, pawn2);
                    if (thing != null && pawn2.CanReserve(thing))
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            return(false);
        }
예제 #12
0
        static void Postfix(WorkGiver_RescueDowned __instance, ref Pawn pawn, ref Thing t, ref bool forced, ref bool __result)
        {
            // mostly the original method, repeated, with three commented changes

            if (__result == true)
            {
                return;                   //new guard clause
            }
            Pawn pawn2 = t as Pawn;

            //if (pawn2 != null && pawn2.Downed && pawn2.Faction == pawn.Faction && !pawn2.InBed())
            if (pawn2 != null && pawn2.Downed && pawn.Map.designationManager.DesignationOn(pawn2, DesignationDefOf.Tame) != null && !pawn2.InBed())
            {
                LocalTargetInfo target = pawn2;
                bool            ignoreOtherReservations = forced;
                if (pawn.CanReserve(target, 1, -1, null, ignoreOtherReservations) && !GenAI.EnemyIsNear(pawn2, 40f))
                {
                    //Thing thing = FindBed(pawn, pawn2);
                    Thing thing = RestUtility.FindBedFor(pawn2, pawn, pawn2.HostFaction == pawn.Faction, checkSocialProperness: false);
                    if (thing != null && pawn2.CanReserve(thing))
                    {
                        __result = true;
                        return;
                    }
                    __result = false;
                    return;
                }
            }
            __result = false;
            return;
        }
예제 #13
0
        // Token: 0x06000524 RID: 1316 RVA: 0x0003381C File Offset: 0x00031C1C
        protected override Job TryGiveJob(Pawn pawn)
        {
            Predicate <Thing> validator = delegate(Thing t)
            {
                Pawn  pawn3   = (Pawn)t;
                float eggDist = 9999f;
                Thing egg     = XenomorphUtil.ClosestReachableEgg(pawn3);
                if (egg != null)
                {
                    eggDist = XenomorphUtil.DistanceBetween(pawn3.Position, egg.Position);
                }
                else
                {
                    return(false);
                }
                if (eggDist == 9999f || eggDist <= 5)
                {
                    return(false);
                }
                return(pawn3.Downed && pawn3.Faction != pawn.Faction && XenomorphUtil.isInfectablePawn(pawn3) && 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), this.radius, validator, null, 0, -1, false, RegionType.Set_Passable, false);

            if (pawn2 == null)
            {
                return(null);
            }
            Thing thing = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(XenomorphDefOf.RRY_EggXenomorphFertilized), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 9999f, null, null, 0, -1, false, RegionType.Set_Passable, false);

            if (thing == null)
            {
                return(null);

                thing = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(XenomorphDefOf.RRY_EggXenomorphFertilized), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 9999f, null, null, 0, -1, false, RegionType.Set_Passable, false);
                if (thing == null)
                {
                    return(null);
                }
            }
            return(new Job(XenomorphDefOf.RRY_Job_XenomorphKidnap, pawn2, thing)
            {
                count = 1
            });
        }
예제 #14
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 == null || !pawn2.Downed || pawn2.Faction != pawn.Faction || pawn2.InBed() || !pawn.CanReserve(pawn2, 1, -1, null, forced) || GenAI.EnemyIsNear(pawn2, 40f))
            {
                return(false);
            }
            Thing thing = FindBed(pawn, pawn2);

            if (thing != null && pawn2.CanReserve(thing))
            {
                return(true);
            }
            return(false);
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 == null || !pawn2.Downed || pawn2.Faction != pawn.Faction || pawn2.InBed() || !pawn.CanReserve(pawn2, 1, -1, null, forced) || GenAI.EnemyIsNear(pawn2, 5f) || pawn2.Map.IsPlayerHome)
            {
                return(false);
            }
            Thing thing = this.FindShip(pawn);

            return(thing != null && pawn2.CanReserve(thing, 1, -1, null, false));
        }