Achievement callback

This commit is contained in:
Garry Newman 2017-05-08 20:51:57 +01:00
parent 3a8ed89583
commit 01cf0f4cec
5 changed files with 5955 additions and 4 deletions

View File

@ -84,6 +84,8 @@ namespace Facepunch.Steamworks
Workshop.friends = Friends; Workshop.friends = Friends;
Stats.UpdateStats();
// //
// Cache common, unchanging info // Cache common, unchanging info
// //

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using SteamNative;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {
@ -11,10 +12,15 @@ namespace Facepunch.Steamworks
public Achievement[] All { get; private set; } public Achievement[] All { get; private set; }
public event Action OnUpdated;
internal Achievements( Client c ) internal Achievements( Client c )
{ {
client = c; client = c;
Refresh();
All = new Achievement[0];
SteamNative.UserStatsReceived_t.RegisterCallback( c, UserStatsReceived );
} }
public void Refresh() public void Refresh()
@ -29,6 +35,14 @@ namespace Facepunch.Steamworks
client = null; client = null;
} }
private void UserStatsReceived( UserStatsReceived_t stats, bool isError )
{
if ( isError ) return;
Refresh();
OnUpdated?.Invoke();
}
} }
public class Achievement public class Achievement

View File

@ -12,8 +12,6 @@ namespace Facepunch.Steamworks
internal Stats( Client c ) internal Stats( Client c )
{ {
client = c; client = c;
UpdateStats();
} }
public void UpdateStats() public void UpdateStats()

File diff suppressed because it is too large Load Diff

View File

@ -112,7 +112,8 @@ namespace Generator
{ {
CallResult( c ); CallResult( c );
} }
else if ( !string.IsNullOrEmpty( c.CallbackId ) )
if ( !string.IsNullOrEmpty( c.CallbackId ) )
{ {
Callback( c ); Callback( c );
} }