/// <summary> /// Updates resource. /// </summary> public virtual void Update() { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMissions.Update"); MyMissions.Update(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyGlobalEvents.Update()"); //Update global events in the game. This should be driven and synchronized //by sector server World.Global.MyGlobalEvents.Update(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("RefreshAvailableMissions"); // update global game time GameDateTime = GameDateTime + new TimeSpan(0, 0, 0, 0, MyConstants.PHYSICS_STEP_SIZE_IN_MILLISECONDS); // check if some new mission are available (because time has advanced) MyMissions.RefreshAvailableMissions(); MotherShipPosition.Update(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
private void SetTransparentParameters(out Vector4 color, out MyTransparentMaterialEnum?faceMaterial, out MyTransparentMaterialEnum?lineMaterial) { if (Game.Editor.MyEditor.Static.IsActive()) { faceMaterial = MyTransparentMaterialEnum.ObjectiveDummyFace; lineMaterial = MyTransparentMaterialEnum.ObjectiveDummyLine; } else { faceMaterial = null; lineMaterial = null; } if (MyMissions.IsMissionEntity(this)) { color = MyHudConstants.MISSION_CUBE_COLOR; } else { MyFactionRelationEnum status = MyFactions.GetFactionsRelation(this, MySession.PlayerShip); switch (status) { case MyFactionRelationEnum.Friend: color = MyHudConstants.FRIEND_CUBE_COLOR; break; case MyFactionRelationEnum.Enemy: color = MyHudConstants.ENEMY_CUBE_COLOR; break; case MyFactionRelationEnum.Neutral: color = MyHudConstants.NEUTRAL_CUBE_COLOR; break; default: throw new MyMwcExceptionApplicationShouldNotGetHere(); } } }
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; }
public override void Load() { //if (!IsMainSector) return; MyScriptWrapper.OnSpawnpointBotSpawned += MyScriptWrapperOnOnSpawnpointBotSpawned; MyScriptWrapper.EntityDeath += OnEntityDeath; MyGuiScreenGamePlay.Static.CameraContrlolledObjectChanged += Static_CameraContrlolledObjectChanged; m_templarBot = (MySmallShipBot)MyScriptWrapper.GetEntity((uint)EntityID.BotTemplar); m_royalBot = (MySmallShipBot)MyScriptWrapper.GetEntity((uint)EntityID.BotRoyal); m_templarBot.SetWaypointPath("Templar"); m_templarBot.PatrolMode = MyPatrolMode.CYCLE; m_templarBot.SpeedModifier = 0.25f; m_templarBot.Patrol(); m_royalBot.SetWaypointPath("Royal"); m_royalBot.PatrolMode = MyPatrolMode.CYCLE; m_royalBot.SpeedModifier = 0.25f; m_royalBot.Patrol(); m_ravenguyBot = MyScriptWrapper.GetEntity("RavenGuy") as MySmallShipBot; m_ravengirlBot = MyScriptWrapper.GetEntity("RavenGirl") as MySmallShipBot; m_marcus = MyScriptWrapper.GetEntity("Marcus") as MySmallShipBot; MyScriptWrapper.UnhideEntity(MyScriptWrapper.GetEntity((uint)EntityID.BotTemplar)); m_deadlyScanners = new MyDeadlyScanners(m_scanners1IDs, new List <int>() { 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000 }); if (!MyScriptWrapper.IsMissionFinished(m_disableScanner2.ID)) { Components.Add(m_deadlyScanners); } DisableEntities(new List <uint>() { (uint)EntityID.Scanner1, (uint)EntityID.Scanner2 }); foreach (var mine in m_minesDummies) { MyScriptWrapper.GenerateMinesField <MyMineBasic>(MyScriptWrapper.GetEntity(mine), MyMwcObjectBuilder_FactionEnum.Russian_KGB, 1, MyTexts.Mine, MyHudIndicatorFlagsEnum.SHOW_BORDER_INDICATORS | MyHudIndicatorFlagsEnum.ALPHA_CORRECTION_BY_DISTANCE | MyHudIndicatorFlagsEnum.SHOW_TEXT | MyHudIndicatorFlagsEnum.SHOW_DISTANCE | MyHudIndicatorFlagsEnum.SHOW_FACTION_RELATION_MARKER | MyHudIndicatorFlagsEnum.SHOW_ONLY_IF_DETECTED_BY_RADAR ); } if (MySession.Static.EventLog.IsMissionFinished(MyMissionID.FORT_VALIANT_C_FOLLOW_FIND_VENTILATION) && !MySession.Static.EventLog.IsMissionFinished(MyMissionID.FORT_VALIANT_C_CATACOMBS)) { SetFriendsPatrol(); } if (!MyMissions.GetMissionByID(MyMissionID.FORT_VALIANT_C_CAPTAIN).IsCompleted()) { var startPosition = MyScriptWrapper.GetEntity((uint)EntityID.StartLocationC).GetPosition(); MyScriptWrapper.Move(MyScriptWrapper.GetEntity(MyActorConstants.GetActorName(MyActorEnum.MADELYN)), startPosition); MyScriptWrapper.MovePlayerAndFriendsToHangar(this.RequiredActors); } base.Load(); }
public void Resume() { if (MyFakes.MULTIPLAYER_DISABLED) { return; } IsWaiting = false; if (!IsHost) { // When host is disconnected in resume, he disconnected in load, so shutdown MP MyPlayerRemote host; if (!Peers.TryGetPlayer(Peers.HostUserId, out host)) { var handler = OnShutdown; if (handler != null) { handler(); } return; } } if (!IsHost) { MyGlobalEvents.DisableAllGlobalEvents(); } if (!IsHost || OtherPlayersConnected) //TODO: remove { RemoveUnsupportedEntities(); } if (!IsHost) { MakeAllEntitiesDummy(); } if (IsSandBox()) { LoadRespawnPoints(); } RegisterCallbacks(); if (!IsHost) { foreach (var p in Peers.Players) { if (p.Ship == null) // Ship can be already assigned (player has respawned before we finished loading) { var newShip = FindPlayerShip(p.PlayerId); if (newShip != null) { p.Ship = newShip; p.Faction = newShip.Faction; OnNewPlayerShip(p.Ship); } } } } if (!IsHost) { if (IsStory()) { MyMissions.Unload(); m_followMission = MyMissions.GetMissionByID(MyMissionID.COOP_FOLLOW_HOST) as MyFollowHostMission; if (m_followMission == null) { m_followMission = new MyFollowHostMission(); m_followMission.Location = new MyMissionBase.MyMissionLocation(MyGuiScreenGamePlay.Static.GetSectorIdentifier().Position, 0); MyMissions.AddMission(m_followMission); } m_followMission.SetHudName(Peers[Peers.HostUserId].GetDisplayName()); UpdateCoopTarget(); m_followMission.Accept(); } } m_processingBuffer = true; Peers.NetworkClient.ProcessBuffered(); m_processingBuffer = false; if (IsSandBox()) { if (IsHost) { MySession.Static.Player.Faction = ChooseFaction(); } } //DisableCheats(); if (!IsHost) { if (IsSandBox()) { // No faction, prevents respawn until server assigns faction MySession.Static.Player.Faction = MyMwcObjectBuilder_FactionEnum.None; } RequestFaction(MyMwcObjectBuilder_FactionEnum.None); } if (!IsStory() || !IsHost) { // Player's ship is dummy MySession.PlayerShip.IsDummy = true; m_respawnTime = MyMinerGame.TotalGamePlayTimeInMilliseconds; } else { m_respawnTime = Int32.MaxValue; } if (IsHost) { // Why is this set only for host? MySession.PlayerShip.ConfigChanged += m_onConfigChanged; MySession.PlayerShip.OnDie += m_onEntityDie; MySession.PlayerShip.InventoryChanged += m_onInventoryChanged; } // Hook entities (hook required events) foreach (var entity in MyEntities.GetEntities().OfType <MyCargoBox>()) { HookEntity(entity); } foreach (var entity in MyEntities.GetEntities().OfType <MyPrefabContainer>()) { HookEntity(entity); } SendGlobalFlag(MyGlobalFlagsEnum.REQUEST_INFO); }
public override void CloseScreenNow() { base.CloseScreenNow(); MyMissions.HandleCloseMissionScreen(); }
public override void AddUniverseEntities(MySolarSystemMapData data) { if (MyMissions.ActiveMission == null && MyMissions.GetAvailableMissions().Count == 0) { AddTemplateGroups(data); } const float maxObjCenterFromOrbit = 0.25f; Random rnd = new Random(0); float orbitRadius = OrbitProperties.AreaCenter.Length(); float baseAngle = MyMath.AngleTo(OrbitProperties.AreaCenter, Vector3.UnitZ).Y; //count of groups per orbit side float step = CalculateStep((OrbitProperties.MaxDistanceFromOrbitHigh + OrbitProperties.MaxDistanceFromOrbitLow) / 2); int testMaxCount = 0; for (float i = baseAngle - HalfAngle; i < baseAngle + HalfAngle; i += step) { float interpolator = 1 - Math.Abs((i - baseAngle) / HalfAngle); // (i + halfLen) / halfLen / 2; float maxDistFromOrbitAtAngle = MathHelper.SmoothStep(OrbitProperties.MaxDistanceFromOrbitLow, OrbitProperties.MaxDistanceFromOrbitHigh, interpolator); step = CalculateStep((OrbitProperties.MaxDistanceFromOrbitHigh + maxDistFromOrbitAtAngle) / 2); //Vector3 centerPos = new Vector3((float)Math.Sin(i) * distance, 0, (float)Math.Cos(i) * distance); //5 = billboards count in smaller group for (int j = 0; j < 2; j++) { Vector2 distFromOrbit = Vector2.Normalize(new Vector2(rnd.Float(-1, 1), rnd.Float(-1, 1))); //distFromOrbit = new Vector2(); distFromOrbit *= maxDistFromOrbitAtAngle * maxObjCenterFromOrbit; float dist = orbitRadius + distFromOrbit.X; float i2 = i + rnd.FloatCubic(-step * maxObjCenterFromOrbit, step * maxObjCenterFromOrbit); float x = (float)Math.Sin(i2) * dist; float z = (float)Math.Cos(i2) * dist; float y = distFromOrbit.Y; Vector3 pos = OrbitProperties.OrbitCenter + new Vector3(x, y, z); Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset); float size = maxDistFromOrbitAtAngle * (1 - maxObjCenterFromOrbit); if (this.SolarMapData != null) { Vector4 clr = new Vector4(this.SolarMapData.DustColor, 1.0f); Color color = rnd.Color(new Color(clr - this.SolarMapData.DustColorVariability), new Color(clr + this.SolarMapData.DustColorVariability)); data.Entities.Add(new MySolarSystemMapEntity(sector, offset, 2 * size, "Dust", MySolarSystemEntityEnum.DustField, color)); testMaxCount++; } if ((AreaType & AreaEnum.PostPlanet) != 0 && j % 2 == 0) { data.Entities.Add(new MySolarSystemMapEntity(sector, offset, size * (1 - maxObjCenterFromOrbit), "Asteroids", MySolarSystemEntityEnum.AsteroidField, Color.White)); testMaxCount++; } //AddEntity(m_data, pos, radius * wide * 4, name + " dust", MySolarSystemEntityEnum.Test1_Dust, rnd.Color(baseColor, colorVariation)); } } //Do not allow to solar area to add more than 1000 objects //System.Diagnostics.Debug.Assert(testMaxCount < 3000); MySolarAreaBorderLine newLine = new MySolarAreaBorderLine(); newLine.AreaCenter = OrbitProperties.AreaCenter; newLine.DistanceHigh = OrbitProperties.MaxDistanceFromOrbitHigh; newLine.DistanceLow = OrbitProperties.MaxDistanceFromOrbitLow; newLine.Spread = OrbitProperties.LongSpread; newLine.col = new Vector4(SolarMapData.DustColor, 1f); data.AreasBorderLines.Add(newLine); }
public MyServerAction LoadSandboxMission(MyMissionID startMission) { var startSector = MyMissions.GetMissionByID(startMission).Location.Sector; return(LoadSandbox(startSector, null, startMission)); }
public void Generate(int sectorCacheCapacity) { m_data = new MySolarSystemMapData(sectorCacheCapacity); // Sun AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SUN_RADIUS, MyTextsWrapper.Get(MyTextsWrapperEnum.Sun).ToString(), MySolarSystemEntityEnum.Sun, Color.White); // Orbits (just orbit lines) AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.MERCURY_POSITION.Length(), "Mercury orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.VENUS_POSITION.Length(), "Venus orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.EARTH_POSITION.Length(), "Earth orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.MARS_POSITION.Length(), "Mars orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.JUPITER_POSITION.Length(), "Jupiter orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SATURN_POSITION.Length(), "Saturn orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.URANUS_POSITION.Length(), "Uranus orbit", MySolarSystemEntityEnum.Orbit, Color.White); AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.NEPTUNE_POSITION.Length(), "Neptune orbit", MySolarSystemEntityEnum.Orbit, Color.White); foreach (var a in MySolarSystemConstants.Areas) { a.Value.AddUniverseEntities(m_data); m_data.Areas.Add(a.Key); } if (MyFakes.ENABLE_RANDOM_STATIONS_IN_SOLAR_SYSTEM && MyMissions.ActiveMission == null && MyMissions.GetAvailableMissions().Count == 0) { foreach (var a in MyFactions.FactionAreas) { if (a.Key == CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilder_FactionEnum.CSR) { continue; } foreach (var circle in a.Value) { Random r = new Random(circle.Position.GetHashCode() ^ circle.Radius.GetHashCode()); var radius = circle.Radius / 100000000; float count = MathHelper.Pi * radius * radius; count = MathHelper.Clamp(count, 0, 10); if (count < 1) { count = r.Next(0, 2); } for (int i = 0; i < count; i++) { float dist = rnd.Float() * circle.Radius; float angle = (float)(rnd.NextDouble() * 2 * MathHelper.Pi); float x = (float)Math.Sin(angle) * dist; float z = (float)Math.Cos(angle) * dist; var pos = circle.GetCenter() + new Vector3(x, 0, z); //pos = circle.GetCenter(); Vector3 offset; MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset); var mark = new MySolarSystemMapNavigationMark(sector, "", null, Color.White, MyTransparentMaterialEnum.SolarMapOutpost); mark.Importance = rnd.Next(2, 5) / 4.0f; mark.DrawVerticalLine = false; m_data.NavigationMarks.Add(mark); m_data.ImportantObjects.Add(new MyImportantSolarObject() { NavigationMark = mark, TemplateGroup = MyTemplateGroupEnum.RandomStations }); } } } } // Filip resize solar map const float factionMapScale = 1.75f; // Faction map - size of map is same as saturn orbit AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SATURN_POSITION.Length() / factionMapScale, "Faction map", MySolarSystemEntityEnum.FactionMap, Color.White); AddEntity(m_data, new Vector3(-352, 0, -40), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussian).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.IndianRed, MyTransparentMaterialEnum.FactionRussia); AddEntity(m_data, new Vector3(-432, 0, -628), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussian).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.IndianRed, MyTransparentMaterialEnum.FactionRussia); AddEntity(m_data, new Vector3(0, 0, 300), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChineseShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Brown, MyTransparentMaterialEnum.FactionChina); AddEntity(m_data, new Vector3(-150, 0, 95), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionJapan).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.DeepSkyBlue, MyTransparentMaterialEnum.FactionJapan); AddEntity(m_data, new Vector3(300, 0, 108), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFreeAsia).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.HotPink, MyTransparentMaterialEnum.FactionFreeAsia); AddEntity(m_data, new Vector3(300, 0, -40), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionSaudiShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Gold, MyTransparentMaterialEnum.FactionSaudi); AddEntity(m_data, new Vector3(220, 0, -180), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionEuroamericanShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.CornflowerBlue, MyTransparentMaterialEnum.FactionEAC); //AddEntity(m_data, new Vector3(65, 0, -135), 0, "CSR", MySolarSystemEntityEnum.FactionInfo, Color.DarkKhaki, MyTransparentMaterialEnum.FactionCSR); AddEntity(m_data, new Vector3(37, 0, -160), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionIndia).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.SandyBrown, MyTransparentMaterialEnum.FactionIndia); AddEntity(m_data, new Vector3(-30, 0, -160), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChurchShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Yellow, MyTransparentMaterialEnum.FactionChurch); AddEntity(m_data, new Vector3(-85, 0, -150), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionOmnicorpShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.LightGreen, MyTransparentMaterialEnum.FactionOmnicorp); AddEntity(m_data, new Vector3(-108, 0, -358), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFourthReichShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.LightSteelBlue, MyTransparentMaterialEnum.FactionFourthReich); // Some navigation marks for testing //AddNavigationMark(m_data, new MyMwcVector3Int(1000000, 0, 1000000), "Mark1"); //AddNavigationMark(m_data, new MyMwcVector3Int(3000000, 0, -1500000), "Mark2"); }
public static MySmallShipTemplate GetTemplateForSpawn(int templateId) { var tier = MyMissions.GetCurrentTier(); return(tier == 0 ? GetTemplate(templateId) : GetTemplate(templateId, tier)); }
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); }