A generic state machine implementation, suitable for games and creative projects.