Example #1
0
        private void TravelSectorLoaded(MyMwcTravelTypeEnum travelType, MyMwcVector3Int targetSector, byte[] sectorDataResponse, MyMwcObjectBuilder_Sector cachedSector)
        {
            var checkpoint = GetCheckpointBuilder(false);

            checkpoint.SectorObjectBuilder = cachedSector;

            // Overwrite current sector
            checkpoint.CurrentSector.Position = targetSector;
            UpdatePlayerPosition(travelType, ref checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation.Position);

            if (sectorDataResponse != null)
            {
                checkpoint.SectorObjectBuilder = MyMwcObjectBuilder_Base.FromBytes <MyMwcObjectBuilder_Sector>(sectorDataResponse);
                MyLocalCache.Save(null, checkpoint.SectorObjectBuilder, checkpoint.CurrentSector);
            }

            // Change NEW_STORY to LOAD_CHECKPOINT, because it's necessary, travel is never new story
            MyMwcStartSessionRequestTypeEnum?sessionStart = null;

            if (MyGuiScreenGamePlay.Static != null)
            {
                sessionStart = MyGuiScreenGamePlay.Static.GetSessionType();
                if (sessionStart.HasValue && sessionStart.Value == MyMwcStartSessionRequestTypeEnum.NEW_STORY)
                {
                    sessionStart = MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT;
                }
            }

            MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, sessionStart, null, null, travelType);
        }
Example #2
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);
            }
        }
Example #3
0
 public MyGuiScreenEnterSectorProgress(MyMwcTravelTypeEnum travelType, MyMwcVector3Int targetSectorPosition, Vector3 currentShipPosition, System.Action <MyMwcObjectBuilder_Sector, Vector3> enterSectorSuccessfulAction)
     : base(MyTextsWrapperEnum.EnterSectorInProgressPleaseWait, false)
 {
     m_backgroundFadeColor         = MyGuiConstants.SCREEN_BACKGROUND_FADE_BLANK_DARK_PROGRESS_SCREEN;
     m_travelType                  = travelType;
     m_targetSectorPosition        = targetSectorPosition;
     m_currentShipPosition         = currentShipPosition;
     m_enterSectorSuccessfulAction = enterSectorSuccessfulAction;
 }
 public MyGuiScreenEnterSectorProgress(MyMwcTravelTypeEnum travelType, MyMwcVector3Int targetSectorPosition, Vector3 currentShipPosition, System.Action<MyMwcObjectBuilder_Sector, Vector3> enterSectorSuccessfulAction)
     : base(MyTextsWrapperEnum.EnterSectorInProgressPleaseWait, false)
 {
     m_backgroundFadeColor = MyGuiConstants.SCREEN_BACKGROUND_FADE_BLANK_DARK_PROGRESS_SCREEN;
     m_travelType = travelType;
     m_targetSectorPosition = targetSectorPosition;
     m_currentShipPosition = currentShipPosition;
     m_enterSectorSuccessfulAction = enterSectorSuccessfulAction;
 }
Example #5
0
        private void PackBeforeLeave(MyMwcTravelTypeEnum travelType)
        {
            if (travelType == MyMwcTravelTypeEnum.SOLAR)
            {
                PackMothership();
            }

            PackDrones();
            MySession.PlayerFriends.PackFriends();
        }
Example #6
0
        public void TravelLeave(MyMwcTravelTypeEnum travelType)
        {
            MyTrace.Send(TraceWindow.Saving, "Player.TravelLeave()");
            var handler = TravelLeaving;

            if (handler != null)
            {
                handler(travelType);
            }

            PackBeforeLeave(travelType);
        }
Example #7
0
        private void UpdatePlayerPosition(MyMwcTravelTypeEnum travelType, ref Vector3 position)
        {
            switch (travelType)
            {
            case MyMwcTravelTypeEnum.SOLAR:
                position = new Vector3(0, 0, 0);
                break;

            case MyMwcTravelTypeEnum.NEIGHBOUR:
                position = MyMwcUtils.GetNeighbourSectorShipPosition(position);
                break;

            default:
                throw new MyMwcExceptionApplicationShouldNotGetHere();
            }
        }
Example #8
0
        private void PackBeforeLeave(MyMwcTravelTypeEnum travelType)
        {
            if (travelType == MyMwcTravelTypeEnum.SOLAR)
            {
                PackMothership();
            }

            PackDrones();
            MySession.PlayerFriends.PackFriends();
        }
Example #9
0
        public void TravelLeave(MyMwcTravelTypeEnum travelType)
        {
            MyTrace.Send(TraceWindow.Saving, "Player.TravelLeave()");
            var handler = TravelLeaving;
            if (handler != null)
            {
                handler(travelType);
            }

            PackBeforeLeave(travelType);
        }
        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 static MyGuiScreenLoading ReloadGameplayScreen(MyMwcObjectBuilder_Checkpoint checkpoint, MyMwcStartSessionRequestTypeEnum? sessionType = null, MyGuiScreenGamePlayType? gameplayType = null, MyMissionID? startMission = null, MyMwcTravelTypeEnum? travelType = null)
        {
            if (MyMultiplayerGameplay.IsRunning)
                MyMultiplayerGameplay.Static.Suspend();

            if (checkpoint.SectorObjectBuilder != null)
            {
                MySession.Static.Is2DSector = MyMwcSectorIdentifier.Is25DSector(checkpoint.SectorObjectBuilder.Name);
            }

            Debug.Assert((gameplayType != null && sessionType != null) || MyGuiScreenGamePlay.Static != null, "Set gameplay type and session type, there's no previous gameplay screen");
            MyGuiScreenGamePlayType newGameplayType = gameplayType.HasValue ? gameplayType.Value : MyGuiScreenGamePlay.Static.GetGameType();
            MyMwcStartSessionRequestTypeEnum? newSessionType = sessionType.HasValue ? sessionType.Value : MyGuiScreenGamePlay.Static.GetSessionType();
            MyGuiScreenGamePlayType? previousGameplaytype = MyGuiScreenGamePlay.Static != null ? MyGuiScreenGamePlay.Static.GetPreviousGameType() : (MyGuiScreenGamePlayType?)null;
            MyMissionID? previousMissionToStart = MyGuiScreenGamePlay.Static != null ? MyGuiScreenGamePlay.Static.m_missionToStart : (MyMissionID?)null;

            var newGameplayScreen = new MyGuiScreenGamePlay(newGameplayType, previousGameplaytype, checkpoint.CurrentSector, checkpoint.SectorObjectBuilder.Version, newSessionType);
            newGameplayScreen.m_missionToStart = previousMissionToStart;
            if (travelType.HasValue)
                newGameplayScreen.m_travelReason = travelType.Value;


            var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);
            loadScreen.AddEnterSectorResponse(checkpoint, startMission);

            /*
            if (MyConfig.NeedShowPerfWarning)
            {
                MyGuiScreenPerformanceWarning perfWarningScreen = new MyGuiScreenPerformanceWarning(loadScreen);

                perfWarningScreen.Closed += delegate
                {
                    MyGuiManager.AddScreen(loadScreen);
                };

                MyGuiManager.AddScreen(perfWarningScreen);
            }
            else*/
            {
                MyGuiManager.AddScreen(loadScreen);
            }

            return loadScreen;
        }
Example #12
0
        private void UpdatePlayerPosition(MyMwcTravelTypeEnum travelType, ref Vector3 position)
        {
            switch (travelType)
            {
                case MyMwcTravelTypeEnum.SOLAR:
                    position = new Vector3(0, 0, 0);
                    break;

                case MyMwcTravelTypeEnum.NEIGHBOUR:
                    position = MyMwcUtils.GetNeighbourSectorShipPosition(position);
                    break;

                default:
                    throw new MyMwcExceptionApplicationShouldNotGetHere();
            }
        }
Example #13
0
        private void TravelSectorLoaded(MyMwcTravelTypeEnum travelType, MyMwcVector3Int targetSector, byte[] sectorDataResponse, MyMwcObjectBuilder_Sector cachedSector)
        {
            var checkpoint = GetCheckpointBuilder(false);
            checkpoint.SectorObjectBuilder = cachedSector;

            // Overwrite current sector
            checkpoint.CurrentSector.Position = targetSector;
            UpdatePlayerPosition(travelType, ref checkpoint.PlayerObjectBuilder.ShipObjectBuilder.PositionAndOrientation.Position);

            if (sectorDataResponse != null)
            {
                checkpoint.SectorObjectBuilder = MyMwcObjectBuilder_Base.FromBytes<MyMwcObjectBuilder_Sector>(sectorDataResponse);
                MyLocalCache.Save(null, checkpoint.SectorObjectBuilder, checkpoint.CurrentSector);
            }

            // Change NEW_STORY to LOAD_CHECKPOINT, because it's necessary, travel is never new story
            MyMwcStartSessionRequestTypeEnum? sessionStart = null;
            if (MyGuiScreenGamePlay.Static != null)
            {
                sessionStart = MyGuiScreenGamePlay.Static.GetSessionType();
                if (sessionStart.HasValue && sessionStart.Value == MyMwcStartSessionRequestTypeEnum.NEW_STORY)
                {
                    sessionStart = MyMwcStartSessionRequestTypeEnum.LOAD_CHECKPOINT;
                }
            }

            MyGuiScreenGamePlay.ReloadGameplayScreen(checkpoint, sessionStart, null, null, travelType);
        }
Example #14
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;
            }
        }