Esempio n. 1
0
        public static void JoinGame(Lobby lobby, bool requestData = true)
        {
            // Data not received
            if (requestData && String.IsNullOrEmpty(lobby.GetLobbyData(MyMultiplayer.AppVersionTag)))
            {
                var helper = new MyLobbyHelper(lobby);
                helper.OnSuccess += (l) => JoinGame(l, false);
                if (helper.RequestData())
                    return;
            }

            if (!JoinGameTest(lobby))
                return;

            if (MyMultiplayerLobby.GetLobbyScenario(lobby))
            {
                MyJoinGameHelper.JoinScenarioGame(lobby.LobbyId);
            }
            else if (MyFakes.ENABLE_BATTLE_SYSTEM && MyMultiplayerLobby.GetLobbyBattle(lobby))
            {
                bool canBeJoined = MyMultiplayerLobby.GetLobbyBattleCanBeJoined(lobby);
                // Check also valid faction ids in battle lobby.
                long faction1Id = MyMultiplayerLobby.GetLobbyBattleFaction1Id(lobby);
                long faction2Id = MyMultiplayerLobby.GetLobbyBattleFaction2Id(lobby);

                if (canBeJoined && faction1Id != 0 && faction2Id != 0)
                    MyJoinGameHelper.JoinBattleGame(lobby.LobbyId);
            }
            else
            {
                JoinGame(lobby.LobbyId);
            }
        }
        public static void JoinBattleGame(Lobby lobby, bool requestData = true)
        {
            // Data not received
            if (requestData && String.IsNullOrEmpty(lobby.GetLobbyData(MyMultiplayer.AppVersionTag)))
            {
                var helper = new MyLobbyHelper(lobby);
                helper.OnSuccess += (l) => JoinBattleGame(l, false);
                if (helper.RequestData())
                    return;
            }

            if (!JoinGameTest(lobby))
                return;

            JoinBattleGame(lobby.LobbyId);
        }
Esempio n. 3
0
 public static string GetLobbyScenarioBriefing(Lobby lobby)
 {
     return lobby.GetLobbyData(MyMultiplayer.ScenarioBriefingTag);
 }
Esempio n. 4
0
        public static List<MyObjectBuilder_Checkpoint.ModItem> GetLobbyMods(Lobby lobby)
        {
            var modsCount = GetLobbyModCount(lobby);
            var mods = new List<MyObjectBuilder_Checkpoint.ModItem>(modsCount);
            for (int i = 0; i < modsCount; ++i)
            {
                string modInfo = lobby.GetLobbyData(MyMultiplayer.ModItemTag + i);

                var index = modInfo.IndexOf("_");
                if (index != -1)
                {
                    ulong publishedFileId = 0;
                    ulong.TryParse(modInfo.Substring(0, index), out publishedFileId);
                    var name = modInfo.Substring(index + 1);
                    mods.Add(new MyObjectBuilder_Checkpoint.ModItem(name, publishedFileId, name));
                }
                else
                {
                    MySandboxGame.Log.WriteLineAndConsole(string.Format("Failed to parse mod details from LobbyData. '{0}'", modInfo));
                }

            }
            return mods;
        }
Esempio n. 5
0
 public static string GetDataHash(Lobby lobby)
 {
     return lobby.GetLobbyData(MyMultiplayer.DataHashTag);
 }
Esempio n. 6
0
 public static int GetLobbyAppVersion(Lobby lobby)
 {
     int result;
     return int.TryParse(lobby.GetLobbyData(MyMultiplayer.AppVersionTag), out result) ? result : 0;
 }
Esempio n. 7
0
 public static string GetLobbyHostName(Lobby lobby)
 {
     return lobby.GetLobbyData(MyMultiplayer.HostNameTag);
 }
Esempio n. 8
0
        public static ulong GetLobbyWorldSize(Lobby lobby)
        {
            var s = lobby.GetLobbyData(MyMultiplayer.WorldSizeTag);
            if (!string.IsNullOrEmpty(s))
                return Convert.ToUInt64(s);

            return 0;
        }
Esempio n. 9
0
 public static bool GetLobbyBool(string key, Lobby lobby, bool defValue)
 {
     bool val;
     if (bool.TryParse(lobby.GetLobbyData(key), out val))
         return val;
     else
         return defValue;
 }
Esempio n. 10
0
 public static ulong GetLobbyULong(string key, Lobby lobby, ulong defValue)
 {
     ulong val;
     if (ulong.TryParse(lobby.GetLobbyData(key), out val))
         return val;
     else
         return defValue;
 }
Esempio n. 11
0
 public static DateTime GetLobbyDateTime(string key, Lobby lobby, DateTime defValue)
 {
     DateTime val;
     if (DateTime.TryParse(lobby.GetLobbyData(key), CultureInfo.InvariantCulture, DateTimeStyles.None, out val))
         return val;
     else
         return defValue;
 }
Esempio n. 12
0
 public static int GetLobbyInt(string key, Lobby lobby, int defValue)
 {
     int val;
     if (int.TryParse(lobby.GetLobbyData(key), NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
         return val;
     else
         return defValue;
 }
Esempio n. 13
0
 public static float GetLobbyFloat(string key, Lobby lobby, float defValue)
 {
     float val;
     if (float.TryParse(lobby.GetLobbyData(key), NumberStyles.Float, CultureInfo.InvariantCulture, out val))
         return val;
     else
         return defValue;
 }
Esempio n. 14
0
 public static MyGameModeEnum GetLobbyGameMode(Lobby lobby)
 {
     int val;
     if (int.TryParse(lobby.GetLobbyData(MyMultiplayer.GameModeTag), out val))
         return (MyGameModeEnum)val;
     else
         return MyGameModeEnum.Creative;
 }