Ejemplo n.º 1
0
        public void ObjectiveCompleted(MyObjective completedObjective)
        {
            UpdateActiveObjectives();

            //if (m_activeSubmissions.Count == 0)
            TestSuccess();

            if (completedObjective.ShowNotificationOnSuccess)
            {
                ShowObjectiveCompleted();
            }
        }
Ejemplo n.º 2
0
        public MyTestMission()
        {
            ID = MyMissionID.TEST_MISSION; /* ID must be added to MyMissions.cs */
            DebugName = new StringBuilder("Test mission");
            Name = Localization.MyTextsWrapperEnum.EmptyDescription;
            Description = Localization.MyTextsWrapperEnum.EmptyDescription;

            MyMwcVector3Int baseSector = new MyMwcVector3Int(-2, 0, 2);

            Location = new MyMissionLocation(baseSector, (uint)EntityID.StartLocation);

            RequiredMissions = new MyMissionID[] { MyMissionID.TEST_MISSION };
            RequiredActors = new MyActorEnum[] { MyActorEnum.MADELYN };

            m_objectives = new List<MyObjective>();

            var objective1 = new MyObjective(
                new StringBuilder("Objective1"),
                MyMissionID.TEST_MISSION_OBJECTIVE1,
                new StringBuilder(""),
                null,
                this,
                new MyMissionID[] { },
                null
            );
            objective1.SaveOnSuccess = true;
            m_objectives.Add(objective1);

            var objective2 = new MyObjective(
                new StringBuilder("Objective2"),
                MyMissionID.TEST_MISSION_OBJECTIVE2,
                new StringBuilder(""),
                null,
                this,
                new MyMissionID[] { MyMissionID.TEST_MISSION_OBJECTIVE1 },
                null
            );
            objective2.SaveOnSuccess = true;
            m_objectives.Add(objective2);


        }
Ejemplo n.º 3
0
        public MyRiftMission()
        {
            m_subShakeAction = new MyTimerActionDelegate(SubShake);
            m_farExplosionAction = new MyTimerActionDelegate(FarExplosion);
            
            ID = MyMissionID.RIFT; /* ID must be added to MyMissions.cs */
            DebugName = new StringBuilder("14-Rift");
            Name = Localization.MyTextsWrapperEnum.RIFT;
            Description = Localization.MyTextsWrapperEnum.RIFT_Description;
            Flags = MyMissionFlags.Story;
            AchievementName = MySteamAchievementNames.Mission21_Rift;

            MyMwcVector3Int baseSector = new MyMwcVector3Int(-56700, 0, 4276);

            Location = new MyMissionLocation(baseSector, (uint)EntityID.StartLocation);

            RequiredMissions = new MyMissionID[] { MyMissionID.JUNKYARD_EAC_AMBUSH };
            RequiredMissionsForSuccess = new MyMissionID[] { MyMissionID.RIFT_GOTO_30 };
            RequiredActors = new MyActorEnum[] { MyActorEnum.MADELYN, MyActorEnum.TARJA, MyActorEnum.VALENTIN };

            m_objectives = new List<MyObjective>();

            MySpawnpointSmartWaves spawnPointSmartWaves = new MySpawnpointSmartWaves(null, null, 2);

            var intro = new MyObjectiveDialog(
                MyMissionID.RIFT_INTRO,
                null,
                this,
                new MyMissionID[] { },
                MyDialogueEnum.RIFT_0050_INTRO
            )
            {
                SaveOnSuccess = true,
            };
            m_objectives.Add(intro);


            //Cannot see dialogues over inv.screen
            /*
            var getSupplies = new MyObjectiveEnterInventroy(
                new StringBuilder("Get supplies for the journey to the Rift"),
                MyMissionID.RIFT_GOTO_GETSUPPLIES1,
                new StringBuilder("Buy whatever useful."),
                null,
                this,
                new MyMissionID[] { MyMissionID.RIFT_INTRO },
                new List<uint>() {  (uint)EntityID.Objective_Vendor }
            )
            {
                SaveOnSuccess = true,
            };*/
            var getSupplies = new MyObjective(
                (MyTextsWrapperEnum.RIFT_GOTO_GETSUPPLIES1_Name),
                MyMissionID.RIFT_GOTO_GETSUPPLIES1,
                (MyTextsWrapperEnum.RIFT_GOTO_GETSUPPLIES1_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.RIFT_INTRO },
                new MyMissionLocation(baseSector, (uint)EntityID.Objective_Vendor),
                radiusOverride: 30
            )
            {
                SaveOnSuccess = true, HudName = MyTextsWrapperEnum.HudSupplies
            };
            getSupplies.OnMissionSuccess += GetSuppliesSubmissionSuccess;
            getSupplies.OnMissionLoaded += GetSuppliesSubmissionLoaded;
            m_objectives.Add(getSupplies);

            var reachTheRiftSubmission = new MyObjective(
                (MyTextsWrapperEnum.RIFT_GOTO_10_Name),
                MyMissionID.RIFT_GOTO_10,
                (MyTextsWrapperEnum.RIFT_GOTO_10_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.RIFT_GOTO_GETSUPPLIES1 },
                new MyMissionLocation(baseSector, (uint)EntityID.Objective_RiftEntraceLocation)
            )
            {
                SaveOnSuccess = true, HudName = MyTextsWrapperEnum.HudRift
            };
            reachTheRiftSubmission.OnMissionLoaded += ReachTheRiftSubmissionLoaded;
            reachTheRiftSubmission.OnMissionSuccess += ReachTheRiftSubmissionSuccess;
            m_objectives.Add(reachTheRiftSubmission);

            var getOreSubmission = new MyHarvestOreSubmission(
                (MyTextsWrapperEnum.RIFT_URANITE_Name),
                MyMissionID.RIFT_URANITE,
                (MyTextsWrapperEnum.RIFT_URANITE_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.RIFT_GOTO_10 },
                new MyMissionLocation(baseSector, (uint)EntityID.Objective_Uranite),
                MyMwcObjectBuilder_Ore_TypesEnum.URANITE,
                URANITE_TO_OBTAIN,
                successDialogId: MyDialogueEnum.RIFT_1000_MINING_DONE
            )
            {
                SaveOnSuccess = true
            };
            getOreSubmission.Components.Add(spawnPointSmartWaves);
            getOreSubmission.OnMissionLoaded += GetOreSubmissionLoaded;
            getOreSubmission.OnMissionSuccess += GetOreSubmissionSuccess;
            m_objectives.Add(getOreSubmission);

            var returnToMothershipSubmission = new MyObjective(
                (MyTextsWrapperEnum.RIFT_GOTO_30_Name),
                MyMissionID.RIFT_GOTO_30,
                (MyTextsWrapperEnum.RIFT_GOTO_30_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.RIFT_URANITE },
                new MyMissionLocation(baseSector, MyMissionLocation.MADELYN_HANGAR),
                radiusOverride: MyMissionLocation.MADELYN_HANGAR_RADIUS
            )
            {
                SaveOnSuccess = true, HudName = MyTextsWrapperEnum.HudMadelynsSapho
            };
            returnToMothershipSubmission.OnMissionLoaded += ReturnSubmissionLoaded;
            returnToMothershipSubmission.OnMissionSuccess += ReturnSubmissionSuccess;
            m_objectives.Add(returnToMothershipSubmission);

            //m_subShakeAction = SubShake;
            //m_farExplosionAction = FarExplosion;
        }
Ejemplo n.º 4
0
        public MyReichstagCMission()
        {
            ID = MyMissionID.REICHSTAG_C; /* ID must be added to MyMissions.cs */
            DebugName = new StringBuilder("18c-Reichstag C");
            Name = MyTextsWrapperEnum.REICHSTAG_C;
            Description = MyTextsWrapperEnum.REICHSTAG_C_Description;
            Flags = MyMissionFlags.Story;
            AchievementName = MySteamAchievementNames.Mission27_Reichstag2;

            MyMwcVector3Int baseSector = new MyMwcVector3Int(-2325831, 0, -7186381);

            Location = new MyMissionLocation(baseSector, (uint)EntityID.StartLocation);

            RequiredMissions = new MyMissionID[] { MyMissionID.NAZI_BIO_LAB };
            RequiredMissionsForSuccess = new MyMissionID[] { MyMissionID.REICHSTAG_C_MOTHERSHIP };
            RequiredActors = new MyActorEnum[] { MyActorEnum.MADELYN, MyActorEnum.TARJA, MyActorEnum.VALENTIN };

            m_objectives = new List<MyObjective>();


            var MeetSubmission = new MyMeetObjective(
                 (MyTextsWrapperEnum.REICHSTAG_C_FOR_Name),
                MyMissionID.REICHSTAG_C_FOR,
                (MyTextsWrapperEnum.REICHSTAG_C_FOR_Description),
                this,
                new MyMissionID[] { },
                null,
                (uint)EntityID.Bot_WaltherStauffenberg,
                100,
                0.25f,
                null
               ) { SaveOnSuccess = true, FollowMe = false };
          /*  MeetSubmission.OnMissionSuccess += MeetSubmissionSuccess;
            MeetSubmission.OnMissionLoaded += MeetSubmissionLoaded;*/
            m_objectives.Add(MeetSubmission);

            var colonelDialogue = new MyObjectiveDialog(
                MyMissionID.REICHSTAG_C_COLONEL_DIALOGUE,
                null,
                this,
                new MyMissionID[] {MyMissionID.REICHSTAG_C_FOR },
                dialogId: MyDialogueEnum.REICHSTAG_C_0100_OFFICER_TALK
                ) { SaveOnSuccess = true };
            m_objectives.Add(colonelDialogue);

            var goToShipyard = new MyMeetObjective(
                (MyTextsWrapperEnum.REICHSTAG_C_GO_TO_SHIPYARD_Name),
                MyMissionID.REICHSTAG_C_GO_TO_SHIPYARD,
                (MyTextsWrapperEnum.REICHSTAG_C_GO_TO_SHIPYARD_Description),
                this,
                new MyMissionID[] { MyMissionID.REICHSTAG_C_COLONEL_DIALOGUE },
                null,
                (uint)EntityID.Bot_ShipyardOfficer,
                100,
                0.25f,
                null,
                startDialogueId: MyDialogueEnum.REICHSTAG_C_0200_ON_THE_WAY
               ) { SaveOnSuccess = true, FollowMe = false };
            m_objectives.Add(goToShipyard);
            goToShipyard.OnMissionLoaded += GoToShipyardLoaded;

            var talkToSupplyOfficer = new MyObjectiveDialog(
                MyMissionID.REICHSTAG_C_TALK_TO_SUPPLY_OFFICER,
                null,
                this,
                new MyMissionID[] { MyMissionID.REICHSTAG_C_GO_TO_SHIPYARD },
                dialogId: MyDialogueEnum.REICHSTAG_C_0400_SUPPLY_OFFICER
                ) { SaveOnSuccess = true };
            m_objectives.Add(talkToSupplyOfficer);

            var ChangeShip = new MyUseObjective(
                (MyTextsWrapperEnum.REICHSTAG_C_CHANGESHIP_Name),
                MyMissionID.REICHSTAG_C_CHANGESHIP,
                (MyTextsWrapperEnum.REICHSTAG_C_CHANGESHIP_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.REICHSTAG_C_TALK_TO_SUPPLY_OFFICER },
                new MyMissionLocation(baseSector, (uint)EntityID.Bot_Disabled_03),
                MyTextsWrapperEnum.PressToBoardShip,
                MyTextsWrapperEnum.Ship,
                MyTextsWrapperEnum.BoardingInProgress,
                3000,
                radiusOverride:30,
                startDialogId: MyDialogueEnum.REICHSTAG_C_0500_REACHING_SHIPS
            );
            m_objectives.Add(ChangeShip);
            ChangeShip.OnMissionSuccess += ChangeShipOnOnMissionSuccess;

            var ShipChangedDialogue = new MyObjectiveDialog(
                MyMissionID.REICHSTAG_C_SHIP_CHANGED_DIALOGUE,
                null,
                this,
                new MyMissionID[] { MyMissionID.REICHSTAG_C_CHANGESHIP },
                dialogId: MyDialogueEnum.REICHSTAG_C_0600_SHIPS_PICKUPED
                ) { SaveOnSuccess = true };
            m_objectives.Add(ShipChangedDialogue);
           
            var GetArmed  = new MyObjectiveEnterInventory(
                (MyTextsWrapperEnum.REICHSTAG_C_WEAPONS_Name),
                MyMissionID.REICHSTAG_C_WEAPONS,
                (MyTextsWrapperEnum.REICHSTAG_C_WEAPONS_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.REICHSTAG_C_SHIP_CHANGED_DIALOGUE },
                (uint)EntityID.Objective_Shipchange,
                successDialogId: MyDialogueEnum.REICHSTAG_C_0800_SHOPPING_FINISHED
            );
            m_objectives.Add(GetArmed);
            GetArmed.OnMissionLoaded += GetArmedLoaded;

            var MeetTransporterCaptain = new MyMeetObjective(
                (MyTextsWrapperEnum.REICHSTAG_C_GO_TO_HANGAR_Name),
                MyMissionID.REICHSTAG_C_GO_TO_HANGAR,
                (MyTextsWrapperEnum.REICHSTAG_C_GO_TO_HANGAR_Description),
                this,
                new MyMissionID[] { MyMissionID.REICHSTAG_C_WEAPONS},
                null,
                (uint)EntityID.Bot_TransporterCaptain,
                100,
                0.25f,
                null
               ) { SaveOnSuccess = true, FollowMe = false };
            m_objectives.Add(MeetTransporterCaptain);

            var TalkToTransporterCaptain = new MyObjectiveDialog(
                MyMissionID.REICHSTAG_C_TRANSPORTER_CAPTAIN_DIALOGUE,
                null,
                this,
                new MyMissionID[] { MyMissionID.REICHSTAG_C_GO_TO_HANGAR },
                dialogId: MyDialogueEnum.REICHSTAG_C_0900_TRANSPORTER_REACHED
                ) { SaveOnSuccess = true };
            m_objectives.Add(TalkToTransporterCaptain);

            var GetWWMothership = new MyObjective(
                 (MyTextsWrapperEnum.REICHSTAG_C_MOTHERSHIP_Name),
                 MyMissionID.REICHSTAG_C_MOTHERSHIP,
                 (MyTextsWrapperEnum.REICHSTAG_C_MOTHERSHIP_Description),
                 null,
                 this,
                 new MyMissionID[] { MyMissionID.REICHSTAG_C_TRANSPORTER_CAPTAIN_DIALOGUE },
                 new MyMissionLocation(baseSector, (uint)EntityID.Objective_Mothership),
                 radiusOverride: 30
             ) { HudName = MyTextsWrapperEnum.HudMothership };
            m_objectives.Add(GetWWMothership);
        }
Ejemplo n.º 5
0
        public void ObjectiveCompleted(MyObjective completedObjective)
        {
            UpdateActiveObjectives();

            //if (m_activeSubmissions.Count == 0)
            TestSuccess();

            if (completedObjective.ShowNotificationOnSuccess)
            {
                ShowObjectiveCompleted();
            }
        }
Ejemplo n.º 6
0
        //  This method is called every update - even if application has not focus
        //  Update world, do physics integration...
        public override bool Update(bool hasFocus)
        {
            int profBlock = -1;
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("GuiScreenGamePlay::Update", ref profBlock);

            if (MyMultiplayerGameplay.IsRunning)
            {
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Multiplayer update");
                MyMultiplayerGameplay.Static.Update();
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            }

            if (MyFakes.GRAVITATION.HasValue)
                MyPhysics.physicsSystem.Gravitation = MyFakes.GRAVITATION.Value;

            if (MySession.Is25DSector)
            {
                MyPhysics.physicsSystem.Gravitation = new Vector3(0, -4000, 0);
            }

            if (MyFakes.MWBUILDER && !MyEditor.Static.IsActive())
            {
                //MyPhysics.physicsSystem.Gravitation = new Vector3(0, -2000, 0);
                MyPhysics.physicsSystem.Gravitation = new Vector3(0, -0, 0);
                /*
    MyVoxelMap voxelMap = MyVoxelMaps.GetVoxelMaps()[0];
    MyPhysics.physicsSystem.GravitationPoints.Clear();
    MyPhysics.physicsSystem.GravitationPoints.Add(new Tuple<BoundingSphere, float>(new BoundingSphere(voxelMap.WorldAABB.GetCenter(), voxelMap.WorldAABB.Size().Length()), 2000));
              */

                MyVoxelMap voxelMap = MyVoxelMaps.GetVoxelMaps()[0];
                float distance = Vector3.Distance(voxelMap.WorldAABB.GetCenter(), MyCamera.Position);
                float alpha = MathHelper.Clamp(distance / voxelMap.WorldAABB.Size().Length(), 0, 1);

                MySector.SunProperties.BackgroundColor = Vector3.Lerp(new Vector3(5, 5, 16), Vector3.One, alpha);

            }

            //MyPhysics.physicsSystem.Gravitation = new Vector3(0,0, 0);

            CheckChatboxMessagesTTL();

            if (m_playInventoryTransferSound && MyMinerGame.TotalGamePlayTimeInMilliseconds > m_inventoryTransferSoundPlayTime)
            {
                m_playInventoryTransferSound = false;
                if (m_inventoryPlaySound == null || !m_inventoryPlaySound.Value.IsPlaying)
                    m_inventoryPlaySound = MyAudio.AddCue2D(MySoundCuesEnum.HudInventoryTransfer);
                else
                    m_inventoryPlaySound = null;
            }


            if (m_invokeGameEditorSwitch)
                TrySwitchBetweenGameAndEditor();

#if RENDER_PROFILING
            MyRender.RenderObjectUpdatesCounter = 0;
#endif

            //  We do not want to do any update when switching between sectors
            if (m_state == MyGuiScreenState.CLOSING)
            {
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(profBlock);
                return false;
            }

            if (base.Update(hasFocus) == false)
            {
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(profBlock);
                return false;
            }

            if (m_startTimeInMilliseconds.HasValue == false)
            {
                m_startTimeInMilliseconds = MyMinerGame.TotalTimeInMilliseconds;
                //MyGuiSounds.PlayClick();
            }

            if (m_updateGPSReminderTimer > 0.5f)
            {
                m_updateGPSReminderTimer = 0;
                UpdateGPSReminder();
            }
            else
            {
                m_updateGPSReminderTimer += MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS;
            }

            ShowOrHideNotification(MyConfig.NeedShowHelpScreen, ref m_needShowHelpNotification, MyTextsWrapperEnum.NotificationNeedShowHelpScreen, null);
            ShowOrHideNotification(!MyEditor.Static.IsActive() && !MyFakes.MWBUILDER && MyHud.GetClosestOreDistanceSquared() < 100 * 100 && (MySession.PlayerShip.Weapons.GetMountedDrill() == null || MySession.PlayerShip.Weapons.GetMountedDrill().CurrentState == MyDrillStateEnum.InsideShip), ref m_oreInRangeNotification, MyTextsWrapperEnum.OreNotification, MyGameControlEnums.HARVEST);
            ShowOrHideNotification(!MyEditor.Static.IsActive() && !MyFakes.MWBUILDER && MyHud.GetClosestOreDistanceSquared() < 100 * 100 && (MySession.PlayerShip != null && MySession.PlayerShip.Weapons.GetMountedDrill() != null && MySession.PlayerShip.Weapons.GetMountedDrill().CurrentState == MyDrillStateEnum.InsideShip), ref m_drillingInRangeNotification, MyTextsWrapperEnum.DrillNotification, MyGameControlEnums.DRILL);
            ShowOrHideNotification(!MyEditor.Static.IsActive() && !MyFakes.MWBUILDER && MySession.PlayerShip != null && MySession.PlayerShip.Weapons.GetMountedDrill() != null && MySession.PlayerShip.Weapons.GetMountedDrill().CurrentState != MyDrillStateEnum.InsideShip, ref m_pressMToDeactivateDrillNotification, MyTextsWrapperEnum.PressMToDeactivateDrill, MyGameControlEnums.DRILL);
            ShowOrHideNotification(!MyEditor.Static.IsActive() && !MyFakes.MWBUILDER && MySession.PlayerShip != null && MySession.PlayerShip.Weapons.GetMountedDrill() != null && MySession.PlayerShip.Weapons.GetMountedDrill().CurrentState == MyDrillStateEnum.Activated, ref m_holdFireToDrillNotification, MyTextsWrapperEnum.HoldFireToDrillNotification, MyGameControlEnums.FIRE_PRIMARY);


            if (m_fireDisableTimeout > 0)
            {
                m_fireDisableTimeout = m_fireDisableTimeout - MyConstants.PHYSICS_STEP_SIZE_IN_MILLISECONDS;
            }

            if (hasFocus == false)
            {
                //  We must reset this
                m_handleInputMouseKeysReleased = false;
            }

            if (m_firstUpdateCall)
            {
                if (MyGuiScreenLoading.Static != null)
                {
                    MyGuiScreenLoading.Static.UnloadContent();
                }

                m_loadingScreen = new MyGuiScreenLoading(null, null, MyGuiScreenLoading.LastBackgroundTexture);
                m_loadingScreen.LoadContent();
                m_firstUpdateCall = false;
                m_firstTimeLoaded = MyMinerGame.TotalTimeInMilliseconds;

                if (IsMainMenuActive())
                {
                    //Allow changing video options from game in DX version
                    MyGuiScreenMainMenu.AddMainMenu(true);
                    //MyGuiScreenMainMenu.AddMainMenu(false);
                }

                switch (m_type)
                {
                    case MyGuiScreenGamePlayType.GAME_STORY:
                        break;
                    case MyGuiScreenGamePlayType.EDITOR_SANDBOX:
                    case MyGuiScreenGamePlayType.EDITOR_MMO:
                    case MyGuiScreenGamePlayType.EDITOR_STORY:
                    case MyGuiScreenGamePlayType.INGAME_EDITOR:
                        FillEditorNotifications();
                        break;
                    default:
                        break;
                }


                if (OnGameLoaded != null)
                    OnGameLoaded(this, null);

                //  we may create GPS waypoints only after the first simulation pass
                if (MyFakes.ENABLE_GENERATED_WAYPOINTS_IN_EDITOR)
                {
                    MyWayPointGraph.CreateWaypointsAroundLargeStaticObjects();
                }
                else
                {
                    switch (m_type)
                    {
                        case MyGuiScreenGamePlayType.EDITOR_STORY:  // don't create them in the editor (use Shift+M)
                        case MyGuiScreenGamePlayType.EDITOR_MMO:
                        case MyGuiScreenGamePlayType.EDITOR_SANDBOX:
                            MyWayPointGraph.RemoveWaypointsAroundLargeStaticObjects();
                            MyWayPointGraph.SetVisibilityOfAllWaypoints(true);
                            break;
                        default:
                            MyWayPointGraph.CreateWaypointsAroundLargeStaticObjects();
                            MyWayPointGraph.SetVisibilityOfAllWaypoints(MyHud.ShowDebugWaypoints);
                            break;
                    }
                }
            }


            if (MyMinerGame.IsGameReady)
            {
                if (MyLoadingPerformance.Instance.IsTiming)
                {
                    MyLoadingPerformance.Instance.LoadingName = MyMissions.ActiveMission == null ? "No mission" : MyMissions.ActiveMission.Name.ToString();
                    MyLoadingPerformance.Instance.FinishTiming();
                }

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Audio");

                if (MyAudio.GetMusicState() == MyMusicState.Stopped &&
                    MyAudio.GetMusicCue() == null &&
                    !MyAudio.HasAnyTransition() &&
                    MyMinerGame.TotalTimeInMilliseconds - m_firstTimeLoaded >= 1000)
                {
                    if (IsMainMenuActive())
                    {
                        MyAudio.ApplyTransition(MyMusicTransitionEnum.MainMenu);
                        MyAudio.AddCue2D(MySoundCuesEnum.MenuWelcome);
                    }
                    else if (IsCreditsActive())
                    {
                        MyAudio.ApplyTransition(MyMusicTransitionEnum.MainMenu);
                    }
                    else if (IsGameActive() || IsPureFlyThroughActive())
                    {
                        MyAudio.ApplyTransition(MyMusicTransitionEnum.CalmAtmosphere);
                    }
                }
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Editor");

                if (IsEditorActive() || IsIngameEditorActive())
                {
                    MyEditor.Static.Update();
                    EditorControls.Update();
                }
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                MyRadar.Update();
                MyFriendlyFire.Update();

                if (m_fadingOut)
                {
                    m_fadeAlpha += m_fadeSpeed;
                    if (m_fadeAlpha >= 1.0f)
                    {
                        m_fadeAlpha = 1.0f;
                        if (FadedOut != null)
                            FadedOut();
                        m_fadingOut = false;
                    }
                }
                else if (m_fadingIn)
                {
                    m_fadeAlpha -= m_fadeSpeed;
                    if (m_fadeAlpha <= 0.0f)
                    {
                        m_fadeAlpha = 0.0f;
                        if (FadedIn != null)
                            FadedIn();
                        m_fadingIn = false;
                    }
                }
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("NonBackgroundThread");
            if (!MyEditor.Static.IsBackgroundWorkThreadAlive())
            {
                if (m_backgroudThreadWasWorking)
                {
                    MyRender.Enabled = true;
                }
                m_backgroudThreadWasWorking = false;

                if (MySession.PlayerShip != null)
                {
                    ProcessSectorBoundaries();
                }

                //  If we detect logged off player during active game (story or MMO, but not main-menu-fly-through), we close actual game and practicaly restart it all
                if (StartTimeoutClosing)
                {
                    //  We must shut-down any game that may be played right now - becase loggouted player is a weird state and we need to reset it all
                    MyGuiManager.BackToMainMenu();
                    MyGuiManager.CloseAllScreensExceptThisOneAndAllTopMost(this);
                    StartTimeoutClosing = false;
                }

                if (MyMinerGame.IsPaused())
                {
                    MyCamera.Zoom.PauseZoomCue();
                }
                else
                {

                    if (MyMinerGame.IsGameReady)
                    {
                        if (IsGameActive())
                        {
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Global events");
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MySunWind");
                            MySunWind.IsVisible = MyGuiScreenSolarSystemMap.Static == null;
                            MySunWind.Update();
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMeteorWind");
                            MyMeteorWind.Update();
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyIceStorm");
                            MyIceStorm.Update();
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyAttackFormations");
                            MyAttackFormations.Instance.Update();
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                            //TODO
                            /*
                           if (MyFakes.ENABLE_SHOUT)
                           {
                               MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyShouts");
                               MyShouts.Update();
                               MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                           }  */
                        }

                        MyRoutefindingHelper.AdvanceRoutefinding();

                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyEntityDetectorsManager.Update");
                        MyEntityDetectorsManager.Update();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyEntities.UpdateBeforeIntegration");
                        UpdateBeforeSimulation();
                        MyEntities.UpdateBeforeSimulation();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();


                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Dust+MyExplosions+MyDistantImpostors");
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("UpdateAndCalculateDustColors");
                        UpdateAndCalculateDustColors();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Explosions update");
                        MyExplosions.Update();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Impostors update");
                        MyDistantImpostors.Update();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();


                        if (MyFakes.MWBUILDER)
                        {                          /*
                        MyVoxelMap voxelMap = MyVoxelMaps.GetVoxelMaps()[0];

                        voxelMap.InvalidateCache(new MyMwcVector3Int(0, 0, 0), new MyMwcVector3Int(1024, 1024, 1024));
                        MyVoxelMaps.RecalcVoxelMaps();     */
                        }



                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyPhysics-Simulate");
                        if (deltaphys <= 0)
                        {
                            if (PHYSICS_SIMULATION_SLOWDOWN)
                                deltaphys = 30;
                            else
                                deltaphys = 0;
                            //  Physics integration
                            // dont allow physics for editor - god mode 
                            switch (m_type)
                            {
                                case MyGuiScreenGamePlayType.EDITOR_STORY:
                                case MyGuiScreenGamePlayType.EDITOR_MMO:
                                case MyGuiScreenGamePlayType.EDITOR_SANDBOX:
                                    //MyPhysics.physicsSystem.Simulate(MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
                                    MyPhysics.physicsSystem.Simulate(0.0f);
                                    break;
                                default:
                                    MyPhysics.physicsSystem.Simulate(MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
                                    break;
                            }
                        }
                        else
                            deltaphys--;
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyTrailerLoad, MyEntities-UAI, MySunWind, WpGen, MySession");
                        //  If this is trailer in load phase, we update attached object's positions to values from files
                        //  We must do it before 'after integration', otherwise velocity/speed won't be calculated with correct positions
                        MyTrailerLoad.Update();

                        if (IsGameActive() || IsIngameEditorActive())
                        {
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MySession.Update");
                            System.Diagnostics.Debug.Assert(MySession.Static != null, "Session cannot be null in the game");
                            MySession.Static.Update();
                            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                        }

                        MyEnemyTargeting.Update();

                        //Do it after MySession.Static.Update(); because they move objects there, and we shoot here
                        MyEntities.UpdateAfterSimulation();

                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyProjectiles");
                        //Be careful, projectiles must be updated AFTER physics to get correct velocity results!
                        //Also must be after UpdateAfterIntegration to have fired bullets
                        MyProjectiles.Update();
                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();


                        //Update sun
                        MyRender.Sun.Direction = -MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized();
                        MyRender.Sun.Color = MySunWind.IsActive ? MySunWind.GetSunColor() : new Vector4(MySector.SunProperties.SunDiffuse, 1.0f);
                        MyRender.Sun.BackColor = MySector.SunProperties.BackSunDiffuse;
                        MyRender.Sun.BackIntensity = MySector.SunProperties.BackSunIntensity;
                        MyRender.Sun.SpecularColor = MySector.SunProperties.SunSpecular;
                        MyRender.Sun.Intensity = MySector.SunProperties.SunIntensity * (MySession.Is25DSector ? 2.5f : 1);
                        MyRender.AmbientColor = MySector.SunProperties.AmbientColor;
                        MyRender.AmbientMultiplier = MySector.SunProperties.AmbientMultiplier;
                        MyRender.EnvAmbientIntensity = MySector.SunProperties.EnvironmentAmbientIntensity;


                        MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                    }
                }
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //  From where will be camera looking? (needs to be called after physics integration - because for view matrix we need to know current position of player's ship)
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Camera");
                MyCamera.Update();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Update spectator");

                if ((CameraAttachedTo == MyCameraAttachedToEnum.PlayerMinerShip) && (MySession.PlayerShip == null))
                {
                    CameraAttachedTo = MyCameraAttachedToEnum.Spectator;
                }

                switch (CameraAttachedTo)
                {
                    case MyCameraAttachedToEnum.Spectator:
                        MyCamera.SetViewMatrix(MySpectator.GetViewMatrix());
                        break;

                    case MyCameraAttachedToEnum.PlayerMinerShip:
                        MyCamera.SetViewMatrix(MySession.PlayerShip.GetViewMatrix());
                        break;

                    case MyCameraAttachedToEnum.BotMinerShip:
                        if (Static.ShipForSimpleTesting != null)
                        {
                            MyCamera.SetViewMatrix(MyGuiScreenGamePlay.Static.ShipForSimpleTesting.GetViewMatrix());
                        }
                        break;

                    case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonFollowing:
                        MySpectator.Position = MySession.PlayerShip.GetPosition() + ThirdPersonCameraDelta;
                        MySpectator.Target = MySession.PlayerShip.GetPosition();
                        MyCamera.SetViewMatrix(MySpectator.GetViewMatrix());
                        break;

                    case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonDynamic:
                        {
                            MySmallShip playerShip = MySession.PlayerShip;

                            if (MySession.Is25DSector)
                            {

                                Vector3 forward = playerShip.GetWorldRotation().Forward;
                                forward.Y = 0;
                                forward.Normalize();
                                //Vector3 right = Vector3.Normalize(playerShip.GetWorldRotation().Right.Project(Vector3.Right));
                                Vector3 right = Vector3.Right;
                                Vector3 up = Vector3.Up;
                                right = Vector3.Cross(up, forward);

                                MyThirdPersonSpectator.TargetOrientation = Matrix.CreateWorld(Vector3.Zero, forward, up);

                                //MyThirdPersonSpectator.TargetOrientation = Matrix.Identity;
                            }
                            else
                                MyThirdPersonSpectator.TargetOrientation = playerShip.GetWorldRotation();

                            MyThirdPersonSpectator.Target = playerShip.GetPosition();

                            MyThirdPersonSpectator.Update();
                            if (!MySession.Is25DSector)
                            {
                                MyThirdPersonSpectator.HandleIntersection(
                                    playerShip, true, playerShip.GetHeadPosition(), playerShip.GetHeadDirection());
                            }

                            MyCamera.SetViewMatrix(MyThirdPersonSpectator.GetViewMatrix(
                                MyCamera.FieldOfView,
                                MyCamera.Zoom.GetZoomLevel(),
                                true, playerShip.GetHeadPosition(), playerShip.GetHeadDirection())
                                );
                        }
                        break;

                    case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonStatic:
                        MyCamera.SetViewMatrix(MySpectator.GetViewMatrix());
                        break;

                    case MyCameraAttachedToEnum.Drone:
                        Debug.Assert(IsControlledDrone);
                        MyCamera.SetViewMatrix(ControlledDrone.GetViewMatrix());
                        break;
                    case MyCameraAttachedToEnum.Camera:
                        Debug.Assert(ControlledCamera != null);
                        MyCamera.SetViewMatrix(ControlledCamera.GetViewMatrix());
                        //MyCamera.ProjectionMatrix = (ControlledCamera.GetProjectionMatrix());
                        break;

                    case MyCameraAttachedToEnum.LargeWeapon:
                        Debug.Assert(ControlledLargeWeapon != null);
                        MyCamera.SetViewMatrix(ControlledLargeWeapon.GetViewMatrix());
                        break;
                }

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                MyRender.PrepareEntitiesForDrawStart();

                if (MyMinerGame.IsGameReady)
                {
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Update playership");

                    // Update spectator reflector properties
                    if (MySession.PlayerShip != null)
                    {
                        MyRender.DrawSpectatorReflector = CameraAttachedTo == MyCameraAttachedToEnum.Spectator;

                        // Update player light properties
                        MyRender.PlayerLight = MySession.PlayerShip.Light;
                        MyRender.SpectatorReflector = MySession.PlayerShip.Light;
                        MyRender.DrawPlayerLightShadow = CameraAttachedTo != MyCameraAttachedToEnum.PlayerMinerShip;


#if !RENDER_PROFILING
                        //We dont want to be bothered by gameplay stuff in editor or profiling
                        if ((m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_STORY) ||
                            (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX) ||
                            (m_sessionType == MyMwcStartSessionRequestTypeEnum.EDITOR_MMO))
#endif
                        {
                            MySession.PlayerShip.Fuel = MySession.PlayerShip.MaxFuel;
                            MySession.PlayerShip.Oxygen = MySession.PlayerShip.MaxOxygen;
                            MySession.PlayerShip.AddHealth(MySession.PlayerShip.MaxHealth);
                            MySession.PlayerShip.ArmorHealth = MySession.PlayerShip.MaxArmorHealth;
                            MySession.PlayerShip.Weight = MySession.PlayerShip.ShipTypeProperties.Physics.Mass;
                            MySession.Static.Player.RestoreHealth();

                            foreach (Inventory.MyInventoryItem item in MySession.PlayerShip.Weapons.AmmoInventoryItems.GetAmmoInventoryItems())
                            {
                                item.Amount = item.MaxAmount;
                            }
                        }

                        if (IsCheatEnabled(MyGameplayCheatsEnum.INFINITE_AMMO))
                        {
                            foreach (Inventory.MyInventoryItem item in MySession.PlayerShip.Weapons.AmmoInventoryItems.GetAmmoInventoryItems())
                            {
                                item.Amount = item.MaxAmount;
                            }
                        }
                        if (IsCheatEnabled(MyGameplayCheatsEnum.INFINITE_FUEL))
                        {
                            MySession.PlayerShip.Fuel = MySession.PlayerShip.MaxFuel;
                        }
                        if (IsCheatEnabled(MyGameplayCheatsEnum.INFINITE_OXYGEN))
                        {
                            MySession.PlayerShip.Oxygen = MySession.PlayerShip.MaxOxygen;
                        }

                        if ((m_quickZoomOut || m_quickZoomWasUsed) && MyCamera.Zoom.GetZoomLevel() == 1.0f)
                        {
                            m_quickZoomOut = false;
                            m_quickZoomWasUsed = false;
                        }
                    }
                    MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
                }

                //ProcessSectorBoundaries();

                ////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //  Update camera forward and sound after view matrix is updated, because you need actual forward and up vectors
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////

                MyCamera.EnableForward();
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyAudio.ReverbControl");

                //  Update reverb coeficient and whole sound engine. This needs to be called!!!
                //MyFpsManager.AddToFrameDebugText("MySounds.ReverbControl: " + MyUtils.GetFormatedFloat(MySounds.ReverbControl, 5));
                MyAudio.ReverbControl = MyVoxelMaps.GetReverb(MyCamera.Position);
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyLights.Update");
                MyLights.Update();
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                MyDebrisField.Update();

            }
            else
            {
                m_backgroudThreadWasWorking = true;
            }
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();


            if (MyMinerGame.IsGameReady)
            {
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Trailer+UpdateMenu+Hud");

                if (MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE == true/* && GetGameType() != MyGuiScreenGamePlayType.GAME_SANDBOX*/)
                {
                    MyTrailerSave.UpdatePositionsAndOrientations();
                    MyTrailerSave.IncreaseActiveTick();
                }

                if (IsGameActive())
                {
                    m_selectAmmoMenu.Update();
                    m_wheelControlMenu.Update();
                }

                MyHudNotification.Update();

                if (IsGameActive()) // enable cursor drawing if we have ammo selection opened
                {
                    DrawMouseCursor = (m_selectAmmoMenu.IsEnabled && IsSelectAmmoVisible());
                }


                if (MyFakes.TEST_MULTIPLE_LOAD_UNLOAD && m_loadMultiple)
                {
                    m_loadMultiple = false;
                    int count = m_multipleLoadsCount;

                    /*
                    string username = MyConfig.Username;
                    string password = MyConfig.Password;

                    int modelMeshes = MyPerformanceCounter.PerAppLifetime.MyModelsMeshesCount;
                    int modelVertices = MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount;
                    int modelTriangles = MyPerformanceCounter.PerAppLifetime.MyModelsTrianglesCount;

                    MyGuiManager.AddScreen(new MyGuiScreenLoginProgress(username, password,
                                                                  new MyGuiScreenStartQuickLaunch(
                                                                      MyMwcQuickLaunchType.NEW_STORY, MyTextsWrapperEnum.StartGameInProgressPleaseWait), null));
                    */

                    MyScriptWrapper.TravelToMission(MyFakes.TEST_MULTIPLE_LOAD_UNLOAD_MISSION);


                    return false;
                }


                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            }


            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(profBlock);




            if (MyFakes.TEST_MISSION_GAMEPLAY && MyMinerGame.IsGameReady)
            {
                m_missionGameplayTestDelay -= MyConstants.PHYSICS_STEP_SIZE_IN_MILLISECONDS;
                if (m_missionGameplayTestDelay <= 0)
                {
                    m_missionGameplayTestDelay = MyFakes.TEST_MISSION_GAMEPLAY_DURATION;

                    if (m_missionGameplayKillsRemaining > 0)
                    {
                        m_missionGameplayKillsRemaining--;
                        MySession.PlayerShip.DoDamage(0, 10000, 0, MyDamageType.Explosion, MyAmmoType.Explosive, null);
                        MyGuiScreenGamePlay.Static.Restart();
                        return false;
                    }

                    if (MyMissions.ActiveMission == null)
                    {
                        MyMissions.RefreshAvailableMissions();
                        var availableMissions = MyMissions.GetAvailableMissions();
                        if (availableMissions.Count > 0)
                        {
                            MyMission mission = null;
                            foreach (MyMission m in availableMissions)
                            {
                                if (m.RequiredMissions.Contains(m_lastMissionID))
                                {
                                    mission = m;
                                    break;
                                }
                            }

                            if (mission != null)
                            {
                                MyScriptWrapper.TravelToMission(mission.ID);
                            }
                        }
                        else
                        { //no next missions => we have reached the end of singleplayer game
                        }
                    }
                    else
                    {
                        m_lastMissionID = MyMissions.ActiveMission.ID;
                        MyObjective activeObjective = MyMissions.ActiveMission.ActiveObjectives[0];
                        m_lastObjective = activeObjective;

                        if (m_missionGameplayKillsRemaining == 0 && (m_lastObjective == null || m_lastObjective.SaveOnSuccess))
                        {
                            m_missionGameplayKillsRemaining = MyFakes.TEST_MISSION_GAMEPLAY_AUTO_KILLS;
                        }

                        MyMissionGameplayStats statistics = new MyMissionGameplayStats
                        {
                            FPS = MyFpsManager.GetFps(),
                            FrameTimeAvg = (float)MyFpsManager.FrameTimeAvg,
                            FrameTimeMax = (int)MyFpsManager.FrameTimeMax,
                            FrameTimeMin = (int)MyFpsManager.FrameTimeMin,

                            GC = GC.GetTotalMemory(false),
                            WorkingSet = Environment.WorkingSet,

                            // TODO: Videomem
                            VideoMemAllocated = 1.0f, //MyProgram.GetResourcesSizeInMB(),
                            VideoMemAvailable = MyMinerGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f)
                        };

                        Dictionary<MyMissionID, MyMissionGameplayStats> missionStats;
                        m_missionGameplayStats.TryGetValue(MyMissions.ActiveMission.ID, out missionStats);
                        if (missionStats == null)
                        {
                            missionStats = new Dictionary<MyMissionID, MyMissionGameplayStats>();
                            m_missionGameplayStats.Add(MyMissions.ActiveMission.ID, missionStats);
                        }

                        if (missionStats.ContainsKey(activeObjective.ID))
                        {
                            missionStats.Remove(activeObjective.ID);
                        }

                        missionStats.Add(activeObjective.ID, statistics);


                        //Store them each time because of possible crash
                        StoreMissionStats();

                        if (activeObjective.Location != null && activeObjective.Location.Entity != null)
                        {
                            Vector3 objectivePosition = activeObjective.Location.Entity.GetPosition();
                            MySession.PlayerShip.SetPosition(objectivePosition + -20 * Vector3.Forward);
                        }
                        else
                        {
                            if (activeObjective.MissionEntityIDs.Count > 0)
                            {
                                MyEntity ent = MyEntities.GetEntityByIdOrNull(new MyEntityIdentifier(activeObjective.MissionEntityIDs[0]));
                                if (ent != null)
                                {
                                    Vector3 objectivePosition = ent.GetPosition();
                                    MySession.PlayerShip.SetPosition(objectivePosition + -20 * Vector3.Forward);
                                }
                            }
                        }

                        MyObjective.SkipSubmission = true;
                    }
                }
                return false;
            }

            // detect if controlled large weapon or camera are in working state (Enabled and IsElectrified)
            if (ControlledLargeWeapon != null && !ControlledLargeWeapon.IsWorking() && !DetachingForbidden)
            {
                CameraAttachedTo = MyCameraAttachedToEnum.PlayerMinerShip;
                ReleaseControlOfLargeWeapon();
            }
            if (ControlledCamera != null && !ControlledCamera.IsWorking())
            {
                ReleaseControlOfCamera();
            }

            /*
            m_backgroundWorkerCanRun = false;
            while (m_backgroundWorkerRunning)
            {
            }
              */
            return true;
        }
        public MyEACSurveySiteMission()
        {
            m_subShakeAction = new MyTimerActionDelegate(SubShake);
            m_farExplosionAction = new MyTimerActionDelegate(FarExplosion);

            ID = MyMissionID.EAC_SURVEY_SITE; /* ID must be added to MyMissions.cs */
            DebugName = new StringBuilder("01-EAC survey site");
            Name = MyTextsWrapperEnum.EAC_SURVEY_SITE;
            Description = MyTextsWrapperEnum.EAC_SURVEY_SITE_Description;
            Flags = MyMissionFlags.Story;
            AchievementName = MySteamAchievementNames.Mission01_EacSS;

            MyMwcVector3Int baseSector = new MyMwcVector3Int(-913818, 0, -790076);

            /* sector where the mission is located */
            Location = new MyMissionLocation(baseSector, (uint)EntityID.StartLocation);
            //m_Shaft7 = new MyMissionLocation(baseSector, (uint)EntityID.FollowDetector);
            RequiredMissions = new MyMissionID[] { };
            RequiredMissionsForSuccess = new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_90 };
            RequiredActors = new MyActorEnum[] { MyActorEnum.MARCUS, MyActorEnum.MADELYN };

            this.OnMissionSuccess += new MissionHandler(MyEACSurveySiteMission_OnMissionSuccess);
            
            m_objectives = new List<MyObjective>();

     
            /*
            m_followSubmission = new MyObjective(
                new StringBuilder("Follow Marcus to the mines"),
                MyMissionID.EAC_SURVEY_SITE_FOLLOWMARCUS_1,
                new StringBuilder("Another boring day...\n"),
                null,
                this,
                new MyMissionID[] { },
                null,
                successDialogId: MyDialogueEnum.EAC_SURVEY_SITE_0200_ACTIONSTARTS
            ) { SaveOnSuccess = true };
            m_followSubmission.OnMissionLoaded += FollowSubmission_OnMissionLoaded;
            m_followSubmission.OnMissionSuccess += FollowSubmissionSuccess;
            m_followSubmission.OnMissionUpdate += FollowSubmission_OnMissionUpdate;

            m_objectives.Add(m_followSubmission);
              */
            var redHubSubmission = new MyObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_10_Name),
                MyMissionID.EAC_SURVEY_SITE_GOTO_10,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_10_Description),
                null,
                this,
                new MyMissionID[] { },
                new MyMissionLocation(baseSector, (uint)EntityID.RedHubSubmissionLocation)
            ) { HudName = MyTextsWrapperEnum.Nothing };
            redHubSubmission.OnMissionLoaded += RedHubLoaded;
            m_objectives.Add(redHubSubmission);

                        
            m_spawnPointSmartWaves = new MySpawnpointSmartWaves(
                new uint[] 
                {
                    (uint)EntityID.SpawnPointPipe1,
                    (uint)EntityID.SpawnPointPipe2,
                    (uint)EntityID.SpawnPointPipe3,
                    (uint)EntityID.SpawnPointPipe4,
                    (uint)EntityID.SpawnPointEnemyStream01,
                    (uint)EntityID.SpawnPointEnemyStream02,
                    (uint)EntityID.SpawnPointEnemyStream03,
                },
               new uint[] { (uint)EntityID.SpawnPointCrazyRussian }
               , MAX_ANNOYING_BOTS);

            Components.Add(m_spawnPointSmartWaves);

            m_barricadeSubmission = new MyObjectiveDestroy(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_CLEAR_THE_WAY_Name),
                MyMissionID.EAC_SURVEY_SITE_CLEAR_THE_WAY,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_CLEAR_THE_WAY_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_10 },
                m_barricade
            ) { HudName = MyTextsWrapperEnum.Nothing };
            m_barricadeSubmission.OnMissionLoaded += BarricadeLoaded;
            m_barricadeSubmission.OnMissionSuccess += BarricadeSuccess;
            m_objectives.Add(m_barricadeSubmission);

            m_toTheBaseSubmission = new MyObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_30_Name),
                MyMissionID.EAC_SURVEY_SITE_GOTO_30,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_30_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_CLEAR_THE_WAY },
                new MyMissionLocation(baseSector, (uint)EntityID.ToTheBaseSubmissionLocation)
            ) { SaveOnSuccess = true, HudName = MyTextsWrapperEnum.HudMainBase };
            m_toTheBaseSubmission.OnMissionLoaded += ToTheBaseLoaded;
            m_objectives.Add(m_toTheBaseSubmission);


            var commandCentreSubmission = new MyObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_40_Name),
                MyMissionID.EAC_SURVEY_SITE_GOTO_40,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_40_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_30 },
                new MyMissionLocation(baseSector, (uint)EntityID.CommandCentreSubmissionLocation),
                successDialogId: MyDialogueEnum.EAC_SURVEY_SITE_0550_COMMANDOFFLINE
            ) { SaveOnSuccess = true, HudName = MyTextsWrapperEnum.HudCommandCenter };
            commandCentreSubmission.OnMissionLoaded += CommandCenterLoaded;// CommandCentreSubmissionSuccess;
            m_objectives.Add(commandCentreSubmission);

            m_generatorSubmission = new MyObjectiveEnablePrefabs(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GENERATOR_Name),
               MyMissionID.EAC_SURVEY_SITE_GENERATOR,
               (MyTextsWrapperEnum.EAC_SURVEY_SITE_GENERATOR_Description),
               null,
               this,
               new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_40 },
               new MyMissionLocation(baseSector, (uint)EntityID.GaneratorHUB),
               new List<uint>() { (uint)EntityID.Generator1, (uint)EntityID.Generator2, (uint)EntityID.Generator3, (uint)EntityID.Generator4 },
               new List<uint>() { (uint)EntityID.Generator1, (uint)EntityID.Generator2, (uint)EntityID.Generator3, (uint)EntityID.Generator4 }
            ) { SaveOnSuccess = true, HudName = MyTextsWrapperEnum.HudHub };
           // m_generatorSubmission = new MyUseObjective(
           //    new StringBuilder("Start the generator"),
           //    MyMissionID.EAC_SURVEY_SITE_GENERATOR,
           //    new StringBuilder("An auxiliary generator is near the workshop.\n"),
           //    null,
           //    this,
           //    new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_40 },
           //    new MyMissionLocation(baseSector, (uint)EntityID.GeneratorSubmissionLocation),
           //    MyTextsWrapperEnum.PressToStartGenerator,
           //    MyTextsWrapperEnum.Generator,
           //    MyTextsWrapperEnum.StartingProgress,
           //    5000,
           //    MyUseObjectiveType.Activating
           //) { SaveOnSuccess = true };
            m_generatorSubmission.OnMissionLoaded += GeneratorLoaded;// GeneratorSubmissionSuccess;
            m_generatorSubmission.OnMissionSuccess += GeneratorSuccess;
            m_objectives.Add(m_generatorSubmission);


            var commandCentreAgainSubmission = new MyObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_60_Name),
                MyMissionID.EAC_SURVEY_SITE_GOTO_60,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_60_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GENERATOR },
                new MyMissionLocation(baseSector, (uint)EntityID.CommandCentreSubmissionLocation),
                successDialogId: MyDialogueEnum.EAC_SURVEY_SITE_0700_MADELYN
            ) { HudName = MyTextsWrapperEnum.HudCommandCenter };
            commandCentreAgainSubmission.OnMissionLoaded += CommandCenterAgainLoaded;// CommandCentreAgainSubmissionSuccess;
            m_objectives.Add(commandCentreAgainSubmission);

            m_optionalSaveMinersAccept = new MyObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_65_Name),
                MyMissionID.EAC_SURVEY_SITE_GOTO_65,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_65_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_60 },
                new MyMissionLocation(baseSector, (uint)EntityID.OptionalSaveMinersAcceptLocation)
            ) { HudName = MyTextsWrapperEnum.Nothing };
            m_optionalSaveMinersAccept.OnMissionSuccess += OptionalSaveMinersAcceptSubmissionSuccess;
            m_optionalSaveMinersAccept.OnMissionLoaded += OptionalSaveMinersAcceptSubmissionLoaded;
            m_objectives.Add(m_optionalSaveMinersAccept);

            m_optionalSaveMiners = new MyObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_SAVEMINERS_Name),
                MyMissionID.EAC_SURVEY_SITE_SAVEMINERS,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_SAVEMINERS_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_65 },
                new MyMissionLocation(baseSector, (uint)EntityID.OptionalSaveMinersLocation)
            ) { HudName = MyTextsWrapperEnum.HudMiners };
            m_optionalSaveMiners.OnMissionSuccess += OptionalSaveMinersSubmissionSuccess;
            m_objectives.Add(m_optionalSaveMiners);


            var hangarSubmission = new MyObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_70_Name),
                MyMissionID.EAC_SURVEY_SITE_GOTO_70,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_70_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_SAVEMINERS },
                new MyMissionLocation(baseSector, (uint)EntityID.HangarSubmissionLocation)
            ) { SaveOnSuccess = true, HudName = MyTextsWrapperEnum.HudHangar };
            hangarSubmission.OnMissionLoaded += HangarLoaded; // HangarSubmissionSuccess;
            m_objectives.Add(hangarSubmission);





            m_hangarLastStand = new MyTimedObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_SURVIVE_Name),
                MyMissionID.EAC_SURVEY_SITE_SURVIVE,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_SURVIVE_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_70 },
                new TimeSpan(0, 3, 0)
            ) { SaveOnSuccess = true };
            m_hangarLastStand.OnMissionLoaded += HangarLastStandLoaded;// Survived;
            m_objectives.Add(m_hangarLastStand);

                           /*
            var TurretsRightSubmission = new MyObjectiveEnablePrefabs(
               new StringBuilder("Activate the turrets"),
               MyMissionID.EAC_SURVEY_SITE_TURRETS_RIGHT,
               new StringBuilder(""),
               null,
               this,
               new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_70 },
               new MyMissionLocation(baseSector, (uint)EntityID.Right_Generator),
               null,
               new List<uint>() { (uint)EntityID.Right_Generator }
           ) { ShowAsOptional = true };
                            
            TurretsRightSubmission.OnMissionSuccess += TurretsRightSuccess;// TurretsRightSubmissionSuccess;
            m_objectives.Add(TurretsRightSubmission);

            var TurretsLeftSubmission = new MyObjectiveEnablePrefabs(
               new StringBuilder("Activate the turrets"),
               MyMissionID.EAC_SURVEY_SITE_TURRETS_LEFT,
               new StringBuilder(""),
               null,
               this,
               new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_GOTO_70 },
               new MyMissionLocation(baseSector, (uint)EntityID.Left_Generator),
               null,
               new List<uint>() { (uint)EntityID.Left_Generator }
           ) { ShowAsOptional = true };
            TurretsLeftSubmission.OnMissionSuccess += TurretLeftSuccess;// TurretsLeftSubmissionSuccess;
            m_objectives.Add(TurretsLeftSubmission);
                            */


            var hangarEscape = new MyObjective(
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_90_Name),
                MyMissionID.EAC_SURVEY_SITE_GOTO_90,
                (MyTextsWrapperEnum.EAC_SURVEY_SITE_GOTO_90_Description),
                null,
                this,
                new MyMissionID[] { MyMissionID.EAC_SURVEY_SITE_SURVIVE },
                //new MyMissionLocation(baseSector, (uint)EntityID.HangerEscapeLocation)
                new MyMissionLocation(baseSector, MyMissionLocation.MADELYN_HANGAR),
                radiusOverride: MyMissionLocation.MADELYN_HANGAR_RADIUS
            ) { HudName = MyTextsWrapperEnum.HudMadelynsSapho };
            hangarEscape.OnMissionLoaded += HangarEscapeLoaded;
            m_objectives.Add(hangarEscape);

            m_subShakeAction = SubShake;
            m_farExplosionAction = FarExplosion;
        }