Class GameSessionState
Mutable runtime state of a single game session. Coordinates session status, elapsed time, and score access.
Inherited Members
Namespace: Serenity.GameSession.Domain.Entities
Assembly: Serenity.GameSession.Domain.dll
Syntax
public class GameSessionState
Constructors
GameSessionState(GameSessionId)
Creates a new GameSessionState with the specified identity.
Declaration
public GameSessionState(GameSessionId id)
Parameters
| Type | Name | Description |
|---|---|---|
| GameSessionId | id | The session identity. |
Properties
ElapsedTime
Gets the total elapsed game time in seconds.
Declaration
public float ElapsedTime { get; }
Property Value
| Type | Description |
|---|---|
| float |
Id
Gets the identity of this session.
Declaration
public GameSessionId Id { get; }
Property Value
| Type | Description |
|---|---|
| GameSessionId |
Score
Gets the score runtime for this session.
Declaration
public ScoreRuntime Score { get; }
Property Value
| Type | Description |
|---|---|
| ScoreRuntime |
Status
Gets or sets the current session status.
Declaration
public GameSessionStatus Status { get; }
Property Value
| Type | Description |
|---|---|
| GameSessionStatus |
Methods
Complete()
Marks the session as successfully completed. Only valid from Playing or Paused; otherwise ignored.
Declaration
public void Complete()
GameOver()
Ends the session with a game-over condition. Only valid from Playing or Paused; otherwise ignored.
Declaration
public void GameOver()
Pause()
Pauses the session.
Declaration
public void Pause()
Resume()
Resumes the session from a paused state.
Declaration
public void Resume()
Start()
Starts the session, transitioning to Playing. Only valid from NotStarted; otherwise ignored.
Declaration
public void Start()
ToSnapshot()
Creates an immutable snapshot of the current session state.
Declaration
public GameSessionSnapshot ToSnapshot()
Returns
| Type | Description |
|---|---|
| GameSessionSnapshot | A read-only snapshot of the session state. |
UpdateTime(float)
Updates the elapsed time. Only accumulates while Playing.
Declaration
public void UpdateTime(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | The time delta to add in seconds. |