コード例 #1
0
        // Token: 0x060000E5 RID: 229 RVA: 0x00007BFC File Offset: 0x00005DFC
        public static Thing FirstBlockingThing(Thing constructible, Pawn pawnToIgnore)
        {
            Blueprint blueprint = constructible as Blueprint;
            bool      flag      = blueprint != null;
            Thing     thing;

            if (flag)
            {
                thing = WPGenConstruct.MiniToInstallOrBuildingToReinstall(blueprint);
            }
            else
            {
                thing = null;
            }
            foreach (IntVec3 c in constructible.OccupiedRect())
            {
                List <Thing> thingList = c.GetThingList(constructible.Map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing2 = thingList[i];
                    bool  flag2  = WPGenConstruct.BlocksConstruction(constructible, thing2) && thing2 != pawnToIgnore && thing2 != thing;
                    if (flag2)
                    {
                        return(thing2);
                    }
                }
            }
            return(null);
        }
        // Token: 0x06000084 RID: 132 RVA: 0x0000525C File Offset: 0x0000345C
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            bool flag = t.Faction != pawn.Faction;
            Job  result;

            if (flag)
            {
                result = null;
            }
            else
            {
                Frame frame = t as Frame;
                bool  flag2 = frame == null;
                if (flag2)
                {
                    result = null;
                }
                else
                {
                    bool flag3 = WPGenConstruct.FirstBlockingThing(frame, pawn) != null;
                    if (flag3)
                    {
                        result = WPGenConstruct.HandleBlockingThingJob(frame, pawn, false);
                    }
                    else
                    {
                        bool flag4 = !WPGenConstruct.CanConstruct(frame, pawn, forced);
                        if (flag4)
                        {
                            result = null;
                        }
                        else
                        {
                            bool flag5 = !pawn.CanReserve(t, 1, -1, null, false);
                            if (flag5)
                            {
                                result = null;
                            }
                            else
                            {
                                bool flag6 = !pawn.CanReserveAndReach(t, PathEndMode.Touch, Danger.Deadly, 1, -1, null, forced);
                                if (flag6)
                                {
                                    result = null;
                                }
                                else
                                {
                                    result = base.ResourceDeliverJobFor(pawn, frame, true);
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
コード例 #3
0
        // Token: 0x06000080 RID: 128 RVA: 0x00005088 File Offset: 0x00003288
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            bool flag = t.Faction != pawn.Faction;
            Job  result;

            if (flag)
            {
                result = null;
            }
            else
            {
                Blueprint blueprint = t as Blueprint;
                bool      flag2     = blueprint == null;
                if (flag2)
                {
                    result = null;
                }
                else
                {
                    bool flag3 = WPGenConstruct.FirstBlockingThing(blueprint, pawn) != null;
                    if (flag3)
                    {
                        result = WPGenConstruct.HandleBlockingThingJob(blueprint, pawn, false);
                    }
                    else
                    {
                        bool flag4 = !WPGenConstruct.CanConstruct(blueprint, pawn, forced);
                        if (flag4)
                        {
                            result = null;
                        }
                        else
                        {
                            bool flag5 = !pawn.CanReserve(blueprint, 1, -1, null, false);
                            if (flag5)
                            {
                                result = null;
                            }
                            else
                            {
                                bool flag6 = !pawn.CanReserve(t, 1, -1, null, false);
                                if (flag6)
                                {
                                    result = null;
                                }
                                else
                                {
                                    bool flag7 = WorkGiver_WPConstructDeliverResources.ShouldRemoveExistingFloorFirst(pawn, blueprint);
                                    if (flag7)
                                    {
                                        result = null;
                                    }
                                    else
                                    {
                                        Job  job   = base.RemoveExistingFloorJob(pawn, blueprint);
                                        bool flag8 = job != null;
                                        if (flag8)
                                        {
                                            result = job;
                                        }
                                        else
                                        {
                                            Job  job2  = base.ResourceDeliverJobFor(pawn, blueprint, true);
                                            bool flag9 = job2 != null;
                                            if (flag9)
                                            {
                                                result = job2;
                                            }
                                            else
                                            {
                                                bool flag10 = this.def.workType != WorkTypeDefOf.Hauling;
                                                if (flag10)
                                                {
                                                    Job  job3   = this.NoCostFrameMakeJobFor(pawn, blueprint);
                                                    bool flag11 = job3 != null;
                                                    if (flag11)
                                                    {
                                                        return(job3);
                                                    }
                                                }
                                                result = null;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
コード例 #4
0
        // Token: 0x060000E6 RID: 230 RVA: 0x00007CD8 File Offset: 0x00005ED8
        public static Job HandleBlockingThingJob(Thing constructible, Pawn worker, bool forced = false)
        {
            Thing thing = WPGenConstruct.FirstBlockingThing(constructible, worker);
            bool  flag  = thing == null;
            Job   result;

            if (flag)
            {
                result = null;
            }
            else
            {
                bool flag2 = thing.def.category == ThingCategory.Plant;
                if (flag2)
                {
                    LocalTargetInfo target    = thing;
                    PathEndMode     peMode    = PathEndMode.ClosestTouch;
                    Danger          maxDanger = worker.NormalMaxDanger();
                    bool            flag3     = worker.CanReserveAndReach(target, peMode, maxDanger, 1, -1, null, forced);
                    if (flag3)
                    {
                        return(new Job(JobDefOf.CutPlant, thing));
                    }
                }
                else
                {
                    bool flag4 = thing.def.category == ThingCategory.Item;
                    if (flag4)
                    {
                        bool everHaulable = thing.def.EverHaulable;
                        if (everHaulable)
                        {
                            return(HaulAIUtility.HaulAsideJobFor(worker, thing));
                        }
                        Log.ErrorOnce(string.Concat(new object[]
                        {
                            "Never haulable ",
                            thing,
                            " blocking ",
                            constructible.ToStringSafe <Thing>(),
                            " at ",
                            constructible.Position
                        }), 6429262, false);
                    }
                    else
                    {
                        bool flag5 = thing.def.category == ThingCategory.Building;
                        if (flag5)
                        {
                            LocalTargetInfo target2    = thing;
                            PathEndMode     peMode2    = PathEndMode.Touch;
                            Danger          maxDanger2 = worker.NormalMaxDanger();
                            bool            flag6      = worker.CanReserveAndReach(target2, peMode2, maxDanger2, 1, -1, null, forced) && worker.RaceProps.Animal;
                            if (flag6)
                            {
                                return(new Job(WPJobDefOf.WPDeconstruct, thing)
                                {
                                    ignoreDesignations = true
                                });
                            }
                            bool flag7 = worker.CanReserveAndReach(target2, peMode2, maxDanger2, 1, -1, null, forced) && !worker.RaceProps.Animal;
                            if (flag7)
                            {
                                return(new Job(JobDefOf.Deconstruct, thing)
                                {
                                    ignoreDesignations = true
                                });
                            }
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
コード例 #5
0
        // Token: 0x060000E4 RID: 228 RVA: 0x0000799C File Offset: 0x00005B9C
        public static bool CanPlaceBlueprintOver(BuildableDef newDef, ThingDef oldDef)
        {
            bool everHaulable = oldDef.EverHaulable;
            bool result;

            if (everHaulable)
            {
                result = true;
            }
            else
            {
                TerrainDef terrainDef = newDef as TerrainDef;
                bool       flag       = terrainDef != null;
                if (flag)
                {
                    bool flag2 = oldDef.category == ThingCategory.Building && !terrainDef.affordances.Contains(oldDef.terrainAffordanceNeeded);
                    if (flag2)
                    {
                        return(false);
                    }
                    bool flag3 = (oldDef.IsBlueprint || oldDef.IsFrame) && !terrainDef.affordances.Contains(oldDef.entityDefToBuild.terrainAffordanceNeeded);
                    if (flag3)
                    {
                        return(false);
                    }
                }
                ThingDef     thingDef     = newDef as ThingDef;
                BuildableDef buildableDef = WPGenConstruct.BuiltDefOf(oldDef);
                ThingDef     thingDef2    = buildableDef as ThingDef;
                bool         flag4        = oldDef == ThingDefOf.SteamGeyser && !newDef.ForceAllowPlaceOver(oldDef);
                if (flag4)
                {
                    result = false;
                }
                else
                {
                    bool flag5 = oldDef.category == ThingCategory.Plant && oldDef.passability == Traversability.Impassable && thingDef != null && thingDef.category == ThingCategory.Building && !thingDef.building.canPlaceOverImpassablePlant;
                    if (flag5)
                    {
                        result = false;
                    }
                    else
                    {
                        bool flag6 = oldDef.category == ThingCategory.Building || oldDef.IsBlueprint || oldDef.IsFrame;
                        if (flag6)
                        {
                            bool flag7 = thingDef != null;
                            if (flag7)
                            {
                                bool flag8 = !thingDef.IsEdifice();
                                if (flag8)
                                {
                                    return((oldDef.building == null || oldDef.building.canBuildNonEdificesUnder) && (!thingDef.EverTransmitsPower || !oldDef.EverTransmitsPower));
                                }
                                bool flag9 = thingDef.IsEdifice() && oldDef != null && oldDef.category == ThingCategory.Building && !oldDef.IsEdifice();
                                if (flag9)
                                {
                                    return(thingDef.building == null || thingDef.building.canBuildNonEdificesUnder);
                                }
                                bool flag10 = thingDef2 != null && thingDef2 == ThingDefOf.Wall && thingDef.building != null && thingDef.building.canPlaceOverWall;
                                if (flag10)
                                {
                                    return(true);
                                }
                                bool flag11 = newDef != ThingDefOf.PowerConduit && buildableDef == ThingDefOf.PowerConduit;
                                if (flag11)
                                {
                                    return(true);
                                }
                            }
                            result = ((newDef is TerrainDef && buildableDef is ThingDef && ((ThingDef)buildableDef).CoexistsWithFloors) || (buildableDef is TerrainDef && !(newDef is TerrainDef)));
                        }
                        else
                        {
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }
コード例 #6
0
        // Token: 0x060000E2 RID: 226 RVA: 0x000071D4 File Offset: 0x000053D4
        public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null, Thing thing = null, ThingDef stuffDef = null)
        {
            CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size);
            bool     flag     = stuffDef == null && thing != null;

            if (flag)
            {
                stuffDef = thing.Stuff;
            }
            foreach (IntVec3 c in cellRect)
            {
                bool flag2 = !c.InBounds(map);
                if (flag2)
                {
                    return(new AcceptanceReport("OutOfBounds".Translate()));
                }
                bool flag3 = c.InNoBuildEdgeArea(map) && !godMode;
                if (flag3)
                {
                    return("TooCloseToMapEdge".Translate());
                }
            }
            bool             flag4 = center.Fogged(map);
            AcceptanceReport result;

            if (flag4)
            {
                result = "CannotPlaceInUndiscovered".Translate();
            }
            else
            {
                List <Thing> thingList = center.GetThingList(map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing2 = thingList[i];
                    bool  flag5  = thing2 != thingToIgnore && thing2.Position == center && thing2.Rotation == rot;
                    if (flag5)
                    {
                        bool flag6 = thing2.def == entDef;
                        if (flag6)
                        {
                            return(new AcceptanceReport("IdenticalThingExists".Translate()));
                        }
                        bool flag7 = thing2.def.entityDefToBuild == entDef;
                        if (flag7)
                        {
                            bool flag8 = thing2 is Blueprint;
                            if (flag8)
                            {
                                return(new AcceptanceReport("IdenticalBlueprintExists".Translate()));
                            }
                            return(new AcceptanceReport("IdenticalThingExists".Translate()));
                        }
                    }
                }
                ThingDef thingDef = entDef as ThingDef;
                bool     flag9    = thingDef != null && thingDef.hasInteractionCell;
                if (flag9)
                {
                    IntVec3 c2     = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map);
                    bool    flag10 = !c2.InBounds(map);
                    if (flag10)
                    {
                        return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate()));
                    }
                    List <Thing> list = map.thingGrid.ThingsListAtFast(c2);
                    for (int j = 0; j < list.Count; j++)
                    {
                        bool flag11 = list[j] != thingToIgnore;
                        if (flag11)
                        {
                            bool flag12 = list[j].def.passability == Traversability.Impassable || list[j].def == thingDef;
                            if (flag12)
                            {
                                return(new AcceptanceReport("InteractionSpotBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst()));
                            }
                            BuildableDef entityDefToBuild = list[j].def.entityDefToBuild;
                            bool         flag13           = entityDefToBuild != null && (entityDefToBuild.passability == Traversability.Impassable || entityDefToBuild == thingDef);
                            if (flag13)
                            {
                                return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(list[j].LabelNoCount, list[j]).CapitalizeFirst()));
                            }
                        }
                    }
                }
                foreach (IntVec3 c3 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size))
                {
                    bool flag14 = c3.InBounds(map);
                    if (flag14)
                    {
                        thingList = c3.GetThingList(map);
                        for (int k = 0; k < thingList.Count; k++)
                        {
                            Thing thing3 = thingList[k];
                            bool  flag15 = thing3 != thingToIgnore;
                            if (flag15)
                            {
                                Blueprint blueprint = thing3 as Blueprint;
                                bool      flag16    = blueprint != null;
                                ThingDef  thingDef3;
                                if (flag16)
                                {
                                    ThingDef thingDef2 = blueprint.def.entityDefToBuild as ThingDef;
                                    bool     flag17    = thingDef2 == null;
                                    if (flag17)
                                    {
                                        goto IL_48F;
                                    }
                                    thingDef3 = thingDef2;
                                }
                                else
                                {
                                    thingDef3 = thing3.def;
                                }
                                bool flag18 = thingDef3.hasInteractionCell && (entDef.passability == Traversability.Impassable || entDef == thingDef3) && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef3, thing3.Position, thing3.Rotation, thing3.Map));
                                if (flag18)
                                {
                                    return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(entDef.label, thingDef3.label).CapitalizeFirst()));
                                }
                            }
                            IL_48F :;
                        }
                    }
                }
                TerrainDef terrainDef = entDef as TerrainDef;
                bool       flag19     = terrainDef != null;
                if (flag19)
                {
                    bool flag20 = map.terrainGrid.TerrainAt(center) == terrainDef;
                    if (flag20)
                    {
                        return(new AcceptanceReport("TerrainIsAlready".Translate(terrainDef.label)));
                    }
                    bool flag21 = map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null;
                    if (flag21)
                    {
                        return(new AcceptanceReport("SpaceBeingSmoothed".Translate()));
                    }
                }
                bool flag22 = WPGenConstruct.CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore, stuffDef);
                if (flag22)
                {
                    bool flag23 = !godMode;
                    if (flag23)
                    {
                        foreach (IntVec3 c4 in cellRect)
                        {
                            thingList = c4.GetThingList(map);
                            for (int l = 0; l < thingList.Count; l++)
                            {
                                Thing thing4 = thingList[l];
                                bool  flag24 = thing4 != thingToIgnore && !WPGenConstruct.CanPlaceBlueprintOver(entDef, thing4.def);
                                if (flag24)
                                {
                                    return(new AcceptanceReport("SpaceAlreadyOccupied".Translate()));
                                }
                            }
                        }
                    }
                    bool flag25 = entDef.PlaceWorkers != null;
                    if (flag25)
                    {
                        for (int m = 0; m < entDef.PlaceWorkers.Count; m++)
                        {
                            AcceptanceReport result2 = entDef.PlaceWorkers[m].AllowsPlacing(entDef, center, rot, map, thingToIgnore, thing);
                            bool             flag26  = !result2.Accepted;
                            if (flag26)
                            {
                                return(result2);
                            }
                        }
                    }
                    result = AcceptanceReport.WasAccepted;
                }
                else
                {
                    bool flag27 = entDef.GetTerrainAffordanceNeed(stuffDef) == null;
                    if (flag27)
                    {
                        result = new AcceptanceReport("TerrainCannotSupport".Translate(entDef).CapitalizeFirst());
                    }
                    else
                    {
                        bool flag28 = entDef.useStuffTerrainAffordance && stuffDef != null;
                        if (flag28)
                        {
                            result = new AcceptanceReport("TerrainCannotSupport_TerrainAffordanceFromStuff".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef), stuffDef).CapitalizeFirst());
                        }
                        else
                        {
                            result = new AcceptanceReport("TerrainCannotSupport_TerrainAffordance".Translate(entDef, entDef.GetTerrainAffordanceNeed(stuffDef)).CapitalizeFirst());
                        }
                    }
                }
            }
            return(result);
        }