Show / Hide Table of Contents

Class GenericGameState

A class used to implement IGameState from a generic object repository and class manager.

Inheritance
object
StateBase<ObjectInfo, IGameObject>
GameStateBase
GenericGameState
UnityGameState
UnrealGameState
Implements
IDisposable
IGenericGameState
IGameState
IState<ObjectInfo, IGameObject>
IReadOnlyCollection<IGameObject>
IEnumerable<IGameObject>
IEnumerable
IEventAggregator<IGameEventArgs>
IEventPublisher<IGameEventArgs>
IHasUpdateTime
IQueryResultConsumer<IGameObject>
IEventProcessor
Inherited Members
GameStateBase.EventReceived
GameStateBase.RecentEvents
GameStateBase.GameCache
GameStateBase.EventAggregator
GameStateBase.GetAll<T>(ObjectInfo, TimeSpan, CancellationToken)
GameStateBase.Existing<T>(ObjectInfo?)
GameStateBase.ExistingAll<T>(string)
GameStateBase.Clear(ObjectInfo?)
GameStateBase.ClearEvents()
GameStateBase.Match(IGameObject, in ObjectInfo)
GameStateBase.GetObject(ObjectInfo, CancellationToken)
GameStateBase.Set(in ObjectInfo, IGameObject)
GameStateBase.PublishEvent(object, IGameEventArgs)
StateBase<ObjectInfo, IGameObject>.Logger
StateBase<ObjectInfo, IGameObject>.UpdateTime
StateBase<ObjectInfo, IGameObject>.Count
StateBase<ObjectInfo, IGameObject>.IsUpdateInProgress
StateBase<ObjectInfo, IGameObject>.Cache
StateBase<ObjectInfo, IGameObject>.Semaphore
StateBase<ObjectInfo, IGameObject>.UpdateProcessor
StateBase<ObjectInfo, IGameObject>.Get(ObjectInfo, TimeSpan, CancellationToken)
StateBase<ObjectInfo, IGameObject>.Existing(ObjectInfo)
StateBase<ObjectInfo, IGameObject>.Clear(ObjectInfo)
StateBase<ObjectInfo, IGameObject>.WaitForUpdateFinished()
StateBase<ObjectInfo, IGameObject>.Dispose()
StateBase<ObjectInfo, IGameObject>.GetEnumerator()
StateBase<ObjectInfo, IGameObject>.GetObject(ObjectInfo, CancellationToken)
StateBase<ObjectInfo, IGameObject>.Set(in ObjectInfo, IGameObject)
StateBase<ObjectInfo, IGameObject>.AgeObject(ObjectInfo)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Microsoft.XboxStudios.GameStateTracker.Generic
Assembly: GameStateTracker.Generic.dll
Syntax
public class GenericGameState : GameStateBase, IDisposable, IGenericGameState, IGameState, IState<ObjectInfo, IGameObject>, IReadOnlyCollection<IGameObject>, IEnumerable<IGameObject>, IEnumerable, IEventAggregator<IGameEventArgs>, IEventPublisher<IGameEventArgs>, IHasUpdateTime, IQueryResultConsumer<IGameObject>, IEventProcessor

Constructors

View Source

GenericGameState(IGenericGameObjectRepository, IClassManager?, ILogger<GenericGameState>?, IGameObjectCache?)

Initializes a new instance of the GenericGameState class.

Declaration
public GenericGameState(IGenericGameObjectRepository repository, IClassManager? classManager = null, ILogger<GenericGameState>? logger = null, IGameObjectCache? cache = null)
Parameters
Type Name Description
IGenericGameObjectRepository repository

The generic object repository.

IClassManager classManager

The class manager.

ILogger<GenericGameState> logger

The logger to use.

IGameObjectCache cache

The cache to use to store game objects.

Fields

View Source

GameStateChangedEventName

The event name for the repository to indicate that game objects have changed.

Declaration
public const string GameStateChangedEventName = "GameStateChanged"
Field Value
Type Description
string

Properties

View Source

ClassManager

Gets the class manager.

Declaration
public IClassManager ClassManager { get; }
Property Value
Type Description
IClassManager
View Source

Repository

Gets the generic game object repository.

Declaration
protected IGenericGameObjectRepository Repository { get; }
Property Value
Type Description
IGenericGameObjectRepository

Methods

View Source

CheckQueryResultChangesGameClass(in QueryResult)

Checks whether the query result changes the class to convert a game object to.

Declaration
protected virtual bool CheckQueryResultChangesGameClass(in QueryResult result)
Parameters
Type Name Description
QueryResult result

The query result.

Returns
Type Description
bool

True if the class is affected.

View Source

ClearAll<T>(params string?[])

Removes all cached objects derived from the given class names.

Declaration
public override void ClearAll<T>(params string?[] classNames) where T : IGameObject
Parameters
Type Name Description
string[] classNames

The class names.

Type Parameters
Name Description
T

The game object type.

Overrides
GameStateBase.ClearAll<T>(params string?[])
View Source

Clear<T>(ObjectInfo?)

Removes an object from the cache.

Declaration
public virtual bool Clear<T>(ObjectInfo? info)
Parameters
Type Name Description
ObjectInfo? info

The object info.

Returns
Type Description
bool

True if the object was removed.

Type Parameters
Name Description
T

The game object type.

View Source

Existing(ObjectInfo)

Gets a cached object with the given info.

Declaration
public override IGameObject? Existing(ObjectInfo info)
Parameters
Type Name Description
ObjectInfo info

The object info.

Returns
Type Description
IGameObject

The object.

Overrides
StateBase<ObjectInfo, IGameObject>.Existing(ObjectInfo)
View Source

Existing<T>(string?)

Gets a cached game object with the given type and object name.

Declaration
public virtual T? Existing<T>(string? objectName = null) where T : class, IGameObject
Parameters
Type Name Description
string objectName

The object name. If null, there must be only one object with the given type.

Returns
Type Description
T

A game object.

Type Parameters
Name Description
T

The game object type.

View Source

GetAll<T>(string, TimeSpan, CancellationToken)

Retrieves all game objects derived from the given class name.

Declaration
public override Task<IEnumerable<T>> GetAll<T>(string className, TimeSpan maxAge, CancellationToken token = default) where T : IGameObject
Parameters
Type Name Description
string className

The class name.

TimeSpan maxAge

The maximum age of the object, if it exists in the cache.

CancellationToken token

The cancellation token.

Returns
Type Description
Task<IEnumerable<T>>

An enumerable of game objects.

Type Parameters
Name Description
T

The game object type.

Overrides
GameStateBase.GetAll<T>(string, TimeSpan, CancellationToken)
View Source

GetAll<T>(TimeSpan, CancellationToken)

Retrieves all game objects derived from the given class name.

Declaration
public override Task<IEnumerable<T>> GetAll<T>(TimeSpan maxAge, CancellationToken token = default) where T : IGameObject
Parameters
Type Name Description
TimeSpan maxAge

The maximum age of the object, if it exists in the cache.

CancellationToken token

The cancellation token.

Returns
Type Description
Task<IEnumerable<T>>

An enumerable of game objects.

Type Parameters
Name Description
T

The game object type.

Overrides
GameStateBase.GetAll<T>(TimeSpan, CancellationToken)
View Source

GetObjects(ObjectInfo, CancellationToken)

Retrieves all objects matching the given query.

Declaration
protected override Task<IEnumerable<IGameObject>> GetObjects(ObjectInfo query, CancellationToken token)
Parameters
Type Name Description
ObjectInfo query

The objects to look for.

CancellationToken token

The cancellation token.

Returns
Type Description
Task<IEnumerable<IGameObject>>

An enumeration of objects.

Overrides
GameStateBase.GetObjects(ObjectInfo, CancellationToken)
View Source

Get<T>(ObjectInfo, TimeSpan, CancellationToken)

Retrieves an object.

Declaration
public override Task<T?> Get<T>(ObjectInfo query, TimeSpan maxAge, CancellationToken token = default) where T : class, IGameObject
Parameters
Type Name Description
ObjectInfo query

The object to look for.

TimeSpan maxAge

The maximum age of the object, if it exists in the cache.

CancellationToken token

The cancellation token.

Returns
Type Description
Task<T>

The object.

Type Parameters
Name Description
T

The object type.

Overrides
GameStateBase.Get<T>(ObjectInfo, TimeSpan, CancellationToken)
View Source

Get<T>(string?, TimeSpan, CancellationToken)

Retrieves an object.

Declaration
public Task<T?> Get<T>(string? objectName, TimeSpan maxAge, CancellationToken token = default) where T : class, IGameObject
Parameters
Type Name Description
string objectName

The object to look for.

TimeSpan maxAge

The maximum age of the object, if it exists in the cache.

CancellationToken token

The cancellation token.

Returns
Type Description
Task<T>

The object.

Type Parameters
Name Description
T

The object type.

View Source

Get<T>(TimeSpan, CancellationToken)

Retrieves an object of the given type.

Declaration
public Task<T?> Get<T>(TimeSpan maxAge, CancellationToken token = default) where T : class, IGameObject
Parameters
Type Name Description
TimeSpan maxAge

The maximum age of the object, if it exists in the cache.

CancellationToken token

The cancellation token.

Returns
Type Description
Task<T>

The object.

Type Parameters
Name Description
T

The object type.

View Source

HandleGameStateChangedEvent(object?, IGameEventArgs)

Used to update the game state when the repository publishes an event with query results.

Declaration
protected virtual void HandleGameStateChangedEvent(object? sender, IGameEventArgs e)
Parameters
Type Name Description
object sender

The event sender.

IGameEventArgs e

The event.

View Source

Match(IGameObject, string)

Determines if the game object has the given class name.

Declaration
protected override bool Match(IGameObject input, string className)
Parameters
Type Name Description
IGameObject input

The game object.

string className

The class name.

Returns
Type Description
bool

True if the game object's class name matches the given name.

Overrides
GameStateBase.Match(IGameObject, string)
View Source

MergeResult(in QueryResult)

Transforms the query result into an object, and then adds the object to the cache.

Declaration
public virtual IGameObject MergeResult(in QueryResult item)
Parameters
Type Name Description
QueryResult item

The query result.

Returns
Type Description
IGameObject

The object.

View Source

ProcessEvents()

Processes the buffer of game events, clearing objects from the game state as needed.

Declaration
public virtual void ProcessEvents()

Implements

IDisposable
IGenericGameState
IGameState
IState<TKey, TValue>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable
IEventAggregator<T>
IEventPublisher<T>
IHasUpdateTime
IQueryResultConsumer<T>
IEventProcessor

Extension Methods

IQueryResultConsumerExtensions.MergeResults<T>(IQueryResultConsumer<T>, IEnumerable<QueryResult>?)
IGameStateExtensions.GetLocalPlayerPawn<T>(IGameState, int, TimeSpan)
IGameStateExtensions.GetLocalPlayerState<T>(IGameState, int, TimeSpan)
IGameStateExtensions.GetLocalPlayer<T>(IGameState, int, TimeSpan)
IGameStateExtensions.GetPlayerLocation<T>(IGameState, int, TimeSpan)
IGameStateExtensions.LocalPlayer(IGameState, int)
IGameStateExtensions.LocalPlayerState(IGameState, int)
IGameStateExtensions.OrderByNearest<T>(IGameState, int, IEnumerable<T>)
IGameStateExtensions.PlayerDistanceTo(IGameState, int, IActor)
IGameStateExtensions.PlayerDistanceTo(IGameState, int, Vector3?)
IGameStateExtensions.PlayerLocation(IGameState, int)
IEnumerableExtensions.WithoutLast<T>(IEnumerable<T>)
  • View Source
In this article
Back to top Generated by DocFX