     states:
 
       idle:
-        name: 'idle'
         enter: (comps,input,u)->
           u.update comps.get('short_beam').set('cooldown',0)
         update: (comps,input,u) ->

            'shoot'

      shoot:
        name: 'shoot'
        enter: (comps,input,u) ->
          u.newEntity newBullet(comps.get('position'), comps.getIn(['samus','direction']))
          
        update: (comps,input,u) ->
          'cooldown'
          # if isShooting(comps.get('controller'))
          #   null
          # else
          #   'idle'

          # if isShooting(comps.get('controller'))
          #   'cooldown'
          # else
          #   'idle'

      cooldown:
        name: 'cooldown'
        enter: (comps,input,u) ->
          u.update comps.get('short_beam').set('cooldown',110)

        update: (comps,input,u) ->
          if isShooting(comps.get('controller'))
            shortBeam = comps.get('short_beam')
            t = shortBeam.get('cooldown') - input.get('dt')
            if t <= 0
              'idle'
            else
              u.update shortBeam.set('cooldown', t)
              null


isShooting = (controller) -> controller.getIn(['states','action1'])

module.exports =
  config:
    filters: ['samus', 'short_beam','controller', 'position']
