Class UnityAchievementDefinitionSource
Answers "which achievements does this project declare" by loading every UnityAchievementDefinition carrying the ACHIEVEMENTS Addressables label, exactly as the leaderboard loads its view definitions.
Inherited Members
Namespace: Serenity.Achievements.Infrastructure.Services
Assembly: Serenity.UnityAchievements.Infrastructure.dll
Syntax
public sealed class UnityAchievementDefinitionSource : IAchievementDefinitionSource, IAchievementConditionSource
Remarks
Answers both of the questions an authored achievement holds — its definition and its unlock condition — from one pass over the assets, because reading the same folder twice to build two halves of the same thing is how the two halves drift apart.
An asset that cannot produce a definition is reported and skipped, so a single half-authored achievement costs itself and nothing else. Which of two assets claiming the same id wins is AchievementDefinitionRegistryBuilder's policy — the later one — so both definitions are handed over intact for it to judge, and the condition map follows the same rule here so the two cannot disagree about which achievement is live.
The load is injectable so a test can hand over ScriptableObject.CreateInstance assets
without an Addressables group, an Addressables build, or a temporary asset on disk.
Constructors
UnityAchievementDefinitionSource(ILogService)
Creates a source that loads the achievement assets by their Addressables label.
Declaration
public UnityAchievementDefinitionSource(ILogService logService)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogService | logService | Logging service used to report an unusable asset. May be |
UnityAchievementDefinitionSource(Func<IReadOnlyList<UnityAchievementDefinition>>, ILogService)
Creates a source that reads its achievement assets from the given loader.
Declaration
public UnityAchievementDefinitionSource(Func<IReadOnlyList<UnityAchievementDefinition>> loadDefinitionAssets, ILogService logService)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IReadOnlyList<UnityAchievementDefinition>> | loadDefinitionAssets | Loads the authored achievement assets. |
| ILogService | logService | Logging service used to report an unusable asset. May be |
Properties
Assets
The authored assets this source read, in load order, including the unusable ones.
Declaration
public IReadOnlyList<UnityAchievementDefinition> Assets { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<UnityAchievementDefinition> |
Conditions
The authored unlock condition of each achievement that has one, by achievement id.
Declaration
public IReadOnlyDictionary<AchievementId, AchievementCondition> Conditions { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<AchievementId, AchievementCondition> |
Methods
GetDefinitions()
Declaration
public IReadOnlyList<AchievementDefinition> GetDefinitions()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<AchievementDefinition> |