public override void Init() { base.Init(); MyMissions.Unload(); if (MyMissions.ActiveMission != null) { MyMissions.ActiveMission.Load(); } EventLog = new MyEventLog(); MyMissions.RefreshAvailableMissions(); }
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); }