Beispiel #1
0
        static void Postfix(ref Pawn_JobTracker __instance, ref ThinkResult __result)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (!pawn.RaceProps.IsMechanoid)
            {
                return;
            }

            ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage();

            if (store != null)
            {
                //de-activate if should auto recharge and power is very low.
                ExtendedPawnData pawnData = store.GetExtendedDataFor(pawn);
                if (pawn.ShouldRecharge() &&
                    pawn.IsActivated()
                    )
                {
                    pawn.drafter.Drafted = false;
                    pawnData.isActive    = false;
                }
            }
            if (pawn.Downed)
            {
                return;
            }
            if (pawn.IsHacked() && pawn.IsActivated() && pawn.health.hediffSet.HasHediff(WTH_DefOf.WTH_TargetingHackedPoorly))
            {
                HackedPoorlyEvent(pawn);
            }
        }
Beispiel #2
0
        public static void Postfix(Job newJob, Pawn ___pawn, Pawn_JobTracker __instance)
        {
            if (newJob.def == JobDefOf.HaulToCell)
            {
                if (newJob.targetA.HasThing)
                {
                    Thing     thing     = newJob.targetA.Thing;
                    SlotGroup slotGroup = ___pawn.Map.haulDestinationManager.SlotGroupAt(newJob.targetB.Cell);

                    int stackCount = newJob.targetA.Thing.stackCount;
                    if (stackCount < 1)
                    {
                        stackCount = int.MaxValue;
                    }
                    int amountCarrying = Math.Min(newJob.count, stackCount);
                    amountCarrying = Math.Min(amountCarrying, ___pawn.carryTracker.AvailableStackSpace(newJob.targetA.Thing.def));

                    //int amountCarrying = newJob.count < 0 ? newJob.targetA.Thing.stackCount : newJob.count;
#if DEBUG
                    Log.Message($"{___pawn} is hauling {newJob.targetA}, count = {amountCarrying}");
#endif

                    PendingHaulJobsTracker.AddNewJob(___pawn, amountCarrying, slotGroup);
                }
            }
            else
            {
                PendingHaulJobsTracker.ClearJobForPawn(___pawn);
            }
        }
Beispiel #3
0
        private static ThinkResult DetermineNextJob2(Pawn_JobTracker __instance, out ThinkTreeDef thinkTree)
        {
            ThinkResult result = funcDetermineNextConstantThinkTreeJob(__instance);

            if (result.Job != null)
            {
                thinkTree = pawnFieldRef(__instance).thinker.ConstantThinkTree;
                return(result);
            }

            ThinkResult result2 = ThinkResult.NoJob;

            try
            {
                result2 = pawnFieldRef(__instance).thinker.MainThinkNodeRoot.TryIssueJobPackage(pawnFieldRef(__instance), default(JobIssueParams));
            }
            catch (Exception exception)
            {
                JobUtility.TryStartErrorRecoverJob(pawnFieldRef(__instance), pawnFieldRef(__instance).ToStringSafe() + " threw exception while determining job (main)", exception);
                thinkTree = null;
                return(ThinkResult.NoJob);
            }

            thinkTree = pawnFieldRef(__instance).thinker.MainThinkTree;
            return(result2);
        }
        static void UnmarkDesignation(Pawn_JobTracker __instance, JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft, bool canReturnToPool)
        {
            if (__instance?.curJob?.bill == null || __instance.curJob.bill.billStack != null || condition != JobCondition.Succeeded)
            {
                return;
            }

            if (__instance.curJob.targetB != null && __instance.curJob.targetB.HasThing && !__instance.curJob.targetB.ThingDestroyed)
            {
                RecipeDef      rec   = __instance.curJob.bill.recipe;
                Thing          thing = __instance.curJob.targetB.Thing;
                DesignationDef dDef  = DefDatabase <DesignationDef> .AllDefsListForReading.FirstOrDefault(x => x.defName == rec.defName + "Designation");

                if (dDef == null)
                {
                    return;
                }

                Designation d = thing.Map.designationManager.DesignationOn(__instance.curJob.targetB.Thing, dDef);

                if (d == null)
                {
                    return;
                }

                thing.Map.designationManager.RemoveDesignation(d);
            }
        }
        static void Postfix(Pawn_JobTracker __instance, ref ThinkResult __result)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            //If a hostile pawn owns an animal, make sure it mounts it whenever possible


            if (pawn.RaceProps.Humanlike && pawn.Faction != null && pawn.Faction.HostileTo(Faction.OfPlayer) && !pawn.Downed && !pawn.IsBurning() && !pawn.IsPrisoner)
            {
                ExtendedPawnData pawnData = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(pawn);
                if (pawnData.owning == null || pawnData.owning.Faction != pawn.Faction || pawnData.mount != null || pawnData.owning.Downed || pawnData.owning.Dead || !pawnData.owning.Spawned || pawnData.owning.IsBurning())
                {
                    return;
                }
                QueuedJob qJob = pawn.jobs.jobQueue.FirstOrFallback(null);
                if (qJob != null && (qJob.job.def == GUC_JobDefOf.Mount))
                {
                    return;
                }
                if (__result.Job.def == GUC_JobDefOf.Mount)
                {
                    return;
                }

                Job mountJob = new Job(GUC_JobDefOf.Mount, pawnData.owning);
                mountJob.count = 1;
                __instance.jobQueue.EnqueueFirst(mountJob);
            }
        }
        public static bool PreFix(ref bool __result, CastPositionRequest newReq, out IntVec3 dest)
        {
            dest = IntVec3.Invalid;
            Pawn caster = newReq.caster;
            Pawn pawn   = newReq.target as Pawn;

            if (caster != null && pawn != null && caster != null && pawn != null)
            {
                bool flag;
                if (caster == null)
                {
                    flag = (null != null);
                }
                else
                {
                    Pawn_JobTracker jobs = caster.jobs;
                    flag = ((jobs?.curJob) != null);
                }
                if (flag && CamoAIUtility.JobIsCastException(caster.jobs.curJob.def))
                {
                    return(true);
                }
                if (CamoUtility.IsTargetHidden(pawn, caster))
                {
                    __result = false;
                    return(false);
                }
            }
            return(true);
        }
Beispiel #7
0
        public static void Postfix(Pawn_JobTracker __instance)
        {
            if (GameAttackTrigger_Patch.ActiveAttacker.Count == 0 &&
                GameAttackTrigger_Patch.ActiveAttackHost.Count == 0)
            {
                return;
            }
            var that = __instance;
            var pawn = that.GetPawn();

            if (pawn.Map == null)
            {
                return;
            }
            GameAttacker client;

            if (GameAttackTrigger_Patch.ActiveAttacker.TryGetValue(pawn.Map, out client))
            {
                client.UIEventNewJob(pawn, null);
            }
            GameAttackHost clientHost;

            if (GameAttackTrigger_Patch.ActiveAttackHost.TryGetValue(pawn.Map, out clientHost))
            {
                clientHost.UIEventNewJob(pawn, null);
            }
        }
            public static bool Prefix(Pawn_JobTracker __instance, Job job, ref bool __result, Pawn ___pawn)
            {
                //Logger.MessageFormat(__instance, "TryTakeOrderedJob Prefix");

                if (___pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = ___pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        bool canTakeJob = compMeeseeksMemory.CanTakeOrderedJob(job);

                        //Logger.MessageFormat(__instance, "TryTakeOrderedJob Meeseeks canTakeJob: {0}", canTakeJob.ToString());

                        if (!canTakeJob)
                        {
                            __result = false;
                            return(false);
                        }
                        else
                        {
                            compMeeseeksMemory.PreTryTakeOrderedJob(job);
                        }
                    }
                }

                return(true);
            }
 // Token: 0x06000007 RID: 7 RVA: 0x00002224 File Offset: 0x00000424
 private static void ClearAllJobs(Pawn pawn)
 {
     if (pawn != null && pawn.Spawned && (pawn?.Map) != null)
     {
         bool flag;
         if (pawn == null)
         {
             flag = (null != null);
         }
         else
         {
             Pawn_JobTracker jobs = pawn.jobs;
             flag = ((jobs?.jobQueue) != null);
         }
         if (flag)
         {
             pawn.jobs.ClearQueuedJobs(true);
         }
         bool flag2;
         if (pawn == null)
         {
             flag2 = (null != null);
         }
         else
         {
             Pawn_JobTracker jobs2 = pawn.jobs;
             flag2 = ((jobs2?.curJob) != null);
         }
         if (flag2)
         {
             pawn.jobs.EndCurrentJob(JobCondition.Succeeded, false, true);
         }
     }
 }
Beispiel #10
0
        private static ThinkResult DetermineNextJob2(Pawn_JobTracker __instance, out ThinkTreeDef thinkTree)
        {
            ThinkResult result = __instance.DetermineNextConstantThinkTreeJob();

            if (result.Job != null)
            {
                thinkTree = __instance.pawn.thinker.ConstantThinkTree;
                return(result);
            }

            ThinkResult result2 = ThinkResult.NoJob;

            try
            {
                result2 = __instance.pawn.thinker.MainThinkNodeRoot.TryIssueJobPackage(__instance.pawn, default);
            }
            catch (Exception exception)
            {
                JobUtility.TryStartErrorRecoverJob(__instance.pawn, __instance.pawn.ToStringSafe() + " threw exception while determining job (main)", exception);
                thinkTree = null;
                return(ThinkResult.NoJob);
            }
            finally
            {
            }

            thinkTree = __instance.pawn.thinker.MainThinkTree;
            return(result2);
        }
Beispiel #11
0
 private static void Postfix(Pawn_JobTracker __instance, Pawn ___pawn, Job newJob, JobTag?tag)
 {
     if (___pawn is Wendigo)
     {
         Log.Message(___pawn + " is starting " + newJob);
     }
 }
Beispiel #12
0
        public static bool DetermineNextJob(Pawn_JobTracker __instance, ref ThinkResult __result, out ThinkTreeDef thinkTree)
        {
            ThinkResult constantThinkTreeJob = __instance.DetermineNextConstantThinkTreeJob();

            if (constantThinkTreeJob.Job != null)
            {
                thinkTree = __instance.pawn.thinker.ConstantThinkTree;
                __result  = constantThinkTreeJob;
                return(false);
            }
            ThinkResult thinkResult = ThinkResult.NoJob;

            try
            {
                thinkResult = __instance.pawn.thinker.MainThinkNodeRoot.TryIssueJobPackage(__instance.pawn, new JobIssueParams());
            }
            catch (Exception ex)
            {
                JobUtility.TryStartErrorRecoverJob(__instance.pawn, __instance.pawn.ToStringSafe <Pawn>() + " threw exception while determining job (main)", ex);
                thinkTree = null;
                __result  = ThinkResult.NoJob;
                return(false);
            }
            finally
            {
            }
            thinkTree = __instance?.pawn?.thinker?.MainThinkTree; //changed
            if (thinkTree == null)                                //changed
            {
                thinkResult = ThinkResult.NoJob;                  //changed
            }
            __result = thinkResult;
            return(false);
        }
Beispiel #13
0
        public static bool Notify_DamageTaken(Pawn_JobTracker __instance, DamageInfo dinfo)
        {
            Job curJob = __instance.curJob;

            if (curJob == null)
            {
                return(false);
            }
            JobDriver curDriver = __instance.curDriver;

            if (curDriver == null)
            {
                return(false);
            }
            curDriver.Notify_DamageTaken(dinfo);
            Job curJob2 = __instance.curJob;

            if (curJob2 != curJob || !dinfo.Def.ExternalViolenceFor(__instance.pawn) || (!dinfo.Def.canInterruptJobs || curJob2.playerForced) || Find.TickManager.TicksGame < __instance.lastDamageCheckTick + 180)
            {
                return(false);
            }
            Thing instigator = dinfo.Instigator;

            if (curJob2.def.checkOverrideOnDamage != CheckJobOverrideOnDamageMode.Always && (curJob2.def.checkOverrideOnDamage != CheckJobOverrideOnDamageMode.OnlyIfInstigatorNotJobTarget || __instance.curJob.AnyTargetIs((LocalTargetInfo)instigator)))
            {
                return(false);
            }
            __instance.lastDamageCheckTick = Find.TickManager.TicksGame;
            __instance.CheckForJobOverride();
            return(false);
        }
        private static void parkAnimal(Pawn_JobTracker __instance, Pawn pawn, ExtendedPawnData pawnData)
        {
            Area_GU areaFound = (Area_GU)pawn.Map.areaManager.GetLabeled(Base.DropAnimal_NPC_LABEL);
            IntVec3 targetLoc = pawn.Position;

            if (areaFound != null && areaFound.ActiveCells.Count() > 0)
            {
                targetLoc = DistanceUtility.getClosestAreaLoc(pawn, areaFound);
            }
            if (pawn.Map.reachability.CanReach(pawn.Position, targetLoc, PathEndMode.OnCell, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)))
            {
                Job dismountJob = new Job(GUC_JobDefOf.Dismount);
                dismountJob.count = 1;
                __instance.jobQueue.EnqueueFirst(dismountJob);
                __instance.jobQueue.EnqueueFirst(new Job(JobDefOf.Goto, targetLoc));
                PawnDuty animalDuty = pawnData.mount.mindState.duty;
                //if(pawnData.mount.GetLord().CurLordToil is LordToil)

                if (animalDuty != null)
                {
                    animalDuty.focus = new LocalTargetInfo(targetLoc);
                }
            }
            else
            {
                Messages.Message("GU_Car_NotReachable_DropAnimal_NPC_Message".Translate(), new RimWorld.Planet.GlobalTargetInfo(targetLoc, pawn.Map), MessageTypeDefOf.NegativeEvent);
            }
        }
Beispiel #15
0
            static void Postfix(Pawn_JobTracker __instance, Job newJob, JobTag?tag)
            {
                if (newJob == null || tag != JobTag.Fieldwork)
                {
                    return;
                }

                if (Pawn_JobTracker_pawn == null)
                {
                    Pawn_JobTracker_pawn = typeof(Pawn_JobTracker).GetField("pawn", BindingFlags.NonPublic | BindingFlags.Instance);
                }

                Pawn pawn = (Pawn)Pawn_JobTracker_pawn.GetValue(__instance);

                IEnumerable <Pawn> animals = from p in Find.CurrentMap.mapPawns.AllPawns
                                             where p.RaceProps.Animal && p.Faction == Faction.OfPlayer && p.playerSettings != null && p.playerSettings.Master == pawn && p.playerSettings.followFieldwork
                                             select p;

                foreach (var animal in animals)
                {
                    if (animal.CurJob != null && animal.CurJob.def != JobDefOf.Wait_Combat && animal.CurJob.def != JobDefOf.Rescue && animal.CurJob.def != JobDefOf.AttackMelee && animal.CurJob.def != JobDefOf.AttackStatic && animal.CurJob.def.casualInterruptible)
                    {
                        animal.jobs.EndCurrentJob(JobCondition.InterruptForced, true);
                    }
                }
            }
 static void Postfix(ref Pawn_JobTracker __instance, ref ThinkResult __result, ref Pawn ___pawn)
 {
     if (___pawn.IsHacked() && ___pawn.IsActivated() && ___pawn.health.hediffSet.HasHediff(WTH_DefOf.WTH_TargetingHackedPoorly))
     {
         HackedPoorlyEvent(___pawn);
     }
 }
Beispiel #17
0
        static void Postfix(Pawn_JobTracker __instance, ref ThinkResult __result)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (!pawn.IsColonistPlayerControlled)
            {
                return;
            }
            ExtendedDataStorage store    = Base.Instance.GetExtendedDataStorage();
            ExtendedPawnData    pawnData = store.GetExtendedDataFor(pawn);

            if (store == null || pawnData == null)
            {
                return;
            }

            if (pawnData.owning == null || !pawnData.owning.Spawned || pawnData.owning.Downed || pawnData.owning.Dead || pawnData.mount != null)
            {
                return;
            }

            LocalTargetInfo target             = DistanceUtility.GetFirstTarget(__result.Job, TargetIndex.A);
            float           pawnTargetDistance = DistanceUtility.QuickDistance(pawnData.owning.Position, target.Cell);

            if (pawnTargetDistance > 10 || __result.Job.def == JobDefOf.LayDown || __result.Job.def == JobDefOf.Research || pawn.InMentalState || pawn.Dead || pawn.Downed)
            {
                if (pawnData.owning.jobs.curJob != null && pawnData.owning.jobs.curJob.def == JobDefOf.Wait)
                {
                    pawnData.owning.jobs.EndCurrentJob(JobCondition.InterruptForced);
                }
                ExtendedPawnData animalData = store.GetExtendedDataFor(pawnData.owning);
                pawnData.owning    = null;
                animalData.ownedBy = null;
            }
        }
 // Token: 0x0600000C RID: 12 RVA: 0x00002524 File Offset: 0x00000724
 public static void CorrectJob(Pawn seer, Pawn target)
 {
     if (seer != null && target != null && (seer?.Map) != null && (target?.Map) != null && seer.Map == target.Map)
     {
         bool flag;
         if (seer == null)
         {
             flag = (null != null);
         }
         else
         {
             Pawn_MindState mindState = seer.mindState;
             flag = ((mindState?.meleeThreat) != null);
         }
         if (!flag && ThingCompUtility.TryGetComp <PawnCamoData>(seer).LastCamoCorrectTick + 120 <= Find.TickManager.TicksGame && seer.Spawned && target.Spawned)
         {
             bool flag2;
             if (seer == null)
             {
                 flag2 = (null != null);
             }
             else
             {
                 Pawn_JobTracker jobs = seer.jobs;
                 flag2 = ((jobs?.curJob) != null);
             }
             if (flag2 && seer.jobs.curJob.def != CamoAIUtility.CamoPauseJobDef() && seer.jobs.curJob.AnyTargetIs(target))
             {
                 ThingCompUtility.TryGetComp <PawnCamoData>(seer).LastCamoCorrectTick = Find.TickManager.TicksGame;
                 CamoAIUtility.RemoveTarget(seer, target);
             }
         }
     }
 }
Beispiel #19
0
        private static void mountAnimal(Pawn_JobTracker __instance, Pawn pawn, ExtendedPawnData pawnData, ref ThinkResult __result)
        {
            Job mountJob = new Job(GUC_JobDefOf.Mount, pawnData.owning);

            __result = new ThinkResult(mountJob, __result.SourceNode, __result.Tag, false);
            __instance.jobQueue.EnqueueFirst(mountJob);
            pawn.mindState.duty = new PawnDuty(DutyDefOf.ExitMapBest);
        }
 static bool Prefix(Pawn_JobTracker __instance)
 {
     if (__instance.curDriver != null && __instance.curDriver.pawn != null && __instance.curDriver.pawn.CurJob != null && __instance.curDriver.pawn.CurJob.def == GUC_JobDefOf.Mounted)
     {
         return(false);
     }
     return(true);
 }
Beispiel #21
0
 private void Init()
 {
     pather  = new Pawn_PathFollower(this);
     stances = new Pawn_StanceTracker(this);
     health  = new Pawn_HealthTracker(this);
     jobs    = new Pawn_JobTracker(this);
     filth   = new Pawn_FilthTracker(this);
 }
Beispiel #22
0
        static void Postfix(Pawn_JobTracker __instance, ref ThinkResult __result)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();


            if (pawn.IsColonistPlayerControlled || pawn.RaceProps.Animal)
            {
                return;
            }

            LocalTargetInfo target = DistanceUtility.GetFirstTarget(__result.Job, TargetIndex.A);

            if (!target.IsValid)
            {
                return;
            }

            ExtendedDataStorage store = Base.Instance.GetExtendedDataStorage();

            if (store == null)
            {
                return;
            }

            //Log.Message("wrong duty");
            ExtendedPawnData PawnData = store.GetExtendedDataFor(pawn);
            Lord             lord     = pawn.GetLord();

            if (lord == null)
            {
                return;
            }
            QueuedJob qJob = pawn.jobs.jobQueue.FirstOrFallback(null);

            if (qJob != null && (qJob.job.def == GUC_JobDefOf.Dismount))
            {
                return;
            }

            Log.Message("curLordToil: " + pawn.GetLord().CurLordToil.ToString() + ", pawn name: " + pawn.Name);
            Log.Message("lordJob: " + pawn.GetLord().LordJob + ", pawn name: " + pawn.Name);
            Log.Message("lord.CurLordToil.GetType().Name" + lord.CurLordToil.GetType().Name);

            if (lord.CurLordToil is LordToil_ExitMapAndEscortCarriers)
            {
                if (PawnData.owning != null && PawnData.mount == null && !PawnData.owning.Downed && PawnData.owning.Spawned)
                {
                    mountAnimal(__instance, pawn, PawnData, ref __result);
                }
            }
            else if (lord.CurLordToil.GetType().Name == "LordToil_DefendTraderCaravan" || lord.CurLordToil is LordToil_DefendPoint) //first option is internal class, hence this way of accessing.
            {
                if (PawnData.mount != null)
                {
                    parkAnimal(__instance, pawn, PawnData);
                }
            }
        }
Beispiel #23
0
        public static bool CleanupCurrentJob(Pawn_JobTracker __instance, JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft = true)
        {
            if (QOLTweaksPack.PickupDropOrders.Value == false)
            {
                return(true);
            }

            if (!FloatMenuMakerMap_AddHumanLikeOrders_Postfix.forceKeep)
            {
                return(true);
            }

            if (!(__instance.curDriver is JobDriver_PickupObject))
            {
                return(true);
            }

            if (__instance.curJob == null)
            {
                return(true);
            }

            if (__instance.debugLog)
            {
                __instance.DebugLogEvent(string.Concat(new object[]
                {
                    "CleanupCurrentJob ",
                    (__instance.curJob == null) ? "null" : __instance.curJob.def.ToString(),
                    " condition ",
                    condition
                }));
            }

            Pawn pawn = (Pawn)Reflection.GetFieldValue(__instance, "pawn");


            __instance.curDriver.ended = true;
            __instance.curDriver.Cleanup(condition);
            __instance.curDriver = null;
            __instance.curJob    = null;
            if (releaseReservations)
            {
                pawn.ClearReservations(false);
            }
            if (cancelBusyStancesSoft)
            {
                pawn.stances.CancelBusyStanceSoft();
            }
            if (!pawn.Destroyed && pawn.carryTracker != null && pawn.carryTracker.CarriedThing != null)
            {
                //Thing thing;
                //pawn.carryTracker.TryDropCarriedThing(pawn.Position, ThingPlaceMode.Near, out thing, null);
                //Do not do this thing
            }

            return(false);
        }
        public static bool UpdateRotation(Pawn_RotationTracker __instance)
        {
            Pawn pawn = pawnField(__instance);

            if (pawn.Destroyed || pawn.jobs.HandlingFacing)
            {
                return(false);
            }

            if (pawn.pather.Moving)
            {
                if (pawn.pather.curPath != null && pawn.pather.curPath.NodesLeftCount >= 1)
                {
                    FaceAdjacentCell2(pawn, pawn.pather.nextCell);
                }

                return(false);
            }

            Stance_Busy stance_Busy = pawn.stances.curStance as Stance_Busy;

            if (stance_Busy != null && stance_Busy.focusTarg.IsValid)
            {
                if (stance_Busy.focusTarg.HasThing)
                {
                    __instance.Face(stance_Busy.focusTarg.Thing.DrawPos);
                }
                else
                {
                    __instance.FaceCell(stance_Busy.focusTarg.Cell);
                }

                return(false);
            }

            Job job = pawn.CurJob; //ADDED

            if (job != null)       //CHANGED
            {
                Pawn_JobTracker jobs = pawn.jobs;
                if (jobs != null)
                {
                    JobDriver jobDriver = jobs.curDriver;
                    if (jobDriver != null)
                    {
                        LocalTargetInfo target = job.GetTarget(jobDriver.rotateToFace); //CHANGED
                        __instance.FaceTarget(target);
                    }
                }
            }

            if (pawn.Drafted)
            {
                pawn.Rotation = Rot4.South;
            }
            return(false);
        }
        private static void mountAnimal(Pawn_JobTracker __instance, Pawn pawn, ExtendedPawnData pawnData, ref ThinkResult __result)
        {
            Job oldJob   = __result.Job;
            Job mountJob = new Job(GUC_JobDefOf.Mount, pawnData.owning);

            mountJob.count = 1;
            __result       = new ThinkResult(mountJob, __result.SourceNode, __result.Tag, false);
            __instance.jobQueue.EnqueueFirst(oldJob);
        }
        static void Postfix(ref Pawn_JobTracker __instance, ref ThinkResult __result)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (pawn.IsHacked() && pawn.IsActivated() && pawn.health.hediffSet.HasHediff(WTH_DefOf.WTH_TargetingHackedPoorly))
            {
                HackedPoorlyEvent(pawn);
            }
        }
Beispiel #27
0
        static bool Prefix(Pawn_JobTracker __instance)
        {
            Pawn pawn = __instance.pawn;

            if (pawn != null && pawn.CurJob != null && pawn.CurJob.def == GUC_JobDefOf.Mounted)
            {
                return(false);
            }
            return(true);
        }
        public static bool HeavySleeperTrait(Pawn_JobTracker __instance)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            return(__instance.curDriver == null ||
                   !pawn.RaceProps.Humanlike ||
                   !__instance.curDriver.asleep ||
                   Traverse.Create(pawn.needs.rest).Field("lastRestTick").GetValue <int>() < Find.TickManager.TicksGame - 200 ||
                   !pawn.story.traits.HasTrait(TraitDefOfPsychology.HeavySleeper));
        }
Beispiel #29
0
        private static bool Prefix(Pawn_JobTracker __instance)
        {
            if (!Active)
            {
                return(true);
            }

            Detour(__instance);
            return(false);
        }
        static bool Prefix(Pawn_JobTracker __instance)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (pawn != null && pawn.CurJob != null && pawn.CurJob.def == GUC_JobDefOf.Mounted)
            {
                return(false);
            }
            return(true);
        }