From d417f2233668f8c05bf736fbe7cda1662f66fc67 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Fri, 9 Jun 2017 10:16:11 +0100 Subject: [PATCH] Call StoreStats when triggering an achievement --- Facepunch.Steamworks/Client/Achievements.cs | 26 +++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Facepunch.Steamworks/Client/Achievements.cs b/Facepunch.Steamworks/Client/Achievements.cs index 7e4137d..a661f13 100644 --- a/Facepunch.Steamworks/Client/Achievements.cs +++ b/Facepunch.Steamworks/Client/Achievements.cs @@ -44,11 +44,20 @@ namespace Facepunch.Steamworks } /// - /// Unlock an achievement by identifier + /// Unlock an achievement by identifier. If apply is true this will happen as expected + /// and the achievement overlay will popup etc. If it's false then you'll have to manually + /// call Stats.StoreStats() to actually trigger it. /// - public bool Trigger( string identifier ) + public bool Trigger( string identifier, bool apply = true ) { - return client.native.userstats.SetAchievement( identifier ); + var r = client.native.userstats.SetAchievement( identifier ); + + if ( apply ) + { + client.Stats.StoreStats(); + } + + return r; } /// @@ -148,12 +157,19 @@ namespace Facepunch.Steamworks /// /// Make this achievement earned /// - public bool Trigger() + public bool Trigger( bool apply = true ) { State = true; UnlockTime = DateTime.Now; - return client.native.userstats.SetAchievement( Id ); + var r = client.native.userstats.SetAchievement( Id ); + + if ( apply ) + { + client.Stats.StoreStats(); + } + + return r; } ///