示例#1
0
        private void lobby_OnDataReceived(bool success, IMyLobby lobby, ulong memberOrLobby)
        {
            MyLobbyDataUpdated onLobbyDataUpdated = this.OnLobbyDataUpdated;

            if (onLobbyDataUpdated != null)
            {
                onLobbyDataUpdated(success, lobby, memberOrLobby);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
 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);
             }
         }
     }
 }
示例#4
0
 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();
 }
示例#5
0
 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();
 }
示例#6
0
 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);
             }
         }
     }
 }
示例#7
0
        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);
        }
示例#8
0
        public static bool HasSameData(IMyLobby lobby)
        {
            string dataHash = GetDataHash(lobby);

            return((dataHash != "") ? (dataHash == MyDataIntegrityChecker.GetHashBase64()) : true);
        }
示例#9
0
 public static string GetLobbyWorldName(IMyLobby lobby) =>
 lobby.GetData("world");
示例#10
0
        public static ulong GetLobbyWorldSize(IMyLobby lobby)
        {
            string data = lobby.GetData("worldSize");

            return(string.IsNullOrEmpty(data) ? 0UL : Convert.ToUInt64(data));
        }
示例#11
0
        public static ulong GetLobbyULong(string key, IMyLobby lobby, ulong defValue)
        {
            ulong num;

            return(!ulong.TryParse(lobby.GetData(key), out num) ? defValue : num);
        }
示例#12
0
 public static int GetLobbyViewDistance(IMyLobby lobby) =>
 GetLobbyInt("view", lobby, 0x4e20);
示例#13
0
        public static bool GetLobbyBool(string key, IMyLobby lobby, bool defValue)
        {
            bool flag;

            return(!bool.TryParse(lobby.GetData(key), out flag) ? defValue : flag);
        }
示例#14
0
 public static string GetLobbyScenarioBriefing(IMyLobby lobby) =>
 lobby.GetData("scenarioBriefing");
示例#15
0
 public static bool IsLobbyCorrectVersion(IMyLobby lobby) =>
 (GetLobbyAppVersion(lobby) == MyFinalBuildConstants.APP_VERSION);
示例#16
0
        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);
        }
示例#17
0
        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);
        }
示例#18
0
 public static ulong GetLobbyHostSteamId(IMyLobby lobby) =>
 GetLobbyULong("host_steamId", lobby, 0UL);
示例#19
0
 public static string GetLobbyHostName(IMyLobby lobby) =>
 lobby.GetData("host");
示例#20
0
        public static MyGameModeEnum GetLobbyGameMode(IMyLobby lobby)
        {
            int num;

            return(!int.TryParse(lobby.GetData("gameMode"), out num) ? MyGameModeEnum.Creative : ((MyGameModeEnum)num));
        }
示例#21
0
        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);
        }
示例#22
0
 public static string GetDataHash(IMyLobby lobby) =>
 lobby.GetData("dataHash");
示例#23
0
 public static bool GetLobbyScenario(IMyLobby lobby) =>
 GetLobbyBool("scenario", lobby, false);
示例#24
0
 public static int GetLobbyModCount(IMyLobby lobby) =>
 GetLobbyInt("mods", lobby, 0);
示例#25
0
        public static int GetLobbyAppVersion(IMyLobby lobby)
        {
            int num;

            return(int.TryParse(lobby.GetData("appVersion"), out num) ? num : 0);
        }