예제 #1
0
        public static MyMwcObjectBuilder_Sector LoadSector(MyMwcSectorIdentifier sectorId)
        {
            MyMwcObjectBuilder_Sector userdataSector = LoadSector(sectorId, GetSectorPath(sectorId));
            MyMwcObjectBuilder_Sector contentSector  = null;

            if (sectorId.UserId == null) // Only non-user sectors loads from Content
            {
                var sectorPath = Path.Combine(ContentSectorPath, GetSectorName(sectorId, false) + ".mws");
                contentSector = LoadSector(sectorId, sectorPath);
            }

            int userVersion    = userdataSector != null ? userdataSector.Version : -1;
            int contentVersion = contentSector != null ? contentSector.Version : -1;

            if (userVersion > contentVersion)
            {
                Log("using USERDATA: ", sectorId, userVersion);
                return(userdataSector);
            }
            else
            {
                if (contentSector != null)
                {
                    Log("using CONTENT: ", sectorId, contentVersion);
                }
                return(contentSector);
            }
        }
        protected override void OnOkClick(MyGuiControlButton sender)
        {
            MyMwcSectorTypeEnum sectorType = string.IsNullOrEmpty(m_playerName.Text) ? MyMwcSectorTypeEnum.STORY : MyMwcSectorTypeEnum.SANDBOX;
            bool namedSector = !string.IsNullOrEmpty(m_sector_name.Text);
            MyMwcSectorIdentifier sectorIdentifier;
            if (namedSector)
            {
                sectorIdentifier = new MyMwcSectorIdentifier(sectorType, null, new MyMwcVector3Int(0, 0, 0), m_sector_name.Text);
            }
            else
            {
                int x, y, z;
                if (!int.TryParse(m_sectorIdentifierX.Text, out x) ||
                    !int.TryParse(m_sectorIdentifierY.Text, out y) ||
                    !int.TryParse(m_sectorIdentifierZ.Text, out z))
                {
                    MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, 
                        MyTextsWrapperEnum.BadSectorIdentifierInput, MyTextsWrapperEnum.MessageBoxCaptionError,
                        MyTextsWrapperEnum.Ok, null));
                    return;
                }

                sectorIdentifier = new MyMwcSectorIdentifier(sectorType, null, new MyMwcVector3Int(x, y, z), null);
            }

            // This screen will be closed on successfull load from progress screen
            MyGuiManager.AddScreen(new MyGuiScreenEditorLoadSectorObjectsProgress(
                this, MyTextsWrapperEnum.LoadingPleaseWait, m_playerName.Text, sectorIdentifier));
        }
예제 #3
0
        public MyServerAction Travel(MyMwcTravelTypeEnum travelType, MyMwcSectorIdentifier targetSector)
        {
            Debug.Assert(targetSector.SectorType == MyMwcSectorTypeEnum.STORY, "Travel is allowed only in story");

            TryPause();

            var sector = MyLocalCache.LoadSector(targetSector);

            if (sector == null)
            {
                var storySectorId = targetSector;
                storySectorId.UserId = null;
                sector = MyLocalCache.LoadSector(storySectorId);
            }

            if (sector != null)
            {
                TravelSectorLoaded(travelType, targetSector.Position, null, sector);
                return(null);
            }
            else // Not using server...so sector is "from generator"
            {
                TravelSectorLoaded(travelType, targetSector.Position, null, MyMwcObjectBuilder_Sector.UseGenerator());
                return(null);
            }
        }
        public void OnOkClick(MyGuiControlButton sender)
        {
            if (m_mapsCombobox.GetSelectedItemKey() == null)
            {
                return;
            }

            //AddFriendSectorsResponse not called?
            if (m_sectorIdentifiers == null)
            {
                return;
            }

            MyMwcSectorIdentifier sectorIdentifier = m_sectorIdentifiers[m_mapsCombobox.GetSelectedItemKey().Value];

            MyConfig.LastFriendName           = m_findPlayerName.Text;
            MyConfig.LastFriendSectorPosition = sectorIdentifier.Position;
            MyConfig.LastFriendSectorUserId   = sectorIdentifier.UserId.Value;
            MyConfig.Save();

            MyGuiManager.CloseAllScreensNowExcept(MyGuiScreenGamePlay.Static);

            if (CustomLoadAction != null)
            {
                CustomLoadAction(sectorIdentifier);
            }
            else
            {
                MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(m_startSessionType, m_startSessionProgressText, sectorIdentifier, MyGameplayDifficultyEnum.EASY, null, m_closeAfterSuccessfulEnter));
            }
        }
        public static MyGuiScreenStartSessionProgress CurrentScreen = null;    //  This is always filled with reference to actual instance of this scree. If there isn't, it's null.


        public MyGuiScreenStartSessionProgress(MyMwcStartSessionRequestTypeEnum sessionType,  MyTextsWrapperEnum progressText, MyMwcSectorIdentifier? sectorIdentifier, MyGameplayDifficultyEnum difficulty, string checkpointName, MyGuiScreenBase closeAfter) : 
            base(progressText, false)
        {
            // TODO: Not ready yet
            //Debug.Assert(sessionType != MyMwcStartSessionRequestTypeEnum.NEW_STORY && sessionType != MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT, "Invalid operation, call OndrejP");

            m_sectorIdentifier = sectorIdentifier;
            m_sessionType = sessionType;
            m_backgroundFadeColor = MyGuiConstants.SCREEN_BACKGROUND_FADE_BLANK_DARK_PROGRESS_SCREEN;
            m_closeAfter = closeAfter;
            m_difficulty = difficulty;
            m_checkpointName = checkpointName;
            CurrentScreen = this;

            OnSuccessEnter = new Action<MyGuiScreenGamePlayType, MyMwcStartSessionRequestTypeEnum, MyMwcObjectBuilder_Checkpoint>((screenType, sessType, checkpoint) =>
            {
                var newGameplayScreen = new MyGuiScreenGamePlay(screenType, null, checkpoint.CurrentSector, checkpoint.SectorObjectBuilder.Version, sessType);
                var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);

                if (sessType == MyMwcStartSessionRequestTypeEnum.NEW_STORY)
                    loadScreen.AddEnterSectorResponse(checkpoint, MyMissionID.EAC_SURVEY_SITE);
                else
                    loadScreen.AddEnterSectorResponse(checkpoint, null);

                MyGuiManager.AddScreen(loadScreen);
            });
        }
        private bool FillGamesFromLobbiesInfo(List <MyGameInfo> games)
        {
            if (games == null || m_games == null)
            {
                return(false);
            }

            m_games.Clear();

            foreach (MyGameInfo game in games)
            {
                if (game.Name.StartsWith("**"))
                {
                    continue;
                }

                if (MyMwcSectorIdentifier.Is25DSector(game.Name))
                {
                    if (MyClientServer.MW25DEnabled)
                    {
                        m_games.Add(new MyGameExtendedInfo(game));
                    }
                }
                else
                {
                    if (MyClientServer.HasFullGame)
                    {
                        m_games.Add(new MyGameExtendedInfo(game));
                    }
                }
            }

            return(true);
        }
예제 #7
0
        public void OnOkClick(MyGuiControlButton sender)
        {
            CloseScreen();
            MyMwcSectorIdentifier sectorIdentifier = m_sectorIdentifiers[m_mapsCombobox.GetSelectedKey()];

            MyGuiManager.AddScreen(new MyGuiScreenEditorLoadObjectGroupsProgress(MyTextsWrapperEnum.LoadingPleaseWait, sectorIdentifier));
        }
예제 #8
0
        protected override void OnOkClick(MyGuiControlButton sender)
        {
            MyMwcSectorTypeEnum sectorType = string.IsNullOrEmpty(m_playerName.Text) ? MyMwcSectorTypeEnum.STORY : MyMwcSectorTypeEnum.SANDBOX;
            bool namedSector = !string.IsNullOrEmpty(m_sector_name.Text);
            MyMwcSectorIdentifier sectorIdentifier;

            if (namedSector)
            {
                sectorIdentifier = new MyMwcSectorIdentifier(sectorType, null, new MyMwcVector3Int(0, 0, 0), m_sector_name.Text);
            }
            else
            {
                int x, y, z;
                if (!int.TryParse(m_sectorIdentifierX.Text, out x) ||
                    !int.TryParse(m_sectorIdentifierY.Text, out y) ||
                    !int.TryParse(m_sectorIdentifierZ.Text, out z))
                {
                    MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR,
                                                                     MyTextsWrapperEnum.BadSectorIdentifierInput, MyTextsWrapperEnum.MessageBoxCaptionError,
                                                                     MyTextsWrapperEnum.Ok, null));
                    return;
                }

                sectorIdentifier = new MyMwcSectorIdentifier(sectorType, null, new MyMwcVector3Int(x, y, z), null);
            }

            // This screen will be closed on successfull load from progress screen
            MyGuiManager.AddScreen(new MyGuiScreenEditorLoadSectorObjectsProgress(
                                       this, MyTextsWrapperEnum.LoadingPleaseWait, m_playerName.Text, sectorIdentifier));
        }
예제 #9
0
        public static string GetSectorName(MyMwcSectorIdentifier sector, bool includeUserId)
        {
            string name;

            switch (sector.SectorType)
            {
            case MyMwcSectorTypeEnum.STORY:
                name = "STORY";
                break;

            case MyMwcSectorTypeEnum.SANDBOX:
                name = "SANDBOX";
                break;

            default:
                throw new MyMwcExceptionApplicationShouldNotGetHere();
            }

            string userId = sector.UserId.HasValue ? sector.UserId.Value.ToString() : "NULL";

            if (includeUserId)
            {
                return(String.Format("{0}_{1}_{2}_{3}_{4}_", name, userId, sector.Position.X, sector.Position.Y, sector.Position.Z));
            }
            else
            {
                return(String.Format("{0}_{1}_{2}_{3}_", name, sector.Position.X, sector.Position.Y, sector.Position.Z));
            }
        }
 public MyGuiScreenEditorLoadSectorObjectsProgress(MyGuiScreenBase parentScreen, MyTextsWrapperEnum loadingText, string playerName, MyMwcSectorIdentifier sectorIdentifier)
     : base(loadingText, false)
 {
     CurrentScreen      = this;
     m_parentScreen     = parentScreen;
     m_playerName       = playerName;
     m_sectorIdentifier = sectorIdentifier;
 }
 public MyGuiScreenEditorSaveProgress(MyMwcSectorIdentifier sectorIdentifier, MyMwcObjectBuilder_Checkpoint checkpoint, bool savePlayer, bool visibleSave = true, bool pause = false)
     : base(MyTextsWrapperEnum.SaveSectorInProgressPleaseWait, false, TimeSpan.FromSeconds(120)) // Enought time to save sector - full of asteroids, etc
 {
     m_checkpoint = checkpoint;
     m_sectorIdentifier = sectorIdentifier;
     m_savePlayer = savePlayer;
     m_forceHide = !visibleSave;
     m_pause = pause;
 }
 public MyGuiScreenEditorSaveProgress(MyMwcSectorIdentifier sectorIdentifier, MyMwcObjectBuilder_Checkpoint checkpoint, bool savePlayer, bool visibleSave = true, bool pause = false)
     : base(MyTextsWrapperEnum.SaveSectorInProgressPleaseWait, false, TimeSpan.FromSeconds(120)) // Enought time to save sector - full of asteroids, etc
 {
     m_checkpoint       = checkpoint;
     m_sectorIdentifier = sectorIdentifier;
     m_savePlayer       = savePlayer;
     m_forceHide        = !visibleSave;
     m_pause            = pause;
 }
예제 #13
0
        public static string GetSectorNameLong(MyMwcSectorIdentifier sector)
        {
            var name = "";

            if (!string.IsNullOrEmpty(sector.SectorName))
            {
                name = String.Format(" ({0})", sector.SectorName);
            }
            return(GetSectorName(sector, true) + name);
        }
예제 #14
0
 private static void Log(string text, MyMwcSectorIdentifier sectorId, int?version = null)
 {
     text = (sectorId.UserId == null ? "CACHE: " : "SAVES: ") + text;
     text = text + " " + GetSectorNameLong(sectorId);
     if (version.HasValue)
     {
         text += ", version: " + version;
     }
     Log(text);
 }
예제 #15
0
 private void AddSectorToCombo(MyMwcSectorIdentifier sectorIdentifier, int index, string username)
 {
     if (string.IsNullOrEmpty(sectorIdentifier.SectorName))
     {
         m_mapsCombobox.AddItem(index, new StringBuilder(string.Format("{0} ({1})",
                                                                       username, sectorIdentifier.Position.ToString())));
     }
     else
     {
         m_mapsCombobox.AddItem(index, new StringBuilder(string.Format("{0} {1} ({2})",
                                                                       username, sectorIdentifier.SectorName, sectorIdentifier.Position.ToString())));
     }
 }
 private void AddSectorToCombo(MyMwcSectorIdentifier sectorIdentifier, int index, string username)
 {
     if (string.IsNullOrEmpty(sectorIdentifier.SectorName))
     {
         m_mapsCombobox.AddItem(index, new StringBuilder(string.Format("{0} ({1})",
             username, sectorIdentifier.Position.ToString())));
     }
     else
     {
         m_mapsCombobox.AddItem(index, new StringBuilder(string.Format("{0} {1} ({2})",
             username, sectorIdentifier.SectorName, sectorIdentifier.Position.ToString())));
     }
 }
예제 #17
0
        public static bool CanBeSaved(bool asTemplate, MyMwcSectorIdentifier sectorId, bool fromEditor)
        {
            bool isLogged          = MyClientServer.LoggedPlayer != null;       // Must be logged
            bool isNotDemo         = !MyClientServer.LoggedPlayer.IsDemoUser(); // Cannot be demo user
            bool sectorCanBeSaved  = sectorId.CanBeCheckpointSaved();           // Sector must be savable (for story only zero plane)
            bool canSaveObjectives = MyMissions.CanSaveObjectives();

            // Story sectors can be only on "zero" plane (Y coordinate is 0)
            return
                (isLogged && isNotDemo && sectorCanBeSaved && canSaveObjectives &&
                 (asTemplate == false || MyClientServer.LoggedPlayer.GetCanAccessEditorForStory()) && // When saving story template, must have story editor access
                 (fromEditor == false || sectorId.SectorType != MyMwcSectorTypeEnum.STORY || MyClientServer.LoggedPlayer.GetCanAccessEditorForStory()));  // To save STORY sector from editor, it's necessary to have rights
        }
예제 #18
0
        public MyServerAction SaveLastCheckpoint(bool createChapter = false)
        {
            if (MyMultiplayerGameplay.IsRunning && !MyMultiplayerGameplay.Static.IsHost)
            {
                return(null);
            }

            var lastChapterTime = MyLocalCache.GetLastChapterTimestamp();
            var nextChapterTime = lastChapterTime + TimeSpan.FromHours(3);

            if (MyMissions.ActiveMission == null && DateTime.Now > nextChapterTime)
            {
                createChapter = true;
            }

            MyMwcSectorIdentifier sectorId = MyGuiScreenGamePlay.Static.GetSectorIdentifier();

            if (CanBeSaved(false, sectorId, false))
            {
                var notification = new MyHudNotification.MyNotification(Localization.MyTextsWrapperEnum.SavingSectorToServer, 2500);
                MyHudNotification.AddNotification(notification);

                var checkpoint = GetCheckpointBuilder(true);
                checkpoint.CurrentSector.UserId = MyClientServer.LoggedPlayer.GetUserId(); // Saving players checkpoint

                if (MySession.PlayerShip != null && checkpoint.PlayerObjectBuilder.ShipObjectBuilder != null)
                {
                    float refilRatio = 0.5f;

                    var ship = checkpoint.PlayerObjectBuilder.ShipObjectBuilder;
                    ship.ArmorHealth     = MathHelper.Clamp(ship.ArmorHealth, refilRatio * MySession.PlayerShip.MaxArmorHealth, MySession.PlayerShip.MaxArmorHealth);
                    ship.ShipHealthRatio = MathHelper.Clamp(ship.ShipHealthRatio, refilRatio, 1.0f);
                    ship.Fuel            = MathHelper.Clamp(ship.Fuel, refilRatio * MySession.PlayerShip.MaxFuel, MySession.PlayerShip.MaxFuel);
                    ship.Oxygen          = MathHelper.Clamp(ship.Oxygen, refilRatio * MySession.PlayerShip.MaxOxygen, MySession.PlayerShip.MaxOxygen);
                    checkpoint.PlayerObjectBuilder.Health = MathHelper.Clamp(checkpoint.PlayerObjectBuilder.Health, refilRatio * 100, 100);
                }

                // Need to store actual checkpoint...because when we travel, we receive only sector, not checkpoint
                MyGuiScreenGamePlay.Static.AddEnterSectorResponse(checkpoint, null);

                Debug.Assert(checkpoint.CurrentSector.UserId != null, "Saving last checkpoint as story");
                UpdatePlayerStartDummy(checkpoint);

                MyLocalCache.SaveCheckpoint(checkpoint, createChapter);
                checkpoint.SectorObjectBuilder = null; // Don't save sector
            }
            return(null);
        }
예제 #19
0
        public void OnOkClick(MyGuiControlButton sender)
        {
            if (m_sectors.Count == 0)
            {
                return;
            }

            MyMwcSectorIdentifier sectorIdentifier = m_sectors[m_sectorsListbox.GetSelectedItemKey().Value];

            if (m_startSessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS)
            {
                //Remove 25D sectors from 2081 game and non 25D sectors from 25D game.
                if (sectorIdentifier.SectorName.ToUpper().Contains("2.5D") || sectorIdentifier.SectorName.ToUpper().Contains("2,5D"))
                {
                    if (!MyClientServer.MW25DEnabled)
                    {
                        MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.MESSAGE, MyTextsWrapperEnum.YouNeed25D, MyTextsWrapperEnum.MessageBoxCaptionFeatureDisabled, MyTextsWrapperEnum.Ok, null));
                        return;
                    }
                }
                else if (!MyClientServer.HasFullGame)
                {
                    MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.MESSAGE, MyTextsWrapperEnum.YouNeedFullGame, MyTextsWrapperEnum.MessageBoxCaptionFeatureDisabled, MyTextsWrapperEnum.Ok, null));
                    return;
                }
            }


            MyConfig.LastSandboxSector = sectorIdentifier.Position;
            MyConfig.Save();

            MyGuiManager.CloseAllScreensNowExcept(MyGuiScreenGamePlay.Static);

            if (CustomLoadAction != null)
            {
                CustomLoadAction(sectorIdentifier);
            }
            else
            {
                MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(m_startSessionType, m_startSessionProgressText,
                                                                           sectorIdentifier,
                                                                           CommonLIB.AppCode.ObjectBuilders.MyGameplayDifficultyEnum.EASY,
                                                                           null,
                                                                           m_closeAfterSuccessfulEnter));
            }
        }
예제 #20
0
 //returns SectorScreenshot texture based on UserId, SectorPosition and Sector Type
 private MyTexture2D GetSectorScreenshot(MyMwcSectorIdentifier sectorIdentifier)
 {
     if (sectorIdentifier.UserId == null && sectorIdentifier.SectorType == MyMwcSectorTypeEnum.SANDBOX)
     {
         if (m_sectorPositionsToTextures.ContainsKey(sectorIdentifier.Position))
         {
             return(MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\SectorScreens\\" + m_sectorPositionsToTextures[sectorIdentifier.Position], flags: TextureFlags.IgnoreQuality));
         }
         else
         {
             return(MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\SectorScreens\\NoPhoto", flags: TextureFlags.IgnoreQuality));
         }
     }
     else
     {
         return(null);
     }
 }
예제 #21
0
        // This method works on foreground, on current thread
        public MyMwcObjectBuilder_SectorObjectGroups LoadSectorGroups(MyMwcVector3Int sectorPosition)
        {
            var sectorId = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, null, sectorPosition, String.Empty);
            var sector   = MyLocalCache.LoadSector(sectorId);
            int?version  = sector != null ? (int?)sector.Version : null;

            var groupBuilder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.SectorObjectGroups, null) as MyMwcObjectBuilder_SectorObjectGroups;

            if (sector == null)
            {
                throw new MyDataCorruptedException("Sector cannot be loaded");
            }

            // Server said: use cache
            groupBuilder.Generated = sector.Generated;
            groupBuilder.Entities  = sector.SectorObjects;
            groupBuilder.Groups    = sector.ObjectGroups;
            return(groupBuilder);
        }
예제 #22
0
 private static MyMwcObjectBuilder_Sector LoadSector(MyMwcSectorIdentifier sectorId, string filename)
 {
     if (File.Exists(filename))
     {
         MyMwcObjectBuilder_Sector result = LoadData <MyMwcObjectBuilder_Sector>(filename);
         if (result == null)
         {
             MyMwcLog.WriteLine("Incorrect save data");
             return(null);
         }
         Log("hit", sectorId, result.Version);
         return(result);
     }
     else
     {
         Log("miss", sectorId);
         return(null);
     }
 }
예제 #23
0
        private MyGuiScreenEditorSaveProgress Save(bool saveSector, string checkpointName, bool asTemplate, bool visibleSave, bool pause)
        {
            MyMwcSectorIdentifier sectorId = MyGuiScreenGamePlay.Static.GetSectorIdentifier();
            bool isEditor = MyGuiScreenGamePlay.Static.IsEditorActive();

            if (CanBeSaved(asTemplate, sectorId, isEditor))
            {
                MyMwcObjectBuilder_Checkpoint checkpoint = GetCheckpointBuilder(saveSector);
                checkpoint.CheckpointName = checkpointName;

                // Need to store actual checkpoint...because when we travel, we receive only sector, not checkpoint
                MyGuiScreenGamePlay.Static.AddEnterSectorResponse(checkpoint, null);

                bool savePlayerShip = MyGuiScreenGamePlay.Static.GetGameType() == MyGuiScreenGamePlayType.EDITOR_STORY ? MyEditor.SavePlayerShip : true;

                if (savePlayerShip && saveSector)
                {
                    UpdatePlayerStartDummy(checkpoint);
                }

                MyHudNotification.MyNotification notification = null;
                if (!visibleSave)
                {
                    notification = new MyHudNotification.MyNotification(Localization.MyTextsWrapperEnum.SavingSectorToServer, 2500);
                    MyHudNotification.AddNotification(notification);
                }

                StringBuilder errors = null;
                if (isEditor)
                {
                    errors = CheckMissingObject(checkpoint);
                }

                MyGuiScreenEditorSaveProgress screen = new MyGuiScreenEditorSaveProgress(sectorId, checkpoint, savePlayerShip, visibleSave, pause);
                //screen.Closed += new MyGuiScreenBase.ScreenHandler((s) => { if (notification != null) notification.Disappear(); });

                CheckErrors(errors, screen);
                return(screen);
            }

            return(null);
        }
예제 #24
0
        public static void LoadContent(MyMwcSectorIdentifier sectorIdentifier)
        {
            MyMwcLog.WriteLine("MyBackgroundCube.LoadContent() - START");
            MyMwcLog.IncreaseIndent();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyBackgroundCube");

            m_sectorIdentifier = sectorIdentifier;

            UpdateTexture();
         
            m_loaded = false;

            //  Projection matrix according to zoom level
            m_backgroundProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(1.0f, MyCamera.ForwardAspectRatio,
                5,
                100000);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyBackgroundCube.LoadContent() - END");
        }
예제 #25
0
        public static void LoadContent(MyMwcSectorIdentifier sectorIdentifier)
        {
            MyMwcLog.WriteLine("MyBackgroundCube.LoadContent() - START");
            MyMwcLog.IncreaseIndent();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyBackgroundCube");

            m_sectorIdentifier = sectorIdentifier;

            UpdateTexture();

            m_loaded = false;

            //  Projection matrix according to zoom level
            m_backgroundProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(1.0f, MyCamera.ForwardAspectRatio,
                                                                               5,
                                                                               100000);

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyBackgroundCube.LoadContent() - END");
        }
예제 #26
0
        private MyServerAction LoadSandbox(MyMwcVector3Int position, int?userId, MyMissionID?startMission)
        {
            var sectorId = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, userId, position, null);
            var sector   = MyLocalCache.LoadSector(sectorId);
            int?version  = sector != null ? (int?)sector.Version : null;

            MyMwcStartSessionRequestTypeEnum startSessionType = userId == MyClientServer.LoggedPlayer.GetUserId() ? MyMwcStartSessionRequestTypeEnum.SANDBOX_OWN : MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS;

            if (userId != null)
            {
                MyServerAction loadAction = new MyServerAction(MyTextsWrapperEnum.EnterSectorInProgressPleaseWait, TimeSpan.FromSeconds(360));
                loadAction.BeginAction = c => c.BeginLoadSandbox(position, userId, version, null, c);
                loadAction.EndAction   = (c, r) => SandboxSectorLoaded(position, MyMwcObjectBuilder_Base.FromBytes <MyMwcObjectBuilder_Checkpoint>(c.EndLoadSandbox(r)), sector, startSessionType, startMission);
                loadAction.Start();
                return(loadAction);
            }
            else if (sector != null)
            {
                var checkpoint = MyLocalCache.MultiplayerCheckpoint();
                if (checkpoint == null)
                {
                    throw new MyDataCorruptedException("Cannot load MP checkpoint");
                }

                if (!MySteam.IsActive && MyClientServer.IsMwAccount)
                {
                    checkpoint.PlayerObjectBuilder.Money = (float)MySectorServiceClient.GetCheckedInstance().GetGameMoney();
                    MySectorServiceClient.SafeClose();
                }

                checkpoint.SectorObjectBuilder = sector;
                SandboxSectorLoaded(position, checkpoint, sector, startSessionType, startMission);
                return(null);
            }
            else
            {
                throw new MyDataCorruptedException("Cannot load sandbox/MP sector");
            }
        }
        static string GetVoxelName(MyVoxelMap voxelMap, MyMwcSectorIdentifier sectorIdentifier, int sectorVersion)
        {
            string name;
            switch (sectorIdentifier.SectorType)
            {
                case MyMwcSectorTypeEnum.STORY:
                    name = "STORY";
                    break;

                case MyMwcSectorTypeEnum.SANDBOX:
                    name = "SANDBOX";
                    break;

                default:
                    throw new MyMwcExceptionApplicationShouldNotGetHere();
            }

            string userId = sectorIdentifier.UserId.HasValue ? sectorIdentifier.UserId.Value.ToString(CultureInfo.InvariantCulture) : "NULL";

            Debug.Assert(voxelMap.EntityId != null, "voxelMap.EntityId != null");
            return String.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}", name, userId, sectorIdentifier.Position.X, sectorIdentifier.Position.Y, sectorIdentifier.Position.Z, sectorVersion, voxelMap.VoxelMapId, voxelMap.EntityId.Value.NumericValue);
        }
예제 #28
0
        static string GetVoxelName(MyVoxelMap voxelMap, MyMwcSectorIdentifier sectorIdentifier, int sectorVersion)
        {
            string name;

            switch (sectorIdentifier.SectorType)
            {
            case MyMwcSectorTypeEnum.STORY:
                name = "STORY";
                break;

            case MyMwcSectorTypeEnum.SANDBOX:
                name = "SANDBOX";
                break;

            default:
                throw new MyMwcExceptionApplicationShouldNotGetHere();
            }

            string userId = sectorIdentifier.UserId.HasValue ? sectorIdentifier.UserId.Value.ToString(CultureInfo.InvariantCulture) : "NULL";

            Debug.Assert(voxelMap.EntityId != null, "voxelMap.EntityId != null");
            return(String.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}", name, userId, sectorIdentifier.Position.X, sectorIdentifier.Position.Y, sectorIdentifier.Position.Z, sectorVersion, voxelMap.VoxelMapId, voxelMap.EntityId.Value.NumericValue));
        }
예제 #29
0
        public static string GetSectorPath(MyMwcSectorIdentifier sector)
        {
            string dir;
            string file;

            if (IsSave(sector))
            {
                dir  = CurrentSavePath;
                file = GetSectorName(sector, false) + ".mws"; // Saves does not include UserId
            }
            else
            {
                dir  = CachePath;
                file = GetSectorName(sector, true) + ".mws"; // Cache include UserId
            }

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            return(Path.Combine(dir, file));
        }
예제 #30
0
 static bool IsSave(MyMwcSectorIdentifier sector)
 {
     return(sector.UserId != null && sector.SectorType == MyMwcSectorTypeEnum.STORY);
 }
예제 #31
0
        public MyServerAction Travel(MyMwcTravelTypeEnum travelType, MyMwcSectorIdentifier targetSector)
        {
            Debug.Assert(targetSector.SectorType == MyMwcSectorTypeEnum.STORY, "Travel is allowed only in story");

            TryPause();

            var sector = MyLocalCache.LoadSector(targetSector);

            if (sector == null)
            {
                var storySectorId = targetSector;
                storySectorId.UserId = null;
                sector = MyLocalCache.LoadSector(storySectorId);
            }

            if (sector != null)
            {
                TravelSectorLoaded(travelType, targetSector.Position, null, sector);
                return null;
            }
            else // Not using server...so sector is "from generator"
            {
                TravelSectorLoaded(travelType, targetSector.Position, null, MyMwcObjectBuilder_Sector.UseGenerator());
                return null;
            }
        }
예제 #32
0
        private MyServerAction LoadSandbox(MyMwcVector3Int position, int? userId, MyMissionID? startMission)
        {
            var sectorId = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, userId, position, null);
            var sector = MyLocalCache.LoadSector(sectorId);
            int? version = sector != null ? (int?)sector.Version : null;

            MyMwcStartSessionRequestTypeEnum startSessionType = userId == MyClientServer.LoggedPlayer.GetUserId() ? MyMwcStartSessionRequestTypeEnum.SANDBOX_OWN : MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS;

            if (userId != null)
            {
                MyServerAction loadAction = new MyServerAction(MyTextsWrapperEnum.EnterSectorInProgressPleaseWait, TimeSpan.FromSeconds(360));
                loadAction.BeginAction = c => c.BeginLoadSandbox(position, userId, version, null, c);
                loadAction.EndAction = (c, r) => SandboxSectorLoaded(position, MyMwcObjectBuilder_Base.FromBytes<MyMwcObjectBuilder_Checkpoint>(c.EndLoadSandbox(r)), sector, startSessionType, startMission);
                loadAction.Start();
                return loadAction;
            }
            else if (sector != null)
            {
                var checkpoint = MyLocalCache.MultiplayerCheckpoint();
                if (checkpoint == null)
                {
                    throw new MyDataCorruptedException("Cannot load MP checkpoint");
                }

                if (!MySteam.IsActive && MyClientServer.IsMwAccount)
                {
                    checkpoint.PlayerObjectBuilder.Money = (float)MySectorServiceClient.GetCheckedInstance().GetGameMoney();
                    MySectorServiceClient.SafeClose();
                }

                checkpoint.SectorObjectBuilder = sector;
                SandboxSectorLoaded(position, checkpoint, sector, startSessionType, startMission);
                return null;
            }
            else
            {
                throw new MyDataCorruptedException("Cannot load sandbox/MP sector");
            }
        }
        public void AddResponse(MyMwcStartSessionResponseTypeEnum startSessionResponse, MyMwcSectorIdentifier? sectorIdentifier, MyGameplayDifficultyEnum difficulty)
        {
            MyGuiScreenGamePlayType screenType;

            if (startSessionResponse == MyMwcStartSessionResponseTypeEnum.OK)
            {
                MyMwcSectorTypeEnum sessionType;
                MyMwcSessionStateEnum sessionStartType;
                int? userId = null;
                MyMwcVector3Int? position = null;

                if ((m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY) || (m_sessionType == MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT))
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.GAME_STORY;

                    sessionType = MyMwcSectorTypeEnum.STORY;
                    sessionStartType = m_sessionType == MyMwcStartSessionRequestTypeEnum.NEW_STORY ? MyMwcSessionStateEnum.NEW_GAME : MyMwcSessionStateEnum.LOAD_CHECKPOINT;
                    userId = MyClientServer.LoggedPlayer.GetUserId();
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX)
                {
                    MySession.Static = new MySandboxSession();
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_SANDBOX;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    Debug.Assert(m_sectorIdentifier.Value.UserId == null || m_sectorIdentifier.Value.UserId == MyClientServer.LoggedPlayer.GetUserId(), "Sandbox sector user identifier must be null or same as current user");
                    sessionType = MyMwcSectorTypeEnum.SANDBOX;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId = m_sectorIdentifier.Value.UserId;
                    position = m_sectorIdentifier.Value.Position;
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_STORY)
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_STORY;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    sessionType = MyMwcSectorTypeEnum.STORY;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId = null;
                    position = m_sectorIdentifier.Value.Position;
                }
                else if (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_MMO)
                {
                    MySession.Static = new MySinglePlayerSession(difficulty);
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.EDITOR_MMO;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for editor");
                    sessionType = MyMwcSectorTypeEnum.MMO;
                    sessionStartType = MyMwcSessionStateEnum.EDITOR;
                    userId = null;
                    position = m_sectorIdentifier.Value.Position;
                }
                else if (
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_OWN) || 
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS) ||
                    (m_sessionType == MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM))
                {
                    MySession.Static = new MySandboxSession();
                    MySession.Static.Init();

                    screenType = MyGuiScreenGamePlayType.GAME_SANDBOX;

                    Debug.Assert(m_sectorIdentifier.HasValue, "Sector identifier must be set for sandbox");
                    sessionType = MyMwcSectorTypeEnum.SANDBOX;
                    sessionStartType = MyMwcSessionStateEnum.LOAD_CHECKPOINT;
                    userId = m_sectorIdentifier.Value.UserId;
                    position = m_sectorIdentifier.Value.Position;
                    //if (m_sessionType != MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM)
                    //{
                    //    position = m_sectorIdentifier.Value.Position;
                    //}
                }
                else
                {
                    throw new NotImplementedException();
                }
                
                Action<MyMwcObjectBuilder_Checkpoint> enterSuccessAction = new Action<MyMwcObjectBuilder_Checkpoint>((checkpoint) =>
                {
                    OnSuccessEnter(screenType, m_sessionType, checkpoint);
                });

                MyGuiManager.AddScreen(new MyGuiScreenLoadCheckpointProgress(sessionType, sessionStartType, userId, position, m_checkpointName, enterSuccessAction));

                if (m_closeAfter != null) m_closeAfter.CloseScreenNow();
            }
            else
            {
                MyMwcLog.WriteLine("Error starting the session: " + startSessionResponse.ToString());
                MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.StartGameFailed,
                    MyTextsWrapperEnum.MessageBoxCaptionError, MyTextsWrapperEnum.Ok, null));
            }

            CloseScreen();
        }
예제 #34
0
        public static void Save(MyMwcObjectBuilder_Checkpoint checkpoint, MyMwcObjectBuilder_Sector sector, MyMwcSectorIdentifier sectorIdentifier, bool createChapter = false)
        {
            if (sector == null) // Nothing to save, saving only checkpoint
            {
                return;
            }

            string sectorPath     = GetSectorPath(sectorIdentifier);
            string storeDirectory = Path.GetDirectoryName(sectorPath);

            // Store current sector
            SaveData(sector, sectorPath);


            // Store checkpoint
            if (checkpoint != null)
            {
                string checkpointPath = Path.Combine(storeDirectory, "Checkpoint.mwc");

                var oldValue = checkpoint.SectorObjectBuilder;
                checkpoint.SectorObjectBuilder = null;

                SaveData(checkpoint, checkpointPath);

                checkpoint.SectorObjectBuilder = oldValue;
            }

            if (createChapter)
            {
                var chapterDirectory = GetChapterDirectory(GetChapterName(checkpoint));
                if (Directory.Exists(chapterDirectory))
                {
                    Directory.Delete(chapterDirectory, true);
                }
                DirectoryExtensions.CopyAll(storeDirectory, chapterDirectory);
            }

            Log("update", sectorIdentifier, sector.Version);
        }
예제 #35
0
        public void TravelToSector(MyMwcSectorIdentifier sectorIdentifier, MyMwcTravelTypeEnum travelType, Vector3 currentShipPosition, MyMissionID? missionToStart = null)
        {
            if (MySession.Static != null)
            {
                if (m_type == MyGuiScreenGamePlayType.GAME_STORY && !MyClientServer.LoggedPlayer.GetCanSave()) // Game travel is not allowed when user cannot save
                {
                    return;
                }
                if (!CanTravel && !MyFakes.ENABLE_SOLAR_MAP && !MyFakes.TEST_MULTIPLE_LOAD_UNLOAD)
                {
                    return;
                }

                m_transferToNeighbouringSectorStarted = true;

                m_travelSectorIdentifier = sectorIdentifier;
                m_travelReason = travelType;
                m_missionToStart = missionToStart;

                if (m_type != MyGuiScreenGamePlayType.EDITOR_STORY && m_previousType != MyGuiScreenGamePlayType.EDITOR_STORY && !MyFakes.DISABLE_AUTO_SAVE)
                {
                    MySession.Static.Player.TravelLeave(m_travelReason);

                    if (!MyMinerGame.IsPaused())
                        MyMinerGame.SwitchPause();

                    MyServerAction serverAction = MySession.Static.SaveLastCheckpoint(); // Saving before travel, save sector
                    travelSaveSuccess();
                }
                else
                {
                    travelSaveSuccess();
                }
            }
        }
        public override bool Update(bool hasFocus)
        {
            if (!hasFocus)
            {
                return(base.Update(hasFocus));
            }

            if (m_childScreenLaunched && hasFocus)
            {
                CloseScreenNow();
            }

            if (m_childScreenLaunched)
            {
                return(base.Update(hasFocus));
            }

            switch (m_quickLaunchType)
            {
            case MyMwcQuickLaunchType.EDITOR_SANDBOX:
            {
                //normally when entering editor, you can choose which sector you would like, this is for programming purposes, choose whatever you want directly
                //MyMwcSectorIdentifier quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorGroupEnum.MIDDLE_WEST, MyMwcSectorTypeEnum.SANDBOX, null, new MyMwcVector3Int(0, 0, 0));

                MyMwcSectorIdentifier quickSectorIdentifier;

                if (MyFakes.MWBUILDER)
                {
                    quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, MyClientServer.LoggedPlayer.GetUserId(),
                                                                      MyFakes.MWBUILDER_SECTOR, null);
                }
                else
                {
                    quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, MyClientServer.LoggedPlayer.GetUserId(),
                                                                      MyConfig.LastSandboxSector, null);
                }

                bool bAssert = (quickSectorIdentifier.SectorType == MyMwcSectorTypeEnum.SANDBOX &&
                                quickSectorIdentifier.UserId == null);
                Debug.Assert(!bAssert);

                if (MyFakes.MWBUILDER)
                {
                    quickSectorIdentifier.UserId = null;
                    MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(
                                               MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX,
                                               MyTextsWrapperEnum.StartEditorInProgressPleaseWait,
                                               quickSectorIdentifier,
                                               MyGameplayDifficultyEnum.EASY, null, null));
                }
                else
                {
                    MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(
                                               MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX,
                                               MyTextsWrapperEnum.StartEditorInProgressPleaseWait,
                                               quickSectorIdentifier,
                                               MyGameplayDifficultyEnum.EASY, null, null));
                }
                m_childScreenLaunched = true;
            }
            break;

            case MyMwcQuickLaunchType.LAST_SANDBOX:
            {
                //normally when entering editor, you can choose which sector you would like, this is for programming purposes, choose whatever you want directly
                //MyMwcSectorIdentifier quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorGroupEnum.MIDDLE_WEST, MyMwcSectorTypeEnum.SANDBOX, null, new MyMwcVector3Int(0, 0, 0));

                MyMwcSectorIdentifier quickSectorIdentifier;

                int             userId = MyClientServer.LoggedPlayer.GetUserId();
                MyMwcVector3Int sector = MyConfig.LastSandboxSector;

                if (MyConfig.LastFriendSectorUserId.HasValue)
                {
                    userId = MyConfig.LastFriendSectorUserId.Value;
                    sector = MyConfig.LastFriendSectorPosition;
                }

                quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, userId,
                                                                  sector, null);

                bool bAssert = (quickSectorIdentifier.SectorType == MyMwcSectorTypeEnum.SANDBOX &&
                                quickSectorIdentifier.UserId == null);
                Debug.Assert(!bAssert);

                MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(
                                           MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS,
                                           MyTextsWrapperEnum.StartGameInProgressPleaseWait,
                                           quickSectorIdentifier,
                                           MyGameplayDifficultyEnum.EASY, null, null));
                m_childScreenLaunched = true;
            }
            break;

            case MyMwcQuickLaunchType.NEW_STORY:
            {
                MySession.StartNewGame(MyGameplayDifficultyEnum.EASY);
                m_childScreenLaunched = true;
            }
            break;

            case MyMwcQuickLaunchType.LOAD_CHECKPOINT:
            {
                MySession.StartLastCheckpoint();
                m_childScreenLaunched = true;
            }
            break;

            case MyMwcQuickLaunchType.SANDBOX_RANDOM:
            {
                MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(
                                           MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM,
                                           MyTextsWrapperEnum.StartGameInProgressPleaseWait,
                                           new MyMwcSectorIdentifier(
                                               MyMwcSectorTypeEnum.SANDBOX, MyClientServer.LoggedPlayer.GetUserId(),
                                               new MyMwcVector3Int(0, 0, 0), null),
                                           MyGameplayDifficultyEnum.EASY,
                                           null,
                                           null));
                m_childScreenLaunched = true;
            }
            break;

            default:
            {
                throw new MyMwcExceptionApplicationShouldNotGetHere();
            }
            }

            return(base.Update(hasFocus));
        }
        public MyGuiScreenSolarSystemMap(MyGuiScreenBase parent, MyMwcSectorIdentifier currentSector)
            : base(new Vector2(0.5f, 0.5f), null, Vector2.One)
        {
            m_parent = parent;
            m_enableBackgroundFade = false;
            DrawMouseCursor        = true;
            m_currentSector        = currentSector;
            m_closeOnEsc           = true;

            Static = this;

            MySolarSystemGenerator generator = new MySolarSystemGenerator(UNIVERSE_SEED);

            generator.Generate(1024);

            m_data           = generator.SolarSystemData;
            m_solarMapRender = new MySolarMapRenderer();
            m_solarMapRender.PlayerSector = currentSector.Position;

            //MyMinerGame.SwitchPause();
            m_particlesEnabled = TransparentGeometry.Particles.MyParticlesManager.Enabled;
            TransparentGeometry.Particles.MyParticlesManager.Enabled = false;

            //AddCaption(MyTextsWrapperEnum.SolarSystemMap);

            MySolarSystemMapNavigationMark playerNavigationMark =
                new MySolarSystemMapNavigationMark(
                    currentSector.Position,
                    "",
                    null,
                    MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR,
                    MyTransparentMaterialEnum.SolarMapPlayer)
            {
                VerticalLineColor  = MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR.ToVector4(),
                DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_green,
                Offset             = new Vector3(0, 0.0f, 0),
                Text       = MyClientServer.LoggedPlayer.GetDisplayName().ToString(),
                Importance = 50
            };

            m_data.NavigationMarks.Add(playerNavigationMark);

            if (MyGuiScreenGamePlay.Static.IsEditorStoryActive() || MyGuiScreenGamePlay.Static.GetPreviousGameType() == MyGuiScreenGamePlayType.EDITOR_STORY)
            {
                // Loads all marks, we want it for editor
                LoadMarks(false);
            }
            else
            {
                // Load only active marks
                MyMissions.AddSolarMapMarks(m_data);
            }

            if (MyMissions.ActiveMission != null)
            {
                MyMissions.ActiveMission.AddSolarMapMarks(m_data);
            }

            m_travelButton = new MyGuiControlButton(this, new Vector2(0.0f, 0.40f),
                                                    new Vector2(650f / 1600f, 120f / 1200f),
                                                    MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyGuiManager.GetTravelButtonTexture(),
                                                    MyGuiManager.GetTravelButtonTexture(),
                                                    MyGuiManager.GetTravelButtonTexture(),
                                                    MyTextsWrapperEnum.Travel,
                                                    MyGuiConstants.BACK_BUTTON_TEXT_COLOR,
                                                    MyGuiConstants.BACK_BUTTON_TEXT_SCALE,
                                                    MyGuiControlButtonTextAlignment.CENTERED,
                                                    OnTravelClick,
                                                    false,
                                                    MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                                    true,
                                                    false);
            m_travelButton.TextOffset = new Vector2(0, -0.0030f);
            m_travelButton.Visible    = false;
            Controls.Add(m_travelButton);

            // target sector 0, 0, 0
            // distance is 1.7 sectors from camera
            Vector3 sector;

            var mostImportantMark = m_data.NavigationMarks.GetMostImportant();

            if (mostImportantMark != null)
            {
                sector = new Vector3(mostImportantMark.Sector.X, mostImportantMark.Sector.Y, mostImportantMark.Sector.Z);
            }
            else
            {
                sector = new Vector3(currentSector.Position.X, currentSector.Position.Y, currentSector.Position.Z);
            }

            sector.Y = 0;

            m_camera = new MySolarSystemMapCamera(sector * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS, 10000000.0f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS);
            m_camera.MinDistanceToTarget = 1.7f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS;
            m_camera.MaxDistanceToTarget = 1.2f * MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length()) * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS;
            m_camera.MaxSector           = MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length());

            MyGuiManager.FullscreenHudEnabled = true;
        }
예제 #38
0
        public void OnEditorClick(MyGuiControlButton sender)
        {
            if (MyClientServer.LoggedPlayer == null || MyClientServer.LoggedPlayer.GetCanAccessEditorForStory() || MyClientServer.LoggedPlayer.GetCanAccessEditorForMMO())
            {
                AddLoginScreen(new MyGuiScreenSelectEditor(this));
            }
            else if (!MySteam.IsActive && !MyClientServer.IsMwAccount) // Demo user...generate sector 0, 0, 0. User cant save.
            {
                MyGuiManager.CloseAllScreensNowExcept(MyGuiScreenGamePlay.Static);

                MySession.Static = new MySandboxSession();
                MySession.Static.Init();

                var sector = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, MyPlayerLocal.OFFLINE_MODE_USERID, new CommonLIB.AppCode.Utils.MyMwcVector3Int(0, 0, 0), String.Empty);
                var newGameplayScreen = new MyGuiScreenGamePlay(MyGuiScreenGamePlayType.EDITOR_SANDBOX, null, sector, 0, MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX);
                var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);

                var checkpoint = new MyMwcObjectBuilder_Checkpoint();
                checkpoint.CurrentSector = sector;
                checkpoint.SectorObjectBuilder = new MyMwcObjectBuilder_Sector();
                checkpoint.SectorObjectBuilder.FromGenerator = true;
                checkpoint.SectorObjectBuilder.Position = sector.Position;
                checkpoint.SessionObjectBuilder = new MyMwcObjectBuilder_Session(MyGameplayDifficultyEnum.EASY);

                loadScreen.AddEnterSectorResponse(checkpoint, null);

                MyGuiManager.AddScreen(loadScreen);
            }
            else
            {
                MyMwcSectorTypeEnum sectorType = MyMwcClientServer.GetSectorTypeFromSessionType(MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX);
                AddLoginScreen(
                    new MyGuiScreenLoadSectorIdentifiersProgress(sectorType, false, new MyGuiScreenEnterSectorMap(this, MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX, MyTextsWrapperEnum.StartEditorInProgressPleaseWait, MyConfig.LastSandboxSector)));
            }
        }
예제 #39
0
 void StartSandbox(MyMwcSectorIdentifier sector)
 {
     MySession.StartSandbox(sector.Position, sector.UserId);
 }
예제 #40
0
        private void MultipleSaveLoadTest()
        {
            Debug.Assert(this == MyGuiScreenGamePlay.Static, "Something went terribly wrong");

            if (m_multipleReloadEntityIds != null)
            {
                HashSet<uint> m_currentEntities = new HashSet<uint>();
                GetAllEntityIds(MyEntities.GetEntities(), m_currentEntities);
                bool isOk = true;

                foreach (var id in m_multipleReloadEntityIds)
                {
                    if (!m_currentEntities.Remove(id))
                    {
                        // Current entities did not contain required entity id!
                        //Debug.Fail("Missing entity ID: " + id.ToEntityId());
                        isOk = false;
                        MyMwcLog.WriteLine("SAVE/LOAD TEST, missing entity id " + id.ToEntityId());
                    }
                }

                if (isOk)
                {
                    MyMwcLog.WriteLine("SAVE/LOAD TEST reload OK, num reloads: " + m_multipleLoadsCount);
                }
                saveSector(null);
            }
            else
            {
                MyMwcLog.WriteLine("Starting SAVE/LOAD TEST sector name: " + m_sectorIdentifier.SectorName + ", sector Id: " + m_sectorIdentifier);

                m_multipleReloadEntityIds = new HashSet<uint>();
                GetAllEntityIds(MyEntities.GetEntities(), m_multipleReloadEntityIds);

                // Little hack to save it to another sector (not to overwrite default)
                var userId = MyClientServer.LoggedPlayer.GetUserId();
                m_sectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, null, new MyMwcVector3Int(245450000 + userId, 0, -345457126), "ReloadTest_" + userId.ToString());

                // Lets tell server we are editing another sector (and drop his response)
                var switchSectorScreen = new MyGuiScreenLoadCheckpointProgress(m_sectorIdentifier.SectorType, MyMwcSessionStateEnum.EDITOR, m_sectorIdentifier.UserId, m_sectorIdentifier.Position, null, DummyEnterAction);
                MyGuiManager.AddScreen(switchSectorScreen);
                switchSectorScreen.Closed += new ScreenHandler(saveSector);
            }
        }
예제 #41
0
        public MyGuiScreenGamePlay(MyGuiScreenGamePlayType type, MyGuiScreenGamePlayType? previousType, MyMwcSectorIdentifier sectorIdentifier, int sectorVersion, MyMwcStartSessionRequestTypeEnum? sessionType)
            : base(Vector2.Zero, null, null)
        {
            MySystemTimer.SetByType(type);

            m_sessionType = sessionType;
            m_sectorIdentifier = sectorIdentifier;
            SectorVersion = sectorVersion;
            m_directionToSunNormalized = -MyMwcUtils.Normalize(GetPositionInMillionsOfKm());
            DrawMouseCursor = false;
            m_closeOnEsc = false;
            m_type = type;
            m_previousType = previousType;
            m_firstUpdateCall = true;
            m_firstDrawCall = FIRST_TOTAL_DELAY;
            m_drawEvenWithoutFocus = true;
            m_enableBackgroundFade = true;
            m_canShareInput = false;
            m_screenCanHide = false;

            m_isPreparedTextureForSectorLoadingScreen = false;
            m_prepareTextureForSectorLoadingScreen = false;

            MinerWars.AppCode.Networking.SectorService.MySectorServerCallback.ClearEvents();
            MinerWars.AppCode.Networking.SectorService.MySectorServerCallback.ShutdownNotification += new MinerWars.AppCode.Networking.SectorService.MySectorServerCallback.ShutdownHandler(MySectorServerCallback_ShutdownNotification);

            m_secondarySetup = new MyRender.MyRenderSetup();
            m_secondarySetup.EnabledModules = new HashSet<MyRenderModuleEnum>();
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Cockpit);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.CockpitGlass);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SunGlareAndLensFlare);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.UpdateOcclusions);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.AnimatedParticlesPrepare);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.TransparentGeometry);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.ParticlesDustField);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.VoxelHand);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.DistantImpostors);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Decals);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.CockpitWeapons);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SunGlow);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SectorBorder);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.DrawSectorBBox);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.DrawCoordSystem);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Explosions);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.BackgroundCube);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.GPS);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.TestField);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.AnimatedParticles);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Lights);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.TransparentGeometryForward);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Projectiles);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.DebrisField);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.ThirdPerson);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.Editor);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SolarObjects);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SolarMapGrid);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.PrunningStructure);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.SunWind);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.IceStormWind);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.PrefabContainerManager);
            m_secondarySetup.EnabledModules.Add(MyRenderModuleEnum.PhysicsPrunningStructure);

            m_showGPSNotification = new MyHudNotification.MyNotification(MyTextsWrapperEnum.GPSReminder, MyHudConstants.MISSION_FONT, MyHudNotification.DONT_DISAPEAR, null, null);
            m_showGPSNotification.SetTextFormatArguments(new object[] { MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.GPS) });
        }
예제 #42
0
        //  Check if we are still in sector and if not load neighbouring sector. Also display info to user that we are approaching the border.
        void ProcessSectorBoundaries()
        {
            if ((IsGameActive() == false) || (m_transferToNeighbouringSectorStarted)) return;

            Debug.Assert(MySession.PlayerShip != null);

            m_distanceToSectorBoundaries = MyUtils.GetClosestDistanceFromPointToAxisAlignedBoundingBox(
                MySession.PlayerShip.GetPosition(), MyMwcSectorConstants.SAFE_SECTOR_SIZE_BOUNDING_BOX);

            if (!CanTravelThroughSectorBoundaries())
            {
                Vector3 playerPosition = MySession.PlayerShip.GetPosition();

                Vector3 newPlayerPosition = Vector3.Clamp(playerPosition, new Vector3(-MyMwcSectorConstants.SECTOR_SIZE_HALF), new Vector3(MyMwcSectorConstants.SECTOR_SIZE_HALF));

                if (!MyMwcUtils.IsZero(newPlayerPosition - playerPosition))
                {
                    MySession.PlayerShip.SetPosition(newPlayerPosition);
                }

                return;
            }

            if (MyMwcSectorConstants.SAFE_SECTOR_SIZE_BOUNDING_BOX.Contains(MySession.PlayerShip.GetPosition()) == MinerWarsMath.ContainmentType.Disjoint)
            {
                //  Choose neighbouring sector in the correct direction
                MyMwcVector3Int neighSectorRelCoord = GetSectorIdentifierCoordinatesFromRealCoordinates(MySession.PlayerShip.GetPosition());
                MyMwcSectorIdentifier sectorIdentifier = new MyMwcSectorIdentifier(m_sectorIdentifier.SectorType, m_sectorIdentifier.UserId, new MyMwcVector3Int(
                    m_sectorIdentifier.Position.X + neighSectorRelCoord.X,
                    m_sectorIdentifier.Position.Y + neighSectorRelCoord.Y,
                    m_sectorIdentifier.Position.Z + neighSectorRelCoord.Z),
                    null);

                if (CanTravelToSector(sectorIdentifier.Position))
                {
                    m_prepareTextureForSectorLoadingScreen = true;
                    if (m_isPreparedTextureForSectorLoadingScreen)
                    {
                        TravelToSector(sectorIdentifier, MyMwcTravelTypeEnum.NEIGHBOUR, MySession.PlayerShip.GetPosition());
                    }
                }
                else
                {
                    MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.ForbiddenSolarMapAreaWarning, MyTextsWrapperEnum.Warning, MyTextsWrapperEnum.Ok, null));

                    Vector3 playerPosition = MySession.PlayerShip.GetPosition();
                    playerPosition = Vector3.Clamp(playerPosition, new Vector3(-MyMwcSectorConstants.SECTOR_SIZE_HALF), new Vector3(MyMwcSectorConstants.SECTOR_SIZE_HALF));
                    MySession.PlayerShip.SetPosition(playerPosition);
                }
            }
        }
 //returns SectorScreenshot texture based on UserId, SectorPosition and Sector Type
 private MyTexture2D GetSectorScreenshot(MyMwcSectorIdentifier sectorIdentifier)
 {
     if (sectorIdentifier.UserId == null && sectorIdentifier.SectorType == MyMwcSectorTypeEnum.SANDBOX)
     {
         if (m_sectorPositionsToTextures.ContainsKey(sectorIdentifier.Position))
         {
             return MyTextureManager.GetTexture<MyTexture2D>("Textures\\GUI\\SectorScreens\\" + m_sectorPositionsToTextures[sectorIdentifier.Position], flags: TextureFlags.IgnoreQuality);
         }
         else
         {
             return MyTextureManager.GetTexture<MyTexture2D>("Textures\\GUI\\SectorScreens\\NoPhoto", flags: TextureFlags.IgnoreQuality);
         }
     }
     else
     {
         return null;
     }
 }
예제 #44
0
        // This method works on foreground, on current thread
        public MyMwcObjectBuilder_SectorObjectGroups LoadSectorGroups(MyMwcVector3Int sectorPosition)
        {
            var sectorId = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, null, sectorPosition, String.Empty);
            var sector = MyLocalCache.LoadSector(sectorId);
            int? version = sector != null ? (int?)sector.Version : null;

            var groupBuilder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.SectorObjectGroups, null) as MyMwcObjectBuilder_SectorObjectGroups;

            if (sector == null)
            {
                throw new MyDataCorruptedException("Sector cannot be loaded");
            }

            // Server said: use cache
            groupBuilder.Generated = sector.Generated;
            groupBuilder.Entities = sector.SectorObjects;
            groupBuilder.Groups = sector.ObjectGroups;
            return groupBuilder;
        }
        public static MyGuiScreenEditorLoadObjectGroupsProgress CurrentScreen = null;    //  This is always filled with reference to actual instance of this scree. If there isn't, it's null.

        public MyGuiScreenEditorLoadObjectGroupsProgress(MyTextsWrapperEnum loadingText, MyMwcSectorIdentifier sectorIdentifier)
            : base(loadingText, false, TimeSpan.FromSeconds(360))
        {
            CurrentScreen = this;
            m_sectorIdentifier = sectorIdentifier;
        }
예제 #46
0
        public static bool CanBeSaved(bool asTemplate, MyMwcSectorIdentifier sectorId, bool fromEditor)
        {
            bool isLogged = MyClientServer.LoggedPlayer != null; // Must be logged
            bool isNotDemo = !MyClientServer.LoggedPlayer.IsDemoUser(); // Cannot be demo user
            bool sectorCanBeSaved = sectorId.CanBeCheckpointSaved(); // Sector must be savable (for story only zero plane)
            bool canSaveObjectives = MyMissions.CanSaveObjectives();

            // Story sectors can be only on "zero" plane (Y coordinate is 0)
            return
                isLogged && isNotDemo && sectorCanBeSaved && canSaveObjectives
                && (asTemplate == false || MyClientServer.LoggedPlayer.GetCanAccessEditorForStory()) // When saving story template, must have story editor access
                && (fromEditor == false || sectorId.SectorType != MyMwcSectorTypeEnum.STORY || MyClientServer.LoggedPlayer.GetCanAccessEditorForStory()); // To save STORY sector from editor, it's necessary to have rights
        }
예제 #47
0
        private void RecreateControls()
        {
            Controls.Clear();

            m_size = new Vector2(1100f / 1600f, 1200 / 1200f);

            Vector2 controlsOriginLeft  = new Vector2(-m_size.Value.X / 2.0f + 0.07f, -m_size.Value.Y / 2.0f + 0.2f - 0.0360f);
            Vector2 controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.07f + 0.355f, -m_size.Value.Y / 2.0f + 0.2f - 0.0360f);



            AddCaption(MyTextsWrapperEnum.TemporarySectorMap, new Vector2(0, 0.035f));

            //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft, null, MyTextsWrapperEnum.Map, MyGuiConstants.LABEL_TEXT_COLOR,
            //    MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            if (m_sectors != null && m_sectors.Count > 0)
            {
                // When editing global story sectors, add some unused sector
                AddUnusedSector();

                int selectedIndex = 0;

                /*m_sectorsCombobox = new MyGuiControlCombobox(this, new Vector2(0, -0.17f), MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 6, true, false, true);
                 * for (int i = 0; i < m_sectors.Count; i++)
                 * {
                 *  MyMwcSectorIdentifier sectorIdentifier = m_sectors[i];
                 *
                 *  if (m_lastSandboxSector.HasValue && sectorIdentifier.Position.Equals(m_lastSandboxSector.Value))
                 *  {
                 *      selectedIndex = i;
                 *  }
                 *
                 *  if (string.IsNullOrEmpty(sectorIdentifier.SectorName))
                 *  {
                 *      m_sectorsCombobox.AddItem(i, GetSectorScreenshot(sectorIdentifier), new StringBuilder(string.Format("{0}", sectorIdentifier.Position.ToString())));
                 *  }
                 *  else
                 *  {
                 *      m_sectorsCombobox.AddItem(i, GetSectorScreenshot(sectorIdentifier), new StringBuilder(string.Format("{0} ({1})", sectorIdentifier.SectorName, sectorIdentifier.Position.ToString())));
                 *  }
                 * }
                 *
                 * SortSectors();
                 *
                 * m_sectorsCombobox.SelectItemByKey(selectedIndex);
                 * m_sectorsCombobox.OnSelectItemDoubleClick += OnItemDoubleClick;
                 * Controls.Add(m_sectorsCombobox);*/

                //Listbox

                m_sectorsListbox = new MyGuiControlListbox(this, new Vector2(0, -0.025f), new Vector2(0.43f, 0.1f), MyGuiConstants.LISTBOX_BACKGROUND_COLOR, null, MyGuiConstants.LABEL_TEXT_SCALE, 1, 6, 1, true, true, false,
                                                           null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 1, 0, MyGuiConstants.LISTBOX_BACKGROUND_COLOR_BLUE, 0f, 0f, 0f, 0f, 0, 0f, -0.01f, -0.01f, -0.02f, 0.02f)
                {
                    IconScale = new Vector2(0.97f)
                };
                for (int i = 0; i < m_sectors.Count; i++)
                {
                    MyMwcSectorIdentifier sectorIdentifier = m_sectors[i];

                    if (m_lastSandboxSector.HasValue && sectorIdentifier.Position.Equals(m_lastSandboxSector.Value))
                    {
                        selectedIndex = i;
                    }

                    if (string.IsNullOrEmpty(sectorIdentifier.SectorName))
                    {
                        m_sectorsListbox.AddItem(i, new StringBuilder(string.Format("{0}", sectorIdentifier.Position.ToString())), GetSectorScreenshot(sectorIdentifier));
                    }
                    else
                    {
                        m_sectorsListbox.AddItem(i, new StringBuilder(string.Format("{0} ({1})", sectorIdentifier.SectorName, sectorIdentifier.Position.ToString())), GetSectorScreenshot(sectorIdentifier));
                    }
                }

                SortSectors();

                m_sectorsListbox.SetSelectedItem(selectedIndex);
                m_sectorsListbox.ItemDoubleClick += OnItemDoubleClick;
                Controls.Add(m_sectorsListbox);
            }
            else
            {
                var text = m_loadingSectors.HasValue ? MyTextsWrapperEnum.LoadingPleaseWait : MyTextsWrapperEnum.NoSectorsAvailable;

                Controls.Add(new MyGuiControlLabel(this, new Vector2(0, -0.03f), null, text, MyGuiConstants.LABEL_TEXT_COLOR,
                                                   MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            }



            //  Buttons OK and CANCEL
            var m_okButton = new MyGuiControlButton(this, new Vector2(-0.0879f, 0.35f), MyGuiConstants.OK_BUTTON_SIZE * 0.75f,
                                                    MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Ok,
                                                    MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick,
                                                    true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(m_okButton);

            var m_cancelButton = new MyGuiControlButton(this, new Vector2(0.0879f, 0.35f), MyGuiConstants.OK_BUTTON_SIZE * 0.75f,
                                                        MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                        MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Cancel,
                                                        MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick,
                                                        true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(m_cancelButton);
        }
        public override bool Update(bool hasFocus)
        {
            if (!hasFocus)
                return base.Update(hasFocus);

            if (m_childScreenLaunched && hasFocus)
                CloseScreenNow();

            if (m_childScreenLaunched)
                return base.Update(hasFocus);

            switch (m_quickLaunchType)
            {
                case MyMwcQuickLaunchType.EDITOR_SANDBOX:
                    {
                        //normally when entering editor, you can choose which sector you would like, this is for programming purposes, choose whatever you want directly
                        //MyMwcSectorIdentifier quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorGroupEnum.MIDDLE_WEST, MyMwcSectorTypeEnum.SANDBOX, null, new MyMwcVector3Int(0, 0, 0));

                        MyMwcSectorIdentifier quickSectorIdentifier;

                        if (MyFakes.MWBUILDER)
                        {
                            quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, MyClientServer.LoggedPlayer.GetUserId(),
                                                                                MyFakes.MWBUILDER_SECTOR, null);
                        }
                        else
                        {
                            quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, MyClientServer.LoggedPlayer.GetUserId(),
                                                                                MyConfig.LastSandboxSector, null);
                        }

                        bool bAssert = (quickSectorIdentifier.SectorType == MyMwcSectorTypeEnum.SANDBOX &&
                                        quickSectorIdentifier.UserId == null);
                        Debug.Assert(!bAssert);

                        if (MyFakes.MWBUILDER)
                        {
                            quickSectorIdentifier.UserId = null;
                            MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(
                                                        MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX,
                                                        MyTextsWrapperEnum.StartEditorInProgressPleaseWait,
                                                         quickSectorIdentifier,
                                                         MyGameplayDifficultyEnum.EASY, null, null));
                        }
                        else
                        {
                            MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(
                                                        MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX,
                                                        MyTextsWrapperEnum.StartEditorInProgressPleaseWait,
                                                         quickSectorIdentifier,
                                                         MyGameplayDifficultyEnum.EASY, null, null));
                        }
                        m_childScreenLaunched = true;
                    }
                    break;
                case MyMwcQuickLaunchType.LAST_SANDBOX:
                    {
                        //normally when entering editor, you can choose which sector you would like, this is for programming purposes, choose whatever you want directly
                        //MyMwcSectorIdentifier quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorGroupEnum.MIDDLE_WEST, MyMwcSectorTypeEnum.SANDBOX, null, new MyMwcVector3Int(0, 0, 0));

                        MyMwcSectorIdentifier quickSectorIdentifier;

                        int userId = MyClientServer.LoggedPlayer.GetUserId();
                        MyMwcVector3Int sector = MyConfig.LastSandboxSector;

                        if (MyConfig.LastFriendSectorUserId.HasValue)
                        {
                            userId = MyConfig.LastFriendSectorUserId.Value;
                            sector = MyConfig.LastFriendSectorPosition;
                        }

                        quickSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.SANDBOX, userId,
                                                                           sector, null);

                        bool bAssert = (quickSectorIdentifier.SectorType == MyMwcSectorTypeEnum.SANDBOX &&
                                        quickSectorIdentifier.UserId == null);
                        Debug.Assert(!bAssert);

                        MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(
                                                    MyMwcStartSessionRequestTypeEnum.SANDBOX_FRIENDS,
                                                    MyTextsWrapperEnum.StartGameInProgressPleaseWait,
                                                     quickSectorIdentifier,
                                                     MyGameplayDifficultyEnum.EASY, null, null));
                        m_childScreenLaunched = true;
                    }
                    break;
                case MyMwcQuickLaunchType.NEW_STORY:
                    {
                        MySession.StartNewGame(MyGameplayDifficultyEnum.EASY);
                        m_childScreenLaunched = true;
                    }
                    break;
                case MyMwcQuickLaunchType.LOAD_CHECKPOINT:
                    {
                        MySession.StartLastCheckpoint();
                        m_childScreenLaunched = true;
                    }
                    break;
                case MyMwcQuickLaunchType.SANDBOX_RANDOM:
                    {
                        MyGuiManager.AddScreen(new MyGuiScreenStartSessionProgress(
                                                        MyMwcStartSessionRequestTypeEnum.SANDBOX_RANDOM,
                                                        MyTextsWrapperEnum.StartGameInProgressPleaseWait,
                                                        new MyMwcSectorIdentifier(
                                                            MyMwcSectorTypeEnum.SANDBOX, MyClientServer.LoggedPlayer.GetUserId(),
                                                            new MyMwcVector3Int(0, 0, 0), null),
                                                            MyGameplayDifficultyEnum.EASY,
                                                            null,
                                                        null));
                        m_childScreenLaunched = true;
                    }
                    break;
                default:
                    {
                        throw new MyMwcExceptionApplicationShouldNotGetHere();
                    }
            }
           
            return base.Update(hasFocus);
        }
        void ValidateAllMissionsStartingFrom(int index)
        {
            var allMissions = MyMissions.Missions.Values.OfType<MyMission>().ToList();
            if (index >= allMissions.Count) return;

            var mission = allMissions[index];
            MyMissionID missionId = mission.ID;
            // each mission is automatically validated after start
            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);

            var startSessionScreen = new MyGuiScreenStartSessionProgress(MyMwcStartSessionRequestTypeEnum.NEW_STORY,
                MyTextsWrapperEnum.StartGameInProgressPleaseWait, null, MyGameplayDifficultyEnum.EASY, null, null);

            startSessionScreen.OnSuccessEnter = new Action<MyGuiScreenGamePlayType, MyMwcStartSessionRequestTypeEnum, MyMwcObjectBuilder_Checkpoint>((screenType, sessionType, checkpoint) =>
            {
                Action<MyMwcObjectBuilder_Sector, Vector3> enterSuccessAction = new Action<MyMwcObjectBuilder_Sector, Vector3>((sector, newPosition) =>
                {
                    MyMwcVector3Int sectorPosition;
                    sectorPosition = sector.Position;

                    MyMwcSectorIdentifier newSectorIdentifier = new MyMwcSectorIdentifier(MyMwcSectorTypeEnum.STORY, MyClientServer.LoggedPlayer.GetUserId(), sectorPosition, null);
                    var newScreen = new MyGuiScreenGamePlay(MyGuiScreenGamePlayType.GAME_STORY, null, newSectorIdentifier, sector.Version, MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT);
                    var loadScreen = new MyGuiScreenLoading(newScreen, MyGuiScreenGamePlay.Static);
                    newScreen.OnGameReady += new ScreenHandler((screen) =>
                    {
                        ((MyMission)MyMissions.GetMissionByID(missionId)).Accept();
                        ValidateAllMissionsStartingFrom(index + 1);  // validate the next mission
                    });

                    loadScreen.AnnounceLeaveToServer = true;
                    loadScreen.LeaveSectorReason = MyMwcLeaveSectorReasonEnum.TRAVEL;

                    // Current sector and sector object builder has changed
                    checkpoint.ActiveMissionID = -1; // Manually deactivate mission
                    checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation.Position = newPosition;
                    checkpoint.EventLogObjectBuilder.Clear(); // Or just clear mission start/finish

                    // Make prereq missions completed
                    foreach (var prereq in mission.RequiredMissions)
                    {
                        var start = new MyEventLogEntry() { EventType = EventTypeEnum.MissionStarted, EventTypeID = (int)prereq }.GetObjectBuilder();
                        var end = new MyEventLogEntry() { EventType = EventTypeEnum.MissionFinished, EventTypeID = (int)prereq }.GetObjectBuilder();
                        checkpoint.EventLogObjectBuilder.Add(start);
                        checkpoint.EventLogObjectBuilder.Add(end);
                    }

                    checkpoint.SectorObjectBuilder = sector;
                    checkpoint.CurrentSector.Position = sector.Position;
                    loadScreen.AddEnterSectorResponse(checkpoint, missionId);

                    MyGuiManager.AddScreen(loadScreen);

                    if (MyMinerGame.IsPaused())
                        MyMinerGame.SwitchPause();
                });

                //  Load neighbouring sector 
                MyGuiManager.AddScreen(new MyGuiScreenEnterSectorProgress(MyMwcTravelTypeEnum.SOLAR, mission.Location.Sector, Vector3.Zero, enterSuccessAction));

                //var newGameplayScreen = new MyGuiScreenGamePlay(screenType, null, checkpoint.CurrentSector, sessionType);
                //var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);

                //loadScreen.AddEnterSectorResponse(checkpoint);
                //MyGuiManager.AddScreen(loadScreen);
            });

            MyGuiManager.AddScreen(startSessionScreen);
        }
        internal override bool Read(System.IO.BinaryReader binaryReader, System.Net.EndPoint senderEndPoint, int gameVersion)
        {
            if (!base.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError();

            // Sector ob
            bool? sectorBuilderExists = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!sectorBuilderExists.HasValue) return NetworkError();

            MyMwcLog.IfNetVerbose_AddToLog("Sector exists " + (SectorObjectBuilder != null));

            if (sectorBuilderExists.Value)
            {
                SectorObjectBuilder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Sector;
                if (SectorObjectBuilder == null || !SectorObjectBuilder.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("Sector read");
            }

            // Gametime
            DateTime? dateTime = MyMwcMessageIn.ReadDateTimeEx(binaryReader, senderEndPoint);
            if (!dateTime.HasValue) return NetworkError();
            this.GameTime = dateTime.Value;
            MyMwcLog.IfNetVerbose_AddToLog("Gametime: " + this.GameTime);

            // Player ob
            bool? playerBuilderExists = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!playerBuilderExists.HasValue) return NetworkError();

            MyMwcLog.IfNetVerbose_AddToLog("Player exists " + (PlayerObjectBuilder != null));

            if (playerBuilderExists.Value)
            {
                PlayerObjectBuilder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Player;
                if (PlayerObjectBuilder == null || !PlayerObjectBuilder.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("Player read");
            }

            // Session ob
            bool? sessionBuilderExists = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!sessionBuilderExists.HasValue) return NetworkError();

            MyMwcLog.IfNetVerbose_AddToLog("Session exists " + (SessionObjectBuilder != null));

            if (sessionBuilderExists.Value)
            {
                SessionObjectBuilder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Session;
                if (SessionObjectBuilder == null || !SessionObjectBuilder.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("Session read");
            }

            // Active mission
            int? activeMissionID = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (!activeMissionID.HasValue) return NetworkError();
            this.ActiveMissionID = activeMissionID.Value;
            MyMwcLog.IfNetVerbose_AddToLog("Active Mission ID: " + this.ActiveMissionID);

            // Events
            int? countEvents = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (countEvents == null) return NetworkError();
            MyMwcLog.IfNetVerbose_AddToLog("Count Events: " + countEvents);
            EventLogObjectBuilder = new List<MyMwcObjectBuilder_Event>(countEvents.Value);
            for (int i = 0; i < countEvents; i++)
            {
                var eventItem = ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Event;
                if (eventItem == null) return NetworkError();
                if (eventItem.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
                EventLogObjectBuilder.Add(eventItem);
            }

            // Faction relation changes
            int? countFactionRelationChanges = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (countFactionRelationChanges == null) return NetworkError();
            MyMwcLog.IfNetVerbose_AddToLog("Factoin Relation Changes: " + countFactionRelationChanges);
            FactionRelationChangesBuilder = new List<MyMwcObjectBuilder_FactionRelationChange>(countFactionRelationChanges.Value);
            for (int i = 0; i < countFactionRelationChanges; i++)
            {
                var factionRelationChangeItem = ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_FactionRelationChange;
                if (factionRelationChangeItem == null) return NetworkError();
                if (factionRelationChangeItem.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
                FactionRelationChangesBuilder.Add(factionRelationChangeItem);
            }

            // Inventory
            bool? inventoryBuilderExists = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!inventoryBuilderExists.HasValue) return NetworkError();

            MyMwcLog.IfNetVerbose_AddToLog("Inventory exists " + (InventoryObjectBuilder != null));

            if (inventoryBuilderExists.Value)
            {
                InventoryObjectBuilder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Inventory;
                if (InventoryObjectBuilder == null || !InventoryObjectBuilder.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("Inventory read");
            }

            // Current sector identifier
            MyMwcSectorIdentifier? currentSector = MyMwcMessageIn.ReadSectorIdentifierEx(binaryReader, senderEndPoint);
            if (!currentSector.HasValue) return NetworkError();
            this.CurrentSector = currentSector.Value;

            // Checkpoint name
            bool? hasName = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!hasName.HasValue) return NetworkError();

            if (hasName.Value)
            {
                CheckpointName = MyMwcMessageIn.ReadStringEx(binaryReader, senderEndPoint);
                if (CheckpointName == null) return NetworkError(); // Has name set and name null? That's can't happen
            }
            else
            {
                CheckpointName = null;
            }

            Dictionary = MyMessageHelper.ReadStringDictionary(binaryReader, senderEndPoint);
            if (Dictionary == null) return NetworkError();

            return true;
        }
        private void RecreateControls()
        {
            m_size = new Vector2(1100f / 1600f, 1200 / 1200f);

            Controls.Clear();

            string prevName = MyConfig.LastFriendName;

            if (m_findPlayerName != null && m_findPlayerName.Text != null)
            {
                prevName = m_findPlayerName.Text;
            }

            AddCaption(MyTextsWrapperEnum.FriendsSectorMap, new Vector2(0, 0.04f));

            Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.1f, -m_size.Value.Y / 2.0f + 0.1f);
            Vector2 controlsDelta      = new Vector2(0, 0.0525f);

            // controls for typing friend name to search
            Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 1f * controlsDelta, null, MyTextsWrapperEnum.FriendName, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            m_findPlayerName = new MyGuiControlTextbox(this, controlsOriginLeft + 1f * controlsDelta + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f + 0.15f, 0), MyGuiControlPreDefinedSize.MEDIUM, prevName, 20, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL);
            Controls.Add(m_findPlayerName);

            var searchButton = new MyGuiControlButton(this, m_findPlayerName.GetPosition() + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f - 0.0208f, 0), MyGuiConstants.SEARCH_BUTTON_SIZE,
                                                      MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                      MyGuiManager.GetButtonSearchTexture(), null, null, MyTextsWrapperEnum.Search,
                                                      MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE * 0.8f, MyGuiControlButtonTextAlignment.CENTERED, OnSearchClick,
                                                      true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, true, true);

            Controls.Add(searchButton);

            // friend maps available for selection
            //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 3* controlsDelta, null, MyTextsWrapperEnum.Map, MyGuiConstants.LABEL_TEXT_COLOR,
            //    MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

            if (m_sectorIdentifiers != null && m_userDetails != null && m_sectorIdentifiers.Count > 0)
            {
                m_mapsCombobox = new MyGuiControlListbox(this, new Vector2(0, -0.010f), new Vector2(0.43f, 0.1f), MyGuiConstants.LISTBOX_BACKGROUND_COLOR, null, MyGuiConstants.LABEL_TEXT_SCALE, 1, 6, 1, true, true, false,
                                                         null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 1, 0, MyGuiConstants.LISTBOX_BACKGROUND_COLOR_BLUE, 0f, 0f, 0f, 0f, 0, 0f, -0.01f, -0.01f, -0.02f, 0.02f);

                for (int i = 0; i < m_sectorIdentifiers.Count; i++)
                {
                    MyMwcSectorIdentifier sectorIdentifier = m_sectorIdentifiers[i];
                    foreach (MyMwcUserDetail userDetail in m_userDetails)
                    {
                        if (sectorIdentifier.UserId.HasValue && sectorIdentifier.UserId.Value == userDetail.UserId)
                        {
                            if (string.IsNullOrEmpty(sectorIdentifier.SectorName))
                            {
                                m_mapsCombobox.AddItem(i, new StringBuilder(string.Format("{0} - {1}", userDetail.DisplayName, sectorIdentifier.Position.ToString())), null);
                            }
                            else
                            {
                                m_mapsCombobox.AddItem(i, new StringBuilder(string.Format("{0} - {1} ({2})", userDetail.DisplayName, sectorIdentifier.SectorName, sectorIdentifier.Position.ToString())), null);
                            }
                        }
                    }
                }

                SortSectors();
                m_mapsCombobox.ItemDoubleClick += OnItemDoubleClick;
                Controls.Add(m_mapsCombobox);
            }
            else
            {
                Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 3 * controlsDelta + new Vector2(0.21f, 0), null, MyTextsWrapperEnum.NoSectorsAvailable, MyGuiConstants.LABEL_TEXT_COLOR,
                                                   MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            }

            //  Buttons OK and CANCEL
            var m_okButton = new MyGuiControlButton(this, new Vector2(-0.0879f, 0.35f), MyGuiConstants.OK_BUTTON_SIZE * 0.75f,
                                                    MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Ok,
                                                    MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick,
                                                    true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(m_okButton);

            var m_cancelButton = new MyGuiControlButton(this, new Vector2(0.0879f, 0.35f), MyGuiConstants.OK_BUTTON_SIZE * 0.75f,
                                                        MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                        MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Cancel,
                                                        MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick,
                                                        true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);

            Controls.Add(m_cancelButton);

            m_findPlayerName.MoveCartrigeToEnd();
            this.SetControlIndex(Controls.IndexOf(m_findPlayerName));
        }
        public MyGuiScreenSolarSystemMap(MyGuiScreenBase parent, MyMwcSectorIdentifier currentSector)
            : base(new Vector2(0.5f, 0.5f), null, Vector2.One)
        {
            m_parent = parent;
            m_enableBackgroundFade = false;
            DrawMouseCursor = true;
            m_currentSector = currentSector;
            m_closeOnEsc = true;

            Static = this;

            MySolarSystemGenerator generator = new MySolarSystemGenerator(UNIVERSE_SEED);
            generator.Generate(1024);

            m_data = generator.SolarSystemData;
            m_solarMapRender = new MySolarMapRenderer();
            m_solarMapRender.PlayerSector = currentSector.Position;

            //MyMinerGame.SwitchPause();
            m_particlesEnabled = TransparentGeometry.Particles.MyParticlesManager.Enabled;
            TransparentGeometry.Particles.MyParticlesManager.Enabled = false;

            //AddCaption(MyTextsWrapperEnum.SolarSystemMap);

            MySolarSystemMapNavigationMark playerNavigationMark =
                new MySolarSystemMapNavigationMark(
                    currentSector.Position,
                    "",
                    null,
                    MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR,
                    MyTransparentMaterialEnum.SolarMapPlayer)
                    {
                        VerticalLineColor = MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR.ToVector4(),
                        DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_green,
                        Offset = new Vector3(0, 0.0f, 0),
                        Text = MyClientServer.LoggedPlayer.GetDisplayName().ToString(),
                        Importance = 50
                    };
            m_data.NavigationMarks.Add(playerNavigationMark);

            if (MyGuiScreenGamePlay.Static.IsEditorStoryActive() || MyGuiScreenGamePlay.Static.GetPreviousGameType() == MyGuiScreenGamePlayType.EDITOR_STORY)
            {
                // Loads all marks, we want it for editor
                LoadMarks(false);
            }
            else
            {
                // Load only active marks
                MyMissions.AddSolarMapMarks(m_data);
            }

            if (MyMissions.ActiveMission != null)
            {
                MyMissions.ActiveMission.AddSolarMapMarks(m_data);
            }

            m_travelButton = new MyGuiControlButton(this, new Vector2(0.0f, 0.40f),
                new Vector2(650f / 1600f, 120f / 1200f),
                MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyGuiManager.GetTravelButtonTexture(),
                MyGuiManager.GetTravelButtonTexture(),
                MyGuiManager.GetTravelButtonTexture(),
                MyTextsWrapperEnum.Travel,
                MyGuiConstants.BACK_BUTTON_TEXT_COLOR,
                MyGuiConstants.BACK_BUTTON_TEXT_SCALE,
                MyGuiControlButtonTextAlignment.CENTERED,
                OnTravelClick,
                false,
                MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                true,
                false);
            m_travelButton.TextOffset = new Vector2(0, -0.0030f);
            m_travelButton.Visible = false;
            Controls.Add(m_travelButton);

            // target sector 0, 0, 0
            // distance is 1.7 sectors from camera
            Vector3 sector;

            var mostImportantMark = m_data.NavigationMarks.GetMostImportant();
            if (mostImportantMark != null) {
                sector = new Vector3(mostImportantMark.Sector.X, mostImportantMark.Sector.Y, mostImportantMark.Sector.Z);
            } else {
                sector = new Vector3(currentSector.Position.X, currentSector.Position.Y, currentSector.Position.Z);
            }

            sector.Y = 0;

            m_camera = new MySolarSystemMapCamera(sector * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS, 10000000.0f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS);
            m_camera.MinDistanceToTarget = 1.7f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS;
            m_camera.MaxDistanceToTarget = 1.2f * MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length()) * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS;
            m_camera.MaxSector = MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length());

            MyGuiManager.FullscreenHudEnabled = true;
        }
예제 #53
0
        internal override bool Read(System.IO.BinaryReader binaryReader, System.Net.EndPoint senderEndPoint, int gameVersion)
        {
            if (!base.Read(binaryReader, senderEndPoint, gameVersion))
            {
                return(NetworkError());
            }

            // Sector ob
            bool?sectorBuilderExists = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!sectorBuilderExists.HasValue)
            {
                return(NetworkError());
            }

            MyMwcLog.IfNetVerbose_AddToLog("Sector exists " + (SectorObjectBuilder != null));

            if (sectorBuilderExists.Value)
            {
                SectorObjectBuilder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Sector;
                if (SectorObjectBuilder == null || !SectorObjectBuilder.Read(binaryReader, senderEndPoint, gameVersion))
                {
                    return(NetworkError());
                }
                MyMwcLog.IfNetVerbose_AddToLog("Sector read");
            }

            // Gametime
            DateTime?dateTime = MyMwcMessageIn.ReadDateTimeEx(binaryReader, senderEndPoint);

            if (!dateTime.HasValue)
            {
                return(NetworkError());
            }
            this.GameTime = dateTime.Value;
            MyMwcLog.IfNetVerbose_AddToLog("Gametime: " + this.GameTime);

            // Player ob
            bool?playerBuilderExists = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!playerBuilderExists.HasValue)
            {
                return(NetworkError());
            }

            MyMwcLog.IfNetVerbose_AddToLog("Player exists " + (PlayerObjectBuilder != null));

            if (playerBuilderExists.Value)
            {
                PlayerObjectBuilder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Player;
                if (PlayerObjectBuilder == null || !PlayerObjectBuilder.Read(binaryReader, senderEndPoint, gameVersion))
                {
                    return(NetworkError());
                }
                MyMwcLog.IfNetVerbose_AddToLog("Player read");
            }

            // Session ob
            bool?sessionBuilderExists = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!sessionBuilderExists.HasValue)
            {
                return(NetworkError());
            }

            MyMwcLog.IfNetVerbose_AddToLog("Session exists " + (SessionObjectBuilder != null));

            if (sessionBuilderExists.Value)
            {
                SessionObjectBuilder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Session;
                if (SessionObjectBuilder == null || !SessionObjectBuilder.Read(binaryReader, senderEndPoint, gameVersion))
                {
                    return(NetworkError());
                }
                MyMwcLog.IfNetVerbose_AddToLog("Session read");
            }

            // Active mission
            int?activeMissionID = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);

            if (!activeMissionID.HasValue)
            {
                return(NetworkError());
            }
            this.ActiveMissionID = activeMissionID.Value;
            MyMwcLog.IfNetVerbose_AddToLog("Active Mission ID: " + this.ActiveMissionID);

            // Events
            int?countEvents = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);

            if (countEvents == null)
            {
                return(NetworkError());
            }
            MyMwcLog.IfNetVerbose_AddToLog("Count Events: " + countEvents);
            EventLogObjectBuilder = new List <MyMwcObjectBuilder_Event>(countEvents.Value);
            for (int i = 0; i < countEvents; i++)
            {
                var eventItem = ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Event;
                if (eventItem == null)
                {
                    return(NetworkError());
                }
                if (eventItem.Read(binaryReader, senderEndPoint, gameVersion) == false)
                {
                    return(NetworkError());
                }
                EventLogObjectBuilder.Add(eventItem);
            }

            // Faction relation changes
            int?countFactionRelationChanges = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);

            if (countFactionRelationChanges == null)
            {
                return(NetworkError());
            }
            MyMwcLog.IfNetVerbose_AddToLog("Factoin Relation Changes: " + countFactionRelationChanges);
            FactionRelationChangesBuilder = new List <MyMwcObjectBuilder_FactionRelationChange>(countFactionRelationChanges.Value);
            for (int i = 0; i < countFactionRelationChanges; i++)
            {
                var factionRelationChangeItem = ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_FactionRelationChange;
                if (factionRelationChangeItem == null)
                {
                    return(NetworkError());
                }
                if (factionRelationChangeItem.Read(binaryReader, senderEndPoint, gameVersion) == false)
                {
                    return(NetworkError());
                }
                FactionRelationChangesBuilder.Add(factionRelationChangeItem);
            }

            // Inventory
            bool?inventoryBuilderExists = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!inventoryBuilderExists.HasValue)
            {
                return(NetworkError());
            }

            MyMwcLog.IfNetVerbose_AddToLog("Inventory exists " + (InventoryObjectBuilder != null));

            if (inventoryBuilderExists.Value)
            {
                InventoryObjectBuilder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Inventory;
                if (InventoryObjectBuilder == null || !InventoryObjectBuilder.Read(binaryReader, senderEndPoint, gameVersion))
                {
                    return(NetworkError());
                }
                MyMwcLog.IfNetVerbose_AddToLog("Inventory read");
            }

            // Current sector identifier
            MyMwcSectorIdentifier?currentSector = MyMwcMessageIn.ReadSectorIdentifierEx(binaryReader, senderEndPoint);

            if (!currentSector.HasValue)
            {
                return(NetworkError());
            }
            this.CurrentSector = currentSector.Value;

            // Checkpoint name
            bool?hasName = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!hasName.HasValue)
            {
                return(NetworkError());
            }

            if (hasName.Value)
            {
                CheckpointName = MyMwcMessageIn.ReadStringEx(binaryReader, senderEndPoint);
                if (CheckpointName == null)
                {
                    return(NetworkError());                        // Has name set and name null? That's can't happen
                }
            }
            else
            {
                CheckpointName = null;
            }

            Dictionary = MyMessageHelper.ReadStringDictionary(binaryReader, senderEndPoint);
            if (Dictionary == null)
            {
                return(NetworkError());
            }

            return(true);
        }