private void SetDesiredMapSize(int newMapSize) { newMapSize = Math.Min(newMapSize, maxMapSize); newMapSize = Math.Max(minMapSize, newMapSize); desiredMapSize = newMapSize; if (compCreator == null) { return; } if (!MapCreated) { desiredComponentCount = (desiredMapSize * desiredMapSize) * compCreator.Props.componentMultiplier; desiredEnergyAmount = desiredMapSize * compCreator.Props.powerMultiplier; } else { desiredComponentCount = ((desiredMapSize * desiredMapSize) - (mapSize * mapSize)) * compCreator.Props.componentMultiplier; desiredEnergyAmount = (desiredMapSize - mapSize) * compCreator.Props.powerMultiplier; } if (compCreator.SupplyCount > desiredComponentCount && this.SpawnedOrAnyParentSpawned) { int amountToRefund = compCreator.SupplyCount - desiredComponentCount; if (compCreator.ConsumeComponents(amountToRefund)) { ThingDef thingToRefundDef = compCreator.Props.componentDef; RefundComponents(thingToRefundDef, amountToRefund); } } }
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); } } }