Пример #1
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            bool flag = forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig && !pawn.CanReachMapEdge()) || (forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction, countDormantPawnsAsHostile: true));

            if (!TryFindGoodExitDest(pawn, flag, out IntVec3 dest))
            {
                return(null);
            }
            if (flag)
            {
                using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, dest, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings)))
                {
                    IntVec3 cellBefore;
                    Thing   thing = path.FirstBlockingBuilding(out cellBefore, pawn);
                    if (thing != null)
                    {
                        Job job = DigUtility.PassBlockerJob(pawn, thing, cellBefore, canMineMineables: true, canMineNonMineables: true);
                        if (job != null)
                        {
                            return(job);
                        }
                    }
                }
            }
            Job job2 = JobMaker.MakeJob(JobDefOf.Goto, dest);

            job2.exitMapOnArrival = true;
            job2.failIfCantJoinOrCreateCaravan = failIfCantJoinOrCreateCaravan;
            job2.locomotionUrgency             = PawnUtility.ResolveLocomotion(pawn, defaultLocomotion, LocomotionUrgency.Jog);
            job2.expiryInterval = jobMaxDuration;
            job2.canBash        = canBash;
            return(job2);
        }
        public override void Notify_PatherFailed()
        {
            if (base.job.attackDoorIfTargetLost)
            {
                Thing thing = default(Thing);
                using (PawnPath pawnPath = base.Map.pathFinder.FindPath(base.pawn.Position, base.TargetA.Cell, TraverseParms.For(base.pawn, Danger.Deadly, TraverseMode.PassDoors, false), PathEndMode.OnCell))
                {
                    if (pawnPath.Found)
                    {
                        IntVec3 intVec = default(IntVec3);
                        thing = pawnPath.FirstBlockingBuilding(out intVec, base.pawn);
                        goto end_IL_004e;
                    }
                    return;

                    end_IL_004e :;
                }
                if (thing != null)
                {
                    base.job.targetA            = thing;
                    base.job.maxNumMeleeAttacks = Rand.RangeInclusive(2, 5);
                    base.job.expiryInterval     = Rand.Range(2000, 4000);
                    return;
                }
            }
            base.Notify_PatherFailed();
        }
        // Token: 0x06000055 RID: 85 RVA: 0x0000428C File Offset: 0x0000248C
        public override void Notify_PatherFailed()
        {
            bool attackDoorIfTargetLost = this.job.attackDoorIfTargetLost;

            if (attackDoorIfTargetLost)
            {
                Thing thing;
                using (PawnPath pawnPath = base.Map.pathFinder.FindPath(this.pawn.Position, base.TargetA.Cell, TraverseParms.For(this.pawn, Danger.Deadly, TraverseMode.PassDoors, false), PathEndMode.OnCell))
                {
                    bool flag = !pawnPath.Found;
                    if (flag)
                    {
                        return;
                    }
                    IntVec3 intVec;
                    thing = pawnPath.FirstBlockingBuilding(out intVec, this.pawn);
                }
                bool flag2 = thing != null;
                if (flag2)
                {
                    bool flag3 = thing.Position.InHorDistOf(this.pawn.Position, 6f);
                    if (flag3)
                    {
                        this.job.targetA            = thing;
                        this.job.maxNumMeleeAttacks = Rand.RangeInclusive(2, 5);
                        this.job.expiryInterval     = Rand.Range(2000, 4000);
                        return;
                    }
                }
            }
            base.Notify_PatherFailed();
        }
        // Token: 0x06003DA3 RID: 15779 RVA: 0x0016D63C File Offset: 0x0016B83C
        protected override Job TryGiveJob(Pawn pawn)
        {
            Room room = pawn.GetRoom(RegionType.Set_Passable);

            if (room.PsychologicallyOutdoors && room.TouchesMapEdge)
            {
                return(null);
            }
            if (!pawn.CanReachMapEdge())
            {
                return(null);
            }
            bool    flag = this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig && !pawn.CanReachMapEdge()) || (this.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (this.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction, true));
            IntVec3 c;

            if (!this.TryFindGoodExitDest(pawn, flag, out c))
            {
                return(null);
            }
            if (flag)
            {
                using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell))
                {
                    IntVec3 cellBeforeBlocker;
                    Thing   thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
                    if (thing.def == XenomorphDefOf.RRY_Xenomorph_Hive_Wall)
                    {
                        CellRect rect = new CellRect(thing.Position.x - 1, thing.Position.y - 1, 3, 3);
                        foreach (IntVec3 cell in rect)
                        {
                            if (cell.InBounds(thing.Map))
                            {
                                if (cell.GetThingList(thing.Map).All(x => x.def != XenomorphDefOf.RRY_Xenomorph_Hive_Wall))
                                {
                                    thing = cell.GetFirstMineable(thing.Map);
                                    break;
                                }
                            }
                        }
                    }
                    if (thing != null && thing.def != XenomorphDefOf.RRY_Xenomorph_Hive_Wall)
                    {
                        Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true);
                        if (job != null)
                        {
                            return(job);
                        }
                    }
                }
            }
            return(null);
        }
Пример #5
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            bool flag = false;

            if (this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig) || (this.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (this.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction)))
            {
                flag = true;
            }
            IntVec3 c;
            Job     result;

            if (!this.TryFindGoodExitDest(pawn, flag, out c))
            {
                result = null;
            }
            else
            {
                if (flag)
                {
                    using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell))
                    {
                        IntVec3 cellBeforeBlocker;
                        Thing   thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
                        if (thing != null)
                        {
                            Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true);
                            if (job != null)
                            {
                                return(job);
                            }
                        }
                    }
                }
                result = new Job(JobDefOf.Goto, c)
                {
                    exitMapOnArrival = true,
                    failIfCantJoinOrCreateCaravan = this.failIfCantJoinOrCreateCaravan,
                    locomotionUrgency             = PawnUtility.ResolveLocomotion(pawn, this.defaultLocomotion, LocomotionUrgency.Jog),
                    expiryInterval = this.jobMaxDuration,
                    canBash        = this.canBash
                };
            }
            return(result);
        }
Пример #6
0
        // Token: 0x06003EB7 RID: 16055 RVA: 0x001D76A8 File Offset: 0x001D5AA8
        protected override Job TryGiveJob(Pawn pawn)
        {
            bool flag = false;

            if (this.forceCanDig || (pawn.mindState.duty != null && pawn.mindState.duty.canDig) || (this.forceCanDigIfCantReachMapEdge && !pawn.CanReachMapEdge()) || (this.forceCanDigIfAnyHostileActiveThreat && pawn.Faction != null && GenHostility.AnyHostileActiveThreatTo(pawn.Map, pawn.Faction)))
            {
                flag = true;
            }
            IntVec3 c;

            if (pawn.xenomorph().HiveLoc == null)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} no hiveloc", pawn));
                }
                return(null);
            }
            if (!pawn.xenomorph().HiveLoc.IsValid)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} no hiveloc", pawn));
                }
                return(null);
            }
            if (pawn.xenomorph().HiveLoc == IntVec3.Zero)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} hiveloc zero", pawn));
                }
                return(null);
            }
            c = pawn.xenomorph().HiveLoc;

            if (!c.IsValid)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} no c", pawn));
                }
                return(null);
            }
            if (c == IntVec3.Zero)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("{0} c zero", pawn));
                }
                return(null);
            }

            if (flag)
            {
                using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell))
                {
                    IntVec3 cellBeforeBlocker;
                    Thing   thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
                    if (thing != null)
                    {
                        if (!thing.def.defName.Contains("Xenomorph_Hive"))
                        {
                            Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true);
                            if (job != null)
                            {
                                return(job);
                            }
                        }
                    }
                }
            }

            /*
             * //    Log.Message("TryGiveJob 6");
             * //    Log.Message(string.Format("TryGiveJob 6 {0}, {1}", pawn.Map, c));
             * if (c.GetFirstBuilding(pawn.Map)!=null)
             * {
             * //    Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == {2}", pawn.Map, c, c.GetFirstBuilding(pawn.Map)));
             *  if (c.GetFirstBuilding(pawn.Map).def == XenomorphDefOf.RRY_Xenomorph_Hive)
             *  {
             *  //    Log.Message("TryGiveJob 6 1");
             *      return null;
             *  }
             * }
             * else
             * {
             * //    Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == Null", pawn.Map, c));
             *  if (c.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive) != null)
             *  {
             *  //    Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == {2}", pawn.Map, c, c.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive)));
             *      if (c.GetFirstBuilding(pawn.Map).def == )
             *      {
             *      //    Log.Message("TryGiveJob 6 1");
             *          return null;
             *      }
             *  }
             *  else
             *  {
             *  //    Log.Message(string.Format("TryGiveJob 6 {0}, {1} Building == Null", pawn.Map, c));
             *  }
             * }
             * //    Log.Message("TryGiveJob 7");
             */
            return(new Job(JobDefOf.Goto, c)
            {
                exitMapOnArrival = false,
                failIfCantJoinOrCreateCaravan = this.failIfCantJoinOrCreateCaravan,
                locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, this.defaultLocomotion, LocomotionUrgency.Jog),
                expiryInterval = this.jobMaxDuration,
                canBash = this.canBash
            });
        }