public float CalculateAdditionalMarketValue(float baseValue) { if (this.doingRecursiveThing) { Logger.MessageFormat(this, "Counting box wealth again recursively. Skipping..."); return(0.0f); } float componentValue = CalculateUsedComponentValue(); float contentValue = 0.0f; MapParent_PocketDimension innerMapParent = PocketDimensionUtility.GetMapParent(this.dimensionSeed); if (innerMapParent != null && innerMapParent.Map != null) { this.doingRecursiveThing = true; try { contentValue = innerMapParent.Map.wealthWatcher.WealthTotal; } finally { this.doingRecursiveThing = false; } } Logger.MessageFormat(this, "Adding value to box: {0}, {1} + {2} + {3} = {4}", this.Label, baseValue, contentValue, componentValue, (baseValue + contentValue + componentValue)); return(contentValue + componentValue); }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo c in base.GetGizmos()) { yield return(c); } // Rename yield return(new Command_Action { icon = ContentFinder <Texture2D> .Get("UI/Buttons/Rename", true), action = () => Find.WindowStack.Add(new Dialog_RenamePocketDimensionEntranceBase(this)), defaultLabel = "CM_RenamePocketDimensionLabel".Translate(), defaultDesc = "CM_RenamePocketDimensionDescription".Translate() }); Building_PocketDimensionEntranceBase otherSide = PocketDimensionUtility.GetOtherSide(this); if (otherSide != null && !otherSide.BeingDestroyed) { // Select other side yield return(new Command_Action { action = delegate { if (otherSide != null) { LookTargets otherSideTarget = new LookTargets(otherSide.SpawnedParentOrMe); CameraJumper.TrySelect(otherSideTarget.TryGetPrimaryTarget()); } }, defaultLabel = this is Building_PocketDimensionBox ? "CM_ViewExitLabel".Translate() : "CM_ViewEntranceLabel".Translate(), defaultDesc = this is Building_PocketDimensionBox ? "CM_ViewExitDescription".Translate() : "CM_ViewEntranceDescription".Translate(), icon = ContentFinder <Texture2D> .Get("UI/Commands/ViewQuest"), }); } if (Prefs.DevMode && MapCreated) { // Fix walls not being owned by player yield return(new Command_Action { action = () => PocketDimensionUtility.ClaimWalls(PocketDimensionUtility.GetMapParent(this.dimensionSeed).Map, Faction.OfPlayer), defaultLabel = "DEBUG: Claim walls", }); } }
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); } } }