private void lobby_OnDataReceived(bool success, IMyLobby lobby, ulong memberOrLobby) { MyLobbyDataUpdated onLobbyDataUpdated = this.OnLobbyDataUpdated; if (onLobbyDataUpdated != null) { onLobbyDataUpdated(success, lobby, memberOrLobby); } }
public void RaiseJoined(bool success, IMyLobby lobby, MyLobbyEnterResponseEnum response, MyMultiplayerBase multiplayer) { Action <bool, IMyLobby, MyLobbyEnterResponseEnum, MyMultiplayerBase> joinDone = this.JoinDone; if (joinDone != null) { joinDone(success, lobby, response, multiplayer); } }
private void Matchmaking_LobbyChatUpdate(IMyLobby lobby, ulong changedUser, ulong makingChangeUser, MyChatMemberStateChangeEnum stateChange) { if (lobby.LobbyId == this.m_lobby.LobbyId) { if (stateChange == MyChatMemberStateChangeEnum.Entered) { object[] objArray1 = new object[] { "Player entered: ", MyGameService.GetPersonaName(changedUser), " (", changedUser, ")" }; MySandboxGame.Log.WriteLineAndConsole(string.Concat(objArray1)); MyGameService.Peer2Peer.AcceptSession(changedUser); if ((Sync.Clients == null) || !Sync.Clients.HasClient(changedUser)) { base.RaiseClientJoined(changedUser); if (this.Scenario && (changedUser != Sync.MyId)) { base.SendAllMembersDataToClient(changedUser); } } if (MySandboxGame.IsGameReady && (changedUser != base.ServerId)) { MyHudNotification notification = new MyHudNotification(MyCommonTexts.NotificationClientConnected, 0x1388, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important); object[] arguments = new object[] { MyGameService.GetPersonaName(changedUser) }; notification.SetTextFormatArguments(arguments); MyHud.Notifications.Add(notification); } } else { if ((Sync.Clients == null) || Sync.Clients.HasClient(changedUser)) { base.RaiseClientLeft(changedUser, stateChange); } if (changedUser == base.ServerId) { base.RaiseHostLeft(); MySessionLoader.UnloadAndExitToMenu(); StringBuilder messageCaption = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError); MyStringId? okButtonText = null; okButtonText = null; okButtonText = null; okButtonText = null; Vector2?size = null; MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MultiplayerErrorServerHasLeft), messageCaption, okButtonText, okButtonText, okButtonText, okButtonText, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, size)); } else if (MySandboxGame.IsGameReady) { MyHudNotification notification = new MyHudNotification(MyCommonTexts.NotificationClientDisconnected, 0x1388, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important); object[] arguments = new object[] { MyGameService.GetPersonaName(changedUser) }; notification.SetTextFormatArguments(arguments); MyHud.Notifications.Add(notification); } } } }
internal MyMultiplayerLobby(IMyLobby lobby, MySyncLayer syncLayer) : base(syncLayer, new EndpointId(Sync.MyId)) { this.m_lobby = lobby; base.ServerId = this.m_lobby.OwnerId; base.SyncLayer.RegisterClientEvents(this); this.HostName = MyGameService.UserName; lobby.OnChatUpdated += new MyLobbyChatUpdated(this.Matchmaking_LobbyChatUpdate); lobby.OnChatReceived += new MessageReceivedDelegate(this.Matchmaking_LobbyChatMsg); lobby.OnChatScriptedReceived += new MessageScriptedReceivedDelegate(this.Matchmaking_LobbyChatScriptedMsg); lobby.OnDataReceived += new MyLobbyDataUpdated(this.lobby_OnDataReceived); base.ClientLeft += new Action <ulong, MyChatMemberStateChangeEnum>(this.MyMultiplayerLobby_ClientLeft); this.AcceptMemberSessions(); }
internal MyMultiplayerLobbyClient(IMyLobby lobby, MySyncLayer syncLayer) : base(syncLayer) { this.Lobby = lobby; base.ServerId = this.Lobby.OwnerId; base.SyncLayer.RegisterClientEvents(this); base.SyncLayer.TransportLayer.IsBuffering = true; if (!base.SyncLayer.Clients.HasClient(base.ServerId)) { base.SyncLayer.Clients.AddClient(base.ServerId); } base.ClientLeft += new Action <ulong, MyChatMemberStateChangeEnum>(this.MyMultiplayerLobby_ClientLeft); lobby.OnChatUpdated += new MyLobbyChatUpdated(this.Matchmaking_LobbyChatUpdate); lobby.OnChatReceived += new MessageReceivedDelegate(this.Matchmaking_LobbyChatMsg); lobby.OnChatScriptedReceived += new MessageScriptedReceivedDelegate(this.Matchmaking_LobbyChatScriptedMsg); lobby.OnDataReceived += new MyLobbyDataUpdated(this.lobby_OnDataReceived); this.AcceptMemberSessions(); }
private void Matchmaking_LobbyChatUpdate(IMyLobby lobby, ulong changedUser, ulong makingChangeUser, MyChatMemberStateChangeEnum stateChange) { if (lobby.LobbyId == this.Lobby.LobbyId) { if (stateChange != MyChatMemberStateChangeEnum.Entered) { if ((Sync.Clients == null) || Sync.Clients.HasClient(changedUser)) { base.RaiseClientLeft(changedUser, stateChange); } if (changedUser == base.ServerId) { base.RaiseHostLeft(); MySessionLoader.UnloadAndExitToMenu(); MyGuiScreenServerReconnector.ReconnectToLastSession(); } else if (MySandboxGame.IsGameReady) { MyHudNotification notification = new MyHudNotification(MyCommonTexts.NotificationClientDisconnected, 0x1388, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important); object[] arguments = new object[] { MyGameService.GetPersonaName(changedUser) }; notification.SetTextFormatArguments(arguments); MyHud.Notifications.Add(notification); } } else { object[] objArray1 = new object[] { "Player entered: ", MyGameService.GetPersonaName(changedUser), " (", changedUser, ")" }; MySandboxGame.Log.WriteLineAndConsole(string.Concat(objArray1)); MyGameService.Peer2Peer.AcceptSession(changedUser); if ((Sync.Clients == null) || !Sync.Clients.HasClient(changedUser)) { base.RaiseClientJoined(changedUser); } if (MySandboxGame.IsGameReady && (changedUser != base.ServerId)) { MyHudNotification notification = new MyHudNotification(MyCommonTexts.NotificationClientConnected, 0x1388, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important); object[] arguments = new object[] { MyGameService.GetPersonaName(changedUser) }; notification.SetTextFormatArguments(arguments); MyHud.Notifications.Add(notification); } } } }
public static List <MyObjectBuilder_Checkpoint.ModItem> GetLobbyMods(IMyLobby lobby) { int lobbyModCount = GetLobbyModCount(lobby); List <MyObjectBuilder_Checkpoint.ModItem> list = new List <MyObjectBuilder_Checkpoint.ModItem>(lobbyModCount); for (int i = 0; i < lobbyModCount; i++) { string data = lobby.GetData("mod" + i); int index = data.IndexOf("_"); if (index == -1) { MySandboxGame.Log.WriteLineAndConsole($"Failed to parse mod details from LobbyData. '{data}'"); } else { ulong num4; ulong.TryParse(data.Substring(0, index), out num4); string name = data.Substring(index + 1); list.Add(new MyObjectBuilder_Checkpoint.ModItem(name, num4, name)); } } return(list); }
public static bool HasSameData(IMyLobby lobby) { string dataHash = GetDataHash(lobby); return((dataHash != "") ? (dataHash == MyDataIntegrityChecker.GetHashBase64()) : true); }
public static string GetLobbyWorldName(IMyLobby lobby) => lobby.GetData("world");
public static ulong GetLobbyWorldSize(IMyLobby lobby) { string data = lobby.GetData("worldSize"); return(string.IsNullOrEmpty(data) ? 0UL : Convert.ToUInt64(data)); }
public static ulong GetLobbyULong(string key, IMyLobby lobby, ulong defValue) { ulong num; return(!ulong.TryParse(lobby.GetData(key), out num) ? defValue : num); }
public static int GetLobbyViewDistance(IMyLobby lobby) => GetLobbyInt("view", lobby, 0x4e20);
public static bool GetLobbyBool(string key, IMyLobby lobby, bool defValue) { bool flag; return(!bool.TryParse(lobby.GetData(key), out flag) ? defValue : flag); }
public static string GetLobbyScenarioBriefing(IMyLobby lobby) => lobby.GetData("scenarioBriefing");
public static bool IsLobbyCorrectVersion(IMyLobby lobby) => (GetLobbyAppVersion(lobby) == MyFinalBuildConstants.APP_VERSION);
public static DateTime GetLobbyDateTime(string key, IMyLobby lobby, DateTime defValue) { DateTime time; return(!DateTime.TryParse(lobby.GetData(key), CultureInfo.InvariantCulture, DateTimeStyles.None, out time) ? defValue : time); }
public static int GetLobbyInt(string key, IMyLobby lobby, int defValue) { int num; return(!int.TryParse(lobby.GetData(key), NumberStyles.Integer, CultureInfo.InvariantCulture, out num) ? defValue : num); }
public static ulong GetLobbyHostSteamId(IMyLobby lobby) => GetLobbyULong("host_steamId", lobby, 0UL);
public static string GetLobbyHostName(IMyLobby lobby) => lobby.GetData("host");
public static MyGameModeEnum GetLobbyGameMode(IMyLobby lobby) { int num; return(!int.TryParse(lobby.GetData("gameMode"), out num) ? MyGameModeEnum.Creative : ((MyGameModeEnum)num)); }
public static float GetLobbyFloat(string key, IMyLobby lobby, float defValue) { float num; return(!float.TryParse(lobby.GetData(key), NumberStyles.Float, CultureInfo.InvariantCulture, out num) ? defValue : num); }
public static string GetDataHash(IMyLobby lobby) => lobby.GetData("dataHash");
public static bool GetLobbyScenario(IMyLobby lobby) => GetLobbyBool("scenario", lobby, false);
public static int GetLobbyModCount(IMyLobby lobby) => GetLobbyInt("mods", lobby, 0);
public static int GetLobbyAppVersion(IMyLobby lobby) { int num; return(int.TryParse(lobby.GetData("appVersion"), out num) ? num : 0); }