in C# Open Source Library ~ read.
Fluent-State-Machine

Fluent-State-Machine

Made at Real Serious Games, this open-source C# library provides a simple interface for setting up hierarchical finite state machines. These kind of state machines are widely used in games for controling things like AI behaviour or player state.

The library is fully unit tested and was designed to be used in Unity, although it is a pure C# library and has no dependency on Unity. State machines keep track of a current state, which defines a behaviour to be called when the state machine is updated. States can be pushed and popped on top of each other, respond to events, and perform special actions when they are activated and deactivated.

Check out the source on GitHub.