Interface IGameState
Represents the game state, a collection of game objects with the capability to update when out-of-date.
Inherited Members
Namespace: Microsoft.XboxStudios.GameStateTracker
Assembly: GameStateTracker.Abstractions.dll
Syntax
public interface IGameState : IState<ObjectInfo, IGameObject>, IReadOnlyCollection<IGameObject>, IEnumerable<IGameObject>, IEnumerable, IEventAggregator<IGameEventArgs>, IEventPublisher<IGameEventArgs>, IHasUpdateTime
Methods
View SourceClear(ObjectInfo?)
Removes an object from the cache.
Declaration
bool Clear(ObjectInfo? info)
Parameters
Type | Name | Description |
---|---|---|
ObjectInfo? | info | The object info. |
Returns
Type | Description |
---|---|
bool | True if the object was removed. |
ClearAll<T>(params string[])
Removes all cached objects derived from the given class names.
Declaration
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. |
ExistingAll<T>(string?)
Gets all cached game objects derived from the given class name.
Declaration
IEnumerable<T> ExistingAll<T>(string? className = null) where T : IGameObject
Parameters
Type | Name | Description |
---|---|---|
string | className | The class name. |
Returns
Type | Description |
---|---|
IEnumerable<T> | An enumerable of game objects. |
Type Parameters
Name | Description |
---|---|
T | The game object type. |
Existing<T>(ObjectInfo?)
Gets a cached game object with the given info.
Declaration
T? Existing<T>(ObjectInfo? info = null) where T : class, IGameObject
Parameters
Type | Name | Description |
---|---|---|
ObjectInfo? | info | The object info. |
Returns
Type | Description |
---|---|
T | A game object. |
Type Parameters
Name | Description |
---|---|
T | The game object type. |
GetAll<T>(ObjectInfo, TimeSpan, CancellationToken)
Retrieves all game objects matching the given query.
Declaration
Task<IEnumerable<T>> GetAll<T>(ObjectInfo query, TimeSpan maxAge, CancellationToken token = default) where T : IGameObject
Parameters
Type | Name | Description |
---|---|---|
ObjectInfo | query | The objects 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<IEnumerable<T>> | An enumerable of game objects. |
Type Parameters
Name | Description |
---|---|
T | The object type. |
GetAll<T>(string, TimeSpan, CancellationToken)
Retrieves all game objects derived from the given class name.
Declaration
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. |
GetAll<T>(TimeSpan, CancellationToken)
Retrieves all game objects derived from the given object type.
Declaration
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. |
Get<T>(ObjectInfo, TimeSpan, CancellationToken)
Retrieves a game object which matches the given query.
Declaration
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 game object. |
Type Parameters
Name | Description |
---|---|
T | The object type. |