private void TryProducePortion(float yieldPct) { ThingDef thingDef; int num; IntVec3 c; bool nextResource = this.GetNextResource(out thingDef, out num, out c); if (thingDef != null) { int num2 = Mathf.Min(num, thingDef.deepCountPerPortion); if (nextResource) { this.parent.Map.deepResourceGrid.SetAt(c, thingDef, num - num2); } int stackCount = Mathf.Max(1, GenMath.RoundRandom((float)num2 * yieldPct)); Thing thing = ThingMaker.MakeThing(thingDef, null); thing.stackCount = stackCount; GenPlace.TryPlaceThing(thing, this.parent.InteractionCell, this.parent.Map, ThingPlaceMode.Near, null, null); if (nextResource && !this.ValuableResourcesPresent()) { if (DeepDrillUtility.GetBaseResource(this.parent.Map) == null) { Messages.Message("DeepDrillExhaustedNoFallback".Translate(), this.parent, MessageTypeDefOf.TaskCompletion, true); } else { Messages.Message("DeepDrillExhausted".Translate(new object[] { Find.ActiveLanguageWorker.Pluralize(DeepDrillUtility.GetBaseResource(this.parent.Map).label, -1) }), this.parent, MessageTypeDefOf.TaskCompletion, true); this.parent.SetForbidden(true, true); } } } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { if (DeepDrillUtility.GetNextResource(loc, map) == null) { return("MustPlaceOnDrillable".Translate()); } return(true); }
public static ThingDef GetNextResource(IntVec3 p, Map map) { ThingDef result; int num; IntVec3 intVec; DeepDrillUtility.GetNextResource(p, map, out result, out num, out intVec); return(result); }
public bool CanDrillNow() { if (powerComp != null && !powerComp.PowerOn) { return(false); } if (DeepDrillUtility.GetBaseResource(parent.Map, parent.Position) != null) { return(true); } return(ValuableResourcesPresent()); }
private void TryProducePortion(float yieldPct) { ThingDef thingDef; int num; IntVec3 intVec; bool nextResource = this.GetNextResource(out thingDef, out num, out intVec); if (thingDef == null) { return; } int num2 = Mathf.Min(num, thingDef.deepCountPerPortion); if (nextResource) { this.parent.Map.deepResourceGrid.SetAt(intVec, thingDef, num - num2); } int stackCount = Mathf.Max(1, GenMath.RoundRandom((float)num2 * yieldPct)); Thing thing = ThingMaker.MakeThing(thingDef, null); thing.stackCount = stackCount; GenPlace.TryPlaceThing(thing, this.parent.InteractionCell, this.parent.Map, ThingPlaceMode.Near, null, null); if (nextResource && !this.ValuableResourcesPresent()) { if (DeepDrillUtility.GetBaseResource(this.parent.Map) == null) { Messages.Message("DeepDrillExhaustedNoFallback".Translate(), this.parent, MessageTypeDefOf.TaskCompletion, true); } else { Messages.Message("DeepDrillExhausted".Translate(Find.ActiveLanguageWorker.Pluralize(DeepDrillUtility.GetBaseResource(this.parent.Map).label, -1)), this.parent, MessageTypeDefOf.TaskCompletion, true); for (int i = 0; i < 9; i++) { IntVec3 c = intVec + GenRadial.RadialPattern[i]; if (c.InBounds(this.parent.Map)) { ThingWithComps firstThingWithComp = c.GetFirstThingWithComp(this.parent.Map); if (firstThingWithComp != null && !firstThingWithComp.GetComp <CompDeepDrill>().ValuableResourcesPresent()) { firstThingWithComp.SetForbidden(true, true); } } } } } }
private void TryProducePortion(float yieldPct) { ThingDef resDef; int countPresent; IntVec3 cell; bool nextResource = GetNextResource(out resDef, out countPresent, out cell); if (resDef == null) { return; } int num = Mathf.Min(countPresent, resDef.deepCountPerPortion); if (nextResource) { parent.Map.deepResourceGrid.SetAt(cell, resDef, countPresent - num); } int stackCount = Mathf.Max(1, GenMath.RoundRandom((float)num * yieldPct)); Thing thing = ThingMaker.MakeThing(resDef); thing.stackCount = stackCount; GenPlace.TryPlaceThing(thing, parent.InteractionCell, parent.Map, ThingPlaceMode.Near); if (!nextResource || ValuableResourcesPresent()) { return; } if (DeepDrillUtility.GetBaseResource(parent.Map, parent.Position) == null) { Messages.Message("DeepDrillExhaustedNoFallback".Translate(), parent, MessageTypeDefOf.TaskCompletion); return; } Messages.Message("DeepDrillExhausted".Translate(Find.ActiveLanguageWorker.Pluralize(DeepDrillUtility.GetBaseResource(parent.Map, parent.Position).label)), parent, MessageTypeDefOf.TaskCompletion); for (int i = 0; i < 21; i++) { IntVec3 c = cell + GenRadial.RadialPattern[i]; if (c.InBounds(parent.Map)) { ThingWithComps firstThingWithComp = c.GetFirstThingWithComp <CompDeepDrill>(parent.Map); if (firstThingWithComp != null && !firstThingWithComp.GetComp <CompDeepDrill>().ValuableResourcesPresent()) { firstThingWithComp.SetForbidden(value: true); } } } }
public static bool GetNextResource(IntVec3 p, Map map, out ThingDef resDef, out int countPresent, out IntVec3 cell) { for (int i = 0; i < 9; i++) { IntVec3 intVec = p + GenRadial.RadialPattern[i]; if (intVec.InBounds(map)) { ThingDef thingDef = map.deepResourceGrid.ThingDefAt(intVec); if (thingDef != null) { resDef = thingDef; countPresent = map.deepResourceGrid.CountAt(intVec); cell = intVec; return(true); } } } resDef = DeepDrillUtility.GetBaseResource(map); countPresent = int.MaxValue; cell = p; return(false); }
public bool CanDrillNow() { return((this.powerComp == null || this.powerComp.PowerOn) && (DeepDrillUtility.GetBaseResource(this.parent.Map) != null || this.ValuableResourcesPresent())); }
private bool GetNextResource(out ThingDef resDef, out int countPresent, out IntVec3 cell) { return(DeepDrillUtility.GetNextResource(this.parent.Position, this.parent.Map, out resDef, out countPresent, out cell)); }