logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class AchievementConditionStateStore

    Everything the evaluator writes back: the progress numerator, the condition state, and the unlock itself. Remembers what has actually been stored, so an evaluation that changed nothing costs nothing and a write that failed is offered again.

    Inheritance
    object
    AchievementConditionStateStore
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Achievements.Application.Services
    Assembly: Serenity.Achievements.Application.dll
    Syntax
    public class AchievementConditionStateStore
    Remarks

    Every write is detached with a logged failure continuation. The evaluator runs on the frame loop and the store may be a network call — waiting on one would stall the game to record a number the in-memory cache already holds.

    Deduplication is against what was CONFIRMED, never against what was attempted. Confirming on attempt is the shape that loses data silently: one failed write and the evaluator would spend the rest of the session believing the store already held a number it never received. HasUnconfirmedWrites(AchievementId) is how the evaluator knows to keep offering a value that has stopped changing on its own.

    The four caches are concurrent because the confirmations run on the continuation of a store task, which for a real backend completes on a pool thread while the evaluator keeps reading on the frame loop.

    Constructors

    AchievementConditionStateStore(IAchievementService, ILogService)

    Initializes a new instance of the AchievementConditionStateStore class.

    Declaration
    public AchievementConditionStateStore(IAchievementService service, ILogService logService)
    Parameters
    Type Name Description
    IAchievementService service

    The service every write goes through.

    ILogService logService

    Logging service. May be null.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when service is null.

    Properties

    LogService

    Logging service used to report a failed write. May be null.

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    Methods

    AdoptRestoredState(AchievementId, string)

    Adopts a state that was restored rather than computed, so the first evaluation after a load does not rewrite what it just read.

    Declaration
    public void AdoptRestoredState(AchievementId achievement, string conditionState)
    Parameters
    Type Name Description
    AchievementId achievement

    The achievement the state belongs to.

    string conditionState

    The state that was restored into its tree.

    Forget()

    Forgets everything recorded, as a reset of the whole aggregate does.

    Declaration
    public void Forget()

    HasUnconfirmedWrites(AchievementId)

    Whether a write for this achievement was attempted and never confirmed — the signal that the evaluator should keep offering its current values even while they sit still.

    Declaration
    public bool HasUnconfirmedWrites(AchievementId achievement)
    Parameters
    Type Name Description
    AchievementId achievement

    The achievement to ask about.

    Returns
    Type Description
    bool

    PersistConditionState(AchievementId, string)

    Writes a condition tree's captured state, unless it is already stored.

    Declaration
    public void PersistConditionState(AchievementId achievement, string conditionState)
    Parameters
    Type Name Description
    AchievementId achievement

    The achievement the state belongs to.

    string conditionState

    The state the tree just captured.

    PersistProgress(AchievementId, long)

    Writes the progress numerator of a progressive achievement, unless it is already stored.

    Declaration
    public void PersistProgress(AchievementId achievement, long current)
    Parameters
    Type Name Description
    AchievementId achievement

    The achievement to advance.

    long current

    The numerator to store.

    Unlock(AchievementId)

    Unlocks an achievement whose condition tree just became met.

    Declaration
    public void Unlock(AchievementId achievement)
    Parameters
    Type Name Description
    AchievementId achievement

    The achievement to unlock.

    In this article
    © 2026 Serenity. All Rights Reserved