From 2cff8ccea14e6d74ac5a8bf1fd44dd4a7dae672f Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 9 May 2017 20:30:29 +0100 Subject: [PATCH] Added utility functions to trigger, find and reset --- Facepunch.Steamworks/Client/Achievements.cs | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Facepunch.Steamworks/Client/Achievements.cs b/Facepunch.Steamworks/Client/Achievements.cs index 85b5aff..34c3246 100644 --- a/Facepunch.Steamworks/Client/Achievements.cs +++ b/Facepunch.Steamworks/Client/Achievements.cs @@ -35,6 +35,30 @@ namespace Facepunch.Steamworks client = null; } + /// + /// Find an achievement by name. Will be null if not found, or not ready. + /// + public Achievement Find( string identifier ) + { + return All.FirstOrDefault( x => x.Id == identifier ); + } + + /// + /// Unlock an achievement by identifier + /// + public bool Trigger( string identifier ) + { + return client.native.userstats.SetAchievement( identifier ); + } + + /// + /// Reset an achievement by identifier + /// + public bool Reset( string identifier ) + { + return client.native.userstats.ClearAchievement( identifier ); + } + private void UserStatsReceived( UserStatsReceived_t stats, bool isError ) { if ( isError ) return;