public StringBuilder GetName() { switch (EventType) { case EventTypeEnum.GlobalEvent: var globalEvent = MyGlobalEvents.GetGlobalEventByType((MyGlobalEventEnum)EventTypeID); if (globalEvent != null) { return(MyTextsWrapper.Get(globalEvent.Name)); } break; case EventTypeEnum.MissionStarted: case EventTypeEnum.MissionFinished: case EventTypeEnum.SubmissionAvailable: case EventTypeEnum.SubmissionFinished: //case EventTypeEnum.Story: var mission = MyMissions.GetMissionByID((MyMissionID)EventTypeID); if (mission != null) { return(mission.NameTemp); } break; } return(null); //return MyTextsWrapperEnum.Null; }
private void OnGenerateListOfMissions(MyGuiControlButton sender) { foreach(MyMissionID missionID in Enum.GetValues(typeof(MyMissionID))){ MyMission mission = MyMissions.GetMissionByID(missionID) as MyMission; if (mission != null) { if (!System.IO.Directory.Exists(MyFileSystemUtils.GetApplicationUserDataFolder() + "\\MissionTexts")) { System.IO.Directory.CreateDirectory(MyFileSystemUtils.GetApplicationUserDataFolder() + "\\MissionTexts"); } using (System.IO.StreamWriter output = new System.IO.StreamWriter(System.IO.File.Open(MyFileSystemUtils.GetApplicationUserDataFolder() + "\\MissionTexts\\" + Enum.GetName(typeof(MyMissionID), missionID) + ".txt", System.IO.FileMode.Create))) { output.WriteLine("Mission: " + mission.DebugName); output.WriteLine(); output.WriteLine("MyMissionID." + Enum.GetName(typeof(MyMissionID), mission.ID)); output.WriteLine("DebugName: \"" + mission.DebugName + "\""); output.WriteLine("Name: \"" + mission.Name + "\""); output.WriteLine("Description: \"" + mission.Description + "\""); output.WriteLine(); output.WriteLine("Objectives:"); foreach(MyObjective objective in mission.Objectives){ output.WriteLine("MyMissionID." + Enum.GetName(typeof(MyMissionID), objective.ID)); output.WriteLine("Name: \"" + objective.Name + "\""); output.WriteLine("Description: \"" + objective.Description + "\""); output.WriteLine(); } output.Flush(); output.Close(); } } } }
void Script_DialogueFinished(MyDialogueEnum dialogue, bool interrupted) { switch (dialogue) { case MyDialogueEnum.JUNKYARD_RETURN_0250: MyMissions.GetMissionByID(MyMissionID.JUNKYARD_RETURN_SPEEDSTER_DIALOGUE).Success(); break; } }
void FillList() { m_chapters = MinerWars.AppCode.Networking.MyLocalCache.LoadChapters().OrderByDescending(c => c.Item2).ToList(); m_listbox.DeselectAll(); m_listbox.RemoveAllRows(); m_listbox.RemoveAllItems(); int index = 0; for (int ind = 0; ind < m_chapters.Count; ind++) { var chapter = m_chapters[ind].Item3; string time = MyUtils.GetDatetimeAsSpentTime(m_chapters[ind].Item2); var name = new StringBuilder(time); name.Append(" - "); if (chapter.ActiveMissionID != -1) { if (MyMissions.GetMissionByID((MyMissionID)chapter.ActiveMissionID) != null) { name.Append(MyTextsWrapper.Get(MyMissions.GetMissionByID((MyMissionID)chapter.ActiveMissionID).Name)); } else { name.Append("<mission deleted>"); } } else { name.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.FreeRoaming)); } var lastEvent = GetLastEvent(chapter); if (lastEvent != null) { name.Append(" - "); if (MyMissions.GetMissionByID((MyMissionID)lastEvent.EventTypeID) != null) { name.Append(MyMissions.GetMissionByID((MyMissionID)lastEvent.EventTypeID).NameTemp); } } var difficultyName = MyGameplayConstants.GetGameplayDifficultyProfile(chapter.SessionObjectBuilder.Difficulty).DifficultyName; name.Append(" - "); name.Append(MyTextsWrapper.Get(difficultyName)); m_listbox.AddItem(index, name); index++; } }
void OnMissionUpdateVars(ref MyEventMissionUpdateVars msg) { var missionId = (MyMissionID)msg.MissionId; if (!MyMwcEnums.IsValidValue <MyMissionID>(missionId)) { Alert("Invalid mission id!", msg.SenderEndpoint, msg.EventType); return; } var mission = MyMissions.GetMissionByID((MyMissionID)msg.MissionId); mission.MissionTimer.SetElapsedTime(TimeSpan.FromMilliseconds(msg.ElapsedTime)); }
public StringBuilder GetDescription() //TODO: change this to MyTextsWrapperEnum { switch (EventType) { case EventTypeEnum.GlobalEvent: var globalEvent = MyGlobalEvents.GetGlobalEventByType((MyGlobalEventEnum)EventTypeID); return(MyTextsWrapper.Get(globalEvent.Description)); case EventTypeEnum.MissionStarted: case EventTypeEnum.MissionFinished: case EventTypeEnum.SubmissionAvailable: case EventTypeEnum.SubmissionFinished: //case EventTypeEnum.Story: var mission = MyMissions.GetMissionByID((MyMissionID)EventTypeID); return(mission.DescriptionTemp); } return(null); }
public void SetObjectives(int?missionId /*, List<MyMissionID> optionalObjectives*/) { MyObjective objective = null; if (missionId.HasValue && (objective = MyMissions.GetMissionByID((MyMissionID)missionId.Value) as MyObjective) != null) { RequiredActors = objective.ParentMission.RequiredActors; MainObjective.RequiredActors = objective.RequiredActors; InsertRequiredActors(); objective.InsertRequiredActors(); Name = objective.ParentMission.Name; NameTemp = objective.ParentMission.NameTemp; Description = objective.ParentMission.Description; DescriptionTemp = objective.ParentMission.DescriptionTemp; } else { Name = MyTextsWrapperEnum.EmptyDescription; NameTemp = new StringBuilder(); Description = MyTextsWrapperEnum.EmptyDescription; DescriptionTemp = new StringBuilder(); } MainObjective.SetObjectives(objective); // Only one objective is active //m_objectives.Clear(); //m_objectives.Add(MainObjective); //foreach (var objective in optionalObjectives) //{ // var baseObjective = MyMissions.GetMissionByID(objective); // if (baseObjective != null) // { // var o = new MyFollowHostObjective(this); // o.SetObjectives(baseObjective); // m_objectives.Add(o); // } //} }
public MyServerAction NewGame(MyMissionID startMission = MyMissionID.EAC_SURVEY_SITE) { TryPause(); MyMwcVector3Int?startSector = null; startSector = MyMissions.GetMissionByID(startMission).Location.Sector; var checkpoint = MyLocalCache.NewGameCheckpoint(); if (checkpoint == null) { throw new MyDataCorruptedException("Checkpoint cannot be loaded from content"); } // Set proper start sector checkpoint.CurrentSector.Position = startSector.Value; NewGameStarted(checkpoint, startMission); return(null); // Finished synchronously }
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 MyServerAction LoadSandboxMission(MyMissionID startMission) { var startSector = MyMissions.GetMissionByID(startMission).Location.Sector; return(LoadSandbox(startSector, null, startMission)); }
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); }