protected override Job TryGiveJob(Pawn pawn)
        {
            Job result;

            if (pawn.playerSettings != null && pawn.playerSettings.UsesConfigurableHostilityResponse)
            {
                result = null;
            }
            else if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
            {
                result = null;
            }
            else
            {
                if (pawn.Faction == null)
                {
                    List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.AlwaysFlee);
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (pawn.Position.InHorDistOf(list[i].Position, 18f))
                        {
                            if (SelfDefenseUtility.ShouldFleeFrom(list[i], pawn, false, false))
                            {
                                Job job = this.FleeJob(pawn, list[i]);
                                if (job != null)
                                {
                                    return(job);
                                }
                            }
                        }
                    }
                    Job job2 = this.FleeLargeFireJob(pawn);
                    if (job2 != null)
                    {
                        return(job2);
                    }
                }
                else if (pawn.GetLord() == null)
                {
                    List <IAttackTarget> potentialTargetsFor = pawn.Map.attackTargetsCache.GetPotentialTargetsFor(pawn);
                    for (int j = 0; j < potentialTargetsFor.Count; j++)
                    {
                        Thing thing = potentialTargetsFor[j].Thing;
                        if (pawn.Position.InHorDistOf(thing.Position, 18f))
                        {
                            if (SelfDefenseUtility.ShouldFleeFrom(thing, pawn, false, true))
                            {
                                Job job3 = this.FleeJob(pawn, thing);
                                if (job3 != null)
                                {
                                    return(job3);
                                }
                            }
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
示例#2
0
        public static bool CanCasuallyInteractNow(this Pawn p, bool twoWayInteraction = false)
        {
            if (p.Drafted)
            {
                return(false);
            }
            if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(p))
            {
                return(false);
            }
            if (p.InAggroMentalState)
            {
                return(false);
            }
            if (!p.Awake())
            {
                return(false);
            }
            if (p.IsFormingCaravan())
            {
                return(false);
            }
            Job curJob = p.CurJob;

            return(curJob == null || !twoWayInteraction || (curJob.def.casualInterruptible && curJob.playerForced));
        }
        public static bool CanCasuallyInteractNow(this Pawn p, bool twoWayInteraction = false)
        {
            if (p.Drafted)
            {
                return(false);
            }
            if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(p))
            {
                return(false);
            }
            if (p.InAggroMentalState)
            {
                return(false);
            }
            if (!p.Awake())
            {
                return(false);
            }
            Job curJob = p.CurJob;

            if (curJob != null && twoWayInteraction && (!curJob.def.casualInterruptible || !curJob.playerForced))
            {
                return(false);
            }
            return(true);
        }
示例#4
0
        //===========================================================================

        public static bool CaresAboutForbidden(Pawn pawn, bool cellTarget)
        {
            if (pawn.HostFaction != null)
            {
                //Player guests care about forbidden if not in a player-home-map,
                //this is so hungry prisoners don't try to eat forbidden meals in hostile
                //faction bases and die
                bool securePlayerGuestInNonPlayerHome = pawn.HostFaction == Faction.OfPlayer &&
                                                        pawn.Spawned &&
                                                        !pawn.Map.IsPlayerHome &&
                                                        (pawn.GetRoom() == null || !pawn.GetRoom().isPrisonCell) && // not in a prison cell
                                                        (!pawn.IsPrisoner || pawn.guest.PrisonerIsSecure); // not escaping

                if (!securePlayerGuestInNonPlayerHome)
                {
                    return(false);
                }
            }

            if (pawn.InMentalState)
            {
                return(false);
            }

            //Animals following drafted masters don't care about forbidden cells (only things, like doors)
            if (cellTarget && ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
            {
                return(false);
            }

            return(true);
        }
示例#5
0
 public static bool CaresAboutForbidden(Pawn pawn, bool cellTarget)
 {
     if (pawn.HostFaction != null)
     {
         if (pawn.HostFaction != Faction.OfPlayer || !pawn.Spawned || pawn.Map.IsPlayerHome || (pawn.GetRoom(RegionType.Set_Passable) != null && pawn.GetRoom(RegionType.Set_Passable).isPrisonCell) || (pawn.IsPrisoner && !pawn.guest.PrisonerIsSecure))
         {
             return(false);
         }
     }
     return(!pawn.InMentalState && (!cellTarget || !ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn)));
 }
 protected override Job TryGiveJob(Pawn pawn)
 {
     if (pawn.playerSettings != null && pawn.playerSettings.UsesConfigurableHostilityResponse)
     {
         return(null);
     }
     if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
     {
         return(null);
     }
     if (pawn.Faction == null)
     {
         List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.AlwaysFlee);
         for (int i = 0; i < list.Count; i++)
         {
             if (pawn.Position.InHorDistOf(list[i].Position, 18f) && SelfDefenseUtility.ShouldFleeFrom(list[i], pawn, checkDistance: false, checkLOS: false))
             {
                 Job job = FleeJob(pawn, list[i]);
                 if (job != null)
                 {
                     return(job);
                 }
             }
         }
         Job job2 = FleeLargeFireJob(pawn);
         if (job2 != null)
         {
             return(job2);
         }
     }
     else if (pawn.GetLord() == null && (pawn.Faction != Faction.OfPlayer || !pawn.Map.IsPlayerHome) && (pawn.CurJob == null || !pawn.CurJobDef.neverFleeFromEnemies))
     {
         List <IAttackTarget> potentialTargetsFor = pawn.Map.attackTargetsCache.GetPotentialTargetsFor(pawn);
         for (int j = 0; j < potentialTargetsFor.Count; j++)
         {
             Thing thing = potentialTargetsFor[j].Thing;
             if (!pawn.Position.InHorDistOf(thing.Position, 18f) || !SelfDefenseUtility.ShouldFleeFrom(thing, pawn, checkDistance: false, checkLOS: true))
             {
                 continue;
             }
             Pawn pawn2 = thing as Pawn;
             if (pawn2 == null || !pawn2.AnimalOrWildMan() || pawn2.Faction != null)
             {
                 Job job3 = FleeJob(pawn, thing);
                 if (job3 != null)
                 {
                     return(job3);
                 }
             }
         }
     }
     return(null);
 }
示例#7
0
        public IEnumerable <Gizmo> GetGizmos()
        {
            if (pawn.Drafted)
            {
                int  count         = 0;
                bool anyCanRelease = false;
                foreach (Pawn item in PawnUtility.SpawnedMasteredPawns(pawn))
                {
                    if (item.training.HasLearned(TrainableDefOf.Release))
                    {
                        anyCanRelease = true;
                        if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(item))
                        {
                            count++;
                        }
                    }
                }
                if (anyCanRelease)
                {
                    Command_Toggle c = new Command_Toggle
                    {
                        defaultLabel = "CommandReleaseAnimalsLabel".Translate() + ((count == 0) ? string.Empty : (" (" + count + ")")),
                        defaultDesc  = "CommandReleaseAnimalsDesc".Translate(),
                        icon         = TexCommand.ReleaseAnimals,
                        hotKey       = KeyBindingDefOf.Misc7,
                        isActive     = (() => ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_016b: stateMachine*/)._0024this.animalsReleased),
                        toggleAction = delegate
                        {
                            ((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0182: stateMachine*/)._0024this.animalsReleased = !((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0182: stateMachine*/)._0024this.animalsReleased;
                            if (((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0182: stateMachine*/)._0024this.animalsReleased)
                            {
                                foreach (Pawn item2 in PawnUtility.SpawnedMasteredPawns(((_003CGetGizmos_003Ec__Iterator0) /*Error near IL_0182: stateMachine*/)._0024this.pawn))
                                {
                                    if (item2.caller != null)
                                    {
                                        item2.caller.Notify_Released();
                                    }
                                    item2.jobs.EndCurrentJob(JobCondition.InterruptForced);
                                }
                            }
                        }
                    };
                    if (count == 0)
                    {
                        c.Disable("CommandReleaseAnimalsFail_NoAnimals".Translate());
                    }
                    yield return((Gizmo)c);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
        }
示例#8
0
        public IEnumerable <Gizmo> GetGizmos()
        {
            if (!pawn.Drafted)
            {
                yield break;
            }
            int  num  = 0;
            bool flag = false;

            foreach (Pawn item in PawnUtility.SpawnedMasteredPawns(pawn))
            {
                if (item.training.HasLearned(TrainableDefOf.Release))
                {
                    flag = true;
                    if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(item))
                    {
                        num++;
                    }
                }
            }
            if (!flag)
            {
                yield break;
            }
            Command_Toggle command_Toggle = new Command_Toggle();

            command_Toggle.defaultLabel = "CommandReleaseAnimalsLabel".Translate() + ((num != 0) ? (" (" + num + ")") : "");
            command_Toggle.defaultDesc  = "CommandReleaseAnimalsDesc".Translate();
            command_Toggle.icon         = TexCommand.ReleaseAnimals;
            command_Toggle.hotKey       = KeyBindingDefOf.Misc7;
            command_Toggle.isActive     = () => animalsReleased;
            command_Toggle.toggleAction = delegate
            {
                animalsReleased = !animalsReleased;
                if (animalsReleased)
                {
                    foreach (Pawn item2 in PawnUtility.SpawnedMasteredPawns(pawn))
                    {
                        if (item2.caller != null)
                        {
                            item2.caller.Notify_Released();
                        }
                        item2.jobs.EndCurrentJob(JobCondition.InterruptForced);
                    }
                }
            };
            if (num == 0)
            {
                command_Toggle.Disable("CommandReleaseAnimalsFail_NoAnimals".Translate());
            }
            yield return(command_Toggle);
        }
 public IEnumerable <Gizmo> GetGizmos()
 {
     if (this.pawn.Drafted)
     {
         int  count         = 0;
         bool anyCanRelease = false;
         foreach (Pawn pawn in PawnUtility.SpawnedMasteredPawns(this.pawn))
         {
             if (pawn.training.HasLearned(TrainableDefOf.Release))
             {
                 anyCanRelease = true;
                 if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
                 {
                     count++;
                 }
             }
         }
         if (anyCanRelease)
         {
             Command_Toggle c = new Command_Toggle();
             c.defaultLabel = "CommandReleaseAnimalsLabel".Translate() + ((count == 0) ? string.Empty : (" (" + count + ")"));
             c.defaultDesc  = "CommandReleaseAnimalsDesc".Translate();
             c.icon         = TexCommand.ReleaseAnimals;
             c.hotKey       = KeyBindingDefOf.Misc7;
             c.isActive     = (() => this.animalsReleased);
             c.toggleAction = delegate()
             {
                 this.animalsReleased = !this.animalsReleased;
                 if (this.animalsReleased)
                 {
                     foreach (Pawn pawn2 in PawnUtility.SpawnedMasteredPawns(this.pawn))
                     {
                         if (pawn2.caller != null)
                         {
                             pawn2.caller.Notify_Released();
                         }
                         pawn2.jobs.EndCurrentJob(JobCondition.InterruptForced, true);
                     }
                 }
             };
             if (count == 0)
             {
                 c.Disable("CommandReleaseAnimalsFail_NoAnimals".Translate());
             }
             yield return(c);
         }
     }
     yield break;
 }
示例#10
0
        // Token: 0x06000433 RID: 1075 RVA: 0x0002D780 File Offset: 0x0002BB80
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.playerSettings != null && pawn.playerSettings.UsesConfigurableHostilityResponse)
            {
                return(null);
            }
            if (ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn))
            {
                return(null);
            }
            Job job2 = this.FleeLargeFireJob(pawn);

            if (job2 != null)
            {
                return(job2);
            }
            return(null);
        }
示例#11
0
 protected override bool Satisfied(Pawn pawn)
 {
     return(ThinkNode_ConditionalShouldFollowMaster.ShouldFollowMaster(pawn));
 }