 PIXI = require "pixi.js"
+
+MetroidLayerDefs = {
+  children:
+    [
+      {
+        id: 'base'
+        name: "Base Layer"
+        children: [
+          {
+            id: 'creatures'
+            name: 'Creatures Layer'
+          }
+          {
+            id: 'rooms'
+            name: 'Rooms Layer'
+          }
+          {
+            id: 'doors'
+            name: 'Doors Layer'
+          }
+        ]
+      }
+      {
+        id: 'overlay'
+        name: "Overlay Layer"
+      }
+    ]
+  aliases:
+    default: 'creatures'
+}
 
 class UIState
   @Defaults =

      y: 1.0
  
  constructor: ({stage, zoomScale, soundController, aspectScale}) ->
    @_layers = @_createLayers(stage,zoomScale,aspectScale)
    @_objectCaches = {}
    @_currentMapName = null
    @drawHitBoxes = false

    scaler.scale.set(aspectScale.x * zoomScale, aspectScale.y * zoomScale)
    scaler._name = "Scaler Layer - (#{scaler.scale.x},#{scaler.scale.y})"

    stage.addChild scaler

    layers = {}
    layers.scaler = scaler
    layers.maps = {}

    newLayer = (info) ->
      l = new PIXI.DisplayObjectContainer()
      l._name = info.name
      layers[info.id] = l
      l

    addChildren = (layer,cinfos) ->
      return unless cinfos?
      for cinfo in cinfos
        cl = newLayer(cinfo)
        addChildren(cl,cinfo.children)
        layer.addChild cl

    defs = MetroidLayerDefs
        
    addChildren(scaler, defs.children)

    if defs.aliases?
      for k,v of defs.aliases
        layers[k] = layers[v]

    return layers

  muteAudio: ->
    @soundController.muteAll()
