public override void Tick()
        {
            base.Tick();

            if (this.GetLost)
            {
                return;
            }

            if (this.IsHashIntervalTick(250))
            {
                Building_PocketDimensionBox box = PocketDimensionUtility.GetBox(this.dimensionSeed);
                if (box == null || !box.ExistsInWorld())
                {
                    this.GetLost = true;
                }
            }

            //Building_PocketDimensionEntranceBase box = this.otherSide;

            //if (box != null && this.IsHashIntervalTick(500))
            //{
            //    string thingString = box.GetType().ToString();
            //    if (box.ParentHolder != null)
            //    {
            //        for (IThingHolder parentHolder = box.ParentHolder; parentHolder != null; parentHolder = parentHolder.ParentHolder)
            //        {
            //            thingString = thingString + " - " + parentHolder.GetType().ToString();
            //        }
            //    }

            //    Logger.MessageFormat(this, "Box: {0}", thingString);
            //}
        }
Beispiel #2
0
        public override void Tick()
        {
            base.Tick();

            if (this.shouldBeDeleted)
            {
                this.CheckRemoveMapNow();

                Building_PocketDimensionBox box = PocketDimensionUtility.GetBox(this.dimensionSeed);
                if (box != null && !box.BeingDestroyed && !box.GetLost)
                {
                    box.GetLost = true;
                }
            }
        }
Beispiel #3
0
        protected override void SetName(string name)
        {
            Building_PocketDimensionBox  box  = PocketDimensionUtility.GetBox(buildingSeed);
            Building_PocketDimensionExit exit = PocketDimensionUtility.GetExit(buildingSeed);

            if (box != null)
            {
                box.uniqueName = curName;
            }
            if (exit != null)
            {
                exit.uniqueName = "CM_PocketDimension_ExitName".Translate(curName);
            }

            Messages.Message("CM_RenamePocketDimensionMessage".Translate(curName), MessageTypeDefOf.TaskCompletion);
        }
Beispiel #4
0
        public void Abandon(bool lost)
        {
            if (!this.shouldBeDeleted)
            {
                TaggedString label = "CM_PocketDimensionDestroyedLetterLabel".Translate();
                TaggedString text  = "CM_PocketDimensionDestroyedLetterText".Translate();

                if (lost)
                {
                    label = "CM_PocketDimensionLostLetterLabel".Translate();
                    text  = "CM_PocketDimensionLostLetterText".Translate();
                }

                Building_PocketDimensionBox box = PocketDimensionUtility.GetBox(this.dimensionSeed);
                if (box != null && !box.BeingDestroyed)
                {
                    Thing thingHolder = box.SpawnedParentOrMe;
                    if (thingHolder != null)
                    {
                        LookTargets lookTarget = new LookTargets(thingHolder.Position, thingHolder.Map);
                        Find.LetterStack.ReceiveLetter(label, text, PocketDimensionDefOf.CM_PocketDimensionBreachedLetter, lookTarget);
                    }
                    else
                    {
                        Find.LetterStack.ReceiveLetter(label, text, PocketDimensionDefOf.CM_PocketDimensionBreachedLetter);
                    }
                }
                else
                {
                    Find.LetterStack.ReceiveLetter(label, text, PocketDimensionDefOf.CM_PocketDimensionBreachedLetter);
                }

                if (box != null)
                {
                    box.GetLost = true;
                }

                Building_PocketDimensionExit exit = PocketDimensionUtility.GetExit(this.dimensionSeed);
                if (exit != null)
                {
                    exit.GetLost = true;
                }
            }

            this.shouldBeDeleted = true;
        }
Beispiel #5
0
        public static Map GetHighestContainingMap(Map map)
        {
            Map result = map;

            if (map != null)
            {
                MapParent_PocketDimension mapParent = map.info.parent as MapParent_PocketDimension;
                if (mapParent != null)
                {
                    Building_PocketDimensionBox box = PocketDimensionUtility.GetBox(mapParent.dimensionSeed);
                    if (box == null)
                    {
                        Logger.ErrorFormat(map, "Looking for a map containing a box that does not exist!");
                    }
                    else if (box.doingRecursiveThing)
                    {
                        Logger.WarningFormat(map, "Tried to find a containing map for a pocket dimension nested in a loop!");
                    }
                    else if (box.SpawnedOrAnyParentSpawned)
                    {
                        box.doingRecursiveThing = true;
                        try
                        {
                            result = GetHighestContainingMap(box.MapHeld);
                        }
                        finally
                        {
                            box.doingRecursiveThing = false;
                        }
                    }
                    else
                    {
                        //Logger.WarningFormat(map, "Could not find map containing pocket dimension box. Is it in a caravan?");
                    }
                }
                else
                {
                    //Logger.MessageFormat(map, "Not a pocket dimension.");
                }
            }

            return(result);
        }
            public static void GetOutdoorTemp(ref float __result, Map ___map)
            {
                MapParent_PocketDimension mapParent = ___map.info.parent as MapParent_PocketDimension;

                if (mapParent != null)
                {
                    Building_PocketDimensionEntranceBase box = PocketDimensionUtility.GetBox(mapParent.dimensionSeed);
                    if (box != null)
                    {
                        __result = 21.0f;

                        if (box.Spawned)
                        {
                            __result = GenTemperature.GetTemperatureForCell(box.Position, box.Map);
                        }
                        else if (box.ParentHolder != null)
                        {
                            for (IThingHolder parentHolder = box.ParentHolder; parentHolder != null; parentHolder = parentHolder.ParentHolder)
                            {
                                if (ThingOwnerUtility.TryGetFixedTemperature(parentHolder, box, out __result))
                                {
                                    return;// false;
                                }
                            }
                        }
                        else if (box.SpawnedOrAnyParentSpawned)
                        {
                            __result = GenTemperature.GetTemperatureForCell(box.PositionHeld, box.MapHeld);
                        }
                        else if (box.Tile >= 0)
                        {
                            __result = GenTemperature.GetTemperatureFromSeasonAtTile(GenTicks.TicksAbs, box.Tile);
                        }

                        // Above logic derived from the following function call. Can't call it here due to an edge case which results in infinite loop
                        //__result = box.AmbientTemperature;
                        return;// false;
                    }
                }

                //return true;
            }
        public override void Generate(Map map, GenStepParams parms)
        {
            MapParent_PocketDimension mapParent = map.Parent as MapParent_PocketDimension;
            List <IntVec3>            list      = new List <IntVec3>();
            TerrainGrid terrainGrid             = map.terrainGrid;
            RoofGrid    roofGrid = map.roofGrid;

            string   terrainDefName = "CM_PocketDimensionFloor";
            ThingDef boxStuffDef    = null;

            // Build terrain defname
            Building_PocketDimensionBox box = PocketDimensionUtility.GetBox(mapParent.dimensionSeed);

            if (box != null && box.Stuff != null)
            {
                boxStuffDef = box.Stuff;
                if (boxStuffDef.stuffProps.categories.Contains(StuffCategoryDefOf.Metallic))
                {
                    terrainDefName += "Metal";
                }
                else if (boxStuffDef.stuffProps.categories.Contains(StuffCategoryDefOf.Stony))
                {
                    terrainDefName += "Stone";
                }
                else if (boxStuffDef.stuffProps.categories.Contains(StuffCategoryDefOf.Woody))
                {
                    terrainDefName += "Wood";
                }

                terrainDefName += "_" + boxStuffDef.defName;
            }

            // If that terrain was not found, use default metal terrain
            TerrainDef terrainDef = DefDatabase <TerrainDef> .GetNamedSilentFail(terrainDefName);

            if (terrainDef == null)
            {
                terrainDef = PocketDimensionDefOf.CM_PocketDimensionFloorMetal;
            }

            foreach (IntVec3 current in map.AllCells)
            {
                terrainGrid.SetTerrain(current, terrainDef);

                if (current.OnEdge(map))
                {
                    Thing wall = ThingMaker.MakeThing(PocketDimensionDefOf.CM_PocketDimensionWall, boxStuffDef);
                    wall.SetFaction(Faction.OfPlayer);
                    GenSpawn.Spawn(wall, current, map);
                }

                roofGrid.SetRoof(current, PocketDimensionDefOf.CM_PocketDimensionRoof);
            }
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 allCell in map.AllCells)
            {
                elevation[allCell] = 0.0f;
            }
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 allCell2 in map.AllCells)
            {
                fertility[allCell2] = 0.0f;
            }
        }