#include "Behaviors/StateMachine.h"

$nodeclass Multitasking2 : StateNode {
  $setupmachine{

    launch: StateNode =N=> {howl, redflash}

    howl: SoundNode($,"howl.wav")
    redflash:LedNode [getMC()->cset(RobotInfo::RedLEDMask, 1.0)]
    {howl, redflash} =C(2)=> {barklow, yellowflash}
    {howl, redflash} =B(RobotInfo::GreenButOffset)[]=> {rblueflash,rtoc}

    barklow: SoundNode($,"barklow.wav")
    yellowflash:LedNode [getMC()->cset(RobotInfo::YellowLEDMask, 1.0)]
    {barklow, yellowflash} =C(2)=> {ping, greenflash}
    {barklow, yellowflash} =B(RobotInfo::GreenButOffset)[]=> {rredflash,rhowl}

    ping: SoundNode($,"ping.wav")
    greenflash:LedNode [getMC()->cset(RobotInfo::GreenLEDMask, 1.0)]
    {ping, greenflash} =C(2)=> {toc, blueflash}
    {ping, greenflash} =B(RobotInfo::GreenButOffset)[]=> {ryellowflash,rbarklow}

    toc: SoundNode($,"toc.wav")
    blueflash:LedNode [getMC()->cset(RobotInfo::BlueLEDMask, 1.0)]
    {toc, blueflash} =C(2)=> {howl, redflash}
    {toc, blueflash} =B(RobotInfo::GreenButOffset)[]=> {rgreenflash,rping}


    rhowl: SoundNode($,"howl.wav")
    rredflash:LedNode [getMC()->cset(RobotInfo::RedLEDMask, 1.0)]
    {rhowl, rredflash} =C(2)=> {rtoc, rblueflash}
    {rhowl, rredflash} =B(RobotInfo::GreenButOffset)[]=> {barklow,yellowflash}

    rbarklow: SoundNode($,"barklow.wav")
    ryellowflash:LedNode [getMC()->cset(RobotInfo::YellowLEDMask, 1.0)]
    {rbarklow, ryellowflash} =C(2)=> {rhowl, rredflash}
    {rbarklow, ryellowflash} =B(RobotInfo::GreenButOffset)[]=> {greenflash,ping}
    
    rping: SoundNode($,"ping.wav")
    rgreenflash:LedNode [getMC()->cset(RobotInfo::GreenLEDMask, 1.0)]
    {rping, rgreenflash} =C(2)=> {rbarklow, ryellowflash}
    {rping, rgreenflash} =B(RobotInfo::GreenButOffset)[]=> {blueflash,toc}
    
    rtoc: SoundNode($,"toc.wav")
    rblueflash:LedNode [getMC()->cset(RobotInfo::BlueLEDMask, 1.0)]
    {rtoc, rblueflash} =C(2)=> {rping, rgreenflash}
    {rtoc, rblueflash} =B(RobotInfo::GreenButOffset)[]=> {redflash,howl}


  }

}

REGISTER_BEHAVIOR(Multitasking2);
