From dd31847990d80de8ea53a53a48c6153bb0ab0085 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 15 Feb 2018 12:43:52 +0000 Subject: [PATCH] Added Friends.OnInvitedToGame callback --- Facepunch.Steamworks/Client/Friends.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Facepunch.Steamworks/Client/Friends.cs b/Facepunch.Steamworks/Client/Friends.cs index fcfb094..3c557b7 100644 --- a/Facepunch.Steamworks/Client/Friends.cs +++ b/Facepunch.Steamworks/Client/Friends.cs @@ -40,6 +40,23 @@ internal Friends( Client c ) client = c; client.RegisterCallback( OnPersonaStateChange ); + client.RegisterCallback( OnGameJoinRequested ); + } + + public delegate void JoinRequestedDelegate( SteamFriend friend, string connect ); + + // + // Called when a friend has invited you to their game (using InviteToGame) + // + public event JoinRequestedDelegate OnInvitedToGame; + + + private void OnGameJoinRequested( GameRichPresenceJoinRequested_t data ) + { + if ( OnInvitedToGame != null ) + { + OnInvitedToGame( Get( data.SteamIDFriend ), data.Connect ); + } } /// @@ -226,6 +243,9 @@ private class PersonaCallback public SteamFriend Get( ulong steamid ) { + var friend = All.Where( x => x.Id == steamid ).FirstOrDefault(); + if ( friend != null ) return friend; + var f = new SteamFriend() { Id = steamid,