protected override Job TryGiveJob(Pawn pawn)
        {
            if (!pawn.HostileTo(Faction.OfPlayer))
            {
                return(null);
            }
            bool     flag     = pawn.natives.IgniteVerb != null && pawn.natives.IgniteVerb.IsStillUsableBy(pawn) && pawn.HostileTo(Faction.OfPlayer);
            CellRect cellRect = CellRect.CenteredOn(pawn.Position, 5);

            for (int i = 0; i < 35; i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                if (!randomCell.InBounds(pawn.Map))
                {
                    continue;
                }
                Building edifice = randomCell.GetEdifice(pawn.Map);
                if (edifice != null && TrashUtility.ShouldTrashBuilding(pawn, edifice) && GenSight.LineOfSight(pawn.Position, randomCell, pawn.Map))
                {
                    if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                    {
                        Find.CurrentMap.debugDrawer.FlashCell(randomCell, 1f, "trash bld");
                    }
                    Job job = TrashUtility.TrashJob(pawn, edifice);
                    if (job != null)
                    {
                        return(job);
                    }
                }
                if (flag)
                {
                    Plant plant = randomCell.GetPlant(pawn.Map);
                    if (plant != null && TrashUtility.ShouldTrashPlant(pawn, plant) && GenSight.LineOfSight(pawn.Position, randomCell, pawn.Map))
                    {
                        if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                        {
                            Find.CurrentMap.debugDrawer.FlashCell(randomCell, 0.5f, "trash plant");
                        }
                        Job job2 = TrashUtility.TrashJob(pawn, plant);
                        if (job2 != null)
                        {
                            return(job2);
                        }
                    }
                }
                if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                {
                    Find.CurrentMap.debugDrawer.FlashCell(randomCell, 0f, "trash no");
                }
            }
            return(null);
        }
        // Token: 0x0600048F RID: 1167 RVA: 0x0002F174 File Offset: 0x0002D574
        protected override Job TryGiveJob(Pawn pawn)
        {
            Map map = pawn.Map;

            if (!pawn.HostileTo(Faction.OfPlayer))
            {
                return(null);
            }
            bool            flag     = pawn.HostileTo(Faction.OfPlayer);
            CellRect        cellRect = CellRect.CenteredOn(pawn.Position, 5);
            List <Building> list     = map.listerBuildings.allBuildingsColonist.FindAll(x => x.TryGetComp <CompPowerPlant>() != null || x.TryGetComp <CompPowerBattery>() != null);

            for (int i = 0; i < 35; i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                if (randomCell.InBounds(pawn.Map))
                {
                    Building edifice = randomCell.GetEdifice(pawn.Map);
                    if (flag)
                    {
                        if (edifice != null && TrashUtility.ShouldTrashBuilding(pawn, edifice, false) && GenSight.LineOfSight(pawn.Position, randomCell, pawn.Map, false, null, 0, 0) && (edifice.TryGetComp <CompPowerPlant>() != null || edifice.TryGetComp <CompPowerBattery>() != null || edifice.TryGetComp <CompPowerTransmitter>() != null))
                        {
                            if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                            {
                                Find.CurrentMap.debugDrawer.FlashCell(randomCell, 1f, "trash bld", 50);
                            }
                            Job job;

                            Building building = edifice as Building;
                            bool     flagb    = building != null && building.def.building.isInert;
                            if (flagb)
                            {
                                return(null);
                            }
                            job = new Job(JobDefOf.AttackMelee, edifice);
                            if (job != null)
                            {
                                return(job);
                            }
                        }
                    }
                    if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map)
                    {
                        Find.CurrentMap.debugDrawer.FlashCell(randomCell, 0f, "trash no", 50);
                    }
                }
            }
            return(null);
        }
예제 #3
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            List <Building> allBuildingsColonist = pawn.Map.listerBuildings.allBuildingsColonist;

            if (allBuildingsColonist.Count == 0)
            {
                return(null);
            }
            for (int i = 0; i < 75; i++)
            {
                Building building = allBuildingsColonist.RandomElement <Building>();
                if (TrashUtility.ShouldTrashBuilding(pawn, building, this.attackAllInert))
                {
                    return(TrashUtility.TrashJob(pawn, building));
                }
            }
            return(null);
        }