diff --git a/Facepunch.Steamworks/SteamUserStats.cs b/Facepunch.Steamworks/SteamUserStats.cs index cc686e7..8592205 100644 --- a/Facepunch.Steamworks/SteamUserStats.cs +++ b/Facepunch.Steamworks/SteamUserStats.cs @@ -159,5 +159,68 @@ public static bool RequestCurrentStats() return new Leaderboard { Id = result.Value.SteamLeaderboard }; } + + + /// + /// Adds this amount to the named stat. Internally this calls Get() and adds + /// to that value. Steam doesn't provide a mechanism for atomically increasing + /// stats like this, this functionality is added here as a convenience. + /// + public static bool AddStat( string name, int amount = 1 ) + { + var val = GetStatInt( name ); + val += amount; + return SetStat( name, val ); + } + + /// + /// Adds this amount to the named stat. Internally this calls Get() and adds + /// to that value. Steam doesn't provide a mechanism for atomically increasing + /// stats like this, this functionality is added here as a convenience. + /// + public static bool AddStat( string name, float amount = 1.0f ) + { + var val = GetStatFloat( name ); + val += amount; + return SetStat( name, val ); + } + + /// + /// Set a stat value. This will automatically call StoreStats() after a successful call + /// unless you pass false as the last argument. + /// + public static bool SetStat( string name, int value ) + { + return Internal.SetStat1( name, value ); + } + + /// + /// Set a stat value. This will automatically call StoreStats() after a successful call + /// unless you pass false as the last argument. + /// + public static bool SetStat( string name, float value ) + { + return Internal.SetStat2( name, value ); + } + + /// + /// Get a Int stat value + /// + public static int GetStatInt( string name ) + { + int data = 0; + Internal.GetStat1( name, ref data ); + return data; + } + + /// + /// Get a float stat value + /// + public static float GetStatFloat( string name ) + { + float data = 0; + Internal.GetStat2( name, ref data ); + return data; + } } } \ No newline at end of file