public static bool IsWideBoyAt(Map map, IntVec3 p, out Thing wideboy) { wideboy = null; if (map == null) { return(false); } wideboy = p.GetFirstThingWithComp <CompWideBoy>(map); if (wideboy != null) { return(true); } return(false); }
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 bool PipeAt(IntVec3 c, Thing parent) { if (!parent.Spawned) { return(false); } if (!c.InBounds(parent.Map)) { return(false); } var firstComp = c.GetFirstThingWithComp <CompPipe>(parent.Map); if (firstComp != null) { var firstComp2 = firstComp.GetComp <CompPipe>(); if (firstComp2.GasProps.ConnectEverything) { return(true); } } if (!parent.Map.GetComponent <GasManager>().PipeAt(c, PipeType)) { return(false); } var comp = parent.TryGetComp <CompPipe>(); if (comp != null && comp.PipeType == PipeType) { return(true); } return(false); }