Exemple #1
0
 public void OnClientNewGame(CoopLobbyInfo lobby)
 {
     if (CoopLobby.IsInLobby)
     {
         CoopLobby.LeaveActive();
     }
     TitleScreen.StartGameSetup.Type   = TitleScreen.GameSetup.InitTypes.New;
     TitleScreen.StartGameSetup.MpType = TitleScreen.GameSetup.MpTypes.Client;
     this.RefreshUI();
     if (this._currentScreen == CoopSteamNGUI.Screens.InviteReceivedScreen)
     {
         this._currentScreen = this._prevScreen;
         this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
     }
     this.SetLoadingText(string.Format("Joining Lobby {0} ...", lobby.Name));
     lobby.UpdateData();
     CoopLobbyManager.Join(lobby, delegate
     {
         lobby.UpdateData();
         this.ClearLoadingAndError();
     }, delegate
     {
         this.ClearLoadingAndError();
         this.SetErrorText("Could not join Steam lobby.");
     });
 }
Exemple #2
0
 private static void LobbyEnter(LobbyEnter_t param)
 {
     try
     {
         CSteamID id = new CSteamID(param.m_ulSteamIDLobby);
         if (id.IsValid() && param.m_EChatRoomEnterResponse == 1u)
         {
             CoopLobbyInfo lobbyInfo = CoopLobbyManager.GetLobbyInfo(id);
             lobbyInfo.UpdateData();
             CoopLobby.SetActive(lobbyInfo);
             if (CoopLobbyManager.enterCallback != null)
             {
                 CoopLobbyManager.enterCallback();
             }
         }
         else if (CoopLobbyManager.enterFailCallback != null)
         {
             CoopLobbyManager.enterFailCallback();
         }
     }
     finally
     {
         CoopLobbyManager.enterCallback     = null;
         CoopLobbyManager.enterFailCallback = null;
     }
 }
Exemple #3
0
 private static void LobbyCreated(LobbyCreated_t param)
 {
     Debug.Log(string.Concat(new object[]
     {
         "LobbyCreated param.m_eResult=",
         param.m_eResult,
         ", lobbyId=",
         param.m_ulSteamIDLobby
     }));
     try
     {
         if (param.m_eResult == EResult.k_EResultOK)
         {
             CSteamID cSteamID = new CSteamID(param.m_ulSteamIDLobby);
             if (cSteamID.IsValid())
             {
                 CoopLobbyInfo coopLobbyInfo = new CoopLobbyInfo(param.m_ulSteamIDLobby);
                 coopLobbyInfo.IsOwner     = true;
                 coopLobbyInfo.Name        = CoopLobbyManager.createValues.Name;
                 coopLobbyInfo.MemberLimit = CoopLobbyManager.createValues.MemberLimit;
                 CoopLobbyManager.LobbyMatchList_Result = new List <CoopLobbyInfo>();
                 CoopLobbyManager.LobbyMatchList_Result.Add(coopLobbyInfo);
                 CoopLobby.SetActive(coopLobbyInfo);
                 if (TitleScreen.StartGameSetup.Type == TitleScreen.GameSetup.InitTypes.Continue)
                 {
                     SaveSlotUtils.LoadHostGameGUID();
                 }
                 if (CoopLobbyManager.createCallback != null)
                 {
                     try
                     {
                         CoopLobbyManager.createCallback();
                     }
                     catch (Exception var_1_E2)
                     {
                     }
                 }
                 goto IL_10C;
             }
         }
         if (CoopLobbyManager.createFailCallback != null)
         {
             try
             {
                 CoopLobbyManager.createFailCallback();
             }
             catch (Exception var_2_106)
             {
             }
         }
         IL_10C :;
     }
     finally
     {
         CoopLobbyManager.createValues       = null;
         CoopLobbyManager.createCallback     = null;
         CoopLobbyManager.createFailCallback = null;
     }
 }
Exemple #4
0
 private void Awake()
 {
     this.ResetDSFlags();
     UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     if (LoadAsync.Scenery)
     {
         Blur blur = (!LoadAsync.Scenery) ? null : LoadAsync.Scenery.GetComponentInChildren <Blur>();
         if (blur)
         {
             blur.enabled = true;
         }
     }
     BoltLauncher.SetUdpPlatform(new SteamPlatform());
     TheForest.Utils.Input.player.controllers.maps.SetMapsEnabled(false, ControllerType.Keyboard, "Default");
     TheForest.Utils.Input.player.controllers.maps.SetMapsEnabled(true, ControllerType.Keyboard, "Menu");
     TheForest.Utils.Input.player.controllers.maps.SetMapsEnabled(true, ControllerType.Joystick, "Menu");
     if (!SteamManager.Initialized)
     {
         if (GameSetup.IsMpServer)
         {
             this.OpenScreen(CoopSteamNGUI.Screens.LobbySetup);
         }
         else
         {
             this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
         }
         this.SetLoadingText(UiTranslationDatabase.TranslateKey("STEAM_NOT_INITIALIZED", "Steam not initialized", this._allCapsTexts));
         return;
     }
     this.RefreshUI();
     if (GameSetup.IsMpServer)
     {
         this._hostGameName    = PlayerPrefs.GetString("MpGameName", this._hostGameName);
         this._hostMaxPlayers  = PlayerPrefs.GetInt("MpGamePlayerCount", this.GetHostPlayersMax()).ToString();
         this._hostFriendsOnly = (PlayerPrefs.GetInt("MpGameFriendsOnly", (!this._hostFriendsOnly) ? 0 : 1) == 1);
         this._lobbySetupScreen._gameNameInput.value     = this._hostGameName;
         this._lobbySetupScreen._playerCountInput.value  = this._hostMaxPlayers;
         this._lobbySetupScreen._privateOnlyToggle.value = this._hostFriendsOnly;
         this.OpenScreen(CoopSteamNGUI.Screens.LobbySetup);
     }
     else
     {
         CoopLobbyManager.QueryList(this._showFriendGames);
         this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
     }
     if (AutoJoinAfterMPInvite.LobbyID != null && (CoopLobby.Instance == null || CoopLobby.Instance.Info.LobbyId.ToString() != AutoJoinAfterMPInvite.LobbyID))
     {
         CoopLobbyInfo lobby = new CoopLobbyInfo(ulong.Parse(AutoJoinAfterMPInvite.LobbyID));
         AutoJoinAfterMPInvite.LobbyID = null;
         if (GameSetup.IsSavedGame)
         {
             this.OnClientContinueGame(lobby);
         }
         else
         {
             this.OnClientNewGame(lobby);
         }
     }
 }
 public static void QueryList(bool friendsOnly)
 {
     CoopLobbyManager.Initialize();
     CoopLobbyManager.LobbyMatchList_Result = (from x in CoopLobbyManager.LobbyMatchList_Result
                                               where x.IsOwner
                                               select x).ToList <CoopLobbyInfo>();
     SteamMatchmaking.AddRequestLobbyListResultCountFilter(100);
     SteamMatchmaking.RequestLobbyList();
 }
 public static void Create(string name, int memberLimit, bool friendsOnly, Action callback, Action callbackFail)
 {
     CoopLobbyManager.Initialize();
     CoopLobbyManager.createCallback           = callback;
     CoopLobbyManager.createFailCallback       = callbackFail;
     CoopLobbyManager.createValues             = new CoopLobbyInfo(0UL);
     CoopLobbyManager.createValues.Name        = name;
     CoopLobbyManager.createValues.MemberLimit = memberLimit;
     SteamMatchmaking.CreateLobby((!friendsOnly) ? ELobbyType.k_ELobbyTypePublic : ELobbyType.k_ELobbyTypeFriendsOnly, memberLimit);
 }
Exemple #7
0
 public void OnClientRefreshGameList()
 {
     this._lobbies = new List <CoopLobbyInfo>(0);
     foreach (MpGameRow current in this._gameRows.Values)
     {
         UnityEngine.Object.Destroy(current.gameObject);
     }
     this._gameRows.Clear();
     CoopLobbyManager.QueryList();
 }
    private static void LobbyMatchList(LobbyMatchList_t param)
    {
        int num = 0;

        while ((long)num < (long)((ulong)param.m_nLobbiesMatching))
        {
            CoopLobbyManager.GetLobbyInfo(SteamMatchmaking.GetLobbyByIndex(num));
            num++;
        }
    }
 public static void Join(CoopLobbyInfo info, Action callback, Action <string> callbackFail)
 {
     CoopLobbyManager.Initialize();
     CoopLobby.LeaveActive();
     if (info.LobbyId.IsValid())
     {
         CoopLobbyManager.enterCallback     = callback;
         CoopLobbyManager.enterFailCallback = callbackFail;
         SteamMatchmaking.JoinLobby(info.LobbyId);
     }
 }
 private static void LobbyDataUpdate(LobbyDataUpdate_t param)
 {
     if (param.m_bSuccess == 1)
     {
         CoopLobbyInfo coopLobbyInfo = CoopLobbyManager.FindLobby(param.m_ulSteamIDLobby);
         if (coopLobbyInfo != null)
         {
             coopLobbyInfo.UpdateData();
         }
     }
 }
    private static CoopLobbyInfo GetLobbyInfo(CSteamID id)
    {
        CoopLobbyInfo coopLobbyInfo = CoopLobbyManager.FindLobby(id);

        if (coopLobbyInfo == null)
        {
            coopLobbyInfo = new CoopLobbyInfo(id);
            coopLobbyInfo.UpdateData();
            CoopLobbyManager.LobbyMatchList_Result.Add(coopLobbyInfo);
        }
        return(coopLobbyInfo);
    }
 private static void LobbyEnter(LobbyEnter_t param)
 {
     Debug.Log("LobbyEnter");
     try
     {
         CSteamID id = new CSteamID(param.m_ulSteamIDLobby);
         if (id.IsValid() && param.m_EChatRoomEnterResponse == 1u)
         {
             CoopLobbyInfo lobbyInfo = CoopLobbyManager.GetLobbyInfo(id);
             lobbyInfo.UpdateData();
             CoopLobby.SetActive(lobbyInfo);
             if (CoopLobbyManager.enterCallback != null)
             {
                 CoopLobbyManager.enterCallback();
             }
         }
         else
         {
             string obj = string.Empty;
             if (id.IsValid())
             {
                 if (param.m_EChatRoomEnterResponse == 4u)
                 {
                     obj = "FULL";
                 }
                 else
                 {
                     CoopLobbyInfo lobbyInfo2 = CoopLobbyManager.GetLobbyInfo(id);
                     if (lobbyInfo2 != null && lobbyInfo2.CurrentMembers >= lobbyInfo2.MemberLimit)
                     {
                         obj = "FULL";
                     }
                 }
             }
             if (CoopLobbyManager.enterFailCallback != null)
             {
                 Debug.Log("calling fail callback");
                 CoopLobbyManager.enterFailCallback(obj);
             }
             else
             {
                 Debug.Log("no fail callback");
             }
         }
     }
     finally
     {
         CoopLobbyManager.enterCallback     = null;
         CoopLobbyManager.enterFailCallback = null;
     }
 }
Exemple #13
0
 private void Awake()
 {
     CoopPeerStarter.Dedicated     = false;
     CoopPeerStarter.DedicatedHost = false;
     UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     this.PrefabDbResource = Resources.LoadAsync <PrefabDatabase>("BoltPrefabDatabase");
     BoltLauncher.SetUdpPlatform(new SteamPlatform());
     TheForest.Utils.Input.player.controllers.maps.SetMapsEnabled(true, ControllerType.Joystick, "Menu");
     if (!SteamManager.Initialized)
     {
         if (TitleScreen.StartGameSetup.MpType == TitleScreen.GameSetup.MpTypes.Server)
         {
             this.OpenScreen(CoopSteamNGUI.Screens.LobbySetup);
         }
         else
         {
             this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
         }
         this.SetLoadingText("Steam not initialized");
         return;
     }
     this.RefreshUI();
     if (TitleScreen.StartGameSetup.MpType == TitleScreen.GameSetup.MpTypes.Server)
     {
         this._hostGameName    = PlayerPrefs.GetString("MpGameName", this._hostGameName);
         this._hostMaxPlayers  = PlayerPrefs.GetInt("MpGamePlayerCount", this.GetHostPlayersMax()).ToString();
         this._hostFriendsOnly = (PlayerPrefs.GetInt("MpGameFriendsOnly", (!this._hostFriendsOnly) ? 0 : 1) == 1);
         this._lobbySetupScreen._gameNameInput.value     = this._hostGameName;
         this._lobbySetupScreen._playerCountInput.value  = this._hostMaxPlayers;
         this._lobbySetupScreen._privateOnlyToggle.value = this._hostFriendsOnly;
         this.OpenScreen(CoopSteamNGUI.Screens.LobbySetup);
     }
     else
     {
         CoopLobbyManager.QueryList();
         this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
     }
     if (AutoJoinAfterMPInvite.LobbyID != null && (CoopLobby.Instance == null || CoopLobby.Instance.Info.LobbyId.ToString() != AutoJoinAfterMPInvite.LobbyID))
     {
         CoopLobbyInfo lobby = new CoopLobbyInfo(ulong.Parse(AutoJoinAfterMPInvite.LobbyID));
         AutoJoinAfterMPInvite.LobbyID = null;
         if (TitleScreen.StartGameSetup.Type == TitleScreen.GameSetup.InitTypes.Continue)
         {
             this.OnClientContinueGame(lobby);
         }
         else
         {
             this.OnClientNewGame(lobby);
         }
     }
 }
Exemple #14
0
 private void OnDestroy()
 {
     if (SteamManager.s_instance != this)
     {
         return;
     }
     SteamManager.s_instance = null;
     if (!this.m_bInitialized)
     {
         return;
     }
     CoopSteamServer.Shutdown();
     CoopSteamClient.Shutdown();
     CoopSteamManager.Shutdown();
     CoopLobbyManager.Shutdown();
     SteamAPI.Shutdown();
 }
Exemple #15
0
 public void OnClientRefreshGameList()
 {
     if (this.RefreshBrowserOverride != null)
     {
         this.RefreshBrowserOverride();
     }
     else
     {
         this._lobbies = new List <CoopLobbyInfo>(0);
         foreach (MpGameRow mpGameRow in this._gameRows.Values)
         {
             UnityEngine.Object.Destroy(mpGameRow.gameObject);
         }
         this._gameRows.Clear();
         CoopLobbyManager.QueryList(this._showFriendGames);
     }
 }
Exemple #16
0
    public void OnHostLobbySetup()
    {
        this._hostGameName    = this._lobbySetupScreen._gameNameInput.value;
        this._hostMaxPlayers  = this._lobbySetupScreen._playerCountInput.value;
        this._hostFriendsOnly = this._lobbySetupScreen._privateOnlyToggle.value;
        PlayerPrefs.SetString("MpGameName", this._hostGameName);
        PlayerPrefs.SetInt("MpGamePlayerCount", this.GetHostPlayersMax());
        PlayerPrefs.SetInt("MpGameFriendsOnly", (!this._hostFriendsOnly) ? 0 : 1);
        PlayerPrefs.Save();
        bool flag = CoopSteamServer.Start(delegate
        {
            this.SetLoadingText(UiTranslationDatabase.TranslateKey("CREATING_LOBBY___", "Creating Lobby...", this._allCapsTexts));
            CoopLobbyManager.Create(this.GetHostGameName(), this.GetHostPlayersMax(), this._hostFriendsOnly, delegate
            {
                if (string.IsNullOrEmpty(CoopLobby.Instance.Info.Guid) && GameSetup.IsNewGame)
                {
                    CoopLobby.Instance.SetGuid(Guid.NewGuid().ToString());
                }
                CoopLobby.Instance.SetPrefabDbVersion("E3C26D06F07B6AB14EC25F4823E9A30D6B4ED0450527C1E768739D96C9F061AE");
                this._lobbyScreen._gameNameLabel.text = StringEx.TryFormat(UiTranslationDatabase.TranslateKey("LOBBY_GAME_NAME", "LOBBY: {0}", this._allCapsTexts), new object[]
                {
                    CoopLobby.Instance.Info.Name.ToUpperInvariant()
                });
                this.OpenScreen(CoopSteamNGUI.Screens.Lobby);
            }, delegate
            {
                this.ClearLoadingAndError();
                this.SetErrorText(UiTranslationDatabase.TranslateKey("COULD_NOT_CREATE_STEAM_LOBBY", "Could not create Steam lobby.", this._allCapsTexts));
            });
        }, delegate
        {
            this.SetErrorText(UiTranslationDatabase.TranslateKey("COULD_NOT_CONNECT_TO_STEAM_MASTER_SERVER", "Could not connect to Steam master server.", this._allCapsTexts));
        });

        if (flag)
        {
            this.SetLoadingText(UiTranslationDatabase.TranslateKey("TALKING_TO_STEAM___", "Talking To Steam...", this._allCapsTexts));
        }
        else
        {
            this.SetErrorText(UiTranslationDatabase.TranslateKey("COULD_NOT_START_STEAM_GAME_SERVER", "Could not start Steam game server.", this._allCapsTexts));
        }
    }
Exemple #17
0
    public void OnHostLobbySetup()
    {
        this._hostGameName    = this._lobbySetupScreen._gameNameInput.value;
        this._hostMaxPlayers  = this._lobbySetupScreen._playerCountInput.value;
        this._hostFriendsOnly = this._lobbySetupScreen._privateOnlyToggle.value;
        PlayerPrefs.SetString("MpGameName", this._hostGameName);
        PlayerPrefs.SetInt("MpGamePlayerCount", this.GetHostPlayersMax());
        PlayerPrefs.SetInt("MpGameFriendsOnly", (!this._hostFriendsOnly) ? 0 : 1);
        PlayerPrefs.Save();
        bool flag = CoopSteamServer.Start(delegate
        {
            this.SetLoadingText("Creating Lobby ...");
            CoopLobbyManager.Create(this.GetHostGameName(), this.GetHostPlayersMax(), this._hostFriendsOnly, delegate
            {
                if (string.IsNullOrEmpty(CoopLobby.Instance.Info.Guid) && TitleScreen.StartGameSetup.Type == TitleScreen.GameSetup.InitTypes.New)
                {
                    CoopLobby.Instance.SetGuid(Guid.NewGuid().ToString());
                }
                this._lobbyScreen._gameNameLabel.text = "Lobby: " + CoopLobby.Instance.Info.Name;
                this.OpenScreen(CoopSteamNGUI.Screens.Lobby);
            }, delegate
            {
                this.ClearLoadingAndError();
                this.SetErrorText("Could not create Steam lobby.");
            });
        }, delegate
        {
            this.SetErrorText("Could not connect to Steam master server.");
        });

        if (flag)
        {
            this.SetLoadingText("Talking To Steam ...");
        }
        else
        {
            this.SetErrorText("Could not start Steam game server.");
        }
    }
Exemple #18
0
 private void OnDestroy()
 {
     if (!SteamDSConfig.isDedicatedServer && SteamManager.s_instance != this)
     {
         return;
     }
     if (SteamDSConfig.isDedicatedServer)
     {
         Debug.Log("SteamManager - Someone call OnDestroy");
     }
     if (!this.initialized)
     {
         return;
     }
     if (SteamDSConfig.isDedicatedServer)
     {
         SteamDSConfig.manager.Shutdown();
     }
     CoopSteamServer.Shutdown();
     CoopSteamClient.Shutdown();
     CoopSteamManager.Shutdown();
     CoopLobbyManager.Shutdown();
 }
Exemple #19
0
 public void OnClientNewGame(CoopLobbyInfo lobby)
 {
     if (CoopLobby.IsInLobby)
     {
         CoopLobby.LeaveActive();
     }
     GameSetup.SetInitType(InitTypes.New);
     GameSetup.SetMpType(MpTypes.Client);
     this.RefreshUI();
     if (this._currentScreen == CoopSteamNGUI.Screens.InviteReceivedScreen)
     {
         this._currentScreen = this._prevScreen;
         this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
     }
     else if (this._currentScreen == CoopSteamNGUI.Screens.JoinP2P)
     {
         this._currentScreen = this._prevScreen;
         this.OpenScreen(CoopSteamNGUI.Screens.GameBrowser);
     }
     try
     {
         this.SetLoadingText(StringEx.TryFormat(UiTranslationDatabase.TranslateKey("JOINING_LOBBY_0____", "Joining Lobby {0}...", this._allCapsTexts), new object[]
         {
             lobby.Name
         }));
     }
     catch
     {
     }
     lobby.UpdateData();
     CoopLobbyManager.Join(lobby, delegate
     {
         lobby.UpdateData();
         this.ClearLoadingAndError();
     }, new Action <string>(this.OnFailedEnterLobby));
 }
 public static CoopLobbyInfo FindLobby(ulong id)
 {
     CoopLobbyManager.Initialize();
     return(CoopLobbyManager.FindLobby(new CSteamID(id)));
 }
 public static CoopLobbyInfo FindLobby(CSteamID id)
 {
     CoopLobbyManager.Initialize();
     return(CoopLobbyManager.LobbyMatchList_Result.FirstOrDefault((CoopLobbyInfo x) => x.LobbyId == id));
 }
 private static void LobbyCreated(LobbyCreated_t param)
 {
     Debug.Log(string.Concat(new object[]
     {
         "LobbyCreated param.m_eResult=",
         param.m_eResult,
         ", lobbyId=",
         param.m_ulSteamIDLobby
     }));
     try
     {
         if (param.m_eResult == EResult.k_EResultOK)
         {
             CSteamID csteamID = new CSteamID(param.m_ulSteamIDLobby);
             if (csteamID.IsValid())
             {
                 CoopLobbyInfo coopLobbyInfo = new CoopLobbyInfo(param.m_ulSteamIDLobby);
                 coopLobbyInfo.IsOwner     = true;
                 coopLobbyInfo.Name        = CoopLobbyManager.createValues.Name;
                 coopLobbyInfo.MemberLimit = CoopLobbyManager.createValues.MemberLimit;
                 CoopLobbyManager.LobbyMatchList_Result = new List <CoopLobbyInfo>();
                 CoopLobbyManager.LobbyMatchList_Result.Add(coopLobbyInfo);
                 CoopLobby.SetActive(coopLobbyInfo);
                 if (GameSetup.IsSavedGame)
                 {
                     SaveSlotUtils.LoadHostGameGUID();
                 }
                 if (CoopLobbyManager.createCallback != null)
                 {
                     try
                     {
                         CoopLobbyManager.createCallback();
                     }
                     catch (Exception exception)
                     {
                         BoltLog.Exception(exception);
                     }
                 }
                 goto IL_112;
             }
         }
         if (CoopLobbyManager.createFailCallback != null)
         {
             try
             {
                 CoopLobbyManager.createFailCallback();
             }
             catch (Exception exception2)
             {
                 BoltLog.Exception(exception2);
             }
         }
         IL_112 :;
     }
     finally
     {
         CoopLobbyManager.createValues       = null;
         CoopLobbyManager.createCallback     = null;
         CoopLobbyManager.createFailCallback = null;
     }
 }