示例#1
0
        private Job TryGetEquipmentJob(Pawn pawn, Thing target)
        {
            Job   newJob            = null;
            Thing selectedEquipment = JobDriver_AcquireEquipment.FindEquipment(pawn);

            if (selectedEquipment != null && pawn.PositionHeld.DistanceTo(selectedEquipment.PositionHeld) < pawn.PositionHeld.DistanceTo(target.Position))
            {
                if (pawn.CanReach(selectedEquipment, PathEndMode.Touch, Danger.Deadly, canBash: true))
                {
                    using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, selectedEquipment, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassDoors)))
                    {
                        if (!pawnPath.Found)
                        {
                            Logger.MessageFormat("Somehow no path was found to {0}", selectedEquipment);
                            return(null);
                        }
                        IntVec3 cellBefore;
                        Thing   blocker = pawnPath.FirstBlockingBuilding(out cellBefore, pawn);
                        if (blocker != null)
                        {
                            newJob = TryMeleeAttackTargetJob(pawn, blocker);
                            if (newJob == null)
                            {
                                newJob = TryRangedAttackTargetJob(pawn, blocker);
                            }
                            if (newJob == null)
                            {
                                newJob = GoToTarget(pawn, cellBefore);
                            }
                        }
                        else
                        {
                            newJob = JobMaker.MakeJob(MeeseeksDefOf.CM_Meeseeks_Box_Job_AcquireEquipment, selectedEquipment);
                        }
                    }
                }
            }

            return(newJob);
        }
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.equipment == null)
            {
                return(null);
            }
            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                return(null);
            }
            if (pawn.GetRegion() == null)
            {
                return(null);
            }

            //if (pawn.Faction != Faction.OfPlayer)
            //{
            //    Log.ErrorOnce(string.Concat("Non-colonist ", pawn, " tried to acquire equipment."), 764323);
            //    return null;
            //}
            if (pawn.IsQuestLodger())
            {
                return(null);
            }

            Thing selectedEquipment = JobDriver_AcquireEquipment.FindEquipment(pawn);

            if (!DebugViewSettings.debugApparelOptimize && Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick)
            {
                return(null);
            }

            if (selectedEquipment != null)
            {
                return(JobMaker.MakeJob(MeeseeksDefOf.CM_Meeseeks_Box_Job_AcquireEquipment, selectedEquipment));
            }

            return(null);
        }