// Token: 0x0600007B RID: 123 RVA: 0x00004EE8 File Offset: 0x000030E8 protected Job RemoveExistingFloorJob(Pawn pawn, Blueprint blue) { bool flag = !WorkGiver_WPConstructDeliverResources.ShouldRemoveExistingFloorFirst(pawn, blue); Job result; if (flag) { result = null; } else { bool flag2 = !pawn.CanReserve(blue.Position, 1, -1, ReservationLayerDefOf.Floor, false); if (flag2) { result = null; } else { Job job = JobMaker.MakeJob(JobDefOf.RemoveFloor, blue.Position); job.ignoreDesignations = true; result = job; } } return(result); }
// Token: 0x06000078 RID: 120 RVA: 0x00004C7C File Offset: 0x00002E7C private HashSet <Thing> FindNearbyNeeders(Pawn pawn, ThingDefCountClass need, IConstructible c, int resTotalAvailable, bool canRemoveExistingFloorUnderNearbyNeeders, out int neededTotal, out Job jobToMakeNeederAvailable) { neededTotal = need.count; HashSet <Thing> hashSet = new HashSet <Thing>(); Thing thing = (Thing)c; foreach (Thing thing2 in GenRadial.RadialDistinctThingsAround(thing.Position, thing.Map, 8f, true)) { bool flag = neededTotal >= resTotalAvailable; if (flag) { break; } bool flag2 = this.IsNewValidNearbyNeeder(thing2, hashSet, c, pawn); if (flag2) { Blueprint blueprint = thing2 as Blueprint; bool flag3 = blueprint == null || !WorkGiver_WPConstructDeliverResources.ShouldRemoveExistingFloorFirst(pawn, blueprint); if (flag3) { int num = GenConstruct.AmountNeededByOf((IConstructible)thing2, need.thingDef); bool flag4 = num > 0; if (flag4) { hashSet.Add(thing2); neededTotal += num; } } } } Blueprint blueprint2 = c as Blueprint; bool flag5 = blueprint2 != null && blueprint2.def.entityDefToBuild is TerrainDef && canRemoveExistingFloorUnderNearbyNeeders && neededTotal < resTotalAvailable; if (flag5) { foreach (Thing thing3 in GenRadial.RadialDistinctThingsAround(thing.Position, thing.Map, 3f, false)) { bool flag6 = this.IsNewValidNearbyNeeder(thing3, hashSet, c, pawn); if (flag6) { Blueprint blueprint3 = thing3 as Blueprint; bool flag7 = blueprint3 != null; if (flag7) { Job job = this.RemoveExistingFloorJob(pawn, blueprint3); bool flag8 = job != null; if (flag8) { jobToMakeNeederAvailable = job; return(hashSet); } } } } } jobToMakeNeederAvailable = null; return(hashSet); }
// 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); }
// Token: 0x06000076 RID: 118 RVA: 0x000047E4 File Offset: 0x000029E4 protected Job ResourceDeliverJobFor(Pawn pawn, IConstructible c, bool canRemoveExistingFloorUnderNearbyNeeders = true) { Blueprint_Install blueprint_Install = c as Blueprint_Install; bool flag = blueprint_Install != null; Job result; if (flag) { result = this.InstallJob(pawn, blueprint_Install); } else { bool flag2 = false; ThingDefCountClass thingDefCountClass = null; List <ThingDefCountClass> list = c.MaterialsNeeded(); int count = list.Count; int i = 0; while (i < count) { ThingDefCountClass need = list[i]; bool flag3 = !pawn.Map.itemAvailability.ThingsAvailableAnywhere(need, pawn); if (flag3) { flag2 = 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_WPConstructDeliverResources.ResourceValidator(pawn, need, r), null, 0, -1, false, RegionType.Set_Passable, false); bool flag4 = foundRes != null; if (flag4) { 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); bool flag5 = job != null; if (flag5) { 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_WPConstructDeliverResources.resourcesAvailable[j].stackCount; j++; }while (num2 < num && j < WorkGiver_WPConstructDeliverResources.resourcesAvailable.Count); WorkGiver_WPConstructDeliverResources.resourcesAvailable.RemoveRange(j, WorkGiver_WPConstructDeliverResources.resourcesAvailable.Count - j); WorkGiver_WPConstructDeliverResources.resourcesAvailable.Remove(foundRes); Job job2 = JobMaker.MakeJob(JobDefOf.HaulToContainer); job2.targetA = foundRes; job2.targetQueueA = new List <LocalTargetInfo>(); for (j = 0; j < WorkGiver_WPConstructDeliverResources.resourcesAvailable.Count; j++) { job2.targetQueueA.Add(WorkGiver_WPConstructDeliverResources.resourcesAvailable[j]); } job2.targetB = thing; bool flag6 = hashSet.Count > 0; if (flag6) { job2.targetQueueB = new List <LocalTargetInfo>(); foreach (Thing t in hashSet) { job2.targetQueueB.Add(t); } } job2.targetC = (Thing)c; job2.count = num; job2.haulMode = HaulMode.ToContainer; return(job2); } else { flag2 = true; thingDefCountClass = need; i++; } } bool flag7 = flag2; if (flag7) { JobFailReason.Is(string.Format("{0}: {1}", WorkGiver_WPConstructDeliverResources.MissingMaterialsTranslated, thingDefCountClass.thingDef.label), null); } result = null; } return(result); }