Example #1
0
        public void DeinitAndRemoveMap(Map map)
        {
            if (map == null)
            {
                Log.Error("Tried to remove null map.");
                return;
            }
            if (!maps.Contains(map))
            {
                Log.Error("Tried to remove map " + map + " but it's not here.");
                return;
            }
            if (map.Parent != null)
            {
                map.Parent.Notify_MyMapAboutToBeRemoved();
            }
            Map currentMap = CurrentMap;

            MapDeiniter.Deinit(map);
            maps.Remove(map);
            if (currentMap != null)
            {
                sbyte b = (sbyte)maps.IndexOf(currentMap);
                if (b < 0)
                {
                    if (maps.Any())
                    {
                        CurrentMap = maps[0];
                    }
                    else
                    {
                        CurrentMap = null;
                    }
                    Find.World.renderer.wantedMode = WorldRenderMode.Planet;
                }
                else
                {
                    currentMapIndex = b;
                }
            }
            if (Current.ProgramState == ProgramState.Playing)
            {
                Find.ColonistBar.MarkColonistsDirty();
            }
            MapComponentUtility.MapRemoved(map);
            if (map.Parent != null)
            {
                map.Parent.Notify_MyMapRemoved(map);
            }
        }
Example #2
0
        public void DeinitAndRemoveMap(Map map)
        {
            if (map == null)
            {
                Log.Error("Tried to remove null map.");
                return;
            }
            if (!this.maps.Contains(map))
            {
                Log.Error("Tried to remove map " + map + " but it's not here.");
                return;
            }
            Map visibleMap = this.VisibleMap;

            MapDeiniter.Deinit(map);
            this.maps.Remove(map);
            if (visibleMap != null)
            {
                sbyte b = (sbyte)this.maps.IndexOf(visibleMap);
                if ((int)b < 0)
                {
                    if (this.maps.Any <Map>())
                    {
                        this.VisibleMap = this.maps[0];
                    }
                    else
                    {
                        this.VisibleMap = null;
                    }
                    Find.World.renderer.wantedMode = WorldRenderMode.Planet;
                }
                else
                {
                    this.visibleMapIndex = b;
                }
            }
            if (Current.ProgramState == ProgramState.Playing)
            {
                Find.ColonistBar.MarkColonistsDirty();
            }
            MapComponentUtility.MapRemoved(map);
            if (map.info.parent != null)
            {
                map.info.parent.Notify_MyMapRemoved(map);
            }
        }