I don´t know if the best place to post this is here or in the showcase, but here it is. I had to program a Finite State Machine to a project I´m working on right now, and I decided to share the class here since it´s very simple to include in many projects and makes the code cleanner than using lots of ifs and switches. It´s not as general and powerfull as behavior trees, but FSM is used by the game industry since PacMan, and for small projects it´s still very usefull. It´s based on chapter 3.1 of Game Programming Gems 1, written by Eric Dybsand, but coded in C#. I also implemented a complete project with a simple NPC to show how to use it. The NPC follows a path of waypoints. If it sees the player, it starts chasing him and returns following the path if the player moves too far away from him. If you have any question about the class or the project, just ask.