2972e59e00
* Fixed dependency * Updates to NeoDictionary * Changes to NeoDictionary * Started working on a Git implementation to integrate into Game Engines in the future * Added commit functionality to the git library * New changes * Added select for NeoDictionary.cs * Fixed issue with previous new method * Added a Benchmarking Tool to be used mostly in game engines * Added IndexOf to NeoDictionary.cs * Added new method for BenchmarkUtility.cs * added an instacedobject class * Added a new shuffle method for lists * fixed return type * Added new Changelog generator * Added new Game logic library to assist with game projects * Added Web Project * Added Nuget package configs * Add workflow for publishing game library NuGet package * Add README for OmegaLeo's Helper Library * Updated Website to reflect all libraries * Fixed missing library in Changelog * Added Contributing and Code of Conduct * Fixed web project * new documentation changes * fix packages * Fixed DocumentationHelper package dependencies * Added Serilog * Added logging * Fixed documentation * Added logging for cache * fixed documentation * Updated README.md * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update OmegaLeo.HelperLib.Web/Controllers/HomeController.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update OmegaLeo.HelperLib.Web/Controllers/HomeController.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix error * changes for Github Packages * Cleanup * Started working on a SteamWorks integration * Added logging * Started working on a Steam library --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
43 lines
1.8 KiB
C#
43 lines
1.8 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using OmegaLeo.HelperLib.Shared.Attributes;
|
|
|
|
namespace OmegaLeo.HelperLib.Steamworks
|
|
{
|
|
[Documentation(nameof(AchievementManager), "Provides helper methods for unlocking and querying Steam achievements.", null,
|
|
@"```csharp
|
|
var achievements = new AchievementManager(logger);
|
|
achievements.UnlockAchievement(""ACH_WIN_ONE_GAME"");
|
|
```")]
|
|
public class AchievementManager
|
|
{
|
|
private readonly ILogger _logger;
|
|
|
|
public AchievementManager(ILogger logger = null)
|
|
{
|
|
_logger = logger ?? SteamManager.Logger;
|
|
}
|
|
|
|
[Documentation(nameof(UnlockAchievement), "Attempts to unlock the provided achievement and store user stats.", new[] { "achievementId: Steam achievement identifier to unlock." }, null)]
|
|
public void UnlockAchievement(string achievementId)
|
|
{
|
|
if (SteamManager.Instance.IsSteamworksInitialized)
|
|
{
|
|
SteamNativeApi.SetAchievement(achievementId);
|
|
SteamNativeApi.StoreStats(); // Don't forget to store the stats
|
|
_logger.LogInformation("Attempting to unlock achievement: {AchievementId}", achievementId);
|
|
}
|
|
}
|
|
|
|
[Documentation(nameof(IsAchievementUnlocked), "Checks whether a Steam achievement is currently unlocked.", new[] { "achievementId: Steam achievement identifier to check.", "unlocked: True when the achievement is unlocked." }, null)]
|
|
public bool IsAchievementUnlocked(string achievementId, out bool unlocked)
|
|
{
|
|
unlocked = false;
|
|
if (SteamManager.Instance.IsSteamworksInitialized)
|
|
{
|
|
return SteamNativeApi.GetAchievement(achievementId, out unlocked);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|