Layer = require './Layer.coffee'

# Primary chunk of interaction. Has a layer stack that gets rendered by the
# Game and handles on touch events dispached by the Game.
module.exports = class State

  @OVERLAY: 'overlay'

  constructor: ->
    @layers = []

  stop: ->

  # Called when we are entering the state
  onStart: ->

  # Called when we are leaving the state but don't want to close it.
  onPause: (pauseType = State.OVERLAY) ->

  # Called as the state is being shut down
  onStop: ->

  # Layer factory preset to screen canvas size
  newLayer: (T) ->
    T ?= Layer
    @addLayer new T
      width: @screen.width
      height: @screen.height

  # Add a layer (and return it)
  addLayer: (layer) ->
    @layers.push layer
    layer

