Table of Contents

Class StateTracker<TStateData>

Namespace
Gamelogic.Extensions
Assembly
Gamelogic.Extensions.dll

Tracks a number of states. Events are raised when any state is started, and when all has stopped.

public class StateTracker<TStateData>

Type Parameters

TStateData

The type of the t state data.

Inheritance
StateTracker<TStateData>
Inherited Members
Extension Methods

Remarks

A loading bar is a typical use case. The loading bar should be displayed when any of a number of load processes has started; it should be removed when all has stopped. Another use-case is keeping track of poisoning, when the poisoning can be caused by a number of poisons, and each poison is cured independently.

Constructors

StateTracker()

Initializes a new instance of the StateTracker<TStateData> class.

Properties

ActiveTokens

Returns all the active tokens: tokens returned when states has been started that has not yet been stopped.

IsActive

Gets a value indicating whether this tracker is active, that is, whether any state has been started that has not been stopped.

Methods

StartState(TStateData)

Starts a state, and returns a token that can be used to stop it again.

StopState(IStateToken<TStateData>)

Stops the state associated with the token. The token must be one that was returned when the state was started.

Events

OnStateActive

Occurs when this tracker is inactive and a state is started (so that this tracker becomes active).

OnStateInactive

Occurs when all active states are stopped, that is, when this tracker is active and becomes inactive.