logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class GameProgressService

    Default IGameProgressService implementation. Holds the current progress as an in-memory cache, mutated through immutable GameProgressData replacements, and delegates persistence to an injected IGameProgressStore. Broadcasts completion/unlock/change signals through an optional event dispatcher.

    Inheritance
    object
    GameProgressService
    Implements
    IGameProgressService
    IService
    IFoundationSettings
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameProgress.Application.Services
    Assembly: Serenity.GameProgress.Application.dll
    Syntax
    public class GameProgressService : IGameProgressService, IService, IFoundationSettings

    Constructors

    GameProgressService(IGameProgressStore, IEventDispatcherService, ILogService)

    Initializes a new instance of the GameProgressService class.

    Declaration
    public GameProgressService(IGameProgressStore store, IEventDispatcherService eventDispatcherService, ILogService logService)
    Parameters
    Type Name Description
    IGameProgressStore store

    Backend store used to persist and load game progress.

    IEventDispatcherService eventDispatcherService

    Dispatcher used to broadcast GameCompletedSignal, ExtraUnlockedSignal and GameProgressChangedSignal. May be null; the service works silently without one.

    ILogService logService

    Logging service. May be null.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when store is null.

    Properties

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

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

    Methods

    GetCustomPayload()

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

    Declaration
    public virtual string GetCustomPayload()
    Returns
    Type Description
    string

    GetProgress()

    Gets the current, in-memory game progress.

    Declaration
    public virtual GameProgressData GetProgress()
    Returns
    Type Description
    GameProgressData

    GetUnlockedExtras()

    Gets every currently unlocked extra id.

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

    IncrementCompletionCount()

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

    Declaration
    public virtual void IncrementCompletionCount()

    IsExtraUnlocked(string)

    Checks whether an extra is unlocked.

    Declaration
    public virtual 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
    public virtual 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
    public virtual 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
    public virtual 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
    public virtual void UnlockExtra(string extraId)
    Parameters
    Type Name Description
    string extraId

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

    Implements

    IGameProgressService
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved