text: (function(){"use strict";var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K={}.hasOwnProperty,L=function(a,b){function c(){this.constructor=a}for(var d in b)K.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},M=function(a,b){return function(){return a.apply(b,arguments)}},N=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};J={signals:{},core:{},fsm:{},tick:{},tools:{}},f=function(){function a(){}return a}(),J.signals.ListenerNode=s=function(){function a(){}return a.prototype.previous=null,a.prototype.next=null,a.prototype.listener=null,a.prototype.once=!1,a}(),J.signals.ListenerNodePool=t=function(){function a(){}return a.prototype.tail=null,a.prototype.cacheTail=null,a.prototype.get=function(){var a;return null!==this.tail?(a=this.tail,this.tail=this.tail.previous,a.previous=null,a):new s},a.prototype.dispose=function(a){a.listener=null,a.once=!1,a.next=null,a.previous=this.tail,this.tail=a},a.prototype.cache=function(a){a.listener=null,a.previous=this.cacheTail,this.cacheTail=a},a.prototype.releaseCache=function(){for(var a;null!==this.cacheTail;)a=this.cacheTail,this.cacheTail=a.previous,a.next=null,a.previous=this.tail,this.tail=a},a}(),J.signals.SignalBase=C=function(){function a(){this.nodes=[],this.keys=[],this.listenerNodePool=new t,this.numListeners=0}return a.prototype.head=null,a.prototype.tail=null,a.prototype.numListeners=0,a.prototype.keys=null,a.prototype.nodes=null,a.prototype.listenerNodePool=null,a.prototype.toAddHead=null,a.prototype.toAddTail=null,a.prototype.dispatching=!1,a.prototype.startDispatch=function(){this.dispatching=!0},a.prototype.endDispatch=function(){this.dispatching=!1,this.toAddHead&&(this.head?(this.tail.next=this.toAddHead,this.toAddHead.previous=this.tail,this.tail=this.toAddTail):(this.head=this.toAddHead,this.tail=this.toAddTail),this.toAddHead=null,this.toAddTail=null),this.listenerNodePool.releaseCache()},a.prototype.getNode=function(a){var b;for(b=this.head;null!==b&&b.listener!==a;)b=b.next;if(null===b)for(b=this.toAddHead;null!==b&&b.listener!==a;)b=b.next;return b},a.prototype.add=function(a){var b;-1===this.keys.indexOf(a)&&(b=this.listenerNodePool.get(),b.listener=a,this.nodes.push(b),this.keys.push(a),this.addNode(b))},a.prototype.addOnce=function(a){var b;-1===this.keys.indexOf(a)&&(b=this.listenerNodePool.get(),b.listener=a,b.once=!0,this.nodes.push(b),this.keys.push(a),this.addNode(b))},a.prototype.addNode=function(a){this.dispatching?null===this.toAddHead?this.toAddHead=this.toAddTail=a:(this.toAddTail.next=a,a.previous=this.toAddTail,this.toAddTail=a):null===this.head?this.head=this.tail=a:(this.tail.next=a,a.previous=this.tail,this.tail=a),this.numListeners++},a.prototype.remove=function(a){var b,c;b=this.keys.indexOf(a),c=this.nodes[b],c&&(this.head===c&&(this.head=this.head.next),this.tail===c&&(this.tail=this.tail.previous),this.toAddHead===c&&(this.toAddHead=this.toAddHead.next),this.toAddTail===c&&(this.toAddTail=this.toAddTail.previous),c.previous&&(c.previous.next=c.next),c.next&&(c.next.previous=c.previous),this.nodes.splice(b,1),this.keys.splice(b,1),this.dispatching?this.listenerNodePool.cache(c):this.listenerNodePool.dispose(c),this.numListeners--)},a.prototype.removeAll=function(){for(var a;this.head;)a=this.head,this.head=this.head.next,this.nodes.splice(index,1),this.listenerNodePool.dispose(a);this.nodes=[],this.keys=[],this.tail=null,this.toAddHead=null,this.toAddTail=null,this.numListeners=0},a}(),J.signals.Signal0=y=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return L(b,a),b.prototype.dispatch=function(){var a;for(this.startDispatch(),a=this.head;null!==a;)a.listener(),a.once&&this.remove(a.listener),a=a.next;return this.endDispatch()},b}(C),J.signals.Signal1=z=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return L(b,a),b.prototype.dispatch=function(a){var b;for(this.startDispatch(),b=this.head;null!==b;)b.listener(a),b.once&&this.remove(b.listener),b=b.next;return this.endDispatch()},b}(C),J.signals.Signal2=A=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return L(b,a),b.prototype.dispatch=function(a,b){var c;for(this.startDispatch(),c=this.head;c;)c.listener(a,b),c.once&&this.remove(c.listener),c=c.next;return this.endDispatch()},b}(C),J.signals.Signal3=B=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return L(b,a),b.prototype.dispatch=function(a,b,c){var d;for(this.startDispatch(),d=this.head;null!==d;)d.listener(a,b,c),d.once&&this.remove(d.listener),d=d.next;return this.endDispatch()},b}(C),J.core.Entity=l=function(){function a(a){null==a&&(a=""),Object.defineProperties(this,{name:{get:function(){return this._name},set:function(a){var b;return this._name!==a?(b=this._name,this._name=a,this.nameChanged.dispatch(this,b)):void 0}}}),this.componentAdded=new A,this.componentRemoved=new A,this.nameChanged=new A,this.components=new f,this._name=""!==a?a:"_entity"+ ++b}var b;return b=0,a.prototype._name="",a.prototype.componentAdded=null,a.prototype.componentRemoved=null,a.prototype.nameChanged=null,a.prototype.previous=null,a.prototype.next=null,a.prototype.components=null,a.prototype.add=function(a,b){return null==b&&(b=a.constructor),b.name in this.components&&this.remove(b),this.components[b.name]=a,this.componentAdded.dispatch(this,b),this},a.prototype.remove=function(a){var b,c;return c=null!=a.name?a.name:a,b=this.components[c],b?(delete this.components[c],this.componentRemoved.dispatch(this,c),b):null},a.prototype.get=function(a){return this.components[a.name]},a.prototype.getAll=function(){var a,b,c,d,e;for(b=[],e=this.components,c=0,d=e.length;d>c;c++)a=e[c],b.push(a);return b},a.prototype.has=function(a){return a.name in this.components},a}(),J.core.EntityList=m=function(){function a(){}return a.prototype.head=null,a.prototype.tail=null,a.prototype.add=function(a){this.head?(this.tail.next=a,a.previous=this.tail,a.next=null,this.tail=a):(this.head=this.tail=a,a.next=a.previous=null)},a.prototype.remove=function(a){this.head===a&&(this.head=this.head.next),this.tail===a&&(this.tail=this.tail.previous),a.previous&&(a.previous.next=a.next),a.next&&(a.next.previous=a.previous)},a.prototype.removeAll=function(){for(var a;this.head;)a=this.head,this.head=this.head.next,a.previous=null,a.next=null;this.tail=null},a}(),J.core.Node=u=function(){function a(){}return a.prototype.entity=null,a.prototype.previous=null,a.prototype.next=null,a}(),J.core.NodeList=v=function(){function a(){this.nodeAdded=new z,this.nodeRemoved=new z}return a.prototype.head=null,a.prototype.tail=null,a.prototype.nodeAdded=null,a.prototype.nodeRemoved=null,a.prototype.add=function(a){this.head?(this.tail.next=a,a.previous=this.tail,a.next=null,this.tail=a):(this.head=this.tail=a,a.next=a.previous=null),this.nodeAdded.dispatch(a)},a.prototype.remove=function(a){this.head===a&&(this.head=this.head.next),this.tail===a&&(this.tail=this.tail.previous),a.previous&&(a.previous.next=a.next),a.next&&(a.next.previous=a.previous),this.nodeRemoved.dispatch(a)},a.prototype.removeAll=function(){for(var a;this.head;)a=this.head,this.head=this.head.next,a.previous=null,a.next=null,this.nodeRemoved.dispatch(a);this.tail=null},Object.defineProperties(a.prototype,{empty:{get:function(){return null===this.head}}}),a.prototype.swap=function(a,b){var c;a.previous===b?(a.previous=b.previous,b.previous=a,b.next=a.next,a.next=b):b.previous===a?(b.previous=a.previous,a.previous=b,a.next=b.next,b.next=a):(c=a.previous,a.previous=b.previous,b.previous=c,c=a.next,a.next=b.next,b.next=c),this.head===a?this.head=b:this.head===b&&(this.head=a),this.tail===a?this.tail=b:this.tail===b&&(this.tail=a),null!==a.previous&&(a.previous.next=a),null!==b.previous&&(b.previous.next=b),null!==a.next&&(a.next.previous=a),null!==b.next&&(b.next.previous=b)},a.prototype.insertionSort=function(a){var b,c,d;if(this.head!==this.tail)for(d=this.head.next,b=d;null!==b;){for(d=b.next,c=b.previous;null!==c;){if(a(b,c)>=0){b!==c.next&&(this.tail===b&&(this.tail=b.previous),b.previous.next=b.next,null!==b.next&&(b.next.previous=b.previous),b.next=c.next,b.previous=c,b.next.previous=b,c.next=b);break}c=c.previous}null===c&&(this.tail===b&&(this.tail=b.previous),b.previous.next=b.next,null!==b.next&&(b.next.previous=b.previous),b.next=this.head,this.head.previous=b,b.previous=null,this.head=b),b=d}},a.prototype.mergeSort=function(a){var b,c,d,e;if(this.head!==this.tail){for(c=[],e=this.head;null!==e;){for(b=e;null!==b.next&&a(b,b.next)<=0;)b=b.next;d=b.next,e.previous=b.next=null,c.push(e),e=d}for(;c.length>1;)c.push(this.merge(c.shift(),c.shift(),a));for(this.tail=this.head=c[0];null!==this.tail.next;)this.tail=this.tail.next}},a.prototype.merge=function(a,b,c){var d,e;for(c(a,b)<=0?(d=e=a,a=a.next):(d=e=b,b=b.next);null!==a&&null!==b;)c(a,b)<=0?(e.next=a,a.previous=e,e=a,a=a.next):(e.next=b,b.previous=e,e=b,b=b.next);return null!==a?(e.next=a,a.previous=e):(e.next=b,b.previous=e),d},a}(),J.core.NodePool=w=function(){function a(a,b){this.nodeClass=a,this.components=b}return a.prototype.tail=null,a.prototype.nodeClass=null,a.prototype.cacheTail=null,a.prototype.components=null,a.prototype.get=function(){var a;return this.tail?(a=this.tail,this.tail=this.tail.previous,a.previous=null,a):new this.nodeClass},a.prototype.dispose=function(a){var b;for(b in this.components)a[b]=null;a.entity=null,a.next=null,a.previous=this.tail,this.tail=a},a.prototype.cache=function(a){a.previous=this.cacheTail,this.cacheTail=a},a.prototype.releaseCache=function(){for(var a;this.cacheTail;)a=this.cacheTail,this.cacheTail=a.previous,this.dispose(a)},a}(),J.core.System=F=function(){function a(){this.update=M(this.update,this)}return a.prototype.previous=null,a.prototype.next=null,a.prototype.priority=0,a.prototype.addToEngine=function(){},a.prototype.removeFromEngine=function(){},a.prototype.update=function(){},a}(),J.core.SystemList=H=function(){function a(){}return a.prototype.head=null,a.prototype.tail=null,a.prototype.add=function(a){var b;if(this.head){for(b=this.tail;b&&!(b.priority<=a.priority);)b=b.previous;b===this.tail?(this.tail.next=a,a.previous=this.tail,a.next=null,this.tail=a):b?(a.next=b.next,a.previous=b,b.next.previous=a,b.next=a):(a.next=this.head,a.previous=null,this.head.previous=a,this.head=a)}else this.head=this.tail=a,a.next=a.previous=null},a.prototype.remove=function(a){this.head===a&&(this.head=this.head.next),this.tail===a&&(this.tail=this.tail.previous),a.previous&&(a.previous.next=a.next),a.next&&(a.next.previous=a.previous)},a.prototype.removeAll=function(){for(var a;this.head;)a=this.head,this.head=this.head.next,a.previous=null,a.next=null;this.tail=null},a.prototype.get=function(a){var b;for(b=this.head;b;){if(b.constructor===a)return b;b=b.next}return null},a}(),J.core.Family=p=function(){function a(){Object.defineProperties(this,{nodeList:{get:function(){return this.nodes}}})}return a.prototype.nodes=null,a.prototype.newEntity=function(){throw new Error("Method must be overriden")},a.prototype.removeEntity=function(){throw new Error("Method must be overriden")},a.prototype.componentAddedToEntity=function(){throw new Error("Method must be overriden")},a.prototype.componentRemovedFromEntity=function(){throw new Error("Method must be overriden")},a.prototype.cleanUp=function(){throw new Error("Method must be overriden")},a}(),J.core.ComponentMatchingFamily=b=function(){function a(a,b){this.nodeClass=a,this.engine=b,this.releaseNodePoolCache=M(this.releaseNodePoolCache,this),this.init()}return a.prototype.nodes=null,a.prototype.entities=null,a.prototype.nodeClass=null,a.prototype.components=null,a.prototype.nodePool=null,a.prototype.engine=null,a.prototype.init=function(){var a,b,c;this.nodes=new v,this.entities=new f,this.components=new f,this.nodePool=new w(this.nodeClass,this.nodeClass.components),c=this.nodeClass.components;for(a in c)b=c[a],this.components[b.name]=b},Object.defineProperties(a.prototype,{nodeList:{get:function(){return this.nodes}}}),a.prototype.newEntity=function(a){this.addIfMatch(a)},a.prototype.componentAddedToEntity=function(a){this.addIfMatch(a)},a.prototype.componentRemovedFromEntity=function(a,b){var c;c=null!=b.name?b.name:b,c in this.components&&this.removeIfMatch(a)},a.prototype.removeEntity=function(a){this.removeIfMatch(a)},a.prototype.addIfMatch=function(a){var b,c,d,e,f;if(null==this.entities[a.name]){e=this.nodeClass.components;for(c in e)if(b=e[c],!a.has(b))return;d=this.nodePool.get(),d.entity=a,f=this.nodeClass.components;for(c in f)b=f[c],d[c]=a.get(b);this.entities[a.name]=d,this.nodes.add(d)}},a.prototype.removeIfMatch=function(a){var b;a.name in this.entities&&(b=this.entities[a.name],delete this.entities[a.name],this.nodes.remove(b),this.engine.updating?(this.nodePool.cache(b),this.engine.updateComplete.add(this.releaseNodePoolCache)):this.nodePool.dispose(b))},a.prototype.releaseNodePoolCache=function(){this.engine.updateComplete.remove(this.releaseNodePoolCache),this.nodePool.releaseCache()},a.prototype.cleanUp=function(){var a;for(a=this.nodes.head;a;)this.entities.remove(a.entity),a=a.next;this.nodes.removeAll()},a}(),J.core.Engine=i=function(){function a(){this.update=M(this.update,this),this.componentRemoved=M(this.componentRemoved,this),this.componentAdded=M(this.componentAdded,this),this.entityNameChanged=M(this.entityNameChanged,this),this.entityList=new m,this.entityNames=new f,this.systemList=new H,this.families=new f,this.updateComplete=new y}return a.prototype.entityNames=null,a.prototype.entityList=null,a.prototype.systemList=null,a.prototype.families=null,a.prototype.updating=!1,a.prototype.updateComplete=null,a.prototype.familyClass=b,Object.defineProperties(a.prototype,{entities:{get:function(){var a,b;for(a=[],b=this.entityList.head;b;)this.entities.push(b),b=b.next;return a}},systems:{get:function(){var a,b;for(b=[],a=this.systemList.head;a;)b.push(a),a=a.next;return b}}}),a.prototype.addEntity=function(a){var b,c,d;if(this.entityNames[a.name])throw"The entity name "+a.name+" is already in use by another entity.";this.entityList.add(a),this.entityNames[a.name]=a,a.componentAdded.add(this.componentAdded),a.componentRemoved.add(this.componentRemoved),a.nameChanged.add(this.entityNameChanged),d=this.families;for(b in d)c=d[b],c.newEntity(a)},a.prototype.removeEntity=function(a){var b,c,d;a.componentAdded.remove(this.componentAdded),a.componentRemoved.remove(this.componentRemoved),a.nameChanged.remove(this.entityNameChanged),d=this.families;for(b in d)c=d[b],c.removeEntity(a);delete this.entityNames[a.name],this.entityList.remove(a)},a.prototype.entityNameChanged=function(a,b){this.entityNames[b]===a&&(delete this.entityNames[b],this.entityNames[a.name]=a)},a.prototype.getEntityByName=function(a){return this.entityNames[a]},a.prototype.removeAllEntities=function(){for(;null!==this.entityList.head;)this.removeEntity(this.entityList.head)},a.prototype.componentAdded=function(a,b){var c,d,e;e=this.families;for(c in e)d=e[c],d.componentAddedToEntity(a,b)},a.prototype.componentRemoved=function(a,b){var c,d,e;e=this.families;for(c in e)d=e[c],d.componentRemovedFromEntity(a,b)},a.prototype.getNodeList=function(a){var b,c;if(a.name in this.families)return this.families[a.name].nodeList;for(c=new this.familyClass(a,this),this.families[a.name]=c,b=this.entityList.head;b;)c.newEntity(b),b=b.next;return c.nodeList},a.prototype.releaseNodeList=function(a){a.name in this.families&&(this.families[a.name].cleanUp(),delete this.families[a.name])},a.prototype.addSystem=function(a,b){a.priority=b,a.addToEngine(this),this.systemList.add(a)},a.prototype.getSystem=function(a){return systemList.get(a)},a.prototype.removeSystem=function(a){this.systemList.remove(a),a.removeFromEngine(this)},a.prototype.removeAllSystems=function(){for(;null!==this.systemList.head;)this.removeSystem(this.systemList.head)},a.prototype.update=function(a){var b;for(this.updating=!0,b=this.systemList.head;b;)b.update(a),b=b.next;this.updating=!1,this.updateComplete.dispatch()},a}(),J.core.PhaserEngine=x=function(a){function c(a,b){this.postRender=M(this.postRender,this),this.removeAllSystems=M(this.removeAllSystems,this),this.removeSystem=M(this.removeSystem,this),this.getSystem=M(this.getSystem,this),this.addSystem=M(this.addSystem,this),this.releaseNodeList=M(this.releaseNodeList,this),this.getNodeList=M(this.getNodeList,this),this.componentRemoved=M(this.componentRemoved,this),this.componentAdded=M(this.componentAdded,this),this.removeAllEntities=M(this.removeAllEntities,this),this.getEntityByName=M(this.getEntityByName,this),this.entityNameChanged=M(this.entityNameChanged,this),this.removeEntity=M(this.removeEntity,this),this.addEntity=M(this.addEntity,this),this.init=M(this.init,this),c.__super__.constructor.call(this,a,b),this.nodes={},this.components={},this.entityList=new m,this.entityNames=new f,this.systemList=new H,this.families=new f,this.updateComplete=new y}return L(c,a),c.prototype.entityNames=null,c.prototype.entityList=null,c.prototype.systemList=null,c.prototype.families=null,c.prototype.nodes=null,c.prototype.components=null,c.prototype.game=null,c.prototype.parent=null,c.prototype.active=!0,c.prototype.visible=!0,c.prototype.hasPostRender=!0,c.prototype.updating=!1,c.prototype.updateComplete=null,c.prototype.familyClass=b,c.prototype.addNode=function(a,b){var c,d,e;if(null==b.components){b.components={},e=b.prototype;for(c in e)K.call(e,c)&&(d=e[c],b.components[c]=d,b.prototype[c]=null);b.prototype.entity=null,b.prototype.previous=null,b.prototype.next=null}return this.nodes[a]=b},c.prototype.init=function(a,b){var c,d,e,f,g,h;if(null!=b)for(d in b)c=b[d],this.components[d]=c;if(null!=a){h=[];for(d in a){if(c=a[d],null==c.components){c.components={},g=c.prototype;for(e in g)K.call(g,e)&&(f=g[e],c.components[e]=f,c.prototype[e]=null);c.prototype.entity=null,c.prototype.previous=null,c.prototype.next=null}h.push(null!=b?this.nodes[d]=c:void 0)}return h}},Object.defineProperties(c.prototype,{entities:{get:function(){var a,b;for(a=[],b=this.entityList.head;b;)this.entities.push(b),b=b.next;return a}},systems:{get:function(){var a,b;for(b=[],a=this.systemList.head;a;)b.push(a),a=a.next;return b}}}),c.prototype.addEntity=function(a){var b,c,d;if(this.entityNames[a.name])throw"The entity name "+a.name+" is already in use by another entity.";this.entityList.add(a),this.entityNames[a.name]=a,a.componentAdded.add(this.componentAdded),a.componentRemoved.add(this.componentRemoved),a.nameChanged.add(this.entityNameChanged),d=this.families;for(b in d)c=d[b],c.newEntity(a)},c.prototype.removeEntity=function(a){var b,c,d;a.componentAdded.remove(this.componentAdded),a.componentRemoved.remove(this.componentRemoved),a.nameChanged.remove(this.entityNameChanged),d=this.families;for(b in d)c=d[b],c.removeEntity(a);delete this.entityNames[a.name],this.entityList.remove(a)},c.prototype.entityNameChanged=function(a,b){this.entityNames[b]===a&&(delete this.entityNames[b],this.entityNames[a.name]=a)},c.prototype.getEntityByName=function(a){return this.entityNames[a]},c.prototype.removeAllEntities=function(){for(;null!==this.entityList.head;)this.removeEntity(this.entityList.head)},c.prototype.componentAdded=function(a,b){var c,d,e;e=this.families;for(c in e)d=e[c],d.componentAddedToEntity(a,b)},c.prototype.componentRemoved=function(a,b){var c,d,e;e=this.families;for(c in e)d=e[c],d.componentRemovedFromEntity(a,b)},c.prototype.getNodeList=function(a){var b,c;if(a.name in this.families)return this.families[a.name].nodeList;for(c=new this.familyClass(a,this),this.families[a.name]=c,b=this.entityList.head;b;)c.newEntity(b),b=b.next;return c.nodeList},c.prototype.releaseNodeList=function(a){a.name in this.families&&(this.families[a.name].cleanUp(),delete this.families[a.name])},c.prototype.addSystem=function(a,b){a.priority=b,a.addToEngine(this),this.systemList.add(a)},c.prototype.getSystem=function(a){return systemList.get(a)},c.prototype.removeSystem=function(a){this.systemList.remove(a),a.removeFromEngine(this)},c.prototype.removeAllSystems=function(){for(;null!==this.systemList.head;)this.removeSystem(this.systemList.head)},c.prototype.postRender=function(){var a,b;for(b=.001*this.game.time.elapsed,this.updating=!0,a=this.systemList.head;a;)a.update(b),a=a.next;this.updating=!1,this.updateComplete.dispatch()},c}(Phaser.Plugin),J.fsm.ComponentInstanceProvider=a=function(){function a(a){this.instance=a}return a.prototype.instance=null,a.prototype.getComponent=function(){return this.instance},Object.defineProperties(a.prototype,{identifier:{get:function(){return this.instance}}}),a}(),J.fsm.ComponentSingletonProvider=d=function(){function a(a){this.componentType=a}return a.prototype.componentType=null,a.prototype.instance=null,a.prototype.getComponent=function(){return null==this.instance&&(this.instance=new this.componentType),this.instance},Object.defineProperties(a.prototype,{identifier:{get:function(){return this.getComponent()}}}),a}(),J.fsm.ComponentTypeProvider=e=function(){function a(a){this.componentType=a}return a.prototype.componentType=null,a.prototype.getComponent=function(){return new this.componentType},Object.defineProperties(a.prototype,{identifier:{get:function(){return this.componentType}}}),a}(),J.fsm.DynamicComponentProvider=g=function(){function a(a){this._closure=a}return a.prototype._closure=null,a.prototype.getComponent=function(){return this._closure},Object.defineProperties(a.prototype,{identifier:{get:function(){return this._closure}}}),a}(),J.fsm.DynamicSystemProvider=h=function(){function a(a){this.method=a}return a.prototype.method=function(){},a.prototype.systemPriority=0,a.prototype.getSystem=function(){return this.method()},Object.defineProperties(a.prototype,{identifier:{get:function(){return this.method}},priority:{get:function(){return this.systemPriority},set:function(a){return this.systemPriority=a}}}),a}(),J.fsm.EngineState=j=function(){function a(){this.providers=[]}return a.prototype.providers=null,a.prototype.addInstance=function(a){return this.addProvider(new G(a))},a.prototype.addSingleton=function(a){return this.addProvider(new I(a))},a.prototype.addMethod=function(a){return this.addProvider(new h(a))},a.prototype.addProvider=function(a){var b;return b=new E(this,a),this.providers.push(a),b},a}(),J.fsm.StateComponentMapping=D=function(){function b(a,b){this.creatingState=a,this.componentType=b,this.withType(b)}return b.prototype.componentType=null,b.prototype.creatingState=null,b.prototype.provider=null,b.prototype.withInstance=function(b){return this.setProvider(new a(b)),this},b.prototype.withType=function(a){return this.setProvider(new e(a)),this},b.prototype.withSingleton=function(a){return null==a&&(a=this.componentType),this.setProvider(new d(a)),this},b.prototype.withMethod=function(a){return this.setProvider(new g(a)),this},b.prototype.withProvider=function(a){return this.setProvider(a),this},b.prototype.add=function(a){return this.creatingState.add(a)},b.prototype.setProvider=function(a){return this.provider=a,this.creatingState.providers[this.componentType]=a},b}(),J.fsm.EngineStateMachine=k=function(){function a(a){this.engine=a,this.states=new f}return a.prototype.engine=null,a.prototype.states=null,a.prototype.currentState=null,a.prototype.addState=function(a,b){return this.states[a]=b,this},a.prototype.createState=function(a){var b;return b=new j,this.states[a]=b,this},a.prototype.changeState=function(a){var b,c,d,e,g,h,i,j;if(d=this.states[a],null==d)throw new Error("Engine state "+a+" doesn't exist");if(d===this.currentState)return void(d=null);h=new f,i=d.providers;for(b in i)g=i[b],c=g.identifier,h[c]=g;if(currentState){j=this.currentState.providers;for(b in j)g=j[b],c=g.identifier,e=h[c],e?delete h[c]:this.engine.removeSystem(g.getSystem())}for(b in h)g=h[b],this.engine.addSystem(g.getSystem(),g.priority);return this.currentState=d},a}(),J.fsm.EntityState=n=function(){function a(){this.providers=new f}return a.prototype.providers=null,a.prototype.add=function(a){return new D(this,a.name)},a.prototype.get=function(a){return this.providers[a]},a.prototype.has=function(a){return null!==this.providers[a]},a}(),J.fsm.EntityStateMachine=o=function(){function a(a){this.entity=a,this.states=new f}return a.prototype.states=null,a.prototype.currentState=null,a.prototype.entity=null,a.prototype.addState=function(a,b){return this.states[a]=b,this},a.prototype.createState=function(a){var b;return b=new n,this.states[a]=b,b},a.prototype.changeState=function(a){var b,c,d,e;if(b=this.states[a],!b)throw new Error("Entity state "+a+" doesn't exist");if(b===this.currentState)return void(b=null);if(this.currentState){d=new f;for(e in b.providers)d[e]=b.providers[e];for(e in this.currentState.providers)c=d[e],c&&c.identifier===this.currentState.providers[e].identifier?delete d[e]:this.entity.remove(e)}else d=b.providers;for(e in d)this.entity.add(d[e].getComponent());return this.currentState=b},a}(),J.fsm.StateSystemMapping=E=function(){function a(a,b){this.creatingState=a,this.provider=b}return a.prototype.creatingState=null,a.prototype.provider=null,a.prototype.withPriority=function(a){return this.provider.priority=a,this},a.prototype.addInstance=function(a){return creatingState.addInstance(a)},a.prototype.addSingleton=function(a){return creatingState.addSingleton(a)},a.prototype.addMethod=function(a){return creatingState.addMethod(a)},a.prototype.addProvider=function(a){return creatingState.addProvider(a)},a}(),J.fsm.SystemInstanceProvider=G=function(){function a(a){this.instance=a}return a.prototype.instance=null,a.prototype.systemPriority=0,a.prototype.getSystem=function(){return this.instance},Object.defineProperties(a.prototype,{identifier:{get:function(){return this.instance}},priority:{get:function(){return this.systemPriority},set:function(a){return this.systemPriority=a}}}),a}(),J.fsm.SystemSingletonProvider=I=function(){function a(a){this.componentType=a}return a.prototype.componentType=null,a.prototype.instance=null,a.prototype.systemPriority=0,a.prototype.getSystem=function(){return this.instance||(this.instance=new this.componentType),this.instance},Object.defineProperties(a.prototype,{identifier:{get:function(){return this.getSystem()}},priority:{get:function(){return this.systemPriority},set:function(a){return this.systemPriority=a}}}),a}(),J.tick.FrameTickProvider=q=function(a){function b(a,c){this.displayObject=a,this.maximumFrameTime=c,this.dispatchTick=M(this.dispatchTick,this),b.__super__.constructor.apply(this,arguments)}return L(b,a),b.prototype.displayObject=null,b.prototype.previousTime=0,b.prototype.maximumFrameTime=0,b.prototype.isPlaying=!1,b.prototype.request=null,b.prototype.timeAdjustment=1,Object.defineProperties(b.prototype,{playing:{get:function(){return this.isPlaying}}}),b.prototype.start=function(){this.request=requestAnimationFrame(this.dispatchTick),this.isPlaying=!0},b.prototype.stop=function(){cancelRequestAnimationFrame(this.request),this.isPlaying=!1},b.prototype.dispatchTick=function(a){var b,c;null==a&&(a=Date.now()),this.displayObject&&this.displayObject.begin(),c=this.previousTime||a,this.previousTime=a,b=.001*(a-c),this.dispatch(b),requestAnimationFrame(this.dispatchTick),this.displayObject&&this.displayObject.end()},b}(z),J.tools.ComponentPool=c=function(){function a(){}var b,c;return c=new f,b=function(a){var b;return b=a.name,N.call(c,b)>=0?c[a.name]:c[a.name]=[]},a.get=function(a){var c;return c=b(a),c.length>0?c.pop():new a},a.dispose=function(a){var c,d;a&&(d=a.constructor,c=b(d),c.push(a))},a.empty=function(){return c=new f},a}(),J.tools.ListIteratingSystem=r=function(a){function b(a,b,c,d){null==c&&(c=null),null==d&&(d=null),this.nodeClass=a,this.nodeUpdateFunction=b,this.nodeAddedFunction=c,this.nodeRemovedFunction=d}return L(b,a),b.prototype.nodeList=null,b.prototype.nodeClass=null,b.prototype.nodeUpdateFunction=null,b.prototype.nodeAddedFunction=null,b.prototype.nodeRemovedFunction=null,b.prototype.addToEngine=function(a){var b;if(this.nodeList=a.getNodeList(this.nodeClass),null!==this.nodeAddedFunction){for(b=this.nodeList.head;b;)this.nodeAddedFunction(b),b=b.next;this.nodeList.nodeAdded.add(this.nodeAddedFunction)}null!==this.nodeRemovedFunction&&this.nodeList.nodeRemoved.add(this.nodeRemovedFunction)},b.prototype.removeFromEngine=function(){null!==this.nodeAddedFunction&&this.nodeList.nodeAdded.remove(this.nodeAddedFunction),null!==this.nodeRemovedFunction&&this.nodeList.nodeRemoved.remove(this.nodeRemovedFunction),this.nodeList=null},b.prototype.update=function(a){var b;for(b=this.nodeList.head;b;)this.nodeUpdateFunction(b,a),b=b.next},b}(F),"undefined"!=typeof module&&null!==module?module.exports=J:window.ash=J}).call(this);