logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Interface IGameProgressService

    Service interface for reading and mutating the player's global, slot-independent game progress: completion count, unlocked extras, and a custom JSON payload.

    Namespace: Serenity.GameProgress.Application.Interfaces.Services
    Assembly: Serenity.GameProgress.Application.dll
    Syntax
    public interface IGameProgressService : IService, IFoundationSettings
    Remarks

    Reads and mutations act on an in-memory cache; PersistAsync(CancellationToken) and LoadAsync(CancellationToken) are the explicit boundary to the configured backend. A caller must await LoadAsync once (e.g. during project bootstrap) before the cache reflects previously saved progress — the service never blocks a synchronous call on store I/O.

    Methods

    GetCustomPayload()

    Gets the current custom JSON payload, or null when none is set.

    Declaration
    string GetCustomPayload()
    Returns
    Type Description
    string

    GetProgress()

    Gets the current, in-memory game progress.

    Declaration
    GameProgressData GetProgress()
    Returns
    Type Description
    GameProgressData

    GetUnlockedExtras()

    Gets every currently unlocked extra id.

    Declaration
    IReadOnlyList<string> GetUnlockedExtras()
    Returns
    Type Description
    IReadOnlyList<string>

    IncrementCompletionCount()

    Increments the completion count by one and dispatches the corresponding signals.

    Declaration
    void IncrementCompletionCount()

    IsExtraUnlocked(string)

    Checks whether an extra is unlocked.

    Declaration
    bool IsExtraUnlocked(string extraId)
    Parameters
    Type Name Description
    string extraId

    The extra's identifier.

    Returns
    Type Description
    bool

    True if the extra is unlocked; otherwise false.

    LoadAsync(CancellationToken)

    Loads progress from the configured store into the in-memory cache.

    Declaration
    Task LoadAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task

    PersistAsync(CancellationToken)

    Persists the current in-memory progress through the configured store.

    Declaration
    Task PersistAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task

    SetCustomPayload(string)

    Replaces the custom JSON payload escape hatch.

    Declaration
    void SetCustomPayload(string json)
    Parameters
    Type Name Description
    string json

    The new payload. May be null.

    UnlockExtra(string)

    Unlocks an extra by id. Idempotent: unlocking an already-unlocked extra is a no-op.

    Declaration
    void UnlockExtra(string extraId)
    Parameters
    Type Name Description
    string extraId

    The extra's identifier. Null or empty is ignored.

    In this article
    © 2026 Serenity. All Rights Reserved