An in-depth explanation for how state machines are setup using enums, signals and globals.