/// <summary> /// Decrease the achievement progress value based on a float amount /// </summary> /// <param name="achievement">Achievement object.</param> /// <param name="amount">Amount to decrease by.</param> public static void Decrease(Achievement achievement, int amount) { if (achievement.value > 0) { achievement.value -= amount; } AchievementController.CheckForCompletion(achievement); AchievementEvents.AchievementValueChanged(achievement); }
/// <summary> /// Increment the achievement progress value based on a float amount /// </summary> /// <param name="achievement">Achievement object.</param> /// <param name="amount">Amount to increment by.</param> public static void Increment(Achievement achievement, int amount) { if (achievement.value < achievement.neededValue) { achievement.value += amount; AchievementController.CheckForCompletion(achievement); AchievementEvents.AchievementValueChanged(achievement); } }
/// <summary> /// Set an achievement's progress value directly /// </summary> /// <param name="achievement">Achievement object.</param> /// <param name="value">Value to set.</param> /// <param name="triggerGrant">Whether to trigger achievement notification if completed.</param> public static void SetValue(Achievement achievement, int value, bool triggerGrant = true) { achievement.value = value; if (achievement.value >= achievement.neededValue) { achievement.completed = true; } if (triggerGrant) { AchievementController.CheckForCompletion(achievement); } AchievementEvents.AchievementValueChanged(achievement); }