public void AddComponents(List <Thing> componentsList) { if (compCreator == null) { return; } while (ComponentsNeeded > 0 && componentsList.Count > 0) { Thing component = componentsList.Pop(); int componentsGiven = Mathf.Min(ComponentsNeeded, component.stackCount); if (compCreator.AddComponents(componentsGiven)) { component.SplitOff(componentsGiven).Destroy(); } else { break; } } }
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); } } }