private float CalculateUsedComponentValue() { float result = 0.0f; if (MapCreated) { int componentsUsed = 0; ThingDef fuelItemDef = null; compCreator = this.GetComp <CompPocketDimensionCreator>(); if (compCreator != null) { if (compCreator.Props.preMadeMapSize > 0) { componentsUsed = -(compCreator.Props.preMadeMapSize * compCreator.Props.preMadeMapSize); } fuelItemDef = compCreator.Props.componentDef; } if (fuelItemDef != null) { componentsUsed += (this.MapSize * this.MapSize) * compCreator.Props.componentMultiplier; result = fuelItemDef.BaseMarketValue * componentsUsed; } } return(result); }
private Thing FindBestComponents(Pawn pawn, Building_PocketDimensionBox pocketDimensionBox) { CompPocketDimensionCreator compCreator = pocketDimensionBox.GetComp <CompPocketDimensionCreator>(); if (compCreator != null) { ThingRequest componentRequest = ThingRequest.ForDef(compCreator.Props.componentDef); Predicate <Thing> validator = delegate(Thing x) { return(!x.IsForbidden(pawn) && pawn.CanReserve(x)); }; return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, componentRequest, PathEndMode.ClosestTouch, TraverseParms.For(pawn), 9999f, validator)); } return(null); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); Logger.MessageFormat(this, "Spawning"); compCreator = this.GetComp <CompPocketDimensionCreator>(); compTransporter = this.GetComp <CompTransporter>(); if (mapSize == 0) { mapSize = 1; } if (fuel >= 1.0f) { if (compCreator != null) { compCreator.AddComponents((int)Mathf.Round(fuel)); fuel = 0.0f; if (compCreator.SupplyCount > desiredComponentCount) { int amountToRefund = compCreator.SupplyCount - desiredComponentCount; if (compCreator.ConsumeComponents(amountToRefund)) { ThingDef thingToRefundDef = compCreator.Props.componentDef; RefundComponents(thingToRefundDef, amountToRefund); } } } else { ThingDef thingToRefundDef = ThingDefOf.ComponentSpacer; int amountToRefund = (int)Mathf.Round(fuel); fuel = 0.0f; RefundComponents(thingToRefundDef, amountToRefund); } } // Reconfigure runtime-set comp property values SetDesiredMapSize(desiredMapSize); if (MapCreated) { MapParent_PocketDimension dimensionMapParent = PocketDimensionUtility.GetMapParent(this.dimensionSeed); // Looks like we just got installed somewhere. Make sure map tile is the same as our current tile if (this.Map != null && dimensionMapParent != null) { dimensionMapParent.Tile = this.Map.Parent.Tile; } } else { if (compCreator != null && compCreator.Props.preMadeMapSize > 0) { SetDesiredMapSize(compCreator.Props.preMadeMapSize); mapSize = desiredMapSize; CreateMap(this.MapDiameter); } } }