StateMachine<TState>.

StateMachine<TState>.StateSelector Class

Summary

A prioritised list of potential states for a Animancer.FSM.StateMachine`1 to enter.
Assembly
Animancer.dll
Namespace
Animancer.FSM
Base Types
graph BT Type-->Base0["SortedList<float, TState>"] Type["StateMachine<TState>.StateSelector"] class Type type-node

Syntax

public class StateMachine<TState>.StateSelector : SortedList<float, TState>

Examples

public StateMachine<CharacterState> stateMachine;
public CharacterState run;
public CharacterState idle;

private readonly StateMachine<CharacterState>.StateSelector
    Selector = new StateMachine<CharacterState>.StateSelector();

private void Awake()
{
    Selector.Add(1, run);
    Selector.Add(0, idle);
}

public void RunOrIdle()
{
    stateMachine.TrySetState(Selector.Values);
    // The "run" state has the highest priority so this will enter it if "run.CanEnterState" returns true.
    // Otherwise if "idle.CanEnterState" returns true it will enter that state instead.
    // If neither allows the transition, nothing happens and "stateMachine.TrySetState" returns false.
}

Remarks

Documentation: State Selectors

Constructors

Name Summary
StateSelector()

Methods

Name Value Summary
Add<TPrioritizable>(TPrioritizable) void
Adds the `state` to this selector with its Animancer.FSM.IPrioritizable.Priority.