Skip to content

Commit

Permalink
Merge pull request #101 from adrian-miasik/feature/bugfix-100-steam-m…
Browse files Browse the repository at this point in the history
…anager-null-ref

Bugfix: Check Steamworks client is valid before accessing Steamworks related methods - Fix null ref
  • Loading branch information
adrian-miasik authored Jan 5, 2023
2 parents 11d469c + 0b7a2b3 commit 447a2ab
Showing 1 changed file with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,30 +155,34 @@ public void SetHorizontalScale(Vector3 newScale)
public void ConsumeTomatoes()
{
#if !UNITY_ANDROID
// CANNED ACHIEVEMENT
// Add discarded pomodoro/tomato to User Stats
SteamUserStats.AddStat("pomodoros_disposed", completedTomatoes.Count);
SteamUserStats.StoreStats();

// Fetch canned achievement
Achievement ach = new("ACH_CANNED");

// If achievement is not unlocked...
if (!ach.State)
// Check if steam client is found...
if (SteamClient.IsValid)
{
// Fetch progression
int pomodorosDiscarded = SteamUserStats.GetStatInt("pomodoros_disposed");

if (pomodorosDiscarded >= 8)
{
ach.Trigger();
Debug.Log("Steam Achievement Unlocked! 'Canned for L8R: Dispose of 8" +
" pomodoros/tomatoes..'");
}
else if (pomodorosDiscarded != 0)
// CANNED ACHIEVEMENT
// Add discarded pomodoro/tomato to User Stats
SteamUserStats.AddStat("pomodoros_disposed", completedTomatoes.Count);
SteamUserStats.StoreStats();
// Fetch canned achievement
Achievement ach = new("ACH_CANNED");

// If achievement is not unlocked...
if (!ach.State)
{
// Display progress every time we discard
SteamUserStats.IndicateAchievementProgress(ach.Identifier, pomodorosDiscarded, 8);
// Fetch progression
int pomodorosDiscarded = SteamUserStats.GetStatInt("pomodoros_disposed");

if (pomodorosDiscarded >= 8)
{
ach.Trigger();
Debug.Log("Steam Achievement Unlocked! 'Canned for L8R: Dispose of 8" +
" pomodoros/tomatoes..'");
}
else if (pomodorosDiscarded != 0)
{
// Display progress every time we discard
SteamUserStats.IndicateAchievementProgress(ach.Identifier, pomodorosDiscarded, 8);
}
}
}
#endif
Expand Down

0 comments on commit 447a2ab

Please sign in to comment.