Animancer v8.0 is coming

State Selectors

The StateMachine<TState>.StateSelector class provides an easy way to manage a prioritised list of potential states:

  1. Construct a new StateMachine<TState>.StateSelector by passing in the target state machine.
  2. Add states to the selector by calling its Add method, which requires you to give them each a priority value. If multiple states have the same priority, the most recently added will be treated as a higher priority.
  3. After you have added all the potential states you want it to choose from, call TrySetState, TryResetState, or ForceSetState to have it try to enter each of the states using the corresponding StateMachine<TState> method.
  4. It attempts to enter each state you have added in order of priority (highest first).
  5. If it successfully enters a state, the selector is cleared.

If you want to define the priority of a state as part of the state class itself (rather than as a second parameter every time you call the Add method), you can implement the IPrioritizable interface. The IPrioritizable.Priority is usually implemented as an abstract or virtual property in your base state class so that each state can override it with their own priority.