Ejemplo n.º 1
0
        private Job InstallJob(Pawn pawn, Blueprint_Install install)
        {
            Thing miniToInstallOrBuildingToReinstall = install.MiniToInstallOrBuildingToReinstall;

            if (miniToInstallOrBuildingToReinstall.IsForbidden(pawn))
            {
                JobFailReason.Is(WorkGiver_ConstructDeliverResources.ForbiddenLowerTranslated, null);
                return(null);
            }
            if (!pawn.CanReach(miniToInstallOrBuildingToReinstall, PathEndMode.ClosestTouch, pawn.NormalMaxDanger(), false, TraverseMode.ByPawn))
            {
                JobFailReason.Is(WorkGiver_ConstructDeliverResources.NoPathTranslated, null);
                return(null);
            }
            if (!pawn.CanReserve(miniToInstallOrBuildingToReinstall, 1, -1, null, false))
            {
                Pawn pawn2 = pawn.Map.reservationManager.FirstRespectedReserver(miniToInstallOrBuildingToReinstall, pawn);
                if (pawn2 != null)
                {
                    JobFailReason.Is("ReservedBy".Translate(pawn2.LabelShort, pawn2), null);
                }
                return(null);
            }
            return(new Job(JobDefOf.HaulToContainer)
            {
                targetA = miniToInstallOrBuildingToReinstall,
                targetB = install,
                count = 1,
                haulMode = HaulMode.ToContainer
            });
        }
        private Job InstallJob(Pawn pawn, Blueprint_Install install)
        {
            Thing miniToInstallOrBuildingToReinstall = install.MiniToInstallOrBuildingToReinstall;

            if (miniToInstallOrBuildingToReinstall.IsForbidden(pawn))
            {
                JobFailReason.Is(ForbiddenLowerTranslated);
                return(null);
            }
            if (!pawn.CanReach(miniToInstallOrBuildingToReinstall, PathEndMode.ClosestTouch, pawn.NormalMaxDanger()))
            {
                JobFailReason.Is(NoPathTranslated);
                return(null);
            }
            if (!pawn.CanReserve(miniToInstallOrBuildingToReinstall))
            {
                Pawn pawn2 = pawn.Map.reservationManager.FirstRespectedReserver(miniToInstallOrBuildingToReinstall, pawn);
                if (pawn2 != null)
                {
                    JobFailReason.Is("ReservedBy".Translate(pawn2.LabelShort, pawn2));
                }
                return(null);
            }
            Job job = new Job(JobDefOf.HaulToContainer);

            job.targetA  = miniToInstallOrBuildingToReinstall;
            job.targetB  = install;
            job.count    = 1;
            job.haulMode = HaulMode.ToContainer;
            return(job);
        }
Ejemplo n.º 3
0
        public static MinifiedThing MakeMinified(this Thing thing)
        {
            if (!thing.def.Minifiable)
            {
                Log.Warning("Tried to minify " + thing + " which is not minifiable.");
                return(null);
            }
            if (thing.Spawned)
            {
                thing.DeSpawn();
            }
            if (thing.holdingOwner != null)
            {
                Log.Warning("Can't minify thing which is in a ThingOwner because we don't know how to handle it. Remove it from the container first. holder=" + thing.ParentHolder);
                return(null);
            }
            Blueprint_Install blueprint_Install = InstallBlueprintUtility.ExistingBlueprintFor(thing);
            MinifiedThing     minifiedThing     = (MinifiedThing)ThingMaker.MakeThing(thing.def.minifiedDef, null);

            minifiedThing.InnerThing = thing;
            if (blueprint_Install != null)
            {
                blueprint_Install.SetThingToInstallFromMinified(minifiedThing);
            }
            if (minifiedThing.InnerThing.stackCount > 1)
            {
                Log.Warning("Tried to minify " + thing.LabelCap + " with stack count " + minifiedThing.InnerThing.stackCount + ". Clamped stack count to 1.");
                minifiedThing.InnerThing.stackCount = 1;
            }
            return(minifiedThing);
        }
        public static Blueprint_Install ExistingBlueprintFor(Thing th)
        {
            ThingDef          installBlueprintDef = th.GetInnerIfMinified().def.installBlueprintDef;
            Blueprint_Install result;

            if (installBlueprintDef == null)
            {
                result = null;
            }
            else
            {
                List <Map> maps = Find.Maps;
                for (int i = 0; i < maps.Count; i++)
                {
                    List <Thing> list = maps[i].listerThings.ThingsMatching(ThingRequest.ForDef(installBlueprintDef));
                    for (int j = 0; j < list.Count; j++)
                    {
                        Blueprint_Install blueprint_Install = list[j] as Blueprint_Install;
                        if (blueprint_Install != null && blueprint_Install.MiniToInstallOrBuildingToReinstall == th)
                        {
                            return(blueprint_Install);
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
Ejemplo n.º 5
0
        public void DrawGhost_NewTmp(IntVec3 at, bool placingMode, Rot4 rotation)
        {
            CellRect          rect          = sketch.OccupiedRect.MovedBy(at);
            Blueprint_Install thingToIgnore = FindMyBlueprint(rect, Find.CurrentMap);

            sketch.Rotate(rotation);
            sketch.DrawGhost(at, Sketch.SpawnPosType.Unchanged, placingMode, thingToIgnore);
        }
Ejemplo n.º 6
0
        public static Blueprint_Install PlaceBlueprintForReinstall(Building buildingToReinstall, IntVec3 center, Map map, Rot4 rotation, Faction faction)
        {
            Blueprint_Install obj = (Blueprint_Install)ThingMaker.MakeThing(buildingToReinstall.def.installBlueprintDef);

            obj.SetBuildingToReinstall(buildingToReinstall);
            obj.SetFactionDirect(faction);
            GenSpawn.Spawn(obj, center, map, rotation);
            return(obj);
        }
Ejemplo n.º 7
0
        public static Blueprint_Install PlaceBlueprintForInstall(MinifiedThing itemToInstall, IntVec3 center, Map map, Rot4 rotation, Faction faction)
        {
            Blueprint_Install obj = (Blueprint_Install)ThingMaker.MakeThing(itemToInstall.InnerThing.def.installBlueprintDef);

            obj.SetThingToInstallFromMinified(itemToInstall);
            obj.SetFactionDirect(faction);
            GenSpawn.Spawn(obj, center, map, rotation);
            return(obj);
        }
        public static Blueprint_Install PlaceBlueprintForInstall(MinifiedThing itemToInstall, IntVec3 center, Map map, Rot4 rotation, Faction faction)
        {
            Blueprint_Install blueprint_Install = (Blueprint_Install)ThingMaker.MakeThing(itemToInstall.InnerThing.def.installBlueprintDef, null);

            blueprint_Install.SetThingToInstallFromMinified(itemToInstall);
            blueprint_Install.SetFactionDirect(faction);
            GenSpawn.Spawn(blueprint_Install, center, map, rotation, WipeMode.Vanish, false);
            return(blueprint_Install);
        }
        public static Blueprint_Install PlaceBlueprintForReinstall(Building buildingToReinstall, IntVec3 center, Map map, Rot4 rotation, Faction faction)
        {
            Blueprint_Install blueprint_Install = (Blueprint_Install)ThingMaker.MakeThing(buildingToReinstall.def.installBlueprintDef, null);

            blueprint_Install.SetBuildingToReinstall(buildingToReinstall);
            blueprint_Install.SetFactionDirect(faction);
            GenSpawn.Spawn(blueprint_Install, center, map, rotation, WipeMode.Vanish, false);
            return(blueprint_Install);
        }
        public static void CancelBlueprintsFor(Thing th)
        {
            Blueprint_Install blueprint_Install = InstallBlueprintUtility.ExistingBlueprintFor(th);

            if (blueprint_Install != null)
            {
                blueprint_Install.Destroy(DestroyMode.Cancel);
            }
        }
        public static Thing MiniToInstallOrBuildingToReinstall(Blueprint b)
        {
            Blueprint_Install blueprint_Install = b as Blueprint_Install;

            if (blueprint_Install != null)
            {
                return(blueprint_Install.MiniToInstallOrBuildingToReinstall);
            }
            return(null);
        }
Ejemplo n.º 12
0
        public override void DrawExtraSelectionOverlays()
        {
            base.DrawExtraSelectionOverlays();
            Blueprint_Install blueprint_Install = InstallBlueprintUtility.ExistingBlueprintFor(this);

            if (blueprint_Install != null)
            {
                GenDraw.DrawLineBetween(this.TrueCenter(), blueprint_Install.TrueCenter());
            }
        }
Ejemplo n.º 13
0
        public void DrawGhost_NewTmp(IntVec3 at, bool placingMode, Rot4 rotation)
        {
            CellRect          rect          = sketch.OccupiedRect.MovedBy(at);
            Blueprint_Install thingToIgnore = FindMyBlueprint(rect, Find.CurrentMap);

            sketch.Rotate(rotation);
            Func <SketchEntity, IntVec3, List <Thing>, Map, bool> validator = null;

            if (placingMode)
            {
                validator = (SketchEntity entity, IntVec3 offset, List <Thing> things, Map map) => MonumentMarkerUtility.GetFirstAdjacentBuilding(entity, offset, things, map) == null;
            }
            sketch.DrawGhost_NewTmp(at, Sketch.SpawnPosType.Unchanged, placingMode, thingToIgnore, validator);
        }
Ejemplo n.º 14
0
        public static Thing MiniToInstallOrBuildingToReinstall(Blueprint b)
        {
            Blueprint_Install blueprint_Install = b as Blueprint_Install;
            Thing             result;

            if (blueprint_Install != null)
            {
                result = blueprint_Install.MiniToInstallOrBuildingToReinstall;
            }
            else
            {
                result = null;
            }
            return(result);
        }
        private Job InstallJob(Pawn pawn, Blueprint_Install install)
        {
            Thing miniToInstallOrBuildingToReinstall = install.MiniToInstallOrBuildingToReinstall;

            if (!miniToInstallOrBuildingToReinstall.IsForbidden(pawn) && pawn.CanReserveAndReach(miniToInstallOrBuildingToReinstall, PathEndMode.ClosestTouch, pawn.NormalMaxDanger(), 1, -1, null, false))
            {
                Job job = new Job(JobDefOf.HaulToContainer);
                job.targetA  = miniToInstallOrBuildingToReinstall;
                job.targetB  = install;
                job.count    = 1;
                job.haulMode = HaulMode.ToContainer;
                return(job);
            }
            return(null);
        }
Ejemplo n.º 16
0
        public static MinifiedThing MakeMinified(this Thing thing)
        {
            MinifiedThing result;

            if (!thing.def.Minifiable)
            {
                Log.Warning("Tried to minify " + thing + " which is not minifiable.", false);
                result = null;
            }
            else
            {
                if (thing.Spawned)
                {
                    thing.DeSpawn(DestroyMode.Vanish);
                }
                if (thing.holdingOwner != null)
                {
                    Log.Warning("Can't minify thing which is in a ThingOwner because we don't know how to handle it. Remove it from the container first. holder=" + thing.ParentHolder, false);
                    result = null;
                }
                else
                {
                    Blueprint_Install blueprint_Install = InstallBlueprintUtility.ExistingBlueprintFor(thing);
                    MinifiedThing     minifiedThing     = (MinifiedThing)ThingMaker.MakeThing(thing.def.minifiedDef, null);
                    minifiedThing.InnerThing = thing;
                    if (blueprint_Install != null)
                    {
                        blueprint_Install.SetThingToInstallFromMinified(minifiedThing);
                    }
                    if (minifiedThing.InnerThing.stackCount > 1)
                    {
                        Log.Warning(string.Concat(new object[]
                        {
                            "Tried to minify ",
                            thing.LabelCap,
                            " with stack count ",
                            minifiedThing.InnerThing.stackCount,
                            ". Clamped stack count to 1."
                        }), false);
                        minifiedThing.InnerThing.stackCount = 1;
                    }
                    result = minifiedThing;
                }
            }
            return(result);
        }
        // Token: 0x0600007C RID: 124 RVA: 0x00004F50 File Offset: 0x00003150
        private Job InstallJob(Pawn pawn, Blueprint_Install install)
        {
            Thing miniToInstallOrBuildingToReinstall = install.MiniToInstallOrBuildingToReinstall;
            bool  flag = miniToInstallOrBuildingToReinstall.IsForbidden(pawn);
            Job   result;

            if (flag)
            {
                JobFailReason.Is(WorkGiver_WPConstructDeliverResources.ForbiddenLowerTranslated, null);
                result = null;
            }
            else
            {
                bool flag2 = !pawn.CanReach(miniToInstallOrBuildingToReinstall, PathEndMode.ClosestTouch, pawn.NormalMaxDanger(), false, TraverseMode.ByPawn);
                if (flag2)
                {
                    JobFailReason.Is(WorkGiver_WPConstructDeliverResources.NoPathTranslated, null);
                    result = null;
                }
                else
                {
                    bool flag3 = !pawn.CanReserve(miniToInstallOrBuildingToReinstall, 1, -1, null, false);
                    if (flag3)
                    {
                        Pawn pawn2 = pawn.Map.reservationManager.FirstRespectedReserver(miniToInstallOrBuildingToReinstall, pawn);
                        bool flag4 = pawn2 != null;
                        if (flag4)
                        {
                            JobFailReason.Is("ReservedBy".Translate(pawn2.LabelShort, pawn2), null);
                        }
                        result = null;
                    }
                    else
                    {
                        Job job = JobMaker.MakeJob(JobDefOf.HaulToContainer);
                        job.targetA  = miniToInstallOrBuildingToReinstall;
                        job.targetB  = install;
                        job.count    = 1;
                        job.haulMode = HaulMode.ToContainer;
                        result       = job;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 18
0
 public Blueprint_Install FindMyBlueprint(CellRect rect, Map map)
 {
     foreach (IntVec3 item in rect)
     {
         if (item.InBounds(map))
         {
             List <Thing> thingList = item.GetThingList(map);
             for (int i = 0; i < thingList.Count; i++)
             {
                 Blueprint_Install blueprint_Install = thingList[i] as Blueprint_Install;
                 if (blueprint_Install != null && blueprint_Install.ThingToInstall == this)
                 {
                     return(blueprint_Install);
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 19
0
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
        {
            MonumentMarker monumentMarker = thing as MonumentMarker;

            if (monumentMarker != null)
            {
                CellRect          rect           = monumentMarker.sketch.OccupiedRect.MovedBy(loc);
                Blueprint_Install thingToIgnore2 = monumentMarker.FindMyBlueprint(rect, map);
                foreach (SketchEntity entity in monumentMarker.sketch.Entities)
                {
                    CellRect cellRect = entity.OccupiedRect.MovedBy(loc);
                    if (!cellRect.InBounds(map))
                    {
                        return(false);
                    }
                    if (cellRect.InNoBuildEdgeArea(map))
                    {
                        return("TooCloseToMapEdge".Translate());
                    }
                    foreach (IntVec3 item in cellRect)
                    {
                        if (!entity.CanBuildOnTerrain(item, map))
                        {
                            return("MonumentBadTerrain".Translate());
                        }
                    }
                    if (entity.IsSpawningBlockedPermanently(loc + entity.pos, map, thingToIgnore2))
                    {
                        return("MonumentBlockedPermanently".Translate());
                    }
                }
                tmpMonumentThings.Clear();
                foreach (SketchBuildable buildable in monumentMarker.sketch.Buildables)
                {
                    Thing       spawnedBlueprintOrFrame = buildable.GetSpawnedBlueprintOrFrame(loc + buildable.pos, map);
                    SketchThing sketchThing;
                    if (spawnedBlueprintOrFrame != null)
                    {
                        tmpMonumentThings.Add(spawnedBlueprintOrFrame);
                    }
                    else if ((sketchThing = (buildable as SketchThing)) != null)
                    {
                        Thing sameSpawned = sketchThing.GetSameSpawned(loc + sketchThing.pos, map);
                        if (sameSpawned != null)
                        {
                            tmpMonumentThings.Add(sameSpawned);
                        }
                    }
                }
                foreach (SketchEntity entity2 in monumentMarker.sketch.Entities)
                {
                    if (!entity2.IsSameSpawnedOrBlueprintOrFrame(loc + entity2.pos, map))
                    {
                        foreach (IntVec3 item2 in entity2.OccupiedRect.MovedBy(loc))
                        {
                            if (item2.InBounds(map))
                            {
                                Building firstBuilding = item2.GetFirstBuilding(map);
                                if (firstBuilding != null && !tmpMonumentThings.Contains(firstBuilding))
                                {
                                    tmpMonumentThings.Clear();
                                    return("MonumentOverlapsBuilding".Translate());
                                }
                            }
                        }
                    }
                }
                foreach (SketchEntity entity3 in monumentMarker.sketch.Entities)
                {
                    if (!entity3.IsSameSpawnedOrBlueprintOrFrame(loc + entity3.pos, map))
                    {
                        foreach (IntVec3 edgeCell in entity3.OccupiedRect.MovedBy(loc).ExpandedBy(1).EdgeCells)
                        {
                            if (edgeCell.InBounds(map))
                            {
                                Building firstBuilding2 = edgeCell.GetFirstBuilding(map);
                                if (firstBuilding2 != null && !tmpMonumentThings.Contains(firstBuilding2) && (firstBuilding2.Faction == null || firstBuilding2.Faction == Faction.OfPlayer))
                                {
                                    tmpMonumentThings.Clear();
                                    return("MonumentAdjacentToBuilding".Translate());
                                }
                            }
                        }
                    }
                }
                tmpMonumentThings.Clear();
            }
            return(true);
        }
        protected Job ResourceDeliverJobFor(Pawn pawn, IConstructible c, bool canRemoveExistingFloorUnderNearbyNeeders = true)
        {
            Blueprint_Install blueprint_Install = c as Blueprint_Install;

            if (blueprint_Install != null)
            {
                return(InstallJob(pawn, blueprint_Install));
            }
            bool flag = false;
            ThingDefCountClass        thingDefCountClass = null;
            List <ThingDefCountClass> list = c.MaterialsNeeded();
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                ThingDefCountClass need = list[i];
                if (!pawn.Map.itemAvailability.ThingsAvailableAnywhere(need, pawn))
                {
                    flag = true;
                    thingDefCountClass = need;
                    break;
                }
                Thing foundRes = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(need.thingDef), PathEndMode.ClosestTouch, TraverseParms.For(pawn), 9999f, (Thing r) => ResourceValidator(pawn, need, r));
                if (foundRes != null)
                {
                    FindAvailableNearbyResources(foundRes, pawn, out int resTotalAvailable);
                    int             neededTotal;
                    Job             jobToMakeNeederAvailable;
                    HashSet <Thing> hashSet = FindNearbyNeeders(pawn, need, c, resTotalAvailable, canRemoveExistingFloorUnderNearbyNeeders, out neededTotal, out jobToMakeNeederAvailable);
                    if (jobToMakeNeederAvailable != null)
                    {
                        return(jobToMakeNeederAvailable);
                    }
                    hashSet.Add((Thing)c);
                    Thing thing = hashSet.MinBy((Thing nee) => IntVec3Utility.ManhattanDistanceFlat(foundRes.Position, nee.Position));
                    hashSet.Remove(thing);
                    int num  = 0;
                    int num2 = 0;
                    do
                    {
                        num += resourcesAvailable[num2].stackCount;
                        num2++;
                    }while (num < neededTotal && num2 < resourcesAvailable.Count);
                    resourcesAvailable.RemoveRange(num2, resourcesAvailable.Count - num2);
                    resourcesAvailable.Remove(foundRes);
                    Job job = new Job(JobDefOf.HaulToContainer);
                    job.targetA      = foundRes;
                    job.targetQueueA = new List <LocalTargetInfo>();
                    for (num2 = 0; num2 < resourcesAvailable.Count; num2++)
                    {
                        job.targetQueueA.Add(resourcesAvailable[num2]);
                    }
                    job.targetB = thing;
                    if (hashSet.Count > 0)
                    {
                        job.targetQueueB = new List <LocalTargetInfo>();
                        foreach (Thing item in hashSet)
                        {
                            job.targetQueueB.Add(item);
                        }
                    }
                    job.targetC  = (Thing)c;
                    job.count    = neededTotal;
                    job.haulMode = HaulMode.ToContainer;
                    return(job);
                }
                flag = true;
                thingDefCountClass = need;
            }
            if (flag)
            {
                JobFailReason.Is($"{MissingMaterialsTranslated}: {thingDefCountClass.thingDef.label}");
            }
            return(null);
        }
Ejemplo n.º 21
0
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null)
        {
            MonumentMarker monumentMarker = thing as MonumentMarker;

            if (monumentMarker != null)
            {
                CellRect          rect           = monumentMarker.sketch.OccupiedRect.MovedBy(loc);
                Blueprint_Install thingToIgnore2 = monumentMarker.FindMyBlueprint(rect, map);
                foreach (SketchEntity entity in monumentMarker.sketch.Entities)
                {
                    CellRect cellRect = entity.OccupiedRect.MovedBy(loc);
                    if (!cellRect.InBounds(map))
                    {
                        return(false);
                    }
                    if (cellRect.InNoBuildEdgeArea(map))
                    {
                        return("TooCloseToMapEdge".Translate());
                    }
                    foreach (IntVec3 item in cellRect)
                    {
                        if (!entity.CanBuildOnTerrain(item, map))
                        {
                            TerrainDef terrain = item.GetTerrain(map);
                            return("CannotPlaceMonumentOnTerrain".Translate(terrain.LabelCap));
                        }
                    }
                }
                tmpMonumentThings.Clear();
                foreach (SketchBuildable buildable in monumentMarker.sketch.Buildables)
                {
                    Thing       spawnedBlueprintOrFrame = buildable.GetSpawnedBlueprintOrFrame(loc + buildable.pos, map);
                    SketchThing sketchThing;
                    if (spawnedBlueprintOrFrame != null)
                    {
                        tmpMonumentThings.Add(spawnedBlueprintOrFrame);
                    }
                    else if ((sketchThing = buildable as SketchThing) != null)
                    {
                        Thing sameSpawned = sketchThing.GetSameSpawned(loc + sketchThing.pos, map);
                        if (sameSpawned != null)
                        {
                            tmpMonumentThings.Add(sameSpawned);
                        }
                    }
                }
                foreach (SketchEntity entity2 in monumentMarker.sketch.Entities)
                {
                    if (entity2.IsSameSpawnedOrBlueprintOrFrame(loc + entity2.pos, map))
                    {
                        continue;
                    }
                    foreach (IntVec3 item2 in entity2.OccupiedRect.MovedBy(loc))
                    {
                        if (item2.InBounds(map))
                        {
                            Building firstBuilding = item2.GetFirstBuilding(map);
                            if (firstBuilding != null && !tmpMonumentThings.Contains(firstBuilding))
                            {
                                tmpMonumentThings.Clear();
                                return("CannotPlaceMonumentOver".Translate(firstBuilding.LabelCap));
                            }
                        }
                    }
                    SketchBuildable sketchBuildable;
                    if ((sketchBuildable = entity2 as SketchBuildable) != null)
                    {
                        Thing thing2 = sketchBuildable.FirstPermanentBlockerAt(loc + entity2.pos, map);
                        if (thing2 != null && !tmpMonumentThings.Contains(thing2))
                        {
                            tmpMonumentThings.Clear();
                            return("CannotPlaceMonumentOver".Translate(thing2.LabelCap));
                        }
                    }
                }
                foreach (SketchEntity entity3 in monumentMarker.sketch.Entities)
                {
                    Building firstAdjacentBuilding = MonumentMarkerUtility.GetFirstAdjacentBuilding(entity3, loc, tmpMonumentThings, map);
                    if (firstAdjacentBuilding != null)
                    {
                        return("MonumentAdjacentToBuilding".Translate(firstAdjacentBuilding.LabelCap));
                    }
                    if (entity3.IsSpawningBlockedPermanently(loc + entity3.pos, map, thingToIgnore2))
                    {
                        tmpMonumentThings.Clear();
                        return("MonumentBlockedPermanently".Translate());
                    }
                }
                tmpMonumentThings.Clear();
            }
            return(true);
        }
Ejemplo n.º 22
0
        protected Job ResourceDeliverJobFor(Pawn pawn, IConstructible c, bool canRemoveExistingFloorUnderNearbyNeeders = true)
        {
            Blueprint_Install blueprint_Install = c as Blueprint_Install;

            if (blueprint_Install != null)
            {
                return(this.InstallJob(pawn, blueprint_Install));
            }
            bool flag = false;
            ThingDefCountClass        thingDefCountClass = null;
            List <ThingDefCountClass> list = c.MaterialsNeeded();
            int count = list.Count;
            int i     = 0;

            while (i < count)
            {
                ThingDefCountClass need = list[i];
                if (!pawn.Map.itemAvailability.ThingsAvailableAnywhere(need, pawn))
                {
                    flag = true;
                    thingDefCountClass = need;
                    break;
                }
                Thing foundRes = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(need.thingDef), PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, (Thing r) => WorkGiver_ConstructDeliverResources.ResourceValidator(pawn, need, r), null, 0, -1, false, RegionType.Set_Passable, false);
                if (foundRes != null)
                {
                    int resTotalAvailable;
                    this.FindAvailableNearbyResources(foundRes, pawn, out resTotalAvailable);
                    int             num;
                    Job             job;
                    HashSet <Thing> hashSet = this.FindNearbyNeeders(pawn, need, c, resTotalAvailable, canRemoveExistingFloorUnderNearbyNeeders, out num, out job);
                    if (job != null)
                    {
                        return(job);
                    }
                    hashSet.Add((Thing)c);
                    Thing thing = hashSet.MinBy((Thing nee) => IntVec3Utility.ManhattanDistanceFlat(foundRes.Position, nee.Position));
                    hashSet.Remove(thing);
                    int num2 = 0;
                    int j    = 0;
                    do
                    {
                        num2 += WorkGiver_ConstructDeliverResources.resourcesAvailable[j].stackCount;
                        j++;
                    }while (num2 < num && j < WorkGiver_ConstructDeliverResources.resourcesAvailable.Count);
                    WorkGiver_ConstructDeliverResources.resourcesAvailable.RemoveRange(j, WorkGiver_ConstructDeliverResources.resourcesAvailable.Count - j);
                    WorkGiver_ConstructDeliverResources.resourcesAvailable.Remove(foundRes);
                    Job job2 = new Job(JobDefOf.HaulToContainer);
                    job2.targetA      = foundRes;
                    job2.targetQueueA = new List <LocalTargetInfo>();
                    for (j = 0; j < WorkGiver_ConstructDeliverResources.resourcesAvailable.Count; j++)
                    {
                        job2.targetQueueA.Add(WorkGiver_ConstructDeliverResources.resourcesAvailable[j]);
                    }
                    job2.targetB = thing;
                    if (hashSet.Count > 0)
                    {
                        job2.targetQueueB = new List <LocalTargetInfo>();
                        foreach (Thing current in hashSet)
                        {
                            job2.targetQueueB.Add(current);
                        }
                    }
                    job2.targetC  = (Thing)c;
                    job2.count    = num;
                    job2.haulMode = HaulMode.ToContainer;
                    return(job2);
                }
                else
                {
                    flag = true;
                    thingDefCountClass = need;
                    i++;
                }
            }
            if (flag)
            {
                JobFailReason.Is(string.Format("{0}: {1}", WorkGiver_ConstructDeliverResources.MissingMaterialsTranslated, thingDefCountClass.thingDef.label), null);
            }
            return(null);
        }