Originally from the supply: http://gameinstitute.ru/tutorials/state-driven_agents/