// Token: 0x0600000B RID: 11 RVA: 0x00002BFC File Offset: 0x00000DFC
        protected override Job TryGiveJob(Pawn pawn)
        {
            Region region = pawn.GetRegion(RegionType.Set_Passable);
            bool   flag   = region == null;
            Job    result;

            if (flag)
            {
                result = null;
            }
            else
            {
                IntVec3         position             = pawn.Position;
                Building        firstBuilding        = position.GetFirstBuilding(pawn.Map);
                List <Building> allBuildingsColonist = pawn.Map.listerBuildings.allBuildingsColonist;
                for (int i = 0; i < allBuildingsColonist.Count; i++)
                {
                    Building building = allBuildingsColonist[i];
                    foreach (Designation designation in pawn.Map.designationManager.AllDesignationsOn(building))
                    {
                        bool flag2 = building.Faction == pawn.Faction && designation.def == DesignationDefOf.Deconstruct && pawn.CanReserve(building, 1, -1, null, false);
                        if (flag2)
                        {
                            return(new Job(WPJobDefOf.WPDeconstruct, building));
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
Ejemplo n.º 2
0
        // Token: 0x06000015 RID: 21 RVA: 0x00003104 File Offset: 0x00001304
        protected override Job TryGiveJob(Pawn pawn)
        {
            Region region = pawn.GetRegion(RegionType.Set_Passable);
            bool   flag   = region == null;
            Job    result;

            if (flag)
            {
                result = null;
            }
            else
            {
                IntVec3      position      = pawn.Position;
                Building     firstBuilding = position.GetFirstBuilding(pawn.Map);
                List <Thing> list          = pawn.Map.listerBuildingsRepairable.RepairableBuildings(pawn.Faction);
                for (int i = 0; i < list.Count; i++)
                {
                    Thing thing = list[i];
                    bool  flag2 = thing.Faction == pawn.Faction && thing.def.useHitPoints && thing.HitPoints != thing.MaxHitPoints && thing.def.building.repairable && pawn.CanReserve(thing, 1, -1, null, false);
                    if (flag2)
                    {
                        return(new Job(WPJobDefOf.WPRepair, thing));
                    }
                }
                result = null;
            }
            return(result);
        }
Ejemplo n.º 3
0
        public void Notify_TerrainDestroyed(IntVec3 c)
        {
            TerrainDef terrainDef = this.TerrainAt(c);

            this.RemoveTopLayer(c, false);
            if (terrainDef.destroyBuildingsOnDestroyed)
            {
                Building firstBuilding = c.GetFirstBuilding(this.map);
                if (firstBuilding != null)
                {
                    firstBuilding.Kill(null, null);
                }
            }
            if (terrainDef.destroyEffectWater != null && this.TerrainAt(c) != null && this.TerrainAt(c).IsWater)
            {
                Effecter effecter = terrainDef.destroyEffectWater.Spawn();
                effecter.Trigger(new TargetInfo(c, this.map, false), new TargetInfo(c, this.map, false));
                effecter.Cleanup();
            }
            else if (terrainDef.destroyEffect != null)
            {
                Effecter effecter2 = terrainDef.destroyEffect.Spawn();
                effecter2.Trigger(new TargetInfo(c, this.map, false), new TargetInfo(c, this.map, false));
                effecter2.Cleanup();
            }
        }
Ejemplo n.º 4
0
 public void Notify_TerrainDestroyed(IntVec3 c)
 {
     if (CanRemoveTopLayerAt(c))
     {
         TerrainDef terrainDef = TerrainAt(c);
         RemoveTopLayer(c, doLeavings: false);
         if (terrainDef.destroyBuildingsOnDestroyed)
         {
             c.GetFirstBuilding(map)?.Kill();
         }
         if (terrainDef.destroyEffectWater != null && TerrainAt(c) != null && TerrainAt(c).IsWater)
         {
             Effecter effecter = terrainDef.destroyEffectWater.Spawn();
             effecter.Trigger(new TargetInfo(c, map), new TargetInfo(c, map));
             effecter.Cleanup();
         }
         else if (terrainDef.destroyEffect != null)
         {
             Effecter effecter2 = terrainDef.destroyEffect.Spawn();
             effecter2.Trigger(new TargetInfo(c, map), new TargetInfo(c, map));
             effecter2.Cleanup();
         }
         ThingUtility.CheckAutoRebuildTerrainOnDestroyed(terrainDef, c, map);
     }
 }
Ejemplo n.º 5
0
        public static bool TryFindSkyfallerCell(ThingDef skyfaller, Map map, out IntVec3 cell, int minDistToEdge = 10, IntVec3 nearLoc = default(IntVec3), int nearLocMaxDist = -1, bool allowRoofedCells = true, bool allowCellsWithItems = false, bool allowCellsWithBuildings = false, bool colonyReachable = false, bool avoidColonistsIfExplosive = true, bool alwaysAvoidColonists = false, Predicate <IntVec3> extraValidator = null)
        {
            bool avoidColonists           = (avoidColonistsIfExplosive && skyfaller.skyfaller.CausesExplosion) || alwaysAvoidColonists;
            Predicate <IntVec3> validator = delegate(IntVec3 x)
            {
                CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, skyfaller.size).GetIterator();
                while (!iterator.Done())
                {
                    IntVec3 current = iterator.Current;
                    if (!current.InBounds(map) || current.Fogged(map) || !current.Standable(map) || (current.Roofed(map) && current.GetRoof(map).isThickRoof))
                    {
                        return(false);
                    }
                    if (!allowRoofedCells && current.Roofed(map))
                    {
                        return(false);
                    }
                    if (!allowCellsWithItems && current.GetFirstItem(map) != null)
                    {
                        return(false);
                    }
                    if (!allowCellsWithBuildings && current.GetFirstBuilding(map) != null)
                    {
                        return(false);
                    }
                    if (current.GetFirstSkyfaller(map) != null)
                    {
                        return(false);
                    }
                    iterator.MoveNext();
                }
                if (avoidColonists && SkyfallerUtility.CanPossiblyFallOnColonist(skyfaller, x, map))
                {
                    return(false);
                }
                if (minDistToEdge > 0 && x.DistanceToEdge(map) < minDistToEdge)
                {
                    return(false);
                }
                if (colonyReachable && !map.reachability.CanReachColony(x))
                {
                    return(false);
                }
                if (extraValidator != null && !extraValidator(x))
                {
                    return(false);
                }
                return(true);
            };

            if (nearLocMaxDist > 0)
            {
                return(CellFinder.TryFindRandomCellNear(nearLoc, map, nearLocMaxDist, validator, out cell));
            }
            return(TryFindRandomNotEdgeCellWith(minDistToEdge, validator, map, out cell));
        }
Ejemplo n.º 6
0
        public static bool TryFindSkyfallerCell(ThingDef skyfaller, Map map, out IntVec3 cell, int minDistToEdge = 10, IntVec3 nearLoc = default(IntVec3), int nearLocMaxDist = -1, bool allowRoofedCells = true, bool allowCellsWithItems = false, bool allowCellsWithBuildings = false, bool colonyReachable = false, bool avoidColonistsIfExplosive = true, bool alwaysAvoidColonists = false, Predicate <IntVec3> extraValidator = null)
        {
            bool avoidColonists           = (avoidColonistsIfExplosive && skyfaller.skyfaller.CausesExplosion) || alwaysAvoidColonists;
            Predicate <IntVec3> validator = delegate(IntVec3 x)
            {
                CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, skyfaller.size).GetIterator();
                while (!iterator.Done())
                {
                    IntVec3 c = iterator.Current;
                    bool    result2;
                    if (!c.InBounds(map) || c.Fogged(map) || !c.Standable(map) || (c.Roofed(map) && c.GetRoof(map).isThickRoof))
                    {
                        result2 = false;
                    }
                    else if (!allowRoofedCells && c.Roofed(map))
                    {
                        result2 = false;
                    }
                    else if (!allowCellsWithItems && c.GetFirstItem(map) != null)
                    {
                        result2 = false;
                    }
                    else if (!allowCellsWithBuildings && c.GetFirstBuilding(map) != null)
                    {
                        result2 = false;
                    }
                    else
                    {
                        if (c.GetFirstSkyfaller(map) == null)
                        {
                            iterator.MoveNext();
                            continue;
                        }
                        result2 = false;
                    }
                    return(result2);
                }
                return((!avoidColonists || !SkyfallerUtility.CanPossiblyFallOnColonist(skyfaller, x, map)) && (minDistToEdge <= 0 || x.DistanceToEdge(map) >= minDistToEdge) && (!colonyReachable || map.reachability.CanReachColony(x)) && (extraValidator == null || extraValidator(x)));
            };
            bool result;

            if (nearLocMaxDist > 0)
            {
                result = CellFinder.TryFindRandomCellNear(nearLoc, map, nearLocMaxDist, validator, out cell, -1);
            }
            else
            {
                result = CellFinderLoose.TryFindRandomNotEdgeCellWith(minDistToEdge, validator, map, out cell);
            }
            return(result);
        }
Ejemplo n.º 7
0
        public static bool TryFindSkyfallerCell(ThingDef skyfaller, Map map, out IntVec3 cell, int minDistToEdge = 10, IntVec3 nearLoc = default(IntVec3), int nearLocMaxDist = -1, bool allowRoofedCells = true, bool allowCellsWithItems = false, bool allowCellsWithBuildings = false, bool colonyReachable = false, Predicate <IntVec3> extraValidator = null)
        {
            Predicate <IntVec3> validator = delegate(IntVec3 x)
            {
                CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, skyfaller.size).GetIterator();
                while (!iterator.Done())
                {
                    IntVec3 current = iterator.Current;
                    if (!current.InBounds(map) || current.Fogged(map) || !current.Standable(map) || (current.Roofed(map) && current.GetRoof(map).isThickRoof))
                    {
                        return(false);
                    }
                    if (!allowRoofedCells && current.Roofed(map))
                    {
                        return(false);
                    }
                    if (!allowCellsWithItems && current.GetFirstItem(map) != null)
                    {
                        return(false);
                    }
                    if (!allowCellsWithBuildings && current.GetFirstBuilding(map) != null)
                    {
                        return(false);
                    }
                    if (current.GetFirstSkyfaller(map) != null)
                    {
                        return(false);
                    }
                    iterator.MoveNext();
                }
                return((minDistToEdge <= 0 || x.DistanceToEdge(map) >= minDistToEdge) && (!colonyReachable || map.reachability.CanReachColony(x)) && (extraValidator == null || extraValidator(x)));
            };

            if (nearLocMaxDist > 0)
            {
                return(CellFinder.TryFindRandomCellNear(nearLoc, map, nearLocMaxDist, validator, out cell));
            }
            return(CellFinderLoose.TryFindRandomNotEdgeCellWith(minDistToEdge, validator, map, out cell));
        }
Ejemplo n.º 8
0
        // Token: 0x0600000D RID: 13 RVA: 0x00002D24 File Offset: 0x00000F24
        protected override Job TryGiveJob(Pawn pawn)
        {
            Region region = pawn.GetRegion(RegionType.Set_Passable);
            bool   flag   = region == null;
            Job    result;

            if (flag)
            {
                result = null;
            }
            else
            {
                for (int i = 0; i < 40; i++)
                {
                    IntVec3 randomCell = region.RandomCell;
                    for (int j = 0; j < 4; j++)
                    {
                        IntVec3 c             = randomCell + GenAdj.CardinalDirections[j];
                        Thing   firstBuilding = c.GetFirstBuilding(pawn.Map);
                        using (IEnumerator <Designation> enumerator = pawn.Map.designationManager.AllDesignationsOn(firstBuilding).GetEnumerator())
                        {
                            if (enumerator.MoveNext())
                            {
                                Designation designation = enumerator.Current;
                                bool        flag2       = designation.def == DesignationDefOf.Flick && pawn.CanReserve(firstBuilding, 1, -1, null, false);
                                if (flag2)
                                {
                                    return(new Job(JobDefOf.Flick, firstBuilding));
                                }
                                return(null);
                            }
                        }
                    }
                }
                result = null;
            }
            return(result);
        }