コード例 #1
0
        public override AcceptanceReport CanDesignateCell(IntVec3 c)
        {
            AcceptanceReport result;

            if (!c.InBounds(base.Map) || c.Fogged(base.Map))
            {
                result = false;
            }
            else
            {
                Thing firstHaulable = c.GetFirstHaulable(base.Map);
                if (firstHaulable == null)
                {
                    result = "MessageMustDesignateHaulable".Translate();
                }
                else
                {
                    AcceptanceReport acceptanceReport = this.CanDesignateThing(firstHaulable);
                    if (!acceptanceReport.Accepted)
                    {
                        result = acceptanceReport;
                    }
                    else
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: JobGiver_Mine.cs プロジェクト: Skullywag/RimBots
        public Job JobOnThing(Pawn pawn, Thing t)
        {
            if (!t.def.mineable)
            {
                return(null);
            }
            if (Find.DesignationManager.DesignationAt(t.Position, DesignationDefOf.Mine) == null)
            {
                return(null);
            }
            if (!pawn.CanReserve(t, 1))
            {
                return(null);
            }
            bool flag = false;

            for (int i = 0; i < 8; i++)
            {
                IntVec3 c = t.Position + GenAdj.AdjacentCells[i];
                if (c.InBounds() && c.Standable())
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                for (int j = 0; j < 8; j++)
                {
                    IntVec3 c2 = t.Position + GenAdj.AdjacentCells[j];
                    if (c2.InBounds())
                    {
                        if (c2.Walkable() && !c2.Standable())
                        {
                            Thing firstHaulable = c2.GetFirstHaulable();
                            if (firstHaulable != null && firstHaulable.def.passability == Traversability.PassThroughOnly)
                            {
                                return(HaulAIUtility.HaulAsideJobFor(pawn, firstHaulable));
                            }
                        }
                    }
                }
                return(null);
            }
            return(new Job(JobDefOf.Mine, t, 1500, true));
        }
コード例 #3
0
 public override AcceptanceReport CanDesignateCell(IntVec3 c)
 {
     if (c.InBounds(base.Map) && !c.Fogged(base.Map))
     {
         Thing firstHaulable = c.GetFirstHaulable(base.Map);
         if (firstHaulable == null)
         {
             return("MessageMustDesignateHaulable".Translate());
         }
         AcceptanceReport result = this.CanDesignateThing(firstHaulable);
         if (!result.Accepted)
         {
             return(result);
         }
         return(true);
     }
     return(false);
 }
コード例 #4
0
        // Token: 0x0600041E RID: 1054 RVA: 0x0002CA54 File Offset: 0x0002AE54
        protected override Job TryGiveJob(Pawn pawn)
        {
            Region region = pawn.GetRegion(RegionType.Set_Passable);

            if (region == null)
            {
                return(null);
            }
            IntVec3 hiveCell;

            if (!XenomorphUtil.ClosestReachableParentHivelike(pawn).DestroyedOrNull())
            {
                hiveCell = XenomorphUtil.ClosestReachableParentHivelike(pawn).Position;
            }
            else if (!XenomorphUtil.ClosestReachableHiveSlime(pawn).DestroyedOrNull())
            {
                hiveCell = XenomorphUtil.ClosestReachableHiveSlime(pawn).Position;
            }
            else
            {
                hiveCell = pawn.mindState.duty.focus.Cell;
            }
            for (int i = 0; i < 40; i++)
            {
                IntVec3 randomCell = region.RandomCell;

                for (int j = 0; j < 8; j++)
                {
                    IntVec3 c = randomCell + GenAdj.AdjacentCellsAround[j];
                    if (c.InBounds(pawn.Map))
                    {
                        Thing thing = c.GetFirstHaulable(pawn.Map);
                        //    Log.Message(string.Format("thing: {0}", thing));
                        if (thing != null && (thing.def.passability == Traversability.Impassable || thing.def.IsDoor) && thing.def.size == IntVec2.One && thing.def != ThingDefOf.CollapsedRocks && pawn.CanReserve(thing, 1, -1, null, false) && XenomorphUtil.DistanceBetween(thing.Position, pawn.mindState.duty.focus.Cell) >= minClearingRange && XenomorphUtil.DistanceBetween(thing.Position, pawn.mindState.duty.focus.Cell) <= maxClearingRange)
                        {
                            return(XenomorphUtil.HaulAsideJobFor(pawn, thing, hiveCell, maxClearingRange));
                        }
                    }
                }
            }
            return(null);
        }
コード例 #5
0
 public override void DesignateSingleCell(IntVec3 c)
 {
     DesignateThing(c.GetFirstHaulable(base.Map));
 }