Exemple #1
0
 void OnDisable()
 {
     // Just incase we have it open when we close/assemblies get reloaded.
     if (!m_RemoteSteamId.IsValid())
     {
         SteamNetworking.CloseP2PSessionWithUser(m_RemoteSteamId);
     }
 }
 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;
     }
 }
        public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
        {
            if (args.IsEmpty || args.Length > 1)
            {
                return(CommandResult.ShowUsage());
            }

            try {
                var steamId = new CSteamID(ulong.Parse(args[0].ToString()));

                if (!steamId.IsValid())
                {
                    return(CommandResult.LangError("INVALID_STEAMID", steamId.m_SteamID));
                }

                ResetPlayer(steamId.m_SteamID);
                EssLang.Send(src, "PLAYER_RESET");
            } catch (FormatException) {
                var target = args[0].ToPlayer;

                if (target == null)
                {
                    return(CommandResult.LangError("PLAYER_NOT_FOUND", args[0]));
                }

                target.Kick(EssLang.Translate("PLAYER_RESET_KICK"));
                ResetPlayer(target.CSteamId.m_SteamID);

                EssLang.Send(src, "PLAYER_RESET");
            }

            return(CommandResult.Success());
        }
Exemple #4
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;
     }
 }
    public void Initialize()
    {
        if (!SteamManager.initializedMain)
        {
            return;
        }

        m_GameRichPresenceJoinRequested = Steamworks.Callback <GameRichPresenceJoinRequested_t> .Create(OnGameRichPresenceJoinRequested);

        m_PersonaStateChange = Steamworks.Callback <PersonaStateChange_t> .Create(OnPersonaStateChange);

        EFriendFlags friendFlags  = EFriendFlags.k_EFriendFlagImmediate;
        int          friendsCount = SteamFriends.GetFriendCount(friendFlags);

        for (int friendIndex = 0; friendIndex < friendsCount; ++friendIndex)
        {
            CSteamID friendSteamId = SteamFriends.GetFriendByIndex(friendIndex, friendFlags);

            if (!friendSteamId.IsValid())
            {
                continue;
            }

            SteamFriend steamFriend = new SteamFriend(friendSteamId);
            m_Friends.Add(friendSteamId, steamFriend);
        }
    }
Exemple #6
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;
     }
 }
 public void SetInvitedToGameId(ulong gameId)
 {
     CSteamID y = new CSteamID(gameId);
     if (y.IsValid() && (CoopLobby.Instance == null || CoopLobby.Instance.Info.LobbyId != y))
     {
         base.StartCoroutine(this.DelayedInviteReceived(new CoopLobbyInfo(gameId)));
     }
 }
        public void SetInvitedToGameId(ulong gameId)
        {
            CSteamID y = new CSteamID(gameId);

            if (y.IsValid() && (CoopLobby.Instance == null || CoopLobby.Instance.Info.LobbyId != y))
            {
                base.StartCoroutine(this.DelayedInviteReceived(new CoopLobbyInfo(gameId)));
            }
        }
Exemple #9
0
    public void OnLobbyDataUpdated(LobbyDataUpdate_t callback)
    {
        Debug.Log("Lobby Data Updated");
        Debug.Log("Success: " + callback.m_bSuccess);
        Debug.Log("LobbyId: " + callback.m_ulSteamIDLobby);
        Debug.Log("MemberId: " + callback.m_ulSteamIDMember);
        CSteamID cSteamID = new CSteamID(callback.m_ulSteamIDMember);

        Debug.Log(cSteamID.IsValid());
        Debug.Log(SteamFriends.GetFriendPersonaName(cSteamID));
        Debug.Log(SteamFriends.GetFriendPersonaName(SteamUser.GetSteamID()));
    }
		protected virtual void Dispose(bool disposing)
		{
			if (disposed)
				return;
			disposed = true;

			if (disposing)
			{
                //DISPOSE OF STEAM P2P SOCKET
                if (steamEndPoint.IsValid())
                {
                    SteamNetworking.CloseP2PSessionWithUser(steamEndPoint);
                }
			}
		}
 private void CheckParameters()
 {
     if (Program.LaunchParameters.ContainsKey("+connect_lobby") && ulong.TryParse(Program.LaunchParameters["+connect_lobby"], out ulong result))
     {
         CSteamID lobbySteamId = new CSteamID(result);
         if (lobbySteamId.IsValid())
         {
             Main.OpenPlayerSelect(delegate(PlayerFileData playerData)
             {
                 Main.ServerSideCharacter = false;
                 playerData.SetAsActive();
                 Main.menuMode   = 882;
                 Main.statusText = "Joining...";
                 _lobby.Join(lobbySteamId, OnLobbyEntered);
             });
         }
     }
 }
		private void CheckParameters()
		{
			ulong ulSteamID;
			if (Program.LaunchParameters.ContainsKey("+connect_lobby") && ulong.TryParse(Program.LaunchParameters["+connect_lobby"], out ulSteamID))
			{
				CSteamID lobbySteamId = new CSteamID(ulSteamID);
				if (lobbySteamId.IsValid())
				{
					Main.OpenPlayerSelect(delegate(PlayerFileData playerData)
					{
						Main.ServerSideCharacter = false;
						playerData.SetAsActive();
						Main.menuMode = 882;
						Main.statusText = "Joining...";
						this._lobby.Join(lobbySteamId, new CallResult<LobbyEnter_t>.APIDispatchDelegate(this.OnLobbyEntered));
					});
				}
			}
		}
Exemple #13
0
        private void CheckParameters()
        {
            ulong num;

            if (Program.LaunchParameters.ContainsKey("+connect_lobby") && ulong.TryParse(Program.LaunchParameters["+connect_lobby"], out num))
            {
                CSteamID cSteamID = new CSteamID(num);
                if (cSteamID.IsValid())
                {
                    Main.OpenPlayerSelect((PlayerFileData playerData) => {
                        Main.ServerSideCharacter = false;
                        playerData.SetAsActive();
                        Main.menuMode   = 10;
                        Main.statusText = "Joining game...";
                        this._lobby.Join(cSteamID, new CallResult <LobbyEnter_t> .APIDispatchDelegate(this.OnLobbyEntered));
                    });
                }
            }
        }
Exemple #14
0
        public void ConnectToLobby(ulong lobbyId)
        {
            CSteamID lobbySteamId = new CSteamID(lobbyId);

            if (!lobbySteamId.IsValid())
            {
                return;
            }
            Main.OpenPlayerSelect((Main.OnPlayerSelected)(playerData =>
            {
                Main.ServerSideCharacter = false;
                playerData.SetAsActive();
                Main.menuMode   = 882;
                Main.statusText = Language.GetTextValue("Social.Joining");
                WeGameHelper.WriteDebugString(" CheckParameters, lobby.join");
                // ISSUE: method pointer
                this._lobby.Join(lobbySteamId, new CallResult <LobbyEnter_t> .APIDispatchDelegate(OnLobbyEntered));
            }));
        }
        /// <summary>
        ///     Called when the player recieves a steam lobby list after requestng the lobbies. Determines if the list is for a playlist or a custom game.
        /// <para/>
        ///     If it is a playlist determines if a valid lobby exists or if one must be created. If one is created that player is host.
        /// </summary>
        /// <param name="pCallback"></param>
        private void OnLobbyListReceived(LobbyMatchList_t pCallback)
        {
            if (NetLogFilter.logInfo)
            {
                Debug.Log($"Lobby list recieved, getting matches | ({Time.time})");
            }
            List <CSteamID> validIds = new List <CSteamID>();

            for (int i = 0; i < pCallback.m_nLobbiesMatching; i++)
            {
                CSteamID id = SteamMatchmaking.GetLobbyByIndex(i);
                if (id.IsValid())
                {
                    validIds.Add(id);
                }
            }

            LobbyListReceived?.Invoke(validIds);
        }
Exemple #16
0
    public static Sprite GetMediumAvatar(CSteamID i_SteamId)
    {
        if (!SteamManager.initializedMain)
        {
            return(null);
        }

        if (!i_SteamId.IsValid())
        {
            return(null);
        }

        // Medium avatar is 64x64.

        int       mediumAvatar = SteamFriends.GetMediumFriendAvatar(i_SteamId);
        Texture2D texture      = BuildTexture(mediumAvatar);
        Sprite    sprite       = TextureToSprite(texture);

        return(sprite);
    }
Exemple #17
0
    public static Sprite GetSmallAvatar(CSteamID i_SteamId)
    {
        if (!SteamManager.initializedMain)
        {
            return(null);
        }

        if (!i_SteamId.IsValid())
        {
            return(null);
        }

        // Small avatar is 32x32.

        int       smallAvatar = SteamFriends.GetSmallFriendAvatar(i_SteamId);
        Texture2D texture     = BuildTexture(smallAvatar);
        Sprite    sprite      = TextureToSprite(texture);

        return(sprite);
    }
        // Token: 0x06000B24 RID: 2852 RVA: 0x003CCC14 File Offset: 0x003CAE14
        private void CheckParameters()
        {
            ulong ulSteamID;

            if (Program.LaunchParameters.ContainsKey("+connect_lobby") && ulong.TryParse(Program.LaunchParameters["+connect_lobby"], out ulSteamID))
            {
                CSteamID lobbySteamId = new CSteamID(ulSteamID);
                if (lobbySteamId.IsValid())
                {
                    Main.OpenPlayerSelect(delegate(PlayerFileData playerData)
                    {
                        Main.ServerSideCharacter = false;
                        playerData.SetAsActive();
                        Main.menuMode   = 882;
                        Main.statusText = Language.GetTextValue("Social.Joining");
                        this._lobby.Join(lobbySteamId, new CallResult <LobbyEnter_t> .APIDispatchDelegate(this.OnLobbyEntered));
                    });
                }
            }
        }
        /// <summary>
        ///     Called when a player sucessfully finds a lobby to join. Starts the tranistion to the lobby scene: <see cref="HVR_MultiplayerSetup.LobbyScene"/>
        /// <para/>
        ///     Assigns the scene load event <see cref="JoinNewMatch(Scene, LoadSceneMode)"/> to be called when the lobby scene is loaded.
        /// </summary>
        /// <param name="pCallback"></param>
        private void OnLobbyEntered(LobbyEnter_t pCallback)
        {
            if (NetLogFilter.logInfo)
            {
                Debug.Log($"Lobby Entered | ({Time.time})");
            }
            CSteamID id = SteamUser.GetSteamID();

            if (id.IsValid())
            {
                SteamConnection conn = new SteamConnection(id, new CSteamID(pCallback.m_ulSteamIDLobby));
                LobbyLocalConnectionConnected?.Invoke(conn);
            }
            else
            {
                if (NetLogFilter.logError)
                {
                    Debug.Log("<color=red>SteamID is Invalid</color>");
                }
            }
        }
Exemple #20
0
        private void OnLobbyMatchList(LobbyMatchList_t result)
        {
            stats.OnLobbyMatchListCount++;
            Debug.WriteLine("OnLobbyMatchList: count=" + result.m_nLobbiesMatching);

            for (int i = 0; i < result.m_nLobbiesMatching; i++)
            {
                CSteamID lobbyID = SteamMatchmaking.GetLobbyByIndex(i);
                if (lobbyID.IsValid())
                {
                    RequestLobbyData(lobbyID);
                }
                else
                {
                    Debug.WriteLine("OnLobbyMatchList: invalid lobbyID at index: " + i);
                }
            }

            lobbyRequestBtn.Enabled   = true;
            lobbyRequestTimer.Enabled = true;

            lastUpdateLabel.Text = DateTime.Now.ToString("HH:mm", CultureInfo.InvariantCulture);
        }
        private void CheckParameters()
        {
            ulong result;

            if (!Program.LaunchParameters.ContainsKey("+connect_lobby") ||
                !ulong.TryParse(Program.LaunchParameters["+connect_lobby"], out result))
            {
                return;
            }
            var lobbySteamId = new CSteamID(result);

            if (!lobbySteamId.IsValid())
            {
                return;
            }
            Main.OpenPlayerSelect((Main.OnPlayerSelected)(playerData =>
            {
                Main.ServerSideCharacter = false;
                playerData.SetAsActive();
                Main.menuMode   = 882;
                Main.statusText = Language.GetTextValue("Social.Joining");
                this._lobby.Join(lobbySteamId, new CallResult <LobbyEnter_t> .APIDispatchDelegate(OnLobbyEntered));
            }));
        }
Exemple #22
0
        private void OnReceiveSteamServers(LobbyMatchList_t x, bool bIOFailure)
        {
            if (bIOFailure)
            {
                Monitor.Log("IO Failure!", LogLevel.Error);
                return;
            }

            Console.WriteLine($"STEAM RECEIVE SERVER LIST, COUNT={x.m_nLobbiesMatching}");

            if (lastLobbyJoined.m_SteamID != 0)
            {
                Console.WriteLine("Disconnecting from last joined lobby");

                try
                {
                    GalaxyInstance.Matchmaking().LeaveLobby(GalaxyIDFromSteamID(lastLobbyJoined));
                }
                catch (Exception)
                {
                    Console.WriteLine("  was not connected to any lobby");
                }
            }

            List <CSteamID> servers = new List <CSteamID>();

            BrowserMenu browser = null;

            int serverI = 0;

            while (true)
            {
                CSteamID steamID = SteamMatchmaking.GetLobbyByIndex(serverI);
                if (!steamID.IsValid() || steamID.m_SteamID == 0)
                {
                    break;
                }

                Console.WriteLine($"DISCOVERED SERVERID={steamID.m_SteamID}");

                var galaxyID = GalaxyIDFromSteamID(steamID);

                Console.WriteLine($"Received galaxy ID = {galaxyID?.ToString() ?? "NULL"}");

                if (galaxyID != null)
                {
                    servers.Add(steamID);

                    var mm = GalaxyInstance.Matchmaking();

                    var unkown = mm.RequestLobbyData(galaxyID);
                    Console.WriteLine($"Request lobby data output = {unkown}");

                    Task task = DelayForLobbyData(steamID, galaxyID, serverI, id => browser?.GetSlot(id), id => browser?.RemoveSlot(id));
                }

                serverI++;
            }
            if (servers.Count == 0)
            {
                Monitor.Log("Couldn't find any servers!", LogLevel.Info);
            }

            var blankTitle = new TitleMenu();

            blankTitle.skipToTitleButtons();
            TitleMenu.subMenu = new CoopMenu();

            //Game1.viewport.Height - 50 * 2
            browser = new BrowserMenu(25, 25, Game1.viewport.Width - 25 * 2, Game1.viewport.Height, servers, blankTitle);
            Game1.activeClickableMenu = browser;
        }
 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;
     }
 }
 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;
     }
 }
 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;
     }
 }