Skip to main content

AchievementManager

A class in Root.Township, Alta.Achievements.

Singleton that loads every achievement and stat definition from Resources and passes unlocks and stat changes to Steam. Client side; get it through Instance.

Constructors​

MemberWhat it is
AchievementManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

7 private and internal fields
MemberWhat it is
private Dictionary<AchievementDefinition, Achievement> achievementMapAchievement objects keyed by their definition asset.
private List<Achievement> achievementsList of every loaded achievement.
private AchievementDefinition[] definitionsAchievement definition assets loaded from Resources.
private PlatformStats platformStatsThe platform backend; always a SteamStats in this build.
private AchievementStatDefinition[] statDefinitionsStat definition assets loaded from Resources.
private Dictionary<AchievementStatDefinition, Stat> statMapStat objects keyed by their definition asset.
private List<Stat> statsList of every loaded stat.

Methods​

MemberWhat it is
Achievement GetAchievement(string identifier)Finds an achievement by identifier (the definition asset's name) or by definition. The string overload throws if none matches.
Achievement GetAchievement(AchievementDefinition definition)Finds an achievement by identifier (the definition asset's name) or by definition. The string overload throws if none matches.
Stat GetStat(string identifier)Finds a stat by identifier (the definition asset's name) or by definition. The string overload throws if none matches.
Stat GetStat(AchievementStatDefinition definition)Finds a stat by identifier (the definition asset's name) or by definition. The string overload throws if none matches.
void UpdateAll()Asks the platform to refresh every achievement and stat. Called once Steam reports stats received.
protected override void Awake()Loads definitions from the Achievements and Stats Resources folders, builds the maps, starts SteamStats and runs SetupAchievements.Setup.
5 private and internal methods
MemberWhat it is
private void Alta.Achievements.IStatManager.Changed(Stat stat)Explicit IStatManager method: called when a stat's value is set, and forwards it to the platform stats.
private void Alta.Achievements.IAchievementManager.Complete(Achievement achievement)Explicit IAchievementManager method: unlocks the achievement on the platform (Steam).
private void LateUpdate()Runs the platform stats' per-frame work (requesting and storing Steam stats).
private void Alta.Achievements.IAchievementManager.RequestUpdate(Achievement achievement)Explicit interface methods: ask the platform for the current state of one achievement or stat.
private void Alta.Achievements.IStatManager.RequestUpdate(Stat stat)Explicit interface methods: ask the platform for the current state of one achievement or stat.