!function(F){if("object"==typeof exports)module.exports=F();else if("function"==typeof define&&define.amd)define(F);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self);b.app=F()}}(function(){return function b(e,m,a){function c(f,q){if(!m[f]){if(!e[f]){var r="function"==typeof require&&require;if(!q&&r)return r(f,!0);if(d)return d(f,!0);throw Error("Cannot find module '"+f+"'");}r=m[f]={exports:{}};e[f][0].call(r.exports,function(d){var a=
e[f][1][d];return c(a?a:d)},r,r.exports,b,e,m,a)}return m[f].exports}for(var d="function"==typeof require&&require,f=0;f<a.length;f++)c(a[f]);return c}({1:[function(b,e,m){var a=b("./src/fejs/core/core"),c=b("./src/fejs/pixi/PixiLayer"),d=b("./src/fejs/core/input"),f=b("./src/fejs/debug/debug"),k=b("./src/fejs/pixi/viewport"),q=b("./src/fejs/pixi/camera"),r=b("./src/client/ClientState"),h=b("./src/fejs/input/input2d"),g=b("./src/fejs/core/resources"),l=b("./src/fejs/debug/DebugGlobals"),s=b("./src/fejs/core/StateSwitcher");
e.exports.initialize=function(b,n){var u=new g;PIXI.scaleModes.DEFAULT=PIXI.scaleModes.NEAREST;u.loadFromResourcesFile("./resources.json",function(){var g=b.document.getElementById("progress");g.parentNode&&g.parentNode.removeChild(g);g=new a;g.stepSize=16;var x=new c(b.document.getElementById("game"));g.addRenderLayer(x);var v=new d(b,x.renderer.view),e=new f;l.debug=e;var z=new q,m=new k(z);m.width=1366;m.height=768;m.addTo(x.stage);z.scale.x=2;z.scale.y=2;g.addPreRenderCallback(function(d){m.update()});
var y=new s;g.addUpdateCallback(y.update.bind(y));g.addPreRenderCallback(y.preRender.bind(y));g.addPostRenderCallback(y.postRender.bind(y));x=new r(x.stage,m,v,u);y.addState(x);y.enterState(x);var y={folder:"Time",step:0.05,listen:!0},B={frame:0,elapsed:0};e.addControl(B,"frame",y);e.addControl(B,"elapsed",y);var A=new h(m,v),E={x:0,y:0},y={folder:"Input",step:0.05,listen:!0};e.addControl(E,"x",y);e.addControl(E,"y",y);var C={cx:0,cy:0,vx:0,vy:0};e.addControl(C,"cx",y);e.addControl(C,"cy",y);e.addControl(C,
"vx",y);e.addControl(C,"vy",y);y={folder:"Camera",step:0.05,listen:!0};e.addControl(z.position,"x",{folder:"Camera",step:1,listen:!0});e.addControl(z.position,"y",{folder:"Camera",step:1,listen:!0});e.addControl(z,"rotation",y);e.addControl(z.scale,"x",{folder:"Camera",step:0.05,listen:!0,name:"sx"});e.addControl(z.scale,"y",{folder:"Camera",step:0.05,listen:!0,name:"sy"});g.addUpdateCallback(function(d){A.update();E.x=v.mouseX;E.y=v.mouseY;C.cx=A.mouseCanvasPosition.x;C.cy=A.mouseCanvasPosition.y;
C.vx=A.mouseViewPosition.x;C.vy=A.mouseViewPosition.y;l.frame++;l.timeElapsed+=d;B.frame=l.frame;B.elapsed=l.timeElapsed});n(g)});u.progressCallbacks.push(function(d,a){b.document.getElementById("progress").innerHTML=d+" / "+a})}},{"./src/client/ClientState":14,"./src/fejs/core/StateSwitcher":34,"./src/fejs/core/core":35,"./src/fejs/core/input":36,"./src/fejs/core/resources":38,"./src/fejs/debug/DebugGlobals":42,"./src/fejs/debug/debug":43,"./src/fejs/input/input2d":47,"./src/fejs/pixi/PixiLayer":49,
"./src/fejs/pixi/camera":51,"./src/fejs/pixi/viewport":53}],2:[function(b,e,m){b=e.exports={};b.nextTick=function(){if("undefined"!==typeof window&&window.setImmediate)return function(a){return window.setImmediate(a)};if("undefined"!==typeof window&&window.postMessage&&window.addEventListener){var a=[];window.addEventListener("message",function(c){var d=c.source;d!==window&&null!==d||"process-tick"!==c.data||(c.stopPropagation(),0<a.length&&a.shift()())},!0);return function(c){a.push(c);window.postMessage("process-tick",
"*")}}return function(a){setTimeout(a,0)}}();b.title="browser";b.browser=!0;b.env={};b.argv=[];b.binding=function(a){throw Error("process.binding is not supported");};b.cwd=function(){return"/"};b.chdir=function(a){throw Error("process.chdir is not supported");}},{}],3:[function(b,e,m){function a(d){c.call(this);this.gameAPI=d}var c=b("../../src/fejs/systems/actions/ActionScript"),d=b("../../src/fejs/systems/physics/SpeedSystem"),f=b("../../src/fejs/systems/physics/MovementComponent"),k=b("../../src/client/objects/StatsComponent"),
q=b("../../src/fejs/systems/SpatialComponent"),r=b("../../src/fejs/systems/display/AnimationComponent"),h=b("../../src/fejs/systems/physics/TileColliderSystem").TileTypes,g=b("../../src/fejs/systems/physics/AABBComponent"),l=b("../../src/fejs/systems/physics/CollisionComponent");a.prototype=Object.create(c.prototype);a.prototype.onUpdate=function(d){};a.prototype.onTrigger=function(d){};a.prototype.onStart=function(d){};a.prototype.onActivating=function(a){var c=a.entity,b=c[f.type];if(b){var u=c[k.type];
if(u){var p=b.acceleration;p.y+=d.addAcceleration(u.maxMoveSpeed.y,b.speed.y,p.y,u.acceleration.y,a.action.userData.direction);b.calculatedFriction.y=0;b=c[q.type];u=c[l.type];b&&u&&u.resolveFor.tiles&&0<a.action.userData.direction&&(a=c[g.type])&&(a=this.gameAPI.getStaticTileAtPoint(a.center.x,a.center.y+a.height/2+1),a!==h.OneWayTop&&a!==h.OneWayBottom&&a!==h.OneWayCenter||b.position.y++);if(c=c[r.type])c.playAnimation="walk",c.loop=!0}}};a.prototype.onStop=function(a){(a=a.entity[r.type])&&"walk"===
a.currentAnimation&&(a.stopAnimation=!0)};a.type="Fly";e.exports=a;e.exports.type=a.type},{"../../src/client/objects/StatsComponent":27,"../../src/fejs/systems/SpatialComponent":54,"../../src/fejs/systems/actions/ActionScript":56,"../../src/fejs/systems/display/AnimationComponent":61,"../../src/fejs/systems/physics/AABBComponent":68,"../../src/fejs/systems/physics/CollisionComponent":75,"../../src/fejs/systems/physics/MovementComponent":77,"../../src/fejs/systems/physics/SpeedSystem":80,"../../src/fejs/systems/physics/TileColliderSystem":81}],
4:[function(b,e,m){function a(a){c.call(this);this.gameAPI=a}var c=b("../../src/fejs/systems/actions/ActionScript"),d=b("../../src/client/HotKeys"),f=b("../../src/client/objects/StatsComponent"),k=b("../../src/fejs/systems/physics/MovementComponent"),q=b("../../src/fejs/systems/physics/CollisionComponent"),r=b("../../src/fejs/systems/SpatialComponent"),h=b("../../src/fejs/systems/physics/TileColliderSystem").TileTypes,g=b("../../src/fejs/systems/physics/AABBComponent");a.prototype=Object.create(c.prototype);
a.prototype.onAdd=function(a){a.userData.counter=0};a.prototype.onUpdate=function(a){a.userData.counter=a.entity[q.type].isCollidingWith.bottom?0:a.userData.counter+a.timePerFrame};a.prototype.onTrigger=function(a){};a.prototype.onStart=function(a){var c=a.entity;if(c){var b=c[f.type];if(b){var n=c[k.type];if(n){var u=c[q.type];if(u){var p=!0;if(this.gameAPI.input.keysDown[d.DOWN]){var e=c[r.type];e&&(c=c[g.type])&&(c=this.gameAPI.getStaticTileAtPoint(c.center.x,c.center.y+c.height/2+1),c===h.OneWayTop||
c===h.OneWayBottom||c===h.OneWayCenter)&&(e.position.y++,p=!1)}u=u.isCollidingWith.bottom;e=a.action.userData.grace;!u&&e&&(u=a.userData.counter<e);p&&u&&(n.speed.y=0,n.acceleration.y+=b.jumpAcceleration)}}}}};a.prototype.onActivating=function(a){var d=a.entity;d&&(a=d[f.type])&&(d=d[k.type])&&0>d.speed.y&&(d.acceleration.y-=a.gravity.y/2)};a.prototype.onStop=function(a){};a.type="Jump";e.exports=a},{"../../src/client/HotKeys":16,"../../src/client/objects/StatsComponent":27,"../../src/fejs/systems/SpatialComponent":54,
"../../src/fejs/systems/actions/ActionScript":56,"../../src/fejs/systems/physics/AABBComponent":68,"../../src/fejs/systems/physics/CollisionComponent":75,"../../src/fejs/systems/physics/MovementComponent":77,"../../src/fejs/systems/physics/TileColliderSystem":81}],5:[function(b,e,m){function a(a){c.call(this);this.gameAPI=a}var c=b("../../src/fejs/systems/actions/ActionScript"),d=b("../../src/client/objects/StatsComponent"),f=b("../../src/fejs/systems/SpatialComponent"),k=b("../../src/fejs/systems/physics/MovementComponent"),
q=b("../../src/fejs/systems/physics/CollisionComponent"),r=b("../../src/client/objects/CollisionGroups"),h=b("../../src/fejs/utility/math"),g=b("../../src/fejs/utility/Random");a.prototype=Object.create(c.prototype);a.prototype.onTrigger=function(a){var c=a.entity;a.userData.shots||(a.userData.shots=[]);var b=c[d.type];if(b){var n=c[q.type];if(n){var u=c[f.type];if(u){for(c=0;c<a.userData.shots.length;c++)this.gameAPI.entitySystem.hasEntity(a.userData.shots[c])||(a.userData.shots.splice(c,1),c--);
c=a.action.userData.maxShots||0;if(!(0<c&&a.userData.shots.length>=c)){var c=this.gameAPI.objectCreator.createFromStore(a.action.userData.shot),p=c[f.type];p.position.x=u.position.x;p.position.y=u.position.y;u=c[d.type];u.damage=b.damage;var e=a.action.userData.minAngle||0,v=a.action.userData.maxAngle||0,e=e+g.pickRandomFloat()*(v-e)||0,e=e*h.DEG_TO_RAD,e=0>b.direction?h.PI-e:e,b=c[k.type];b.speed.x=Math.cos(e)*u.maxMoveSpeed.x;b.speed.y=Math.sin(e)*u.maxMoveSpeed.y;0>b.speed.x&&(p.scale.x=-1);a.action.userData.offsetX&&
(p.position.x+=a.action.userData.offsetX*p.scale.x);a.action.userData.offsetY&&(p.position.y+=a.action.userData.offsetY*p.scale.y);b=c[q.type];0<=n.groups.indexOf(r.ALLY)?b.targetOrGroups.push(r.ENEMY):b.targetOrGroups.push(r.ALLY);a.userData.shots.push(c);this.gameAPI.playSound(a.action.userData.sound)}}}}};a.type="MainAttack";e.exports=a},{"../../src/client/objects/CollisionGroups":22,"../../src/client/objects/StatsComponent":27,"../../src/fejs/systems/SpatialComponent":54,"../../src/fejs/systems/actions/ActionScript":56,
"../../src/fejs/systems/physics/CollisionComponent":75,"../../src/fejs/systems/physics/MovementComponent":77,"../../src/fejs/utility/Random":82,"../../src/fejs/utility/math":84}],6:[function(b,e,m){function a(){c.call(this)}var c=b("../../src/fejs/systems/actions/ActionScript");b("../../src/fejs/systems/physics/MovementComponent");var d=b("../../src/client/objects/StatsComponent");b("../../src/fejs/systems/SpatialComponent");b("../../src/fejs/systems/display/AnimationComponent");a.prototype=Object.create(c.prototype);
a.prototype.onStart=function(a){var c=a.entity[d.type];if(c){var q=c.maxMoveSpeed.x*a.action.userData.multiplier-c.maxMoveSpeed.x;a.userData.moveIncrease=q;c.maxMoveSpeed.x+=q}};a.prototype.onStop=function(a){var c=a.entity[d.type];c&&(c.maxMoveSpeed.x-=a.userData.moveIncrease)};a.type="Run";e.exports=a},{"../../src/client/objects/StatsComponent":27,"../../src/fejs/systems/SpatialComponent":54,"../../src/fejs/systems/actions/ActionScript":56,"../../src/fejs/systems/display/AnimationComponent":61,
"../../src/fejs/systems/physics/MovementComponent":77}],7:[function(b,e,m){function a(){c.call(this)}var c=b("../../src/fejs/systems/actions/ActionScript"),d=b("../../src/fejs/systems/physics/SpeedSystem"),f=b("../../src/fejs/systems/physics/MovementComponent"),k=b("../../src/client/objects/StatsComponent"),q=b("../../src/fejs/systems/SpatialComponent"),r=b("../../src/fejs/systems/display/AnimationComponent");a.prototype=Object.create(c.prototype);a.prototype.onActivating=function(a){var c=a.entity,
b=c[f.type];if(b){var s=c[k.type];if(s){var t=b.acceleration;t.x+=d.addAcceleration(s.maxMoveSpeed.x,b.speed.x,t.x,s.acceleration.x,a.action.userData.direction);b.calculatedFriction.x=0;if(b=c[q.type])if(a.action.userData.flip&&(0>a.action.userData.direction?0<b.scale.x&&(b.scale.x*=-1):0>b.scale.x&&(b.scale.x*=-1),s.direction=a.action.userData.direction),a=c[r.type])a.playAnimation="walk",a.loop=!0}}};a.prototype.onStop=function(a){(a=a.entity[r.type])&&"walk"===a.currentAnimation&&(a.stopAnimation=
!0)};a.type="Walk";e.exports=a},{"../../src/client/objects/StatsComponent":27,"../../src/fejs/systems/SpatialComponent":54,"../../src/fejs/systems/actions/ActionScript":56,"../../src/fejs/systems/display/AnimationComponent":61,"../../src/fejs/systems/physics/MovementComponent":77,"../../src/fejs/systems/physics/SpeedSystem":80}],8:[function(b,e,m){function a(){d.call(this)}var c=b("../../src/client/HotKeys"),d=b("../../src/fejs/systems/ai/AIScript"),f=b("../../src/fejs/systems/actions/ActionComponent");
a.prototype=Object.create(d.prototype);a.prototype.onStart=function(a){if(a=a.entity[f.type])for(var d=a.actions,b=0;b<d.length;b++)d[b].hotkey===c.ACTIVE1&&a.triggerActions.push(b)};a.prototype.update=function(a){};a.type="Active1ChannelAI";e.exports=a},{"../../src/client/HotKeys":16,"../../src/fejs/systems/actions/ActionComponent":55,"../../src/fejs/systems/ai/AIScript":59}],9:[function(b,e,m){function a(){c.call(this)}var c=b("../../src/fejs/systems/ai/AIScript"),d=b("../../src/fejs/systems/actions/ActionComponent"),
f=b("../../src/client/HotKeys"),k=b("../../src/fejs/systems/actions/ActionSystem");a.prototype=Object.create(c.prototype);a.prototype.onStart=function(a){};a.prototype.onTarget=function(a,d,f){};a.prototype.update=function(a){if(a.target&&(a=a.entity[d.type])){var c=k.getActionIndicesByHotkey(a,f.ACTIVE1);a.triggerActions=a.triggerActions.concat(c)}};a.type="ActiveTriggerAI";e.exports=a;e.exports.type=a.type},{"../../src/client/HotKeys":16,"../../src/fejs/systems/actions/ActionComponent":55,"../../src/fejs/systems/actions/ActionSystem":57,
"../../src/fejs/systems/ai/AIScript":59}],10:[function(b,e,m){function a(a){c.call(this);this.gameAPI=a}var c=b("../../src/fejs/systems/ai/AIScript"),d=b("../../src/fejs/systems/physics/MovementComponent"),f=b("../../src/client/objects/StatsComponent"),k=b("../../src/fejs/systems/physics/AABBComponent"),q=b("../../src/client/level/Level"),r=b("../../src/fejs/systems/SpatialComponent"),h=b("../../src/fejs/systems/actions/ActionComponent"),g=b("../../src/client/HotKeys"),l=b("../../src/fejs/systems/actions/ActionSystem");
a.prototype=Object.create(c.prototype);a.prototype.onStart=function(a){a.userData.moveDirection=-1;var d=a.entity[h.type];if(d){var f=[],f=0>a.userData.moveDirection?l.getActionIndicesByHotkey(d,g.LEFT):l.getActionIndicesByHotkey(d,g.RIGHT);d.triggerActions=d.triggerActions.concat(f)}a.userData.counter=0};a.prototype.onTarget=function(a,d,f){};a.prototype.update=function(a){var c=a.entity,b=c[d.type];if(b){var u=c[f.type];if(u){var p=c[h.type],e=a.userData.moveDirection,v=a.script.userData.directionPeriod;
v&&(a.userData.counter+=a.period,a.userData.counter>=v&&(a.userData.moveDirection*=-1,a.userData.counter=0));c=c[k.type];v=this.gameAPI.getStaticTileAtPoint(c.center.x-c.width/2-1,c.center.y);v===q.TileTypes.Static&&(a.userData.moveDirection=1);v=this.gameAPI.getStaticTileAtPoint(c.center.x+c.width/2+1,c.center.y);v===q.TileTypes.Static&&(a.userData.moveDirection=-1);v=this.gameAPI.getStaticTileAtPoint(c.center.x-c.width/2-1,c.center.y+c.height/2+1);v===q.TileTypes.Empty&&(a.userData.moveDirection=
1);v=this.gameAPI.getStaticTileAtPoint(c.center.x+c.width/2+1,c.center.y+c.height/2+1);v===q.TileTypes.Empty&&(a.userData.moveDirection=-1);p&&1>=Math.abs(b.speed.x)&&(b=0>a.userData.moveDirection?l.getActionIndicesByHotkey(p,g.LEFT):l.getActionIndicesByHotkey(p,g.RIGHT),p.triggerActions=p.triggerActions.concat(b));p&&e!==a.userData.moveDirection&&(b=0>e?l.getActionIndicesByHotkey(p,g.LEFT):l.getActionIndicesByHotkey(p,g.RIGHT),p.stopActions=p.stopActions.concat(b),b=0>a.userData.moveDirection?l.getActionIndicesByHotkey(p,
g.LEFT):l.getActionIndicesByHotkey(p,g.RIGHT),p.triggerActions=p.triggerActions.concat(b));p=a.entity[r.type];e=a.userData.moveDirection;p&&a.target&&(e=p.position.x<a.target[r.type].position.x?1:-1);u.direction=e;p&&(0>e?0<p.scale.x&&(p.scale.x*=-1):0>p.scale.x&&(p.scale.x*=-1))}}};a.type="SkeletonAI";e.exports=a;e.exports.type=a.type},{"../../src/client/HotKeys":16,"../../src/client/level/Level":21,"../../src/client/objects/StatsComponent":27,"../../src/fejs/systems/SpatialComponent":54,"../../src/fejs/systems/actions/ActionComponent":55,
"../../src/fejs/systems/actions/ActionSystem":57,"../../src/fejs/systems/ai/AIScript":59,"../../src/fejs/systems/physics/AABBComponent":68,"../../src/fejs/systems/physics/MovementComponent":77}],11:[function(b,e,m){function a(a){c.call(this);this.gameAPI=a}var c=b("../../src/fejs/systems/ai/AIScript"),d=b("../../src/fejs/systems/SpatialComponent"),f=b("../../src/fejs/systems/ai/AIComponent"),k=b("../../src/fejs/utility/math");a.prototype=Object.create(c.prototype);a.prototype.onStart=function(a){};
a.prototype.onTarget=function(a,d,f){};a.prototype.update=function(a){var c=a.entity,b=c[d.type];if(b){var c=c[f.type],g=this.gameAPI.getClosestPlayerCharacter(b.position.x,b.position.y);if(g){var l=g[d.type];l&&(l=l.position,a=a.script.userData.radius,k.calcDistancePointsNoRoot(b.position.x,b.position.y,l.x,l.y)>a*a?c.target=null:c.target=g.id)}}};a.type="TargetRadiusAI";e.exports=a;e.exports.type=a.type},{"../../src/fejs/systems/SpatialComponent":54,"../../src/fejs/systems/ai/AIComponent":58,"../../src/fejs/systems/ai/AIScript":59,
"../../src/fejs/utility/math":84}],12:[function(b,e,m){function a(){c.call(this)}var c=b("../../src/fejs/systems/ai/AIScript"),d=b("../../src/fejs/systems/physics/MovementComponent"),f=b("../../src/client/objects/StatsComponent"),k=b("../../src/fejs/systems/SpatialComponent"),q=b("../../src/fejs/systems/physics/SpeedSystem"),r=b("../../src/fejs/systems/actions/ActionComponent"),h=b("../../src/client/HotKeys"),g=b("../../src/fejs/systems/actions/ActionSystem");a.prototype=Object.create(c.prototype);
a.prototype.onStart=function(a){a.userData.direction=-1};a.prototype.onTarget=function(a,d,f){};a.prototype.update=function(a){var c=a.entity,b=c[d.type];if(b){var n=c[r.type];if(a.target){var u=c[f.type];if(u){var p=c[k.type];if(p&&(c=a.target[k.type])){c=c.position;p=p.position;a.userData.direction=0>p.x-c.x?1:-1;n?0<a.userData.direction?(n.triggerActions=n.triggerActions.concat(g.getActionIndicesByHotkey(n,h.RIGHT)),n.stopActions=n.stopActions.concat(g.getActionIndicesByHotkey(n,h.LEFT))):(n.triggerActions=
n.triggerActions.concat(g.getActionIndicesByHotkey(n,h.LEFT)),n.stopActions=n.stopActions.concat(g.getActionIndicesByHotkey(n,h.RIGHT))):b.acceleration.x=q.addAcceleration(u.maxMoveSpeed.x,b.speed.x,b.acceleration.x,u.acceleration.x,a.userData.direction);var e=0,e=0>p.y-c.y?1:-1;n?0<e?(n.triggerActions=n.triggerActions.concat(g.getActionIndicesByHotkey(n,h.DOWN)),n.stopActions=n.stopActions.concat(g.getActionIndicesByHotkey(n,h.JUMP))):(n.triggerActions=n.triggerActions.concat(g.getActionIndicesByHotkey(n,
h.JUMP)),n.stopActions=n.stopActions.concat(g.getActionIndicesByHotkey(n,h.DOWN))):b.acceleration.y=q.addAcceleration(u.maxMoveSpeed.y,b.speed.y,b.acceleration.y,u.acceleration.y,e);u.direction=a.userData.direction}}}else b.speed.x*=0.8,b.speed.y*=0.8,n&&(n.stopActions=n.stopActions.concat(g.getActionIndicesByHotkey(n,h.LEFT)),n.stopActions=n.stopActions.concat(g.getActionIndicesByHotkey(n,h.RIGHT)),n.stopActions=n.stopActions.concat(g.getActionIndicesByHotkey(n,h.JUMP)),n.stopActions=n.stopActions.concat(g.getActionIndicesByHotkey(n,
h.DOWN)))}};a.type="WispAI";e.exports=a;e.exports.type=a.type},{"../../src/client/HotKeys":16,"../../src/client/objects/StatsComponent":27,"../../src/fejs/systems/SpatialComponent":54,"../../src/fejs/systems/actions/ActionComponent":55,"../../src/fejs/systems/actions/ActionSystem":57,"../../src/fejs/systems/ai/AIScript":59,"../../src/fejs/systems/physics/MovementComponent":77,"../../src/fejs/systems/physics/SpeedSystem":80}],13:[function(b,e,m){function a(a){c.call(this);this.gameAPI=a}var c=b("../../src/fejs/systems/ai/AIScript"),
d=b("../../src/fejs/systems/physics/MovementComponent"),f=b("../../src/client/objects/StatsComponent"),k=b("../../src/fejs/systems/physics/AABBComponent"),q=b("../../src/client/level/Level"),r=b("../../src/fejs/systems/SpatialComponent"),h=b("../../src/fejs/systems/actions/ActionComponent"),g=b("../../src/client/HotKeys"),l=b("../../src/fejs/systems/actions/ActionSystem");a.prototype=Object.create(c.prototype);a.prototype.onStart=function(a){a.userData.direction=-1;var d=a.entity[h.type];if(d){var f=
[],f=0>a.userData.direction?l.getActionIndicesByHotkey(d,g.LEFT):l.getActionIndicesByHotkey(d,g.RIGHT);d.triggerActions=d.triggerActions.concat(f)}};a.prototype.onTarget=function(a,d,f){};a.prototype.update=function(a){var c=a.entity,b=c[d.type];if(b){var u=c[f.type];if(u){var p=c[h.type];p||(b.acceleration.x=a.userData.direction*u.acceleration.x);var e=a.userData.direction,v=c[k.type],w=this.gameAPI.getStaticTileAtPoint(v.center.x-v.width/2-1,v.center.y);w===q.TileTypes.Static&&(a.userData.direction=
1);w=this.gameAPI.getStaticTileAtPoint(v.center.x+v.width/2+1,v.center.y);w===q.TileTypes.Static&&(a.userData.direction=-1);w=this.gameAPI.getStaticTileAtPoint(v.center.x-v.width/2-1,v.center.y+v.height/2+1);w===q.TileTypes.Empty&&(a.userData.direction=1);w=this.gameAPI.getStaticTileAtPoint(v.center.x+v.width/2+1,v.center.y+v.height/2+1);w===q.TileTypes.Empty&&(a.userData.direction=-1);p&&1>=Math.abs(b.speed.x)&&(b=0>a.userData.direction?l.getActionIndicesByHotkey(p,g.LEFT):l.getActionIndicesByHotkey(p,
g.RIGHT),p.triggerActions=p.triggerActions.concat(b));p&&e!==a.userData.direction&&(b=0>e?l.getActionIndicesByHotkey(p,g.LEFT):l.getActionIndicesByHotkey(p,g.RIGHT),p.stopActions=p.stopActions.concat(b),b=0>a.userData.direction?l.getActionIndicesByHotkey(p,g.LEFT):l.getActionIndicesByHotkey(p,g.RIGHT),p.triggerActions=p.triggerActions.concat(b));u.direction=a.userData.direction;if(c=c[r.type])0>a.userData.direction?0<c.scale.x&&(c.scale.x*=-1):0>c.scale.x&&(c.scale.x*=-1)}}};a.type="ZombieAI";e.exports=
a;e.exports.type=a.type},{"../../src/client/HotKeys":16,"../../src/client/level/Level":21,"../../src/client/objects/StatsComponent":27,"../../src/fejs/systems/SpatialComponent":54,"../../src/fejs/systems/actions/ActionComponent":55,"../../src/fejs/systems/actions/ActionSystem":57,"../../src/fejs/systems/ai/AIScript":59,"../../src/fejs/systems/physics/AABBComponent":68,"../../src/fejs/systems/physics/MovementComponent":77}],14:[function(b,e,m){function a(a,d,f,b){c.call(this);this.stage=a;this.viewport=
d;this.input=f;this.resources=b;this.levelInstance=null}var c=b("../fejs/core/CoreState"),d=b("../fejs/core/input"),f=b("./HotKeys");b("./level/Level");var k=b("./LevelInstance"),q=b("./GameAPI");b("./objects/StatsComponent");a.prototype=Object.create(c.prototype);a.prototype.createAPI=function(){var a=new q;a.viewport=this.viewport;a.input=this.input;a.resources=this.resources;a.stage=this.stage;a.network=this.client;a.hooks.onLevelRestart=this.restartLevel.bind(this);return a};a.prototype._createLevel=
function(){var a=this.createAPI(),a=new k(a);a.startLevel();return a};a.prototype.onAdd=function(a){this.levelInstance=this._createLevel();this.input.addHotkey(d.CharCodes.Up,f.JUMP);this.input.addHotkey(d.CharCodes.Left,f.LEFT);this.input.addHotkey(d.CharCodes.Down,f.DOWN);this.input.addHotkey(d.CharCodes.Right,f.RIGHT);this.input.addHotkey(d.CharCodes.Space,f.JUMP);this.input.addHotkey(d.CharToKeyCode("W"),f.JUMP);this.input.addHotkey(d.CharToKeyCode("A"),f.LEFT);this.input.addHotkey(d.CharToKeyCode("S"),
f.DOWN);this.input.addHotkey(d.CharToKeyCode("D"),f.RIGHT);this.input.addHotkey(d.CharCodes.Shift,f.EVADE);this.input.addHotkey(d.CharToKeyCode("E"),f.USE);this.input.addHotkey(d.P1PadCodes.ButtonDown,f.JUMP);this.input.addHotkey(d.P1PadCodes.Up,f.JUMP);this.input.addHotkey(d.P1PadCodes.Left,f.LEFT);this.input.addHotkey(d.P1PadCodes.Down,f.DOWN);this.input.addHotkey(d.P1PadCodes.Right,f.RIGHT);this.input.addHotkey(d.P1PadCodes.ButtonLeft,f.ACTIVE1);this.input.addHotkey(d.P1PadCodes.ButtonUp,f.ACTIVE2);
this.input.addHotkey(d.P1PadCodes.ButtonRight,f.ACTIVE3);this.input.addHotkey(d.P1PadCodes.R2,f.EVADE);this.input.addHotkey(d.CharToKeyCode("Z"),f.ACTIVE1);this.input.addHotkey(d.CharToKeyCode("X"),f.ACTIVE2);this.input.addHotkey(d.CharToKeyCode("C"),f.ACTIVE3);this.input.addHotkey(d.CharToKeyCode("V"),f.ACTIVE4);this.input.addHotkey(d.CharToKeyCode("J"),f.ACTIVE1);this.input.addHotkey(d.CharToKeyCode("K"),f.ACTIVE2);this.input.addHotkey(d.CharToKeyCode("L"),f.ACTIVE3);this.input.addHotkey(d.CharToKeyCode(";"),
f.ACTIVE4)};a.prototype.update=function(a){this.input.update(a);this.levelInstance&&this.levelInstance.update(a);this.input.flush()};a.prototype.preRender=function(a){};a.prototype.postRender=function(a){};a.prototype.restartLevel=function(){this.levelInstance.destroy();this.levelInstance=this._createLevel()};e.exports=a},{"../fejs/core/CoreState":33,"../fejs/core/input":36,"./GameAPI":15,"./HotKeys":16,"./LevelInstance":17,"./level/Level":21,"./objects/StatsComponent":27}],15:[function(b,e,m){function a(){this.bodyColliderSystem=
this.network=this.objectCreator=this.level=this.layers=this.statusDisplaySystem=this.entitySystem=this.input=this.resources=this.viewport=this.stage=null;this.playerCharacters=[];this.scripts={};this.variables={};this.setup()}var c=b("../fejs/systems/physics/BodyComponent"),d=b("./../fejs/systems/display/Character");b("../fejs/systems/physics/CollisionComponent");var f=b("../fejs/systems/display/DisplayComponent"),k=b("../fejs/systems/SpatialComponent"),q=b("./objects/StatsComponent"),r=b("../fejs/systems/physics/MovementComponent"),
h=b("./systems/ScriptsComponent"),g=b("./../fejs/systems/display/SfxComponent"),l=b("./systems/TimeComponent");b("./Level/Level");var s=b("./level/Level"),t=b("../fejs/utility/math"),n=b("../fejs/utility/Random");a.prototype.callEntityScripts=function(a,d,f,c,b,q,g,k,r,l){var e=d[h.type];if(e)for(a=e[a],e=0;e<a.length;e++){var n=this.scripts[a[e]];n&&n.call(this,d,f,c,b,q,g,k,r,l)}};a.prototype.setup=function(){this.scripts.BodyAttack=function(a,d){var f=a[q.type];if(f)for(var c=0;c<d.length&&this.damage(d[c],
f.damage,a);c++){var b=a[k.type];b&&this.applyForcePlane(d[c],b.position,f.force,!0,!1)}};this.scripts.PlayerDeath=function(a,d){this.restartLevel()};this.scripts.RemoveOnCollide=function(a,d){this.entitySystem.removeEntity(a)};this.scripts.RemoveOnTileCollide=function(a,d){for(var f=0;f<d.length;f++)0!==d[f].index&&this.entitySystem.removeEntity(a)};this.scripts.RemoveOnDeath=function(a,d){this.entitySystem.removeEntity(a)};this.scripts.TimedLifeExpire=function(a){this.entitySystem.removeEntity(a)};
this.scripts.RegionSpawnStart=function(a,d){var f=a[l.type];if(f)for(var c=a.userData.period||1E3,b=0;b<f.timers.length;b++)f.timers[b].duration=c};this.scripts.RegionSpawnStop=function(a,d){var f=a[l.type];if(f)for(var c=0;c<f.timers.length;c++)f.timers[c].duration=Number.MAX_VALUE};this.scripts.RegionSpawnObject=function(a){var d=a[k.type];if(d){var f=a.userData.object;if(f){var b=a.userData[s.ObjectData.MapId],q=b?this.getEntityByMapId(b):null,g=null,g=b&&q?q[c.type]:a[c.type];a=this.objectCreator.createFromStore(f);
g&&0<g.shapes.length&&g.shapes[0].box?(d=g.shapes[0],f=d.box.width,g=d.box.height,f=d.position.x-f/2+n.pickRandomFloat()*f,d=d.position.y-g/2+n.pickRandomFloat()*g,this.setEntityPosition(a,f,d)):this.setEntityPosition(a,d.position.x,d.position.y)}}};this.scripts.CrystalDeath=function(a,d){function f(a,d){b.removeTile(a,d);b.removeTile(a+1,d);b.removeTile(a+2,d);b.removeTile(a+3,d)}function c(a,d){f(9,a);g=b.level.getRegionByName(d+"-zone");b.variables.level=d;if(g){var r=b.getObjectsInRectangle(g.x-
g.width/2,g.y-g.height/2,g.width,g.height),l=0;for(q=0;q<r.length;q++){var h=null,u=r[q];u.gid===s.ObjectTypes.Crystal&&l++;if(h=u.name?b.objectCreator.createFromData(b.resources.getJson(u.name)):b.objectCreator.createFromID(u.gid,u))if(h=h[k.type])h.position.x=u.x,h.position.y=u.y}b.variables.crystals=l;b.variables.brokenCrystals=0}}var b=this,q,g;switch(a.name){case "c-1-1":c(9,"c-1-1");break;case "c-2-1":c(31,"c-2-1");break;case "c-3-1":c(53,"c-3-1");break;case "c-4-1":c(75,"c-4-1");break;case "c-5-1":c(97,
"c-5-1");break;case "c-6-1":c(186,"c-6-1");break;default:if(b.variables.brokenCrystals++,b.variables.crystals===b.variables.brokenCrystals)switch(b.variables.level){case "c-1-1":f(9,22);break;case "c-2-1":f(1,44);break;case "c-3-1":f(9,66);break;case "c-4-1":f(9,88);break;case "c-5-1":f(9,110)}}}};a.prototype.update=function(a){for(var d=this.entitySystem.getEntities(h.type).getAllRaw(),f=0;f<d.length;f++)this.callEntityScripts("update",d[f],a)};a.prototype.hooks={};a.prototype.hooks.onSensorTileCollide=
function(a,d){this.callEntityScripts("sensorTileCollide",a,d)};a.prototype.hooks.onStaticTileCollide=function(a,d,f){this.callEntityScripts("staticTileCollide",a.colliderEntity,a,d,f)};a.prototype.hooks.onBodySensorCollide=function(a,d){this.callEntityScripts("sensorBodyCollide",a,d)};a.prototype.hooks.onBodyStaticCollide=function(a){this.callEntityScripts("staticBodyCollide",a.colliderEntity,a)};a.prototype.hooks.onBodyStartCollide=function(a,d){this.callEntityScripts("bodyStartCollide",a,d)};a.prototype.hooks.onBodyStopCollide=
function(a,d){this.callEntityScripts("bodyStopCollide",a,d)};a.prototype.hooks.onActionAdd=function(a){};a.prototype.hooks.onActionUpdate=function(a){};a.prototype.hooks.onActionTrigger=function(a){};a.prototype.hooks.onActionStart=function(a){};a.prototype.hooks.onActionActivating=function(a){};a.prototype.hooks.onActionStop=function(a){};a.prototype.hooks.onLevelRestart=null;a.prototype.hooks.onLevelStart=function(){for(var a=this.entitySystem.getEntities(h.type).getAllRaw(),d=0;d<a.length;d++)this.callEntityScripts("levelStart",
a[d])};a.prototype.hooks.onLevelEnd=function(){for(var a=this.entitySystem.getEntities(h.type).getAllRaw(),d=0;d<a.length;d++)this.callEntityScripts("levelEnd",a[d])};a.prototype.hooks.onTimerComplete=function(a,d){var f=a[h.type];if(f&&(f=f.timers[d.name]))for(var c=0;c<f.length;c++){var b=this.scripts[f[c]];b&&b.call(this,a,d)}};a.prototype.getSound=function(a){return this.resources.sounds[a]};a.prototype.playSound=function(a,d){var f=this.resources.sounds[a];if(!f)return null;var c=null;f.play(d,
function(a){c=a});return c};a.prototype.pauseSound=function(a,d){var f=this.resources.sounds[a];return f?f.pause(d):null};a.prototype.stopSound=function(a,d){var f=this.resources.sounds[a];return f?f.stop(d):null};a.prototype.shakeCamera=function(a,d,f,c){var b=this.viewport.camera;a+=n.pickRandomFloat()*d;f+=n.pickRandomFloat()*c;b.position.x+=a;b.position.y+=f};a.prototype.setEntityTint=function(a,c){var b=a[f.type];b&&(b.tint=c,b=b.displayable,b instanceof d&&b.setTint(c))};a.prototype.getEntityByMapId=
function(a){for(var d=null,f=this.entitySystem.getEntities[k.type],c=0;c<f.length;c++)if(f[c].userData.mapId===a){d=f[c];break}return d};a.prototype.applyForce=function(a,d,f){var c=a[q.type];if(c&&0!==f){var b=a[k.type];if(b){if(a=a[r.type])a.speed.x=0,a.speed.y=0;d=-Math.atan2(d.y-b.position.y,d.x-b.position.x);c.appliedForce.x+=-f*Math.cos(d);c.appliedForce.y+=f*Math.sin(d)}}};a.prototype.applyForceDiagonal=function(a,d,f){var c=a[q.type];if(c&&0!==f){var b=a[k.type];if(b){if(a=a[r.type])a.speed.x=
0,a.speed.y=0;c.appliedForce.x=b.position.x>d.x?c.appliedForce.x+f:c.appliedForce.x-f;c.appliedForce.y-=f}}};a.prototype.applyForcePlane=function(a,d,f,c,b){var g=a[q.type];if(g&&0!==f){var h=a[k.type];h&&(a=a[r.type],c&&(a&&(a.speed.x=0),g.appliedForce.x=h.position.x>d.x?g.appliedForce.x+f:g.appliedForce.x-f),b&&(a&&(a.speed.y=0),g.appliedForce.y=h.position.y>d.y?g.appliedForce.y+f:g.appliedForce.y-f))}};a.prototype.damage=function(a,d,f){var c=a[q.type];if(!c||c.isDead||0<c.currentInvinciblity)return!1;
var b=d-c.defense;0>=b&&0!==d&&(b=1);c.hitPoints-=b;c.currentInvinciblity=c.invincibility;if(d=a[g.type])d.blinkingDuration=c.currentInvinciblity,d.isBlinking=!0,d.isFlashing=!0;0>=c.hitPoints&&(d=!c.isDead,c.isDead=!0,d&&this.callEntityScripts("justDeath",a,f));(a=a[k.type])&&this.createFadingText(a.position.x,a.position.y,b.toString());return!0};a.prototype.getClosestPlayerCharacter=function(a,d){for(var f=null,c=Number.MAX_VALUE,b=0;b<this.playerCharacters.length;b++){var q=this.playerCharacters[b][k.type];
q&&t.calcDistancePointsNoRoot(q.position.x,q.position.y,a,d)<c&&(f=this.playerCharacters[b])}return f};a.prototype.createFadingText=function(a,d,c){var b=this.entitySystem.createEntity();c=new PIXI.Text(c,{font:"bold 16px Arial",fill:"red",stroke:"black",strokeThickness:3});c.anchor.x=0.5;c.anchor.y=0.5;this.layers.scrollingGUI.addChild(c);this.entitySystem.setComponent(b,f.type,new f({displayable:c}));this.entitySystem.setComponent(b,k.type,new k({position:{x:a,y:d}}));this.entitySystem.setComponent(b,
r.type,new r({speed:{y:-45}}));this.entitySystem.setComponent(b,l.type,new l({timers:[{name:"TimedLifeExpire",duration:1E3,removeOnComplete:!0}]}));this.entitySystem.setComponent(b,h.type,new h({timers:{TimedLifeExpire:["TimedLifeExpire"]}}));return b};a.prototype.setEntityPosition=function(a,d,f){if(a=a[k.type])a.position.x=d,a.position.y=f};a.prototype.restartLevel=function(){if(this.hooks.onLevelRestart)this.hooks.onLevelRestart()};a.prototype.getStaticTileAtPoint=function(a,d){if(!this.level)return null;
var f=Math.floor(a/this.level.tileWidth),c=Math.floor(d/this.level.tileHeight);return this.level.staticTiles[c]?this.level.staticTiles[c][f]:null};a.prototype.removeTile=function(a,d){if(this.level){this.level.staticTiles[d][a]=s.TileTypes.Empty;this.level.sensorTiles[d][a]=s.TileTypes.Empty;this.level.tiles[d][a]=s.TileTypes.Empty;var f=this.level.spriteTiles[d][a];f&&f.parent&&f.parent.removeChild(f)}};a.prototype.getObjectsInRectangle=function(a,d,f,c){for(var b=[],q=this.level.objects,g=0;g<q.length;g++){var k=
q[g];k.x>=a&&k.x<=a+f&&k.y>=d&&k.y<=d+c&&b.push(k)}return b};e.exports=a},{"../fejs/systems/SpatialComponent":54,"../fejs/systems/display/DisplayComponent":64,"../fejs/systems/physics/BodyComponent":70,"../fejs/systems/physics/CollisionComponent":75,"../fejs/systems/physics/MovementComponent":77,"../fejs/utility/Random":82,"../fejs/utility/math":84,"./../fejs/systems/display/Character":63,"./../fejs/systems/display/SfxComponent":66,"./Level/Level":18,"./level/Level":21,"./objects/StatsComponent":27,
"./systems/ScriptsComponent":29,"./systems/TimeComponent":30}],16:[function(b,e,m){e.exports={JUMP:"jump",LEFT:"left",RIGHT:"right",DOWN:"down",EVADE:"evade",USE:"use",ACTIVE1:"active1",ACTIVE2:"active2",ACTIVE3:"active3",ACTIVE4:"active4"}},{}],17:[function(b,e,m){function a(a){this.gameAPI=a;this.stage=a.stage;this.viewport=a.viewport;this.resources=a.resources;this.input=a.input;this.scene=new d;this.viewport.addScene(this.scene);this.layers={background:new PIXI.DisplayObjectContainer,objectBack:new PIXI.DisplayObjectContainer,
object:new PIXI.DisplayObjectContainer,objectFront:new PIXI.DisplayObjectContainer,tile:new PIXI.DisplayObjectContainer,projectile:new PIXI.DisplayObjectContainer,foreground:new PIXI.DisplayObjectContainer,scrollingGUI:new PIXI.DisplayObjectContainer,gui:null};this.scene.display.addChild(this.layers.background);this.scene.display.addChild(this.layers.objectBack);this.scene.display.addChild(this.layers.object);this.scene.display.addChild(this.layers.objectFront);this.scene.display.addChild(this.layers.tile);
this.scene.display.addChild(this.layers.projectile);this.scene.display.addChild(this.layers.foreground);this.scene.display.addChild(this.layers.scrollingGUI);this.gui=new d;this.gui.isLocked=!0;this.layers.gui=this.gui.display;this.viewport.addScene(this.gui);this.entitySystem=new f;this.systems=[];this.input2D=new c(this.viewport,this.input);this.tweenSystem=new E;this.objectCreator=new A(this.entitySystem,this.layers,this.resources.getJson("./media/data/config/actions.json"),this.resources.getJson("./media/data/config/ai.json"));
this.character=this.level=null}b("../fejs/core/CoreState");b("../fejs/core/input");var c=b("../fejs/input/input2d"),d=b("../fejs/pixi/Viewport").ViewportScene,f=b("../fejs/entitysystem/entitysystem"),k=b("../fejs/systems/physics/BoundsSystem"),q=b("../fejs/systems/physics/BoundsDebugSystem"),r=b("../fejs/systems/display/DisplaySystem"),h=b("../fejs/systems/display/DisplayComponent"),g=b("../fejs/systems/SpatialComponent"),l=b("../fejs/systems/physics/MovementSystem"),s=b("../fejs/systems/physics/SpeedSystem"),
t=b("../fejs/systems/physics/TileColliderSystem"),n=b("../fejs/systems/physics/BodyColliderSystem"),u=b("./gui/StatusDisplaySystem"),p=b("../fejs/systems/ai/AISystem"),x=b("../fejs/systems/actions/ActionComponent"),v=b("../fejs/systems/actions/ActionSystem"),w=b("../fejs/systems/display/AnimationSystem"),z=b("./objects/ForceSystem"),D=b("./objects/StatusSystem"),y=b("../fejs/loaders/TiledMapData"),B=b("./level/Level"),A=b("./objects/ObjectCreator");b("./GameAPI");var E=b("../fejs/core/tween").TweenSystem;
a.prototype.startLevel=function(){var a,d=JSON.parse(this.resources.data["./media/data/config/objects.json"]);for(a=0;a<d.objects.length;a++)this.objectCreator.storeObject(d.objects[a],this.resources.data[d.objects[a]]);d=new y;d.loadFromTMX(this.resources.data["./media/data/levels/stage.tmx"]);this.level=new B;this.level.createFromMap(d);this.level.generateDisplay(this.layers.background,this.layers.tile,this.layers.foreground);this.systems.push(new D(this.entitySystem));var f=new v(this.entitySystem);
this.systems.push(f);a=new p(this.entitySystem);this.systems.push(a);var c=new (b("./systems/TimeSystem"))(this.entitySystem);this.systems.push(c);this.systems.push(new z(this.entitySystem));this.systems.push(new s(this.entitySystem));this.systems.push(new k(this.entitySystem));this.systems.push(new q(this.entitySystem,this.scene.display));var h=new t(this.entitySystem,{tiles:this.level.tiles,staticTiles:this.level.staticTiles,sensorTiles:this.level.sensorTiles,tileWidth:this.level.tileWidth,tileHeight:this.level.tileHeight});
h.tileProperties.oneWayHeight=6;this.systems.push(h);var e=new n(this.entitySystem);this.systems.push(e);this.systems.push(new l(this.entitySystem));d=new u(this.entitySystem,this.viewport,this.layers.gui);d.mainEntity=this.character;this.systems.push(d);this.systems.push(new w(this.entitySystem));this.systems.push(new (b("./../fejs/systems/display/SfxSystem"))(this.entitySystem));this.systems.push(new r(this.entitySystem));this.gameAPI.entitySystem=this.entitySystem;this.gameAPI.level=this.level;
this.gameAPI.objectCreator=this.objectCreator;this.gameAPI.statusDisplaySystem=d;this.gameAPI.layers=this.layers;this.gameAPI.bodyColliderSystem=e;h.sensorCollisionCallbacks.push(this.gameAPI.hooks.onSensorTileCollide.bind(this.gameAPI));h.staticCollisionCallbacks.push(this.gameAPI.hooks.onStaticTileCollide.bind(this.gameAPI));e.sensorCollisionCallbacks.push(this.gameAPI.hooks.onBodySensorCollide.bind(this.gameAPI));e.staticCollisionCallbacks.push(this.gameAPI.hooks.onBodyStaticCollide.bind(this.gameAPI));
e.startCollisionCallbacks.push(this.gameAPI.hooks.onBodyStartCollide.bind(this.gameAPI));e.stopCollisionCallbacks.push(this.gameAPI.hooks.onBodyStopCollide.bind(this.gameAPI));f.actionAddCallbacks.push(this.gameAPI.hooks.onActionAdd.bind(this.gameAPI));f.actionUpdateCallbacks.push(this.gameAPI.hooks.onActionUpdate.bind(this.gameAPI));f.actionTriggerCallbacks.push(this.gameAPI.hooks.onActionTrigger.bind(this.gameAPI));f.actionStartCallbacks.push(this.gameAPI.hooks.onActionStart.bind(this.gameAPI));
f.actionActivatingCallbacks.push(this.gameAPI.hooks.onActionActivating.bind(this.gameAPI));f.actionStopCallbacks.push(this.gameAPI.hooks.onActionStop.bind(this.gameAPI));c.timerCompleteCallbacks.push(this.gameAPI.hooks.onTimerComplete.bind(this.gameAPI));c=b("../../scripts/action/Jump");f.addScript(c.type,new c(this.gameAPI));c=b("../../scripts/action/Walk");f.addScript(c.type,new c);c=b("../../scripts/action/Run");f.addScript(c.type,new c);c=b("../../scripts/action/MainAttack");f.addScript(c.type,
new c(this.gameAPI));c=b("../../scripts/action/Fly");f.addScript(c.type,new c(this.gameAPI));f=b("../../scripts/ai/Active1ChannelAI");a.addScript(f.type,new f);f=b("../../scripts/ai/ZombieAI");a.addScript(f.type,new f(this.gameAPI));f=b("../../scripts/ai/TargetRadiusAI");a.addScript(f.type,new f(this.gameAPI));f=b("../../scripts/ai/ActiveTriggerAI");a.addScript(f.type,new f);f=b("../../scripts/ai/WispAI");a.addScript(f.type,new f);f=b("../../scripts/ai/SkeletonAI");a.addScript(f.type,new f(this.gameAPI));
c=this.level.objects;for(a=0;a<c.length;a++)if(h=c[a],h.name&&("./media/data/objects/instructions.json"===h.name||"./media/data/objects/description.json"===h.name||"."!==h.name[0])&&(f=null,f="."===h.name[0]?this.objectCreator.createFromStore(h.name):this.objectCreator.createFromID(h.gid,h)))if(f=f[g.type])f.position.x=h.x,f.position.y=h.y;f=this.level.regions;for(a=0;a<f.length;a++)this.objectCreator.createRegion(f[a]);this.character=this.objectCreator.createFromData(this.resources.getJson("./media/data/characters/hero.json"));
a=this.level.getFirstObjectOfID(0);f=this.character[g.type];f.position.x=a.x;f.position.y=a.y;d.mainEntity=this.character;this.viewport.isCameraRounded=!1;this.viewport.camera.position.x=this.calculateCameraX(f.position.x);this.viewport.camera.position.y=this.calculateCameraY(f.position.y);this.gameAPI.playerCharacters.push(this.character);this.gameAPI.hooks.onLevelStart.call(this.gameAPI)};a.prototype.calculateCameraX=function(a){var d=this.viewport.width/this.viewport.camera.scale.x;d>this.level.width*
this.level.tileWidth?a=this.level.width*this.level.tileWidth/2:0>=a-d/2?a=d/2:a+d/2>=this.level.width*this.level.tileWidth&&(a=this.level.width*this.level.tileWidth-d/2);return a};a.prototype.calculateCameraY=function(a){var d=this.viewport.height/this.viewport.camera.scale.y;d>this.level.height*this.level.tileHeight?a=this.level.height*this.level.tileHeight/2:0>=a-d/2?a=d/2:a+d/2>=this.level.height*this.level.tileHeight&&(a=this.level.height*this.level.tileHeight-d/2);return a};a.prototype.updatePreLogic=
function(a){};a.prototype.updateLogic=function(a){for(var d=this.character[x.type],f=0;f<d.actions.length;f++){var c=d.actions[f];c.justDownOnly?this.input.keysJustDown[c.hotkey]&&d.triggerActions.push(f):this.input.keysDown[c.hotkey]&&d.triggerActions.push(f);c.isChanneled&&this.input.keysUp[c.hotkey]&&d.stopActions.push(f)}this.gameAPI.update(a)};a.prototype.updatePostLogic=function(a){var d=this.character[h.type];d&&(d.position.x=Math.floor(d.position.x),d.position.y=Math.floor(d.position.y));
var d=this.viewport.camera,f=this.character[g.type];if(f){var c=this.calculateCameraX(f.position.x),f=this.calculateCameraY(f.position.y);d.position.x+=0.1*(c-d.position.x);d.position.y+=0.1*(f-d.position.y)}this.tweenSystem.update(a)};a.prototype.update=function(a){this.input2D.update();this.updatePreLogic(a);this.systems.forEach(function(d){d.preUpdate(a)});this.updateLogic(a);this.systems.forEach(function(d){d.update(a)});this.updatePostLogic(a);this.systems.forEach(function(a){a.cleanup()});this.entitySystem.flushChanges()};
a.prototype.destroy=function(){this.gameAPI.hooks.onLevelEnd.call(this.gameAPI);this.systems.forEach(function(a){a.destroy()});this.entitySystem.removeAllEntities();this.viewport.removeScene(this.scene)};e.exports=a},{"../../scripts/action/Fly":3,"../../scripts/action/Jump":4,"../../scripts/action/MainAttack":5,"../../scripts/action/Run":6,"../../scripts/action/Walk":7,"../../scripts/ai/Active1ChannelAI":8,"../../scripts/ai/ActiveTriggerAI":9,"../../scripts/ai/SkeletonAI":10,"../../scripts/ai/TargetRadiusAI":11,
"../../scripts/ai/WispAI":12,"../../scripts/ai/ZombieAI":13,"../fejs/core/CoreState":33,"../fejs/core/input":36,"../fejs/core/tween":40,"../fejs/entitysystem/entitysystem":46,"../fejs/input/input2d":47,"../fejs/loaders/TiledMapData":48,"../fejs/pixi/Viewport":50,"../fejs/systems/SpatialComponent":54,"../fejs/systems/actions/ActionComponent":55,"../fejs/systems/actions/ActionSystem":57,"../fejs/systems/ai/AISystem":60,"../fejs/systems/display/AnimationSystem":62,"../fejs/systems/display/DisplayComponent":64,
"../fejs/systems/display/DisplaySystem":65,"../fejs/systems/physics/BodyColliderSystem":69,"../fejs/systems/physics/BoundsDebugSystem":73,"../fejs/systems/physics/BoundsSystem":74,"../fejs/systems/physics/MovementSystem":78,"../fejs/systems/physics/SpeedSystem":80,"../fejs/systems/physics/TileColliderSystem":81,"./../fejs/systems/display/SfxSystem":67,"./GameAPI":15,"./gui/StatusDisplaySystem":20,"./level/Level":21,"./objects/ForceSystem":23,"./objects/ObjectCreator":25,"./objects/StatusSystem":28,
"./systems/TimeSystem":31}],18:[function(b,e,m){function a(a){this.tiles=[];this.backgroundTiles=[];this.staticTiles=[];this.sensorTiles=[];this.tileHeight=this.tileWidth=this.height=this.width=0;this.objects=[];this.regions=[];this.properties={};this.type=a;this._backgroundBase=new PIXI.DisplayObjectContainer;this._staticBase=new PIXI.DisplayObjectContainer;this.spriteBackgroundTiles=[];this.spriteTiles=[]}function c(d,f,c,b,k,e){d=[];var t,n;for(t=0;t<f.length;t++)d.push([]);var u,p;for(t=0;t<f.length;t++)for(n=
0;n<f[t].length;n++)p=f[t][n],0>=p||p===a.TileTypes.Connector||d[t][n]||(u=PIXI.Texture.fromImage("./media/images/tileset.png-"+(p-1)),u=new PIXI.Sprite(u),u.position.x=k/2+k*n,u.position.y=e/2+e*t,u.anchor.x=0.5,u.anchor.y=0.5,d[t][n]=u,p===a.TileTypes.OneWayBottom||p===a.TileTypes.OneWayCenter||p===a.TileTypes.OneWayTop?c.addChild(u):b.addChild(u));return d}var d=b("../../fejs/systems/physics/TileColliderSystem").TileTypes,f=b("../../fejs/utility/Random"),k=b("../../fejs/utility/collections");a.copyTiles=
function(a){for(var d=[],f=0;f<a.length;f++){var c=[].concat(a[f]);d.push(c)}return d};a.copyObjects=function(a){for(var d=[],c=0;c<a.length;c++){var b=a[c];b.chance&&f.pickRandomFloat()>b.chance||(b=k.shallowCopyObject(b),d.push(b))}return d};a.copyRegions=function(a){for(var d=[],c=0;c<a.length;c++){var b=a[c];b.chance&&f.pickRandomFloat()>b.chance||d.push(k.shallowCopyObject(b))}return d};a.copyProperties=function(a){var d={},f;for(f in a)a.hasOwnProperty(f)&&(d[f]=a[f]);return d};a.prototype.createFromMap=
function(f){this.tiles=a.copyTiles(f.tileLayers[a.TileLayers.Tiles]);this.backgroundTiles=a.copyTiles(f.tileLayers[a.TileLayers.Background]);this.sensorTiles=a.copyTiles(this.tiles);for(var c=a.copyTiles(this.tiles),b=0;b<c.length;b++)for(var g=0;g<c[b].length;g++){var k=c[b][g];k!==a.TileTypes.Empty&&k!==a.TileTypes.Static&&k!==a.TileTypes.OneWayTop&&k!==a.TileTypes.OneWayBottom&&k!==a.TileTypes.OneWayCenter&&(c[b][g]=k===a.TileTypes.Connector?0:d.Static)}this.staticTiles=c;this.width=this.tiles[0].length;
this.height=this.tiles.length;this.tileWidth=f.tileWidth;this.tileHeight=f.tileHeight;this.objects=a.copyObjects(f.objectLayers[a.ObjectLayers.Objects]);this.regions=a.copyRegions(f.regionLayers[a.ObjectLayers.Objects]);this.properties=a.copyProperties(f.properties)};a.prototype.getFirstObjectOfID=function(a){for(var d=0;d<this.objects.length;d++){var f=this.objects[d];if(f.gid===a)return f}return null};a.prototype.generateDisplay=function(a,d,f){null!==this._backgroundBase.parent&&this._backgroundBase.parent.removeChild(this._backgroundBase);
this._backgroundBase=new PIXI.DisplayObjectContainer;a.addChild(this._backgroundBase);null!==this._staticBase.parent&&this._staticBase.parent.removeChild(this._staticBase);this._staticBase=new PIXI.DisplayObjectContainer;d.addChild(this._staticBase);var b;if(a=this.properties.backgroundImage)if(b=PIXI.Texture.fromImage(a),"true"===this.properties.backgroundTiled){var k=Math.ceil(this.width*this.tileWidth/b.baseTexture.width),e=Math.ceil(this.height*this.tileHeight/b.baseTexture.height);for(d=0;d<
k;d++)for(a=0;a<e;a++)f=new PIXI.Sprite(b),f.position.x=d*b.baseTexture.width,f.position.y=a*b.baseTexture.height,this._backgroundBase.addChild(f)}else f=new PIXI.Sprite(b),this._backgroundBase.addChild(f);a=this.backgroundTiles;this.spriteBackgroundTiles=c(this.type,a,this._backgroundBase,this._backgroundBase,this.tileWidth,this.tileHeight);a=this.tiles;this.spriteTiles=c(this.type,a,this._backgroundBase,this._staticBase,this.tileWidth,this.tileHeight)};a.prototype.getRegionByName=function(a){for(var d=
null,f=0;f<this.regions.length;f++)if(this.regions[f].name===a){d=this.regions[f];break}return d};a.TileLayers={Tiles:"tiles",Background:"background"};a.ObjectLayers={Objects:"objects"};a.TileTypes={Empty:0,Static:1,OneWayTop:2,OneWayBottom:3,OneWayCenter:4};a.ObjectTypes={Spawn:0,PresetEnemy:32,SolidSpikeTop:33,SolidSpikeLeft:34,SolidSpikeDown:35,SolidSpikeRight:36,Crystal:64};a.ObjectData={MapId:"mapId",Period:"period",Object:"object"};a.RegionTypes={Object:"object"};e.exports=a;e.exports.TileLayers=
a.TileLayers;e.exports.ObjectLayers=a.ObjectLayers;e.exports.TileTypes=a.TileTypes;e.exports.ObjectTypes=a.ObjectTypes;e.exports.ObjectData=a.ObjectData;e.exports.RegionTypes=a.RegionTypes},{"../../fejs/systems/physics/TileColliderSystem":81,"../../fejs/utility/Random":82,"../../fejs/utility/collections":83}],19:[function(b,e,m){function a(a){c.call(this);this.displayHp=!1;this.setParams(a)}var c=b("../../fejs/core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&
(this.displayHp=a.displayHp||this.displayHp)};a.type="StatusDisplayComponent";e.exports=a},{"../../fejs/core/Component":32}],20:[function(b,e,m){function a(){this.hitPointsPerBar=3;this.barWidth=6;this.outerBarImage="./media/images/gui/outer-hp-bar.png";this.barFrameEnabled=!1;this.innerBarImages=["./media/images/gui/full-hp-bar.png","./media/images/gui/1-3-hp-bar.png","./media/images/gui/2-3-hp-bar.png"];this.emptyBarImage="./media/images/gui/empty-hp-bar.png";this.base=new PIXI.DisplayObjectContainer;
this._barsOuterLayer=new PIXI.DisplayObjectContainer;this.base.addChild(this._barsOuterLayer);this._barsInnerLayer=new PIXI.DisplayObjectContainer;this.base.addChild(this._barsInnerLayer);this._barsOuter=[];this._barsInner=[];this._maxHp=this._lastHP=0}function c(f,c,b){d.call(this);this.entitySystem=f;this.viewport=c;this.layer=b;this.mainEntity=null;this.partyEntities=[];this.bossEntity=this.targetEntity=null;this._mainDisplay=new PIXI.DisplayObjectContainer;f=c.width/c.camera.scale.x;c=c.height/
c.camera.scale.y;this._mainDisplay.position.x=-f/2+0.05*f;this._mainDisplay.position.y=-c/2+0.05*c;this.layer.addChild(this._mainDisplay);this._mainHpBars=new a;this._mainDisplay.addChild(this._mainHpBars.base);this._bossDisplay=new PIXI.DisplayObjectContainer;this._bossDisplay.position.y=c/2-0.05*c;this.layer.addChild(this._bossDisplay);this._bossHpBars=new a;this._bossDisplay.addChild(this._bossHpBars.base)}var d=b("../../fejs/core/system"),f=b("./StatusDisplayComponent"),k=b("../objects/StatsComponent");
a.prototype.setHP=function(a){if(a!==this.lastHP){this.lastHP=a;var d;for(d=0;d<this._barsInner.length;d++)this._barsInnerLayer.removeChild(this._barsInner[d]);this._barsInner=[];var f=Math.ceil(this._maxHp/this.hitPointsPerBar),c=Math.ceil(a/this.hitPointsPerBar);for(d=0;d<f;d++){var b;d===c-1&&0!==a%this.hitPointsPerBar?(b=a%this.hitPointsPerBar,b=b>=this.innerBarImages.length?new PIXI.Sprite(PIXI.Texture.fromImage(this.innerBarImages[this.innerBarImages.length-1])):new PIXI.Sprite(PIXI.Texture.fromImage(this.innerBarImages[b]))):
b=d>c-1?new PIXI.Sprite(PIXI.Texture.fromImage(this.emptyBarImage)):new PIXI.Sprite(PIXI.Texture.fromImage(this.innerBarImages[0]));b.position.x=d*(this.barWidth+1);this._barsInnerLayer.addChild(b);this._barsInner.push(b)}}};a.prototype.setMaxHP=function(a){if(this._maxHp!==a){this._maxHp=a;if(this.barFrameEnabled){var d;for(d=0;d<this._barsOuter.length;d++)this._barsOuterLayer.removeChild(this._barsOuter[d]);this._barsOuter=[];a=Math.ceil(a/this.hitPointsPerBar);for(d=0;d<a;d++){var f=new PIXI.Sprite(PIXI.Texture.fromImage(this.outerBarImage));
f.position.x=d*(this.barWidth+1);this._barsOuterLayer.addChild(f);this._barsOuter.push(f)}}this.setHP(this._lastHP+1);this.setHP(this._lastHP-1)}};c.prototype=Object.create(d.prototype);c.prototype._updateMainStatus=function(){if(this.mainEntity&&this.mainEntity[f.type]){this._mainDisplay.visible=!0;var a=this.mainEntity[k.type];this.mainEntity[f.type].displayHp&&a?(this._mainHpBars.base.visible=!0,this._mainHpBars.setMaxHP(a.maxHitPoints),this._mainHpBars.setHP(a.hitPoints)):this._mainHpBars.base.visible=
!1}else this._mainDisplay.visible=!1};c.prototype._updateBossStatus=function(){if(this.bossEntity&&this.bossEntity[k.type]){this._bossDisplay.visible=!0;var a=this.bossEntity[k.type];a&&(this._bossHpBars.setMaxHP(a.maxHitPoints),this._bossHpBars.setHP(a.hitPoints))}else this._bossDisplay.visible=!1};c.prototype.update=function(a){this._updateMainStatus();this._updateBossStatus()};e.exports=c},{"../../fejs/core/system":39,"../objects/StatsComponent":27,"./StatusDisplayComponent":19}],21:[function(b,
e,m){e.exports=b(18)},{"../../fejs/systems/physics/TileColliderSystem":81,"../../fejs/utility/Random":82,"../../fejs/utility/collections":83}],22:[function(b,e,m){e.exports={ALLY:"ally",ENEMY:"enemy",HAZARD:"hazard",PROJECTILE:"projectile",REGION:"region"}},{}],23:[function(b,e,m){function a(a){c.call(this);this.entitySystem=a}var c=b("../../fejs/core/system"),d=b("./StatsComponent"),f=b("../../fejs/systems/physics/MovementComponent");a.prototype=Object.create(c.prototype);a.prototype.update=function(a){a=
this.entitySystem.getEntities(d.type).getAllRaw();for(var c=0;c<a.length;c++){var b=a[c],h=b[f.type];h&&(b=b[d.type],h.acceleration.x+=b.gravity.x,h.acceleration.y+=b.gravity.y,0<b.weight&&(h.acceleration.x+=b.appliedForce.x/b.weight,h.acceleration.y+=b.appliedForce.y/b.weight),b.appliedForce.x=0,b.appliedForce.y=0)}};e.exports=a},{"../../fejs/core/system":39,"../../fejs/systems/physics/MovementComponent":77,"./StatsComponent":27}],24:[function(b,e,m){function a(a){c.call(this);this.layer=null;this.setParams(a)}
var c=b("../../fejs/core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(this.layer=a.layer||this.layer)};a.type="LayerComponent";e.exports=a},{"../../fejs/core/Component":32}],25:[function(b,e,m){function a(a,d,f,c){this.entitySystem=a;this.layers=d;this.actions=f;this.aiScripts=c;this.debugBounds=!1;this._objectDataCache={};this._componentStore={};this.storeComponent(r);this.storeComponent(h);this.storeComponent(g);this.storeComponent(l);this.storeComponent(s);
this.storeComponent(t);this.storeComponent(n);this.storeComponent(u);this.storeComponent(p);this.storeComponent(x);this.storeComponent(v);this.storeComponent(w);this.storeComponent(z);this.storeComponent(D);this.storeComponent(y);this.storeComponent(B)}var c=b("../../fejs/systems/display/Character"),d=b("../level/Level").ObjectTypes,f=b("../level/Level").RegionTypes,k=b("../../fejs/utility/Random"),q=b("./CollisionGroups"),r=b("../../fejs/systems/physics/AABBComponent"),h=b("../../fejs/systems/actions/ActionComponent"),
g=b("../../fejs/systems/ai/AIComponent"),l=b("../../fejs/systems/display/AnimationComponent"),s=b("../../fejs/systems/physics/BodyComponent"),t=b("../../fejs/systems/physics/BoundsDebugComponent"),n=b("../../fejs/systems/physics/CollisionComponent"),u=b("../../fejs/systems/display/DisplayComponent"),p=b("./LayerComponent"),x=b("../../fejs/systems/physics/MovementComponent");b("../objects/OwnerComponent");var v=b("../systems/ScriptsComponent"),w=b("../../fejs/systems/display/SfxComponent"),z=b("../../fejs/systems/SpatialComponent"),
D=b("../objects/StatsComponent"),y=b("../gui/StatusDisplayComponent"),B=b("../systems/TimeComponent");a.prototype.storeComponent=function(a){this._componentStore[a.type]=a};a.prototype.createFromID=function(a,f){var c=null,b;switch(a){case d.Spawn:c=this.createFromStore("./media/data/objects/spawn.json");break;case d.SpikeTop:c=this.createFromStore("./media/data/hazards/triangle-spike.json");break;case d.SpikeLeft:c=this.createFromStore("./media/data/hazards/triangle-spike.json");b=c[z.type];b.rotation=
-Math.PI/2;break;case d.SpikeDown:c=this.createFromStore("./media/data/hazards/triangle-spike.json");b=c[z.type];b.rotation=Math.PI;break;case d.SpikeRight:c=this.createFromStore("./media/data/hazards/triangle-spike.json");b=c[z.type];b.rotation=Math.PI/2;break;case d.PresetEnemy:c=this.createFromStore(f.name);break;case d.SolidSpikeTop:c=this.createFromStore("./media/data/hazards/solid-spike.json");break;case d.SolidSpikeLeft:c=this.createFromStore("./media/data/hazards/solid-spike.json");b=c[z.type];
b.rotation=-Math.PI/2;break;case d.SolidSpikeDown:c=this.createFromStore("./media/data/hazards/solid-spike.json");b=c[z.type];b.rotation=Math.PI;break;case d.SolidSpikeRight:c=this.createFromStore("./media/data/hazards/solid-spike.json");b=c[z.type];b.rotation=Math.PI/2;break;case d.Exit:c=this.createFromStore("./media/data/objects/crystal.json");c.name=f.name||"none";break;case d.Enemy:c=this.createFromStore(k.pickRandomElement(this.enemies));break;case d.RangedEnemy:c=this.createFromStore(k.pickRandomElement(this.rangedEnemies));
break;case d.MeleeEnemy:c=this.createFromStore(k.pickRandomElement(this.meleeEnemies));break;case d.FlyingEnemy:c=this.createFromStore(k.pickRandomElement(this.flyingEnemies));break;case d.GroundEnemy:c=this.createFromStore(k.pickRandomElement(this.groundEnemies));break;case d.Crystal:c=this.createFromStore("./media/data/objects/crystal.json");c.name=f.name;c.userData.type=f.type;break;default:return null}if(c)for(var g in f)f.hasOwnProperty(g)&&(c.userData[g]=f[g]);return c};a.prototype.createRegion=
function(a){var d=null;a.type===f.Object?d=this.createFromStore(a.name):(d=this.entitySystem.createEntity(),d.name=a.name,d.userData.type=a.type,this.entitySystem.setComponent(d,n.type,new n({resolvesFor:{tiles:!1,objects:!1},collidesWith:{tiles:!1,objects:!1},resolvable:!1,groups:[q.REGION]})));d&&(this.entitySystem.setComponent(d,z.type,new z({position:{x:a.x,y:a.y}})),this.entitySystem.setComponent(d,s.type,new s({allowMultipleCollide:!1,shapes:[{name:a.name,box:{width:a.width,height:a.height}}]})),
this.debugBounds&&this.entitySystem.setComponent(d,t.type,new t));if(d)for(var c in a)a.hasOwnProperty(c)&&(d.userData[c]=a[c]);return d};a.prototype.storeObject=function(a,d){d&&(this._objectDataCache[a]=JSON.parse(d))};a.prototype.createFromData=function(a){var d,f=this.entitySystem.createEntity(),b;switch(a.type){case "character":var k=new c;for(d=0;d<a.parts.length;d++){var q=a.parts[d];b=new PIXI.Sprite(PIXI.Texture.fromImage(q.defaultTexture));b.anchor.x=q.anchor.x;b.anchor.y=q.anchor.y;b.position.x=
q.position.x;b.position.y=q.position.y;b.rotation=q.rotation;b.scale.x=q.scale.x;b.scale.y=q.scale.y;k.addPart(q.name,b,q.animations)}this.entitySystem.setComponent(f,u.type,new u({displayable:k}));break;case "sprite":b=new PIXI.Sprite(PIXI.Texture.fromImage(a.sprite.texture)),b.anchor.x=a.sprite.anchor.x,b.anchor.y=a.sprite.anchor.y,this.entitySystem.setComponent(f,u.type,new u({displayable:b}))}f.name=a.name;f[z.type]||this.entitySystem.setComponent(f,z.type,new z);a=a.components;for(var l in a)if(q=
a[l],d=this._componentStore[l]){b=d.type;(k=f[b])?k.setParams(q):(k=new d(q),this.entitySystem.setComponent(f,b,k));if(b===h.type){var e=q.actions,n=[];for(d=0;d<e.length;d++){var v=this.actions[e[d]];v&&n.push(v)}k.setParams({actions:n});this.entitySystem.setComponent(f,b,k)}if(b===g.type){q=q.scripts;e=[];for(d=0;d<q.length;d++)(n=this.aiScripts[q[d]])&&e.push(n);k.setParams({scripts:e});this.entitySystem.setComponent(f,b,k)}}f[u.type]&&f[u.type].displayable&&(l=this.layers.object,(d=f[p.type])&&
this.layers[d.layer]&&(l=this.layers[d.layer]),l.addChild(f[u.type].displayable));this.debugBounds&&(f[r.type]||f[s.type])&&this.entitySystem.setComponent(f,t.type,new t);return f};a.prototype.createFromStore=function(a){return(a=this._objectDataCache[a])?this.createFromData(a):null};e.exports=a},{"../../fejs/systems/SpatialComponent":54,"../../fejs/systems/actions/ActionComponent":55,"../../fejs/systems/ai/AIComponent":58,"../../fejs/systems/display/AnimationComponent":61,"../../fejs/systems/display/Character":63,
"../../fejs/systems/display/DisplayComponent":64,"../../fejs/systems/display/SfxComponent":66,"../../fejs/systems/physics/AABBComponent":68,"../../fejs/systems/physics/BodyComponent":70,"../../fejs/systems/physics/BoundsDebugComponent":72,"../../fejs/systems/physics/CollisionComponent":75,"../../fejs/systems/physics/MovementComponent":77,"../../fejs/utility/Random":82,"../gui/StatusDisplayComponent":19,"../level/Level":21,"../objects/OwnerComponent":26,"../objects/StatsComponent":27,"../systems/ScriptsComponent":29,
"../systems/TimeComponent":30,"./CollisionGroups":22,"./LayerComponent":24}],26:[function(b,e,m){function a(a){c.call(this);this.creator=this.owner=null;this.setParams(a)}var c=b("../../fejs/core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(this.owner=a.owner||this.owner,this.creator=a.creator||this.creator)};a.type="OwnerComponent";e.exports=a;e.exports.type=a.type},{"../../fejs/core/Component":32}],27:[function(b,e,m){function a(a){c.call(this);this.acceleration=
{x:0,y:0};this.maxMoveSpeed={x:0,y:0};this.jumpAcceleration=0;this.gravity={x:0,y:0};this.direction=1;this.weight=0;this.appliedForce={x:0,y:0};this.isDead=!1;this.force=this.defense=this.damage=this.hitPoints=this.maxHitPoints=0;this.range=this.cooldown=1;this.currentStun=this.currentInvinciblity=this.invincibility=0;this.setParams(a)}var c=b("../../fejs/core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(a.acceleration&&(this.acceleration.x=a.acceleration.x||
this.acceleration.x,this.acceleration.y=a.acceleration.y||this.acceleration.y),a.maxMoveSpeed&&(this.maxMoveSpeed.x=a.maxMoveSpeed.x||this.maxMoveSpeed.x,this.maxMoveSpeed.y=a.maxMoveSpeed.y||this.maxMoveSpeed.y),this.jumpAcceleration=a.jumpAcceleration||this.jumpAcceleration,a.gravity&&(this.gravity.x=a.gravity.x||this.gravity.x,this.gravity.y=a.gravity.y||this.gravity.y),this.weight=a.weight||this.weight,a.appliedForce&&(this.appliedForce.x=a.appliedForce.x||this.appliedForce.x,this.appliedForce.y=
a.appliedForce.y||this.appliedForce.y),this.direction=a.direction||this.direction,this.isDead=a.isDead||this.isDead,this.maxHitPoints=a.maxHitPoints||this.maxHitPoints,this.hitPoints=a.hitPoints||this.maxHitPoints,this.damage=a.damage||this.damage,this.defense=a.defense||this.defense,this.force=a.force||this.force,this.cooldown=a.cooldown||this.cooldown,this.range=a.range||this.range,this.invincibility=a.invincibility||this.invincibility,this.currentInvinciblity=a.currentInvinciblity||this.currentInvinciblity,
this.currentStun=a.currentStun||this.currentStun)};a.type="StatsComponent";e.exports=a},{"../../fejs/core/Component":32}],28:[function(b,e,m){function a(a){c.call(this);this.entitySystem=a}var c=b("../../fejs/core/system"),d=b("./StatsComponent");b("../../fejs/systems/display/DisplayComponent");var f=b("../../fejs/systems/actions/ActionComponent");a.prototype=Object.create(c.prototype);a.prototype.updateStun=function(a,c){var b=c[d.type];b.currentStun=0<b.currentStun?b.currentStun-a:0;if(!(0>=b.currentStun)&&
(b=c[f.type])){for(var h=b.actions,g=0,l;g<b.triggerActions.length;)l=h[b.triggerActions[g]],l.unblockable?g++:b.triggerActions.splice(g,1);for(g=0;g<h.length;g++)l=h[g],l.unblockable||b.stopActions.push(g)}};a.prototype.updateInvincibility=function(a,f){var c=f[d.type];c.currentInvinciblity=0<c.currentInvinciblity?c.currentInvinciblity-a:0};a.prototype.update=function(a){for(var f=this.entitySystem.getEntities(d.type).getAllRaw(),c=0;c<f.length;c++){var b=f[c];this.updateStun(a,b);this.updateInvincibility(a,
b)}};e.exports=a},{"../../fejs/core/system":39,"../../fejs/systems/actions/ActionComponent":55,"../../fejs/systems/display/DisplayComponent":64,"./StatsComponent":27}],29:[function(b,e,m){function a(a){c.call(this);this.sensorTileCollide=[];this.staticTileCollide=[];this.staticBodyCollide=[];this.sensorBodyCollide=[];this.bodyStartCollide=[];this.bodyStopCollide=[];this.justDeath=[];this.timers={};this.update=[];this.levelStart=[];this.levelEnd=[];this.setParams(a)}var c=b("../../fejs/core/Component");
a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){if(a){this.sensorTileCollide=c.copyPrimitiveArray(this.sensorTileCollide,a.sensorTileCollide);this.staticTileCollide=c.copyPrimitiveArray(this.staticTileCollide,a.staticTileCollide);this.sensorBodyCollide=c.copyPrimitiveArray(this.sensorBodyCollide,a.sensorBodyCollide);this.staticBodyCollide=c.copyPrimitiveArray(this.staticBodyCollide,a.staticBodyCollide);this.bodyStartCollide=c.copyPrimitiveArray(this.bodyStartCollide,a.bodyStartCollide);
this.bodyStopCollide=c.copyPrimitiveArray(this.bodyStopCollide,a.bodyStopCollide);this.justDeath=c.copyPrimitiveArray(this.justDeath,a.justDeath);if(a.timers)for(var f in a.timers)a.timers.hasOwnProperty(f)&&(this.timers[f]=c.copyPrimitiveArray([],a.timers[f]));this.update=c.copyPrimitiveArray(this.update,a.update);this.levelStart=c.copyPrimitiveArray(this.levelStart,a.levelStart);this.levelEnd=c.copyPrimitiveArray(this.levelEnd,a.levelEnd)}};a.type="ScriptsComponent";e.exports=a;e.exports.type=a.type},
{"../../fejs/core/Component":32}],30:[function(b,e,m){function a(a){c.call(this);this.timers=[];this.setParams(a)}var c=b("../../fejs/core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){if(a&&a.timers)for(var f=0;f<a.timers.length;f++){var c=a.timers[f];this.timers.push({name:c.name,current:c.current||0,duration:c.duration||0,removeOnComplete:c.removeOnComplete,resetOnComplete:c.resetOnComplete})}};a.type="TimeComponent";e.exports=a;e.exports.type=a.type},{"../../fejs/core/Component":32}],
31:[function(b,e,m){function a(a){c.call(this);this.entitySystem=a;this.timerCompleteCallbacks=[]}var c=b("../../fejs/core/system"),d=b("./TimeComponent");a.prototype=Object.create(c.prototype);a.prototype.update=function(a){this.entitySystem.getEntities(d.type).each(function(c,b){for(var e=c[d.type].timers,h=0;h<e.length;){var g=e[h];g.current+=a;if(g.current>=g.duration){g.resetOnComplete&&(g.current=0);for(var l=0;l<b.timerCompleteCallbacks.length;l++)b.timerCompleteCallbacks[l](c,g);if(g.removeOnComplete&&
0<=e.indexOf(g)){e.splice(h,1);continue}}h++}},this)};e.exports=a},{"../../fejs/core/system":39,"./TimeComponent":30}],32:[function(b,e,m){function a(){}a.prototype.setParams=function(a){};a.type="Component";a.copyField=function(a,d){return null===a||void 0===a?d:a};a.copyPrimitiveArray=function(a,d){return d?a.concat(d):a};e.exports=a;e.exports.copyPrimitiveArray=a.copyPrimitiveArray;e.exports.copyField=a.copyField},{}],33:[function(b,e,m){function a(){this.switcher=null}a.prototype.onAdd=function(a){};
a.prototype.onEnter=function(a){};a.prototype.update=function(a){};a.prototype.preRender=function(a){};a.prototype.postRender=function(a){};a.prototype.onLeave=function(a){};a.prototype.onRemove=function(a){};a.prototype.destroy=function(){};a.type="default";e.exports=a},{}],34:[function(b,e,m){function a(){this._states=[];this._activeStates=[]}var c=b("../utility/collections");a.prototype.update=function(a){for(var f=0;f<this._activeStates.length;f++)this._activeStates[f].update(a)};a.prototype.preRender=
function(a){for(var f=0;f<this._activeStates.length;f++)this._activeStates[f].preRender(a)};a.prototype.postRender=function(a){for(var f=0;f<this._activeStates.length;f++)this._activeStates[f].postRender(a)};a.prototype.addState=function(a,f){this._states.indexOf(a);c.contains(this._states,a)||(this._states.push(a),a.switcher||(a.switcher=this),a.onAdd(f))};a.prototype.removeState=function(a,f){if(c.contains(this._activeStates,a))return!1;a.onRemove(f);c.remove(this._states,a);return!0};a.prototype.retrieveState=
function(a){return this._states.find(function(f){return f.type===a?f:null})};a.prototype.switchState=function(a,f,c,b){var e=this._activeStates.indexOf(a);if(-1===e)return!1;this._states.indexOf(f);if(-1===e)return!1;a.onLeave(c);this._activeStates[e]=f;f.onEnter(b);return!0};a.prototype.enterState=function(a,f){if(!c.contains(this._states,a)||c.contains(this._activeStates,a))return!1;this._activeStates.push(a);a.onEnter(f);return!0};a.prototype.leaveState=function(a,f){if(!c.contains(this._states,
a))return!1;var b=this._activeStates.indexOf(a);if(-1===b)return!1;a.onLeave(f);this._activeStates.splice(b,1);return!0};e.exports=a},{"../utility/collections":83}],35:[function(b,e,m){(function(a){var c=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}(),d=0===a.argv.length;e.exports=function(a){function b(a){s.forEach(function(d){d(a)});
g.forEach(function(d){d.render(a)});t.forEach(function(d){d(a)})}function q(a){l.forEach(function(d){d(a)})}function e(){if(n){var a=Date.now(),f=a-u;if(d){h.stepSize&&(f=h.stepSize);var g;for(g=0;g<p.length;g++)p[g](f);q(f);b(f);for(g=0;g<p.length;g++)m[g](f);u=a}else if(f>=1E3/60){h.stepSize&&(f=h.stepSize);for(g=0;g<p.length;g++)p[g](f);q(f);b(f);for(g=0;g<p.length;g++)m[g](f);u=a}d?c(e):setImmediate(e)}}var h=this;this.stepSize=0;var g=[],l=[],s=[],t=[],n=!1,u=0,p=[],m=[];this.start=function(){n=
!0;u=Date.now();e()};this.stop=function(){n=!1};this.resize=function(a,d){g.forEach(function(f){f.resize(a,d)})};this.addRenderLayer=function(a){g.push(a)};this.removeRenderLayer=function(a){a=t.indexOf(a);-1<a&&g.splice(a,1)};this.addUpdateCallback=function(a){l.push(a)};this.removeUpdateCallback=function(a){a=l.indexOf(a);-1<a&&l.splice(a,1)};this.addPreRenderCallback=function(a){s.push(a)};this.removePreRenderCallback=function(a){a=t.indexOf(a);-1<a&&s.splice(a,1)};this.addPostRenderCallback=function(a){t.push(a)};
this.removePostRenderCallback=function(a){a=t.indexOf(a);-1<a&&t.splice(a,1)};this.addBeginCallback=function(a){p.push(a)};this.removeBeginCallback=function(a){a=p.indexOf(a);-1<a&&p.splice(a,1)};this.addEndCallback=function(a){m.push(a)};this.removeEndCallback=function(a){a=m.indexOf(a);-1<a&&m.splice(a,1)}}}).call(this,b("D:\\Projects\\Games\\LD29\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js"))},{"D:\\Projects\\Games\\LD29\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js":2}],
36:[function(b,e,m){(function(a){function c(a,f){this.window=a;this.document=f;this.navigator=a.navigator;this.focusElement=null;this.offsetY=this.offsetX=0;this.width=f?f.offsetWidth:0;this.height=f?f.offsetHeight:0;this.isMouseDown=this.isMouseReleased=this.isMouseClicked=!1;this.mouseY=this.mouseX=0;this.keysDown={};this.keysUp={};this.keysJustDown={};this.hotkeys={};this.enableGamePads=!0;this.deadZone=0.25;this.gamepads=[];this.gamepadsButtonsPrevious=[];this.gamepadSupportAvailable=this.navigator.getGamepads||
!!this.navigator.webkitGetGamepads||!!this.navigator.webkitGamepads;if(f){var c=f;if(c.offsetParent){do this.offsetX+=c.offsetLeft,this.offsetY+=c.offsetTop;while(c=c.offsetParent)}this.disableDefaults(f);f.ownerDocument.addEventListener("mousedown",function(a){this.focusElement=a.target}.bind(this),!1);f.addEventListener("mousedown",this.onMouseDown.bind(this),!1);f.addEventListener("mouseup",this.onMouseUp.bind(this),!1);f.addEventListener("mousemove",this.onMouseMove.bind(this),!1);f.ownerDocument.addEventListener("keydown",
this.onKeyDown.bind(this));f.ownerDocument.addEventListener("keyup",this.onKeyUp.bind(this))}}b("../utility/math");c.prototype.update=function(a){this.gamepadSupportAvailable&&this.enableGamePads&&this.updateGamePads()};c.prototype.onMouseDown=function(a){this.isMouseDown=this.isMouseClicked=!0};c.prototype.onMouseUp=function(a){this.isMouseDown=!1;this.isMouseReleased=!0};c.prototype.onMouseMove=function(a){this.mouseX=(a.pageX-this.offsetX-this.width/2)/(this.width/2);this.mouseY=-(a.pageY-this.offsetY-
this.height/2)/(this.height/2)};c.prototype.onKeyDown=function(a){a=a.keyCode;this.keysDown[a]||(this.keysJustDown[a]=!0);this.keysDown[a]=!0;if(this.hotkeys[a])for(var f=0;f<this.hotkeys[a].length;f++)this.keysDown[this.hotkeys[a][f]]=!0,this.keysJustDown[this.hotkeys[a][f]]=this.keysJustDown[a];return!1};c.prototype.onKeyUp=function(a){a=a.keyCode;this.keysDown[a]=!1;this.keysUp[a]=!0;if(this.hotkeys[a])for(var f=0;f<this.hotkeys[a].length;f++)this.keysDown[this.hotkeys[a][f]]=!1,this.keysUp[this.hotkeys[a][f]]=
!0};c.prototype.updateGamePads=function(){if(this.gamepadSupportAvailable&&this.enableGamePads){var a=navigator.getGamepads&&navigator.getGamepads()||navigator.webkitGetGamepads&&navigator.webkitGetGamepads(),f;if(a)for(this.gamepads=[],f=0;f<a.length;f++)a[f]&&this.gamepads.push(a[f]);var c,b=[];for(f=0;f<this.gamepads.length;f++){var e=this.gamepads[f];if(e){if(!this.gamepadsButtonsPrevious[f])for(this.gamepadsButtonsPrevious[f]=[],a=0;a<e.buttons.length;a++)this.gamepadsButtonsPrevious[f][a]=0;
b=[].concat(e.buttons);for(a=0;a<b.length;a++){e.axes[0]<-this.deadZone?b[14]=1:e.axes[0]>this.deadZone&&(b[15]=1);e.axes[1]<-this.deadZone?b[12]=1:e.axes[1]>this.deadZone&&(b[13]=1);var h=c=!1;this.gamepadsButtonsPrevious[f][a]<=this.deadZone&&b[a]>this.deadZone&&(c=!0);this.gamepadsButtonsPrevious[f][a]>this.deadZone&&b[a]<=this.deadZone&&(h=!0);var g="GP"+(f+1)+"-"+a;if(c&&(this.keysDown[g]||(this.keysJustDown[g]=!0,this.keysDown[g]=!0),this.hotkeys[g]&&this.keysJustDown[g]))for(c=0;c<this.hotkeys[g].length;c++)this.keysDown[this.hotkeys[g][c]]=
!0,this.keysJustDown[this.hotkeys[g][c]]=this.keysJustDown[g];if(h&&(this.keysDown[g]&&(this.keysDown[g]=!1,this.keysUp[g]=!0),this.hotkeys[g]))for(c=0;c<this.hotkeys[g].length;c++)this.keysDown[this.hotkeys[g][c]]&&(this.keysDown[this.hotkeys[g][c]]=!1,this.keysUp[this.hotkeys[g][c]]=!0);this.gamepadsButtonsPrevious[f][a]=b[a]}}}}};c.prototype.flush=function(){this.isMouseReleased=this.isMouseClicked=!1;this.keysUp={};this.keysJustDown={}};c.prototype.unproject=function(a,f){var c,b,e,h=new THREE.Vector3(this.mouseX,
this.mouseY,1);(new THREE.Projector).unprojectVector(h,a);var g=new THREE.Raycaster;g.set(a.position,h.sub(a.position).normalize());h=g.intersectObject(f,!1);0<h.length&&(e=h[0].point,c=e.x,b=e.y,e=e.z);return{x:c,y:b,z:e}};c.prototype.addHotkey=function(a,f){this.hotkeys[a]||(this.hotkeys[a]=[]);-1===this.hotkeys[a].indexOf(f)&&this.hotkeys[a].push(f)};c.prototype.removeHotkey=function(a,f){if(this.hotkeys[a]){var c=this.hotkeys[a].indexOf(f);-1!==c&&this.hotkeys[a].splice(c,1)}};c.prototype.disableDefaults=
function(a){function f(a){a.preventDefault()}a.addEventListener("contextmenu",function(a){a.preventDefault()},!1);a.addEventListener("DOMMouseScroll",function(a){f(a)},!1);a.onmousewheel=f;a.ownerDocument.addEventListener("keydown",function(a){this.focusElement===this.document&&-1<[32,37,38,39,40].indexOf(a.keyCode)&&a.preventDefault()}.bind(this),!1)};c.CharToKeyCode=function(a){return a.charCodeAt(0)};c.CharCodes={Space:32,Left:37,Up:38,Right:39,Down:40,Shift:16,Ctrl:17,Alt:18,Tab:9,CapsLock:20};
c.P1PadCodes={AxisX:"GP1-AX",AxisY:"GP1-AY",AxisZ:"GP1-AZ",Left:"GP1-14",Up:"GP1-12",Right:"GP1-15",Down:"GP1-13",ButtonLeft:"GP1-2",ButtonUp:"GP1-3",ButtonRight:"GP1-1",ButtonDown:"GP1-0",L1:"GP1-4",R1:"GP1-5",L2:"GP1-6",R2:"GP1-7",L3:"GP1-10",R3:"GP1-11",Select:"GP1-8",Start:"GP1-9"};e.exports=c;e.exports.CharCodes=c.CharCodes;e.exports.P1PadCodes=c.P1PadCodes}).call(this,b("D:\\Projects\\Games\\LD29\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js"))},
{"../utility/math":84,"D:\\Projects\\Games\\LD29\\node_modules\\browserify\\node_modules\\insert-module-globals\\node_modules\\process\\browser.js":2}],37:[function(b,e,m){function a(){}a.prototype.render=function(a){};a.prototype.resize=function(a,d){};e.exports=a},{}],38:[function(b,e,m){function a(){this.images=[];this.spritesheets=[];this.sounds={};this.data={};this.jsonData={};this.progressCallbacks=[]}var c=b("./../utility/collections");a.prototype.loadFromResourcesFile=function(a,f){var c=
this,b=new PIXI.AjaxRequest;b.onreadystatechange=function(a){return function(){if(4===a.readyState&&(200===a.status||-1===window.location.protocol.indexOf("http"))){var d=JSON.parse(a.responseText);c.images=c.images.concat(d.images);c.spritesheets=c.spritesheets.concat(d.spritesheets);var b;for(b=0;b<d.sounds.length;b++)c.sounds[d.sounds[b]]=null;for(b=0;b<d.data.length;b++)c.data[d.data[b]]=null;c.loadAll(f)}}}(b);b.open("GET",a,!0);b.send()};a.prototype.loadAll=function(a){function f(){for(var a=
0;a<e.progressCallbacks.length;a++)e.progressCallbacks[a](h,g)}function b(c,g){return function(){4!==c.readyState||200!==c.status&&-1!==window.location.protocol.indexOf("http")||(e.data[g]=c.responseText,l++,h++,f(),l>=s&&a())}}function q(){l++;h++;f();l>=s&&a()}var e=this,h=0,g=this.images.length+c.objectSize(this.data)+c.objectSize(this.sounds),l=0,s=c.objectSize(this.data)+c.objectSize(this.sounds),t=new PIXI.AssetLoader(this.images);t.onComplete=function(){e.spritesheets.forEach(function(a){(new PIXI.ImageLoader(a.texture)).loadFramedSpriteSheet(a.width,
a.height,a.name)});for(var f in e.sounds)e.sounds.hasOwnProperty(f)&&(e.sounds[f]=new Howl({urls:[f],onload:q,onloaderror:q}));if(0===s)a();else for(f in e.data)if(e.data.hasOwnProperty(f)){var c=new PIXI.AjaxRequest;c.onreadystatechange=b(c,f);c.open("GET",f,!0);c.send()}};t.onProgress=function(){h++;f()};t.load()};a.prototype.getJson=function(a){if(!this.jsonData[a]){if(!this.data[a])return null;this.jsonData[a]=JSON.parse(this.data[a])}return this.jsonData[a]};e.exports=a},{"./../utility/collections":83}],
39:[function(b,e,m){function a(){}e.exports=a;a.prototype.preUpdate=function(a){};a.prototype.update=function(a){};a.prototype.cleanup=function(){};a.prototype.destroy=function(){}},{}],40:[function(b,e,m){function a(){this._tweens=[]}function c(){this.isComplete=!1;this._startValues={};this._endValues={};this._currentValues={};this.delay=this.currentRepeat=this.repeat=0;this.duration=1E3;this.currentDuration=0;this.easing=c.Easing.Linear.None;this.onCompleteCallback=this.onUpdateCallback=this.onStartCallback=
this.chainedTween=this.parent=null;this.userData={}}var d=b("../utility/collections");e.exports.TweenSystem=a;a.prototype.add=function(a,c){c&&a.reset();if(!d.contains(this._tweens,a))if(a.isComplete)for(var b=a;b&&b.isComplete;){if((b=b.chainedTween)&&!b.isComplete){this._tweens.push(b);break}}else this._tweens.push(a)};a.prototype.remove=function(a){d.remove(this._tweens,a)};a.prototype.contains=function(a){return d.contains(this._tweens,a)};a.prototype.update=function(a){for(var c=0,d=[];c<this._tweens.length;){var b=
this._tweens[c];b.update(a);b.isComplete?(this._tweens.splice(c,1),b.chainedTween&&(d.push(b.chainedTween),b.chainedTween.parent=b)):c++}for(c=0;c<d.length;c++)this.add(d[c])};e.exports.Tween=c;c.prototype.update=function(a){if(!this.isComplete&&this._startValues&&this._endValues){if(0===this.currentDuration&&this.onStartCallback)this.onStartCallback(this);this.currentDuration+=a;a=this.currentDuration-this.delay;if(a>=this.duration){for(var c in this._endValues)this._currentValues[c]=parseFloat(this._endValues[c]);
if(0===this.repeat||this.currentRepeat>=this.repeat){if(this.onCompleteCallback)this.onCompleteCallback(this);this.isComplete=!0}else this.currentRepeat++,this.currentDuration=0}if(!this.isComplete){if(0<=a)for(c in a=this.easing(a/this.duration),this._currentValues){var d=this._startValues[c]||0;this._currentValues[c]=d+((this._endValues[c]||0)-d)*a}if(this.onUpdateCallback)this.onUpdateCallback(this)}}};c.prototype.reset=function(){this.isComplete=!1;this.currentTime=this.currentRepeat=0;this._startValues&&
this._endValues&&this.from(this._startValues)};c.prototype.getStartValues=function(){return this._startValues};c.prototype.getEndValues=function(){return this._endValues};c.prototype.getCurrentValues=function(){return this._currentValues};c.prototype.from=function(a){for(var c in a)this._currentValues[c]=parseFloat(a[c]);this._startValues=a;return this};c.prototype.to=function(a){this._endValues=a;return this};c.prototype.withRepeat=function(a){this.repeat=a;return this};c.prototype.withDuration=
function(a){this.duration=a;return this};c.prototype.withDelay=function(a){this.delay=a;return this};c.prototype.withEasing=function(a){this.easing=a;return this};c.prototype.chain=function(a){this.chainedTween=a;return this};c.prototype.onStart=function(a){this.onStartCallback=a;return this};c.prototype.onUpdate=function(a){this.onUpdateCallback=a;return this};c.prototype.onComplete=function(a){this.onCompleteCallback=a;return this};c.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*
a},Out:function(a){return a*(2-a)},InOut:function(a){return 1>(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a:0.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a:-0.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*
a*a:0.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return 0.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:1>(a*=2)?0.5*Math.pow(1024,a-1):0.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*
a)},InOut:function(a){return 1>(a*=2)?-0.5*(Math.sqrt(1-a*a)-1):0.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var c,d=0.1;if(0===a)return 0;if(1===a)return 1;!d||1>d?(d=1,c=0.1):c=0.4*Math.asin(1/d)/(2*Math.PI);return-(d*Math.pow(2,10*(a-=1))*Math.sin(2*(a-c)*Math.PI/0.4))},Out:function(a){var c,d=0.1;if(0===a)return 0;if(1===a)return 1;!d||1>d?(d=1,c=0.1):c=0.4*Math.asin(1/d)/(2*Math.PI);return d*Math.pow(2,-10*a)*Math.sin(2*(a-c)*Math.PI/0.4)+1},InOut:function(a){var c,d=0.1;if(0===a)return 0;
if(1===a)return 1;!d||1>d?(d=1,c=0.1):c=0.4*Math.asin(1/d)/(2*Math.PI);return 1>(a*=2)?-0.5*d*Math.pow(2,10*(a-=1))*Math.sin(2*(a-c)*Math.PI/0.4):d*Math.pow(2,-10*(a-=1))*Math.sin(2*(a-c)*Math.PI/0.4)*0.5+1}},Back:{In:function(a){return a*a*(2.70158*a-1.70158)},Out:function(a){return--a*a*(2.70158*a+1.70158)+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*(3.5949095*a-2.5949095):0.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)}},Bounce:{In:function(a){return 1-c.Easing.Bounce.Out(1-a)},Out:function(a){return a<
1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375},InOut:function(a){return 0.5>a?0.5*c.Easing.Bounce.In(2*a):0.5*c.Easing.Bounce.Out(2*a-1)+0.5}}}},{"../utility/collections":83}],41:[function(b,e,m){function a(){this._objects=[]}a.prototype.add=function(a){return this.contains(a)?!1:(this._objects.push(a),!0)};a.prototype.remove=function(a){a=this._objects.indexOf(a);return-1<a?(this._objects.splice(a,1),!0):!1};a.prototype.each=
function(a,d){for(var b=0;b<this._objects.length;b++)a(this._objects[b],d)};a.prototype.contains=function(a){return-1<this._objects.indexOf(a)};a.prototype.size=function(){return this._objects.length};a.prototype.getAll=function(){var a=[];return a=a.concat(this._objects)};a.prototype.clear=function(){this._objects=[]};e.exports=a},{}],42:[function(b,e,m){e.exports={debug:null,frame:0,timeElapsed:0}},{}],43:[function(b,e,m){function a(){this.gui=new dat.GUI;this.folders={};this.folders.Debug=this.gui.addFolder("Debug");
this.folders.Debug.open()}var c=b("../utility/collections");a.Globals={};a.prototype.addControl=function(a,b,e){var q;e=e||{};e.folder?(c.objectContainsKey(this.folders,e.folder)||(this.folders[e.folder]=this.gui.addFolder(e.folder)),q=this.folders[e.folder],q.open()):q=this.folders.Debug;a=q.add(a,b);e.name&&a.name(e.name);e.min&&a.min(e.min);e.max&&a.max(e.max);e.step&&a.step(e.step);e.listen&&a.listen()};e.exports=a},{"../utility/collections":83}],44:[function(b,e,m){e.exports=function(a){this.name=
"";this.userData={};if(void 0===a||null===a||"number"!==typeof a&&"string"!==typeof a)throw new TypeError("Invalid ID");this.getID=function(){return a};this.toString=function(){return"entity"+a};Object.defineProperty(this,"id",{get:function(){return a},set:function(a){throw Error("Cannot set entity ID after creation.");}})}},{}],45:[function(b,e,m){var a=b("../datastructures/set");e.exports=function(){var c=new a,d=new a,b=new a,e=new a,q=[],r=[],h=[];this.add=function(a){if(c.add(a)){e.remove(a);
b.remove(a);d.add(a);for(var l=0;l<q.length;l++)q[l](a)}};this.change=function(a){if(c.contains(a)){b.add(a);for(var d=0;d<r.length;d++)r[d](a)}};this.remove=function(a){if(c.remove(a)){d.remove(a);b.remove(a);e.add(a);for(var l=0;l<h.length;l++)h[l](a)}};this.each=function(a,d){c.each(a,d)};this.eachAdded=function(a,c){d.each(a,c)};this.eachChanged=function(a,c){b.each(a,c)};this.eachRemoved=function(a,c){e.each(a,c)};this.contains=function(a){return c.contains(a)};this.size=function(){return c.size()};
this.flush=function(){d.clear();b.clear();e.clear()};this.getAll=function(){return c.getAll()};this.getAllRaw=function(){return c._objects};this.addAddedCallback=function(a){q.push(a)};this.removeAddedCallback=function(a){a=q.indexOf(a);0<=a&&q.splice(a,1)};this.addChangedCallback=function(a){r.push(a)};this.removeChangedCallback=function(a){a=r.indexOf(a);0<=a&&r.splice(a,1)};this.addRemovedCallback=function(a){h.push(a)};this.removeRemovedCallback=function(a){a=h.indexOf(a);0<=a&&h.splice(a,1)};
this.clear=function(){c.clear();this.flush();q=[];r=[];h=[]}}},{"../datastructures/set":41}],46:[function(b,e,m){var a=b("../utility/collections"),c=b("./entity"),d=b("./entityset"),f=b("../utility/math");e.exports=function(){this.isLazySets=!1;this.useUUID=!0;var b=0,e={},r={},h={},g={};this.createEntity=function(a){a=a?new c(a):this.useUUID?new c(f.generateUUID()):new c(b);e[a.getID()]=a;b++;r[a.getID()]={};return a};this.hasEntity=function(a){var c=e[a.getID()];return c?c===a:!1};this.getEntityByID=
function(a){return e[a]?e[a]:null};this.getEntityByName=function(a){for(var c in e)if(e.hasOwnProperty(c)&&e[c].name===a)return e[c];return null};this.removeEntity=function(a){if(e[a.getID()]){h[a.getID()]=r[a.getID()];for(var c in g)g[c].remove(a);delete e[a.getID()]}};this.getComponent=function(c,d){var b=null;if(a.objectContainsKey(r,c.getID())){b=r[c.getID().toString()];if(a.objectContainsKey(b,d))return b[d];b=null}return null===b&&a.objectContainsKey(h,c.getID())&&(b=h[c.getID()],a.objectContainsKey(b,
d))?b[d]:null};this.setComponent=function(c,b,f){if(e[c.getID()]){var h=r[c.getID().toString()];c[b]=f;var k;if(a.objectContainsKey(g,b))k=g[b];else{if(this.isLazySets){h[b]=f;return}k=new d;g[b]=k}a.objectContainsKey(h,b)?k.change(c):k.add(c);h[b]=f}};this.hasComponent=function(c,d){if(!a.objectContainsKey(r,c.getID()))return!1;var b=r[c.getID().toString()];return a.objectContainsKey(b,d)};this.removeComponent=function(c,d){if(a.objectContainsKey(r,c.getID())){var b=r[c.getID().toString()];a.objectContainsKey(h,
c.getID())||(h[c.getID().toString()]={});h[c.getID()][d]=b[d];delete r[c.getID()][d];a.objectContainsKey(g,d)&&g[d].remove(c)}};this.getEntities=function(c){if(!a.objectContainsKey(g,c)){var b=new d,f;for(f in e)this.hasComponent(e[f],c)&&b.add(e[f]);g[c]=b}return g[c]};this.flushChanges=function(){for(var a in g)g.hasOwnProperty(a)&&g[a].flush();h={}};this.removeAllEntities=function(){for(var a in e)e.hasOwnProperty(a)&&this.removeEntity(e[a])}}},{"../utility/collections":83,"../utility/math":84,
"./entity":44,"./entityset":45}],47:[function(b,e,m){function a(a,d){this.viewport=a;this.input=d;this.mouseCanvasPosition={x:0,y:0};this.mouseViewPosition={x:0,y:0}}a.prototype.update=function(){var a=this.viewport.camera;this.mouseCanvasPosition.x=this.input.mouseX*this.viewport.width/2;this.mouseCanvasPosition.y=-this.input.mouseY*this.viewport.height/2;this.mouseViewPosition.x=a.position.x+this.input.mouseX*this.viewport.width/2/a.scale.x;this.mouseViewPosition.y=a.position.y-this.input.mouseY*
this.viewport.height/2/a.scale.y};e.exports=a},{}],48:[function(b,e,m){function a(){this.tileLayers={};this.tileHeight=this.tileWidth=this.height=this.width=0;this.properties={};this.objectLayers={};this.regionLayers={}}function c(a){var c=[],d=parseInt(a.attributes.width.nodeValue),b=parseInt(a.attributes.height.nodeValue),e,g;for(e=0;e<b;e++)for(c.push([]),g=0;g<d;g++)c[e][g]=0;a=a.getElementsByTagName("data")[0].innerHTML;a=atob(a.replace(/\s/g,""));a=a.split("").map(function(a){return a.charCodeAt(0)});
a=(new Zlib.Inflate(a)).decompress();b=[];for(e=0;e<a.length;e++)0===e%4&&b.push(a[e]);for(e=0;e<b.length;e++)c[Math.floor(e/d)][e%d]=b[e];return c}function d(a){var c=a,d=parseFloat(a);2!==a.split(".").length||isNaN(d)||(c=d);return c}a.prototype.loadFromTMX=function(a){a=(new DOMParser).parseFromString(a,"text/xml");var b=a.getElementsByTagName("map")[0];this.width=parseInt(b.attributes.width.nodeValue);this.height=parseInt(b.attributes.height.nodeValue);this.tileWidth=parseInt(b.attributes.tilewidth.nodeValue);
this.tileHeight=parseInt(b.attributes.tileheight.nodeValue);a.getElementsByTagName("tileset");var b=a.getElementsByTagName("tileset")[1].attributes.firstgid.nodeValue,e=a.getElementsByTagName("layer"),r,h,g;for(h=0;h<e.length;h++){var l=e[h];r=l.attributes.name.nodeValue;this.tileLayers[r]=c(l)}var e=a.getElementsByTagName("objectgroup"),s,t,n,u;for(h=0;h<e.length;h++){s=e[h];r=s.attributes.name.nodeValue;var l=[],p=[];this.objectLayers[r]=l;this.regionLayers[r]=p;s=s.getElementsByTagName("object");
for(r=0;r<s.length;r++){g=s[r];var m={x:parseFloat(g.attributes.x.nodeValue)+this.tileWidth/2,y:parseFloat(g.attributes.y.nodeValue)-this.tileHeight/2};g.attributes.name&&(m.name=g.attributes.name.nodeValue);g.attributes.type&&(m.type=g.attributes.type.nodeValue);g.attributes.gid?(m.gid=g.attributes.gid.nodeValue-b,l.push(m)):(m.width=parseFloat(g.attributes.width.nodeValue),m.height=parseFloat(g.attributes.height.nodeValue),m.x=parseFloat(g.attributes.x.nodeValue)+m.width/2,m.y=parseFloat(g.attributes.y.nodeValue)+
m.height/2,p.push(m));t=g.getElementsByTagName("properties");if(0<t.length)for(t=t[0].getElementsByTagName("property"),g=0;g<t.length;g++)n=t[g],u=n.attributes.name.nodeValue,n=n.attributes.value.nodeValue,n=d(n),m[u]=n}}if(s=a.getElementsByTagName("properties")[0])for(t=s.getElementsByTagName("property"),h=0;h<t.length;h++)n=t[h],u=n.attributes.name.nodeValue,n=n.attributes.value.nodeValue,n=d(n),this.properties[u]=n};e.exports=a},{}],49:[function(b,e,m){function a(a){c.call(this);this.renderer=
new PIXI.WebGLRenderer(1366,768);this.stage=new PIXI.Stage;a.appendChild(this.renderer.view)}var c=b("../core/renderlayer");a.prototype=Object.create(c.prototype);a.prototype.render=function(a){this.renderer.render(this.stage)};a.prototype.resize=function(a,c){this.renderer.resize(a,c)};e.exports=a},{"../core/renderlayer":37}],50:[function(b,e,m){function a(a){this.display=new PIXI.DisplayObjectContainer;this.scenes=[];this.camera=a;this.height=this.width=0;this.isCameraRounded=!0}a.prototype.getCalculatedCameraX=
function(){var a=-this.camera.position.x*this.camera.scale.x+this.width/2;return this.isCameraRounded?Math.round(a):a};a.prototype.getCalculatedCameraY=function(){var a=-this.camera.position.y*this.camera.scale.y+this.height/2;return this.isCameraRounded?Math.round(a):a};a.prototype.update=function(){if(this.camera)for(var a=0;a<this.scenes.length;a++){var d=this.scenes[a],b=d.display;b.position.x=this.getCalculatedCameraX();b.position.y=this.getCalculatedCameraY();b.scale.x=this.camera.scale.x;b.scale.y=
this.camera.scale.y;b.rotation=this.camera.rotation;d.isLocked&&(b.position.x=this.width/2,b.position.y=this.height/2)}};a.prototype.addScene=function(a){this.display.addChild(a.display);this.scenes.push(a)};a.prototype.removeScene=function(a){this.display.removeChild(a.display);a=this.scenes.indexOf(a);-1!==a&&this.scenes.splice(a,1)};a.prototype.addTo=function(a){a.addChild(this.display)};a.prototype.removeFromParent=function(){this.display.parent&&this.display.parent.removeChild(this.display)};
e.exports=a;e.exports.ViewportScene=function(){this.display=new PIXI.DisplayObjectContainer;this.isLocked=!1}},{}],51:[function(b,e,m){function a(){this.camera=null;this.position={x:0,y:0};this.rotation=0;this.scale={x:1,y:1}}a.prototype.update=function(){};e.exports=a},{}],52:[function(b,e,m){function a(){PIXI.AbstractFilter.call(this);this.passes=[this];this.uniforms={r:{type:"1f",value:1},g:{type:"1f",value:1},b:{type:"1f",value:1}};this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;",
"varying vec4 vColor;","uniform sampler2D uSampler;","uniform float r;","uniform float g;","uniform float b;","void main(void) {","   vec4 color = texture2D(uSampler, vTextureCoord);","   color.r = color.r * r;","   color.g = color.g * g;","   color.b = color.b * b;","   gl_FragColor = color;","}"]}a.prototype=Object.create(PIXI.AbstractFilter.prototype);a.prototype.constructor=a;a.prototype.setColor=function(a,d,b){this.uniforms.r.value=a;this.uniforms.g.value=d;this.uniforms.b.value=b};e.exports=
a},{}],53:[function(b,e,m){e.exports=b(50)},{}],54:[function(b,e,m){function a(a){c.call(this);this.position={x:0,y:0};this.scale={x:1,y:1};this.direction=this.rotation=0;this.setParams(a)}var c=b("../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(a.position&&(this.position.x=a.position.x||this.position.x,this.position.y=a.position.y||this.position.y),a.scale&&(this.scale.x=a.scale.x||1,this.scale.y=a.scale.y||1),this.rotation=a.rotation||0,this.direction=
c.copyField(a.direction,this.direction))};a.type="SpatialComponent";e.exports=a;e.exports.type=a.type},{"../core/Component":32}],55:[function(b,e,m){function a(a){c.call(this);this.actions=[];this.areActionsBlocked=!1;this.triggerActions=[];this.stopActions=[];this.setParams(a)}var c=b("../../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){if(a){if(a.actions)for(var c=0;c<a.actions.length;c++){var b=a.actions[c];if("string"!==typeof b){var e={},r;for(r in b)if(b.hasOwnProperty(r))if("userData"===
r){e.userData={};for(var h in b[r])b[r].hasOwnProperty(h)&&(e.userData[h]=b[r][h])}else e[r]=b[r];this.actions.push(e)}}this.areActionsBlocked=!1;this.triggerActions=a.triggerActions?this.triggerActions.concat(a.triggerActions):[];this.stopActions=a.stopActions?this.stopActions.concat(a.stopActions):[]}};a.type="ActionComponent";e.exports=a},{"../../core/Component":32}],56:[function(b,e,m){function a(){}a.prototype.onAdd=function(a){};a.prototype.onUpdate=function(a){};a.prototype.onStart=function(a){};
a.prototype.onTrigger=function(a){};a.prototype.onActivating=function(a){};a.prototype.onStop=function(a){};a.type="ActionScript";e.exports=a},{}],57:[function(b,e,m){function a(){this.action=null;this.isActive=!1;this.index=0;this.entity=null;this.currentCooldown=0;this.position={x:0,y:0};this.duration=this.countdown=this.direction=this.rotation=0;this.isStopped=!1;this.timePerFrame=16;this.userData={}}function c(a){d.call(this);this.entitySystem=a;this.scripts={};this.activeActions={};this.actionAddCallbacks=
[];this.actionTriggerCallbacks=[];this.actionUpdateCallbacks=[];this.actionStartCallbacks=[];this.actionStopCallbacks=[];this.actionActivatingCallbacks=[];a=this.entitySystem.getEntities(f.type);a.addAddedCallback(this.onAdd.bind(this));a.addChangedCallback(this.onAdd.bind(this));a.addRemovedCallback(this.onRemoved.bind(this))}var d=b("../../core/system"),f=b("./ActionComponent"),k=b("../SpatialComponent");c.prototype=Object.create(d.prototype);c.prototype.onAdd=function(c){var d=c[f.type].actions,
b=this.activeActions[c.id];this.activeActions[c.id]=[];for(var g=this.activeActions[c.id],e=0;e<d.length;e++){var k=d[e];if(!b||!b[e]||b[e].action!==k){var t=new a;t.currentCooldown=k.startingCooldown||t.currentCooldown;t.action=k;t.entity=c;t.index=e;g.push(t);if(k=this.scripts[k.script])for(k.onAdd(t),k=0;k<this.actionAddCallbacks.length;k++)this.actionAddCallbacks[k](t)}}};c.prototype.onRemoved=function(a){delete this.activeActions[a.id]};c.prototype.resetActiveAction=function(a){a.isActive=!1;
a.currentCooldown=a.action.cooldown;a.isStopped=!1;a.duration=0;a.countdown=a.action.castTime};c.prototype.unblockActions=function(a,c){for(var d=this.activeActions[a.id],b=!0,e=0;e<d.length;e++)if(d[e]!==c&&d[e].action.blockActions){b=!1;break}b&&(a[f.type].areActionsBlocked=!1)};c.prototype.update=function(a){var c,d=this.entitySystem.getEntities(f.type).getAllRaw(),b,e,k,t;for(b=0;b<d.length;b++){k=d[b];var n=this.activeActions[k.id];for(c=0;c<n.length;c++)t=n[c],t.currentCooldown-=a,0>t.currentCooldown&&
(t.currentCooldown=0);c=k[f.type];for(e=0;e<c.triggerActions.length;e++)-1!==c.triggerActions[e]&&this.activateAction(k,c.triggerActions[e]);for(e=0;e<c.stopActions.length;e++)-1!==c.stopActions[e]&&this.stopAction(k,c.stopActions[e]);0<c.triggerActions.length&&(c.triggerActions=[]);0<c.stopActions.length&&(c.stopActions=[]);for(c=0;c<n.length;c++){t=n[c];e=t.action;t.timePerFrame=a;var u=this.scripts[e.script];if(u){u.onUpdate(t);for(e=0;e<this.actionUpdateCallbacks.length;e++)this.actionUpdateCallbacks[e](t);
if(t.isActive){t.countdown-=a;e=t.duration;t.duration+=a;if(0===e)for(u.onStart(t),e=0;e<this.actionStartCallbacks.length;e++)this.actionStartCallbacks[e](t);if(0>=t.countdown){this.unblockActions(k,t);u.onTrigger(t);for(e=0;e<this.actionTriggerCallbacks.length;e++)this.actionTriggerCallbacks[e](t);this.resetActiveAction(t)}else if(t.isStopped){this.unblockActions(k,t);u.onStop(t);for(e=0;e<this.actionStopCallbacks.length;e++)this.actionStopCallbacks[e](t);this.resetActiveAction(t)}else for(u.onActivating(t),
e=0;e<this.actionActivatingCallbacks.length;e++)this.actionActivatingCallbacks[e](t)}}}}};c.prototype.stopAction=function(a,c){var d=this.activeActions[a.id];d&&(d=d[c])&&d.isActive&&(d.isStopped=!0)};c.prototype.activateAction=function(a,c){var d=a[f.type];if(d){var b=this.activeActions[a.id];if(b){var e=b[c],s=e.action;if(s&&e&&!e.isActive&&(s.unblockable||!d.areActionsBlocked)&&0>=e.currentCooldown){if(s.blockActions)for(d.areActionsBlocked=!0,d=0;d<b.length;d++)b[d]!==e&&(b[d].isStopped=!0);if(b=
a[k.type])e.position.x=b.position.x,e.position.y=b.position.y,e.rotation=b.rotation,e.direction=b.direction;e.countdown=s.castTime;e.duration=0;e.isActive=!0}}}};c.prototype.addScript=function(a,c){this.scripts[a]=c};c.getActionIndicesByHotkey=function(a,c){for(var d=[],b=0;b<a.actions.length;b++)a.actions[b].hotkey===c&&d.push(b);return d};e.exports=c;e.exports.getActionIndicesByHotkey=c.getActionIndicesByHotkey},{"../../core/system":39,"../SpatialComponent":54,"./ActionComponent":55}],58:[function(b,
e,m){function a(a){c.call(this);this.scripts=[];this.currentDuration=0;this.target=null;this.targetPosition={x:0,y:0};this.setParams(a)}var c=b("../../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){if(a){if(a.scripts)for(var c=0;c<a.scripts.length;c++){var b=a.scripts[c];if("string"!==typeof b){var e={},r;for(r in b)if(b.hasOwnProperty(r))if("userData"===r){e.userData={};for(var h in b[r])b[r].hasOwnProperty(h)&&(e.userData[h]=b[r][h])}else e[r]=b[r];this.scripts.push(e)}}this.currentDuration=
a.currentDuration||this.currentDuration;this.target=a.target||this.target;a.targetPosition&&(this.targetPosition.x=a.targetPosition.x||this.targetPosition.x,this.targetPosition.y=a.targetPosition.y||this.targetPosition.y)}};a.type="AIComponent";e.exports=a},{"../../core/Component":32}],59:[function(b,e,m){function a(){}a.prototype.onStart=function(a){};a.prototype.onTarget=function(a,b,f){};a.prototype.update=function(a){};a.type="AIScript";e.exports=a},{}],60:[function(b,e,m){function a(){this.script=
this.entity=null;this.period=this.counter=this.duration=0;this.target=null;this.targetPosition={x:0,y:0};this.userData={}}function c(a){d.call(this);this.entitySystem=a;this.scripts={};this.entityMap={};a=a.getEntities(f.type);a.addAddedCallback(this.onAdded.bind(this));a.addChangedCallback(this.onAdded.bind(this));a.addRemovedCallback(this.onRemoved.bind(this))}var d=b("../../core/system"),f=b("./AIComponent");c.prototype=Object.create(d.prototype);c.prototype.onAdded=function(c){var b=c[f.type],
d=b.scripts;if(d){this.entityMap[c.id]=[];for(var e=0;e<d.length;e++){var g=new a;g.script=d[e];g.entity=c;this.entityMap[c.id].push(g);var l=!1;b.target&&(g.target=b.target,l=!0);0!==b.targetPosition.x&&0!==b.targetPosition.y&&(g.targetPosition.x=b.targetPosition.x,g.targetPosition.y=b.targetPosition.y,l=!0);if(l&&(l=this.scripts[g.script.script]))l.onTarget(g,null,g.target)}}};c.prototype.onRemoved=function(a){delete this.entityMap[a.id]};c.prototype.update=function(a){for(var c=this.entitySystem.getEntities(f.type).getAllRaw(),
b=0;b<c.length;b++){var d=c[b],e=d[f.type];if(d=this.entityMap[d.id])for(var l=0;l<d.length;l++){var s=d[l],t=this.scripts[s.script.script];if(t){if(0>=s.duration)s.duration=0,t.onStart(s);else{s.counter+=a;s.period=s.counter;if(s.counter>=s.script.rate)s.counter=0;else{s.duration+=a;continue}var n=!1;if(s.targetPosition.x!==e.targetPosition.x||s.targetPosition.y!==e.targetPosition.y)n=!0;e.target?s.target?e.target!==s.target.id&&(n=!0):n=!0:s.target&&(n=!0);n&&(n=s.target,s.target=e.target?this.entitySystem.getEntityByID(e.target):
null,s.targetPosition.x=e.targetPosition.x,s.targetPosition.y=e.targetPosition.y,t.onTarget(s,n,e.target));t.update(s)}s.duration+=a}}}};c.prototype.addScript=function(a,c){this.scripts[a]=c};e.exports=c},{"../../core/system":39,"./AIComponent":58}],61:[function(b,e,m){function a(a){c.call(this);this.timePerFrame=32;this.loop=!1;this.playAnimation=null;this.stopAnimation=!1;this.stopTexture=null;this.priority=this.startTime=this.stopFrame=0;this.setParams(a)}var c=b("../../core/Component");a.prototype=
Object.create(c.prototype);a.prototype.setParams=function(a){a&&(this.timePerFrame=a.timePerFrame||this.timePerFrame,this.loop=a.loop||this.loop,this.playAnimation=a.playAnimation||this.playAnimation,this.stopAnimation=a.stopAnimation||this.stopAnimation,this.stopTexture=a.stopTexture||this.stopTexture,this.startTime=a.startTime||this.startTime,this.priority=a.priority||this.priority,this.stopFrame=a.stopFrame||this.stopFrame)};a.type="AnimationComponent";e.exports=a},{"../../core/Component":32}],
62:[function(b,e,m){function a(a){c.call(this);this.entitySystem=a}var c=b("../../core/system"),d=b("./Character"),f=b("./DisplayComponent"),k=b("./AnimationComponent");a.prototype=Object.create(c.prototype);a.prototype.update=function(a){for(var c=this.entitySystem.getEntities(k.type).getAllRaw(),b={},e=0;e<c.length;e++){var l=c[e],s=l[f.type];if(s){s=s.displayable;if(!(s instanceof d))break;s.update(a);l=l[k.type];l.currentAnimation!==l.playAnimation&&(l.currentAnimation=l.playAnimation,b.timePerFrame=
l.timePerFrame,b.loop=l.loop,b.priority=l.priority,b.startTime=l.startTime,b.stopTexture=l.stopTexture,b.stopFrame=l.stopFrame,s.playAnimation(l.currentAnimation,b));l.stopAnimation&&(l.currentAnimation=null,s.stopAnimation());l.playAnimation=null;l.stopAnimation=!1}}};e.exports=a},{"../../core/system":39,"./AnimationComponent":61,"./Character":63,"./DisplayComponent":64}],63:[function(b,e,m){function a(){PIXI.DisplayObjectContainer.call(this);this.partAnimations={}}a.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);
a.prototype.update=function(a){var b,f,e;for(e in this.partAnimations)if(b=this.partAnimations[e],b.currentAnimation&&(f=b.animations[b.currentAnimation]))!b.loop&&b.time>b.animations[b.currentAnimation].length*b.timePerFrame?(b.stopTexture?f=b.stopTexture:(f=b.animations[b.currentAnimation],f=f[b.stopFrame]),f=PIXI.Texture.fromImage(f),b.sprite.setTexture(f),b.currentAnimation=null):(f=b.animations[b.currentAnimation],f=f[Math.floor(b.time/b.timePerFrame)%f.length],f=PIXI.Texture.fromImage(f),b.sprite.setTexture(f),
b.time+=a)};a.prototype.playAnimation=function(a,b){for(var f in this.partAnimations){var e=this.partAnimations[f];!e.animations[a]||b.priority&&e.priority&&b.priority<e.priority||(e.currentAnimation=a,b&&(e.loop=b.loop||!1,e.time=b.startTime||0,e.timePerFrame=b.timePerFrame||16,e.priority=b.priority||0,e.stopTexture=b.stopTexture||null,e.stopFrame=b.stopFrame||0))}};a.prototype.stopAnimation=function(){var a,b;for(b in this.partAnimations){var f=this.partAnimations[b];f.currentAnimation&&(a=f.animations[f.currentAnimation])&&
(f.stopTexture?a=f.stopTexture:(a=f.animations[f.currentAnimation],a=a[f.stopFrame]),a=PIXI.Texture.fromImage(a),f.sprite.setTexture(a),f.currentAnimation=null)}};a.prototype.addPart=function(a,b,f){this.addChild(b);this.partAnimations[a]={sprite:b,animations:f,loop:!1,time:0}};a.prototype.removePart=function(a){this.partAnimations[a]&&this.removeChild(this.partAnimations[a].sprite);delete this.partAnimations[a]};a.prototype.setTint=function(a){for(var b in this.partAnimations)this.partAnimations.hasOwnProperty(b)&&
(this.partAnimations[b].sprite.tint=a)};a.prototype.setBlendMode=function(a){for(var b in this.partAnimations)this.partAnimations.hasOwnProperty(b)&&(this.partAnimations[b].sprite.blendMode=a)};e.exports=a},{}],64:[function(b,e,m){function a(a){c.call(this);this.displayable=null;this.position={x:0,y:0,z:0};this.scale={x:1,y:1,z:1};this.rotation=0;this.tint=16777215;this.setParams(a)}var c=b("../../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(this.displayable=
a.displayable,a.position&&(this.position.x=a.position.x||this.position.x,this.position.y=a.position.y||this.position.y,this.position.z=a.position.z||this.position.z),a.scale&&(this.scale.x=a.scale.x||this.scale.x,this.scale.y=a.scale.y||this.scale.y,this.scale.z=a.scale.z||this.scale.z),this.rotation=a.rotation||this.rotation,this.tint=a.tint||this.tint)};a.type="DisplayComponent";e.exports=a;e.exports.type=a.type},{"../../core/Component":32}],65:[function(b,e,m){function a(a){d.call(this);this.entitySystem=
a}function c(a,b){var c=a[k.type],d=b.displayable;c?(d.position.x=c.position.x,d.position.y=c.position.y,d.scale.x=c.scale.x,d.scale.y=c.scale.y,d.rotation=c.rotation):(d.position.x=b.position.x,d.position.y=b.position.y,d.scale.x=b.scale.x,d.scale.y=b.scale.y,d.rotation=b.rotation);d.tint=b.tint}var d=b("../../core/system"),f=b("./DisplayComponent"),k=b("./../SpatialComponent");a.prototype=Object.create(d.prototype);a.prototype.update=function(a){a=this.entitySystem.getEntities(f.type);for(var b=
a.getAllRaw(),d=0;d<b.length;d++){var e=b[d][f.type],k=e.displayable;k&&k instanceof PIXI.DisplayObject&&c(b[d],e)}a.eachRemoved(function(a){(a=a[f.type].displayable)&&a instanceof PIXI.DisplayObject&&a.parent&&a.parent.removeChild(a)})};e.exports=a},{"../../core/system":39,"./../SpatialComponent":54,"./DisplayComponent":64}],66:[function(b,e,m){function a(a){c.call(this);this.isBlinking=!1;this.blinkingDuration=0;this.isFlashing=!1;this.flashDuration=200;this.timesToFlash=3;this.flashColor={r:35,
g:35,b:35};this.setParams(a)}var c=b("../../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(this.isBlinking=c.copyField(a.isBlinking,this.isBlinking),this.blinkingDuration=c.copyField(a.blinkingDuration,this.blinkingDuration),this.isFlashing=c.copyField(a.isFlashing,this.isFlashing),this.flashDuration=c.copyField(a.flashDuration,this.flashDuration),this.timesToFlash=c.copyField(a.timesToFlash,this.timesToFlash),a.flashColor&&(this.flashColor.r=c.copyField(a.flashColor.r,
this.flashColor.r),this.flashColor.g=c.copyField(a.flashColor.g,this.flashColor.g),this.flashColor.b=c.copyField(a.flashColor.b,this.flashColor.b)))};a.type="SfxComponent";e.exports=a;e.exports.type=a.type},{"../../core/Component":32}],67:[function(b,e,m){function a(a){c.call(this);this.entitySystem=a;this.entityEffectMap={};this.flickerPeriod=50;a=a.getEntities(d.type);a.addAddedCallback(this.onAdded.bind(this));a.addRemovedCallback(this.onRemoved.bind(this))}var c=b("../../core/system"),d=b("./SfxComponent");
b("./Character");var f=b("./DisplayComponent"),k=b("../../pixi/filters/OverlayFilter");a.prototype=Object.create(c.prototype);a.prototype.updateBlinking=function(a,b){var c=a[f.type];if(c){var e=this.entityEffectMap[a.id],k=a[d.type];k.isBlinking&&(e.isBlinking=0);var s=e.isBlinking;"undefined"!==typeof s&&null!==s&&(c=c.displayable,s<k.blinkingDuration?(c.visible=s%(2*this.flickerPeriod)>=this.flickerPeriod,e.isBlinking+=b):(c.visible=!0,delete e.isBlinking))}};a.prototype.updateFlashing=function(a,
b){var c=a[f.type];if(c){var e=this.entityEffectMap[a.id],l=a[d.type],c=c.displayable;l.isFlashing&&(e.isFlashing=0);var s=e.isFlashing;if("undefined"!==typeof s&&null!==s){var t=!1,n=c.filters;n||(n=[],t=!0);for(var u,p=0;p<n.length;p++)n[p]instanceof k&&(u=n[p]);u||(u=new k,t=!0,n.push(u));s<l.flashDuration?(p=l.flashColor,l=l.flashDuration/l.timesToFlash,l=1-s%l/l,0>=l&&(l=0.01),u.setColor(p.r*l,p.g*l,p.b*l),e.isFlashing+=b):(delete e.isFlashing,t=!0,u.setColor(1,1,1),e=n.indexOf(u),0<=e&&n.splice(e,
1),0===n.length&&(n=null));t&&(c.filters=n)}}};a.prototype.onAdded=function(a){this.entityEffectMap[a.id]={}};a.prototype.onRemoved=function(a){delete this.entityEffectMap[a.id]};a.prototype.update=function(a){for(var b=this.entitySystem.getEntities(d.type).getAllRaw(),c=0;c<b.length;c++){var f=b[c];this.updateBlinking(f,a);this.updateFlashing(f,a)}};a.prototype.cleanup=function(){for(var a=this.entitySystem.getEntities(d.type).getAllRaw(),b=0;b<a.length;b++){var c=a[b][d.type];c.isBlinking=!1;c.isFlashing=
!1}};e.exports=a},{"../../core/system":39,"../../pixi/filters/OverlayFilter":52,"./Character":63,"./DisplayComponent":64,"./SfxComponent":66}],68:[function(b,e,m){function a(a){c.call(this);this.center={x:0,y:0};this.offset={x:0,y:0};this.height=this.width=1;this.setParams(a)}var c=b("../../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(a.center&&(this.center.x=a.center.x||0,this.center.y=a.center.y||0),a.offset&&(this.offset.x=a.offset.x||0,this.offset.y=
a.offset.y||0),this.width=a.width||1,this.height=a.height||1)};a.type="AABBComponent";e.exports=a;e.exports.type=a.type},{"../../core/Component":32}],69:[function(b,e,m){function a(a){k.call(this);this.entitySystem=a;this.simpleResolver=new l;this.staticCollisionCallbacks=[];this.sensorCollisionCallbacks=[];this.startCollisionCallbacks=[];this.stopCollisionCallbacks=[]}function c(a){for(var b=a[r.type],c=[],d=0;d<b.shapes.length;d++){var f=b.shapes[d],e;if(f.circle)e=new SAT.Circle(new SAT.Vector(0,
0),f.circle.radius),e.pos.x=f.position.x,e.pos.y=f.position.y;else if(f.box)e=new SAT.Box(new SAT.Vector(0,0),f.box.width,f.box.height),e=e.toPolygon(),e.pos.x=f.position.x-f.box.width/2,e.pos.y=f.position.y-f.box.height/2;else if(f.polygon){e=[];for(var g=0;g<f.polygon.vertices.length;g++){var k=f.polygon.vertices[g];e.push(new SAT.Vector(k.x,k.y))}e=new SAT.Polygon(new SAT.Vector(0,0),e);e.pos.x=f.position.x;e.pos.y=f.position.y;e.setAngle(f.rotation)}e.userData=a;c.push(e)}return c}function d(a,
b){var c=a[h.type];if(!c)return b;b.x=c.center.x;b.y=c.center.y;b.width=c.width;b.height=c.height;b.userData.entity=a;return b}function f(a,b){var c;if(b&&0!==b.groups.length&&(0!==a.targetAndGroups.length||0!==a.targetOrGroups)){c=!1;var d=!0,f;if(0!==a.targetAndGroups.length){for(c=0;c<a.targetAndGroups.length;c++)if(f=a.targetAndGroups[c],-1===b.groups.indexOf(f)){d=!1;break}c=!0}if(!d)return!1;if(!c&&0!==a.targetOrGroups.length){d=!1;for(c=0;c<a.targetOrGroups.length;c++)if(f=a.targetOrGroups[c],
-1!==b.groups.indexOf(f)){d=!0;break}if(!d)return!1}}return!0}var k=b("../../core/system"),q=b("./CollisionComponent"),r=b("./BodyComponent");b("./CollisionInfo");var h=b("./AABBComponent"),g=b("./Bounds"),l=b("./SimpleResolver"),s=b("./MovementComponent");a.prototype=Object.create(k.prototype);a.prototype.collideSensor=function(a){var b=a[r.type];if(b){var d=c(a);if(0!==d.length){var e=this.entitySystem.getEntities(r.type).getAllRaw(),g=[],k,h,l=a[q.type];for(k=0;k<e.length;k++){var s=e[k];s.getID()!==
a.getID()&&(h=s[q.type])&&f(l,h)&&(g=g.concat(c(s)))}if(0!==g.length){h=[];var m=null;for(k=0;k<d.length;k++)for(var B=d[k],e=0;e<g.length;e++){var A=g[e];if(b.allowMultipleCollide||m!==A.userData)s=!1,B instanceof SAT.Circle&&A instanceof SAT.Circle&&(s=SAT.testCircleCircle(B,A)),B instanceof SAT.Circle&&A instanceof SAT.Polygon&&(s=SAT.testCirclePolygon(B,A)),B instanceof SAT.Polygon&&A instanceof SAT.Circle&&(s=SAT.testPolygonCircle(B,A)),B instanceof SAT.Polygon&&A instanceof SAT.Polygon&&(s=
SAT.testPolygonPolygon(B,A)),s&&(m=A.userData,h.push(A.userData))}if(0<h.length){for(k=0;k<h.length;k++)b=h[k].getID(),-1===l.colliding.indexOf(b)&&l.startColliding.push(b);for(k=0;k<l.colliding.length;){b=l.colliding[k];d=!1;for(e=0;e<h.length;e++)if(h[e].getID()===b){d=!0;break}d?k++:(l.stopColliding.push(b),l.colliding.splice(k,1))}for(k=0;k<this.sensorCollisionCallbacks.length;k++)this.sensorCollisionCallbacks[k](a,h)}else l.stopColliding=l.stopColliding.concat(l.colliding),l.colliding=[];if(0<
l.startColliding.length)for(k=0;k<this.startCollisionCallbacks.length;k++)this.startCollisionCallbacks[k](a,l.startColliding);if(0<l.stopColliding.length)for(k=0;k<this.startCollisionCallbacks.length;k++)this.stopCollisionCallbacks[k](a,l.stopColliding)}}}};a.prototype.collide=function(a){var b=a[s.type];if(b&&a[h.type]){var c=a[q.type],e=new g,k=this.entitySystem.getEntities(h.type).getAllRaw(),l,r=[];for(l=0;l<k.length;l++)if(a.getID()!==k[l].getID()){var m=k[l],D=m[q.type];D&&D.resolvable&&f(c,
D)&&r.push(d(m,new g))}if(0!==r.length&&(e=d(a,e),e=this.simpleResolver.resolve(e,b.move.x,b.move.y,r),e.colliderEntity=a,b.move.x=e.move.x,b.move.y=e.move.y,e.verticalColliderBounds&&(0<b.speed.y?c.isCollidingWith.bottom=!0:0>b.speed.y&&(c.isCollidingWith.top=!0),c.stopsOnCollide.y&&(b.speed.y=0),l=e.verticalColliderBounds.userData.entity[q.type])&&(b.calculatedFriction.x+=l.friction.x),e.horizontalColliderBounds&&(0<b.speed.x?c.isCollidingWith.left=!0:0>b.speed.y&&(c.isCollidingWith.right=!0),c.stopsOnCollide.x&&
(b.speed.x=0),l=e.horizontalColliderBounds.userData.entity[q.type])&&(b.calculatedFriction.y+=l.friction.y),e.verticalColliderBounds||e.horizontalColliderBounds))for(b=null,e.verticalColliderBounds&&(b=e.verticalColliderBounds.userData.entity),c=null,e.horizontalColliderBounds&&(c=e.horizontalColliderBounds.userData.entity),l=0;l<this.staticCollisionCallbacks.length;l++)this.staticCollisionCallbacks[l](e,c,b)}};a.prototype.update=function(a){a=this.entitySystem.getEntities(q.type).getAllRaw();for(var b=
0;b<a.length;b++){var c=a[b],d=c[q.type];d.collidesWith.objects&&(d.colliding=d.colliding.concat(d.startColliding),d.startColliding=[],d.stopColliding=[],d.resolveFor.objects&&c[h.type]&&this.collide(c),c[r.type]&&this.collideSensor(c))}};e.exports=a},{"../../core/system":39,"./AABBComponent":68,"./BodyComponent":70,"./Bounds":71,"./CollisionComponent":75,"./CollisionInfo":76,"./MovementComponent":77,"./SimpleResolver":79}],70:[function(b,e,m){function a(a){c.call(this);this.shapes=[];this.allowMultipleCollide=
!1;this.setParams(a)}var c=b("../../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){if(a){if(a.shapes)for(var b=0;b<a.shapes.length;b++){var c=a.shapes[b],e={};e.name=c.name;e.position={x:0,y:0};e.offset={x:0,y:0};e.rotation=c.rotation||0;e.offsetRotation=c.offsetRotation||0;c.position&&(e.position.x=c.position.x||e.position.x,e.position.y=c.position.y||e.position.y);c.offset&&(e.offset.x=c.offset.x||e.offset.x,e.offset.y=c.offset.y||e.offset.y);c.circle&&
(e.circle={radius:1},e.circle.radius=c.circle.radius||e.circle.radius);c.box&&(e.box={width:1,height:1},e.box.width=c.box.width||e.box.width,e.box.height=c.box.height||e.box.height);if(c.polygon&&c.polygon.vertices){if(0===c.polygon.vertices.length)continue;e.polygon={vertices:[]};for(var r=0;r<c.polygon.vertices.length;r++){var h=c.polygon.vertices[r];e.polygon.vertices.push({x:h.x||0,y:h.y||0})}}this.shapes.push(e)}this.allowMultipleCollide=a.allowMultipleCollide||this.allowMultipleCollide}};a.type=
"BodyComponent";e.exports=a;e.exports.type=a.type},{"../../core/Component":32}],71:[function(b,e,m){function a(a,b,e,k){this.x=a;this.y=b;this.resolve={left:!0,right:!0,top:!0,bottom:!0};this.width=e;this.height=k;this.userData={}}a.prototype.getLeft=function(){return this.x-this.width/2};a.prototype.getRight=function(){return this.x+this.width/2};a.prototype.getTop=function(){return this.y-this.height/2};a.prototype.getBottom=function(){return this.y+this.height/2};a.prototype.copy=function(a){this.x=
a.x;this.y=a.y;this.width=a.width;this.height=a.height};a.prototype.addToBounds=function(a,b){this.x+=a/2;this.y+=b/2;this.width+=Math.abs(a);this.height+=Math.abs(b)};e.exports=a},{}],72:[function(b,e,m){function a(a){c.call(this);this.showFor={aabb:!0,body:!0};this.color=16776960;this.alpha=0.5;this.setParams(a)}var c=b("../../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(this.color=a.color||this.color,this.alpha=a.alpha||this.alpha,a.showFor&&(this.showFor.aabb=
a.showFor.aabb||this.showFor.aabb,this.showFor.body=a.showFor.body||this.showFor.body))};a.type="BoundsDebugComponent";e.exports=a;e.exports.type=a.type},{"../../core/Component":32}],73:[function(b,e,m){function a(a,b){f.call(this);this.entitySystem=a;this.scene=b;this.aabbMap={};this.bodyMap={};var c=a.getEntities(k.type);c.addAddedCallback(this.addAABBDebug.bind(this));c.addRemovedCallback(this.removeAABBDebug.bind(this));c.addAddedCallback(this.addBodyDebug.bind(this));c.addRemovedCallback(this.removeBodyDebug.bind(this))}
function c(a,b){var c=a[q.type];if(c){var d=b.aabbMap[a.getID()];d&&(d.position.x=c.center.x,d.position.y=c.center.y)}}function d(a,b){for(var c=b.bodyMap[a.getID()],d=0;d<c.length;d++){var e=c[d].shape,f=c[d].display;f.position.x=e.position.x;f.position.y=e.position.y;e.polygon&&(f.rotation=e.rotation)}}var f=b("../../core/system"),k=b("./BoundsDebugComponent"),q=b("./AABBComponent"),r=b("./BodyComponent");a.prototype=Object.create(f.prototype);a.prototype.addAABBDebug=function(a){var b=a[q.type];
if(b){var c=a[k.type];if(c.showFor.aabb){var d=new PIXI.Graphics;d.beginFill(c.color);d.moveTo(-b.width/2,-b.height/2);d.lineTo(-b.width/2,b.height/2);d.lineTo(b.width/2,b.height/2);d.lineTo(b.width/2,-b.height/2);d.endFill();d.alpha=c.alpha;d.position.x=b.center.x;d.position.y=b.center.y;this.aabbMap[a.getID()]=d;this.scene.addChild(d)}}};a.prototype.removeAABBDebug=function(a){var b=this.aabbMap[a.getID()];b&&(this.scene.removeChild(b),delete this.aabbMap[a.getID()])};a.prototype.addBodyDebug=function(a){var b=
a[r.type];if(b){var c=a[k.type];if(c.showFor.body){this.bodyMap[a.getID()]=[];a=this.bodyMap[a.getID()];for(var d=0;d<b.shapes.length;d++){var e=b.shapes[d];if(e.circle||e.box||e.polygon){var f=new PIXI.Graphics;f.beginFill(c.color);if(e.circle)f.drawCircle(0,0,e.circle.radius);else if(e.box)f.moveTo(-e.box.width/2,-e.box.height/2),f.lineTo(-e.box.width/2,e.box.height/2),f.lineTo(e.box.width/2,e.box.height/2),f.lineTo(e.box.width/2,-e.box.height/2);else if(e.polygon)for(var q=e.polygon.vertices,p=
0;p<q.length;p++){var m=q[p];0===p?f.moveTo(m.x,m.y):f.lineTo(m.x,m.y)}f.endFill();f.alpha=c.alpha;f.position.x=e.position.x;f.position.y=e.position.y;a.push({shape:e,display:f});this.scene.addChild(f)}}}}};a.prototype.removeBodyDebug=function(a){for(var b=this.bodyMap[a.getID()],c=0;c<b.length;c++)this.scene.removeChild(b[c].display);delete this.bodyMap[a.getID()]};a.prototype.update=function(a){a=this.entitySystem.getEntities(k.type);a.each(c,this);a.each(d,this)};e.exports=a},{"../../core/system":39,
"./AABBComponent":68,"./BodyComponent":70,"./BoundsDebugComponent":72}],74:[function(b,e,m){function a(a){c.call(this);this.entitySystem=a}var c=b("../../core/system"),d=b("../../systems/SpatialComponent"),f=b("./AABBComponent"),k=b("./BodyComponent");a.prototype=Object.create(c.prototype);a.prototype.update=function(){var a=this.entitySystem.getEntities(f.type),a=a.getAllRaw(),b,c,e;for(b=0;b<a.length;b++)if(c=a[b],e=c[d.type])c=c[f.type],c.center.x=e.position.x+c.offset.x,c.center.y=e.position.y+
c.offset.y;a=this.entitySystem.getEntities(k.type);a=a.getAllRaw();for(b=0;b<a.length;b++)if(c=a[b],e=c[d.type]){var l=c[k.type];for(c=0;c<l.shapes.length;c++){var s=l.shapes[c];s.position.x=e.position.x+s.offset.x;s.position.y=e.position.y+s.offset.y;s.rotation=e.rotation+s.offsetRotation}}};e.exports=a},{"../../core/system":39,"../../systems/SpatialComponent":54,"./AABBComponent":68,"./BodyComponent":70}],75:[function(b,e,m){function a(a){c.call(this);this.collidesWith={tiles:!1,objects:!1};this.resolveFor=
{tiles:!1,objects:!1};this.resolvable=!1;this.groups=[];this.targetAndGroups=[];this.targetOrGroups=[];this.friction={x:0,y:0};this.isCollidingWith={top:!1,bottom:!1,left:!1,right:!1};this.stopsOnCollide={x:!0,y:!0};this.startColliding=[];this.colliding=[];this.stopColliding=[];this.setParams(a)}var c=b("../../core/Component");a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(a.collidesWith&&(this.collidesWith.tiles=a.collidesWith.tiles||this.collidesWith.tiles,this.collidesWith.objects=
a.collidesWith.objects||this.collidesWith.objects),a.resolveFor&&(this.resolveFor.tiles=a.resolveFor.tiles||this.resolveFor.tiles,this.resolveFor.objects=a.resolveFor.objects||this.resolveFor.objects),this.resolvable=a.resolvable||this.resolvable,a.friction&&(this.friction.x=a.friction.x||this.friction.x,this.friction.y=a.friction.y||this.friction.y),a.isCollidingWith&&(this.isCollidingWith.top=a.isCollidingWith.top||this.isCollidingWith.top,this.isCollidingWith.bottom=a.isCollidingWith.bottom||this.isCollidingWith.bottom,
this.isCollidingWith.left=a.isCollidingWith.left||this.isCollidingWith.left,this.isCollidingWith.right=a.isCollidingWith.right||this.isCollidingWith.right),a.stopsOnCollide&&(this.stopsOnCollide.x=a.stopsOnCollide.x||this.stopsOnCollide.x,this.stopsOnCollide.y=a.stopsOnCollide.y||this.stopsOnCollide.y),this.groups=a.groups?this.groups.concat(a.groups):this.groups,a.targetAndGroups&&(this.targetAndGroups=this.targetAndGroups.concat(a.targetAndGroups)),a.targetOrGroups&&(this.targetOrGroups=this.targetOrGroups.concat(a.targetOrGroups)),
this.startColliding=a.startColliding?this.startColliding.concat(a.startColliding):this.startColliding,this.colliding=a.colliding?this.colliding.concat(a.colliding):this.colliding,this.stopColliding=a.stopColliding?this.stopColliding.concat(a.stopColliding):this.stopColliding)};a.type="CollisionComponent";e.exports=a;e.exports.type=a.type},{"../../core/Component":32}],76:[function(b,e,m){function a(){this.horizontalColliderBounds=this.verticalColliderBounds=this.colliderBounds=this.targetEntity=this.colliderEntity=
null;this.move={x:0,y:0}}a.prototype.reset=function(){this.horizontalColliderBounds=this.verticalColliderBounds=this.colliderBounds=this.targetEntity=this.colliderEntity=null;this.move.x=0;this.move.y=0};e.exports=a},{}],77:[function(b,e,m){function a(a){c.call(this);this.move={x:0,y:0};this.speed={x:0,y:0};this.acceleration={x:0,y:0};this.damping=1;this.isDamped={x:!1,y:!1};this.friction={x:0,y:0};this.calculatedFriction={x:0,y:0};this.maxSpeed={x:0,y:0};this.setParams(a)}var c=b("../../core/Component");
a.prototype=Object.create(c.prototype);a.prototype.setParams=function(a){a&&(a.move&&(this.move.x=a.move.x||this.move.x,this.move.y=a.move.y||this.move.y),a.speed&&(this.speed.x=a.speed.x||this.speed.x,this.speed.y=a.speed.y||this.speed.y),a.acceleration&&(this.acceleration.x=a.acceleration.x||this.acceleration.x,this.acceleration.y=a.acceleration.y||this.acceleration.y),this.damping=a.damping||this.damping,a.isDamped&&(this.isDamped.x=a.isDamped.x||this.isDamped.x,this.isDamped.y=a.isDamped.y||this.isDamped.y),
a.friction&&(this.friction.x=a.friction.x||this.friction.x,this.friction.y=a.friction.y||this.friction.y),a.calculatedFriction&&(this.calculatedFriction.x=a.calculatedFriction.x||0,this.calculatedFriction.y=a.calculatedFriction.x||0),a.maxSpeed&&(this.maxSpeed.x=a.maxSpeed.x||this.maxSpeed.x,this.maxSpeed.y=a.maxSpeed.y||this.maxSpeed.y))};a.type="MovementComponent";e.exports=a;e.exports.type=a.type},{"../../core/Component":32}],78:[function(b,e,m){function a(a){c.call(this);this.entitySystem=a}var c=
b("../../core/system"),d=b("./MovementComponent"),f=b("../../systems/SpatialComponent");a.prototype=Object.create(c.prototype);a.prototype.update=function(a){a=this.entitySystem.getEntities(d.type).getAllRaw();for(var b=0;b<a.length;b++){var c=a[b],e=c[f.type];c[f.type]&&(c=c[d.type],e.position.x+=c.move.x,e.position.y+=c.move.y)}};a.prototype.cleanup=function(){for(var a=this.entitySystem.getEntities(d.type).getAllRaw(),b=0;b<a.length;b++){var c=a[b][d.type];c.move.x=0;c.move.y=0}};e.exports=a},
{"../../core/system":39,"../../systems/SpatialComponent":54,"./MovementComponent":77}],79:[function(b,e,m){function a(){this.bounds=new d(0,0,1,1);this.collisionInfo=new f}function c(a,b,c,d,e){var f=e;0<e&&d-k<=a&&(a-=d,a<e&&(f=a));0>e&&c+k>=b&&(a=b-c,a>e&&(f=a));return f}var d=b("./Bounds"),f=b("./CollisionInfo"),k=0;a.prototype.resolve=function(a,b,d,e){this.collisionInfo.reset();this.collisionInfo.colliderBounds=a;this.bounds.copy(a);a=this.bounds.getLeft();var f=this.bounds.getRight(),s=this.bounds.getTop(),
t=this.bounds.getBottom(),n,m,p,x,v=d,w;for(d=0;d<e.length;d++)w=e[d],n=w.getLeft(),m=w.getRight(),x=w.getTop(),p=w.getBottom(),m-k>a&&n+k<f&&(n=c(x,p,s,t,v),n===v||0<n&&!w.resolve.top||0>n&&!w.resolve.bottom||(v=n,this.collisionInfo.verticalColliderBounds=w));this.collisionInfo.move.y=v;this.bounds.y+=this.collisionInfo.move.y;a=this.bounds.getLeft();f=this.bounds.getRight();s=this.bounds.getTop();t=this.bounds.getBottom();v=b;for(d=0;d<e.length;d++)w=e[d],n=w.getLeft(),m=w.getRight(),x=w.getTop(),
p=w.getBottom(),p-k>s&&x+k<t&&(n=c(n,m,a,f,v),n===v||0<n&&!w.resolve.left||0>n&&!w.resolve.right||(v=n,this.collisionInfo.horizontalColliderBounds=w));this.collisionInfo.move.x=v;return this.collisionInfo};e.exports=a},{"./Bounds":71,"./CollisionInfo":76}],80:[function(b,e,m){function a(a){c.call(this);this.entitySystem=a}var c=b("../../core/system"),d=b("./MovementComponent");b("../../systems/SpatialComponent");var f=b("../../utility/math");a.prototype=Object.create(c.prototype);a.prototype.applyDamping=
function(a){if(a=a[d.type])a.isDamped.x&&(a.speed.x*=a.damping),a.isDamped.y&&(a.speed.y*=a.damping)};a.prototype.applyAccelerationFriction=function(a){if(a=a[d.type]){var b=1-(a.friction.x+a.calculatedFriction.x)/2,b=f.clamp(b,0,1);a.acceleration.x*=b;b=1-(a.friction.y+a.calculatedFriction.y)/2;b=f.clamp(b,0,1);a.acceleration.y*=b}};a.prototype.applyFriction=function(a){if(a=a[d.type]){var b=0;0===a.acceleration.x&&(b=1-(a.friction.x+a.calculatedFriction.x)/2,b=f.clamp(b,0,1),a.speed.x*=b);0===a.acceleration.y&&
(b=1-(a.friction.y+a.calculatedFriction.y)/2,b=f.clamp(b,0,1),a.speed.y*=b)}};a.prototype.clampSpeed=function(a){if(a=a[d.type])0!==a.maxSpeed.x&&(a.speed.x=f.clamp(a.speed.x,-a.maxSpeed.x,a.maxSpeed.x)),0!==a.maxSpeed.y&&(a.speed.y=f.clamp(a.speed.y,-a.maxSpeed.y,a.maxSpeed.y))};a.prototype.update=function(a){for(var b=this.entitySystem.getEntities(d.type).getAllRaw(),c=0;c<b.length;c++){var e=b[c],f=e[d.type];f.speed.x+=f.acceleration.x;f.speed.y+=f.acceleration.y;this.applyDamping(e);this.applyFriction(e);
this.clampSpeed(e);f.move.x+=f.speed.x*a/1E3;f.move.y+=f.speed.y*a/1E3}};a.prototype.cleanup=function(){for(var a=this.entitySystem.getEntities(d.type).getAllRaw(),b=0;b<a.length;b++){var c=a[b][d.type];c.acceleration.x=0;c.acceleration.y=0;c.calculatedFriction.x=0;c.calculatedFriction.y=0}};a.addAcceleration=function(a,b,c,d,e){if(!e)return 0;if(0===a)return e*d;var f=b+c;return 0<e&&f>a||0>e&&f<-a?0:Math.abs(f+d*e)<=a?d*e:e*a-b-c};e.exports=a;e.exports.addAcceleration=a.addAcceleration},{"../../core/system":39,
"../../systems/SpatialComponent":54,"../../utility/math":84,"./MovementComponent":77}],81:[function(b,e,m){function a(a,b){d.call(this);this.entitySystem=a;this.simpleResolver=new h;this.tiles=b.tiles;this.staticTiles=b.staticTiles;this.sensorTiles=b.sensorTiles;this.tileWidth=b.tileWidth;this.tileHeight=b.tileHeight;this.tileProperties={oneWayHeight:1};this.tileFriction={x:0.5,y:0};this.bounds=new r(0,0,1,1);this.tileIndices={minX:0,minY:0,maxX:0,maxY:0};this.staticCollisionCallbacks=[];this.sensorCollisionCallbacks=
[]}function c(a,b){var c=a[k.type];if(!c)return b;b.x=c.center.x;b.y=c.center.y;b.width=c.width;b.height=c.height;return b}var d=b("../../core/system"),f=b("./MovementComponent"),k=b("./AABBComponent"),q=b("./CollisionComponent"),r=b("./Bounds"),h=b("./SimpleResolver");a.prototype=Object.create(d.prototype);a.prototype.isBoundsInTiles=function(a,b,c,d,e){if(!e)return!1;c=0>c&&0>d||c>=e.length*this.tileHeight&&d>=e.length*this.tileHeight;return!(0>a&&0>b||a>=e[0].length*this.tileWidth&&b>=e[0].length*
this.tileWidth||c)};a.prototype.normalizeIndices=function(a,b){0>a.minX&&(a.minX=0);a.maxX>=b[0].length&&(a.maxX=b[0].length-1);0>a.minY&&(a.minY=0);a.maxY>=b.length&&(a.maxY=b.length-1);return this.tileIndices};a.prototype.getTileIndicesFromBounds=function(a,b,c,d){this.tileIndices.minX=Math.floor(a/this.tileWidth);this.tileIndices.maxX=Math.floor(b/this.tileWidth);this.tileIndices.minY=Math.floor(c/this.tileHeight);this.tileIndices.maxY=Math.floor(d/this.tileHeight);return this.tileIndices};a.prototype.collideSensor=
function(a,b){if(a[k.type]){this.bounds=c(a,this.bounds);var d=this.bounds.getLeft(),e=this.bounds.getRight(),f=this.bounds.getTop(),h=this.bounds.getBottom();if(this.isBoundsInTiles(d,e,f,h,b)){var m=[];this.tileIndices=this.normalizeIndices(this.getTileIndicesFromBounds(d,e,f,h),b);for(d=this.tileIndices.minY;d<=this.tileIndices.maxY;d++)for(e=this.tileIndices.minX;e<=this.tileIndices.maxX;e++)f=b[d][e],0!==f&&m.push({x:e*this.tileWidth+this.tileWidth/2,y:d*this.tileWidth+this.tileWidth/2,index:f});
if(0<m.length)for(d=0;d<this.sensorCollisionCallbacks.length;d++)this.sensorCollisionCallbacks[d](a,m)}}};a.prototype.collide=function(b,d){if(b[k.type]){var e=b[f.type];if(e){var h=b[q.type];if(h.resolveFor.tiles){h.isCollidingWith.top=!1;h.isCollidingWith.bottom=!1;h.isCollidingWith.left=!1;h.isCollidingWith.right=!1;this.bounds=c(b,this.bounds);this.bounds.addToBounds(e.move.x,e.move.y);var n=this.bounds.getLeft(),m=this.bounds.getRight(),p=this.bounds.getTop(),x=this.bounds.getBottom();if(this.isBoundsInTiles(n,
m,p,x,d)){this.tileIndices=this.normalizeIndices(this.getTileIndicesFromBounds(n,m,p,x),d);n=[];for(p=this.tileIndices.minY;p<=this.tileIndices.maxY;p++)for(x=this.tileIndices.minX;x<=this.tileIndices.maxX;x++){var v=d[p][x];if(0!==v){switch(v){case a.TileTypes.OneWayTop:m=new r(x*this.tileWidth+this.tileWidth/2,p*this.tileHeight+this.tileProperties.oneWayHeight/2,this.tileWidth,this.tileProperties.oneWayHeight);m.resolve.left=!1;m.resolve.right=!1;m.resolve.bottom=!1;break;case a.TileTypes.OneWayBottom:m=
new r(x*this.tileWidth+this.tileWidth/2,p*this.tileHeight+this.tileHeight-this.tileProperties.oneWayHeight/2,this.tileWidth,this.tileProperties.oneWayHeight);m.resolve.left=!1;m.resolve.right=!1;m.resolve.bottom=!1;break;case a.TileTypes.OneWayCenter:m=new r(x*this.tileWidth+this.tileWidth/2,p*this.tileHeight+this.tileHeight/2,this.tileWidth,this.tileProperties.oneWayHeight);m.resolve.left=!1;m.resolve.right=!1;m.resolve.bottom=!1;break;default:m=new r(x*this.tileWidth+this.tileWidth/2,p*this.tileHeight+
this.tileHeight/2,this.tileWidth,this.tileHeight)}m&&(m.userData.index=v,n.push(m))}}this.bounds=c(b,this.bounds);n=this.simpleResolver.resolve(this.bounds,e.move.x,e.move.y,n);n.colliderEntity=b;e.move.x=n.move.x;e.move.y=n.move.y;n.verticalColliderBounds&&(0<e.speed.y?h.isCollidingWith.bottom=!0:0>e.speed.y&&(h.isCollidingWith.top=!0),h.stopsOnCollide.y&&(e.speed.y=0),e.calculatedFriction.x+=this.tileFriction.x);n.horizontalColliderBounds&&(0<e.speed.x?h.isCollidingWith.left=!0:0>e.speed.y&&(h.isCollidingWith.right=
!0),h.stopsOnCollide.x&&(e.speed.x=0),e.calculatedFriction.y+=this.tileFriction.y);if(n.verticalColliderBounds||n.horizontalColliderBounds)for(h=0,n.verticalColliderBounds&&(h=n.verticalColliderBounds.userData.index),m=0,n.horizontalColliderBounds&&(m=n.horizontalColliderBounds.userData.index),e=0;e<this.staticCollisionCallbacks.length;e++)this.staticCollisionCallbacks[e](n,m,h)}}}}};a.prototype.update=function(a){a=this.entitySystem.getEntities(q.type).getAllRaw();for(var b=0;b<a.length;b++){var c=
a[b],d=c[q.type];d.collidesWith.tiles&&(d.resolveFor.tiles&&this.collide(c,this.staticTiles),this.collideSensor(c,this.sensorTiles))}};a.TileTypes={Empty:0,Static:1,OneWayTop:2,OneWayBottom:3,OneWayCenter:4};e.exports=a;e.exports.TileTypes=a.TileTypes},{"../../core/system":39,"./AABBComponent":68,"./Bounds":71,"./CollisionComponent":75,"./MovementComponent":77,"./SimpleResolver":79}],82:[function(b,e,m){e.exports.pickRandomFloat=function(){return Math.random()};e.exports.pickRandomProperty=function(a){var b=
Object.keys(a);return 0===b.length?null:a[b[Math.floor(b.length*Math.random())]]};e.exports.pickRandomElement=function(a){return a?a[Math.floor(Math.random()*a.length)]:null}},{}],83:[function(b,e,m){e.exports.contains=function(a,b){return-1<a.indexOf(b)};e.exports.objectContainsValue=function(a,b){for(var d in a)if(a[d]===b)return!0;return!1};e.exports.objectContainsKey=function(a,b){return a[b]?!0:!1};e.exports.objectSize=function(a){var b=0,d;for(d in a)a.hasOwnProperty(d)&&b++;return b};e.exports.shuffle=
function(a){for(var b=a.length-1;0<b;b--){var d=Math.floor(Math.random()*b),e=a[d];a[d]=a[b];a[b]=e}};e.exports.remove=function(a,b){var d=a.indexOf(b);return-1<d?(a.splice(d,1),!0):!1};e.exports.array2dToString=function(a){for(var b="",d=0;d<a.length;d++){for(var b=b+"[",e=0;e<a[d].length;e++)b+=a[d][e],e!==a[d].length-1&&(b+="\t");b+="]";d!==a.length-1&&(b+="\n")}return b};e.exports.shallowCopyObject=function(a){var b={},d;for(d in a)b[d]=a[d];return b}},{}],84:[function(b,e,m){e.exports={UnitsPerMeter:100,
UnitsPerCentimeter:1,DefaultFloat:0.001,RAD_TO_DEG:57.2957795,DEG_TO_RAD:0.01745329,PI:Math.PI,clamp:function(a,b,d){return Math.min(Math.max(a,b),d)},generateUUID:function(){for(var a=[],b=0;256>b;b++)a[b]=(16>b?"0":"")+b.toString(16);return function(){var b=4294967295*Math.random()|0,c=4294967295*Math.random()|0,e=4294967295*Math.random()|0,m=4294967295*Math.random()|0;return a[b&255]+a[b>>8&255]+a[b>>16&255]+a[b>>24&255]+"-"+a[c&255]+a[c>>8&255]+"-"+a[c>>16&15|64]+a[c>>24&255]+"-"+a[e&63|128]+
a[e>>8&255]+"-"+a[e>>16&255]+a[e>>24&255]+a[m&255]+a[m>>8&255]+a[m>>16&255]+a[m>>24&255]}}(),calcDistancePoints:function(a,b,d,e){a-=d;b-=e;return Math.sqrt(a*a+b*b)},calcDistancePointsNoRoot:function(a,b,d,e){a-=d;b-=e;return a*a+b*b}}},{}]},{},[1])(1)});
