UNPKG

@akashic/akashic-sandbox

Version:
1 lines 321 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.engineFilesV1_1_16=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){module.exports=require("./lib/main.node")},{"./lib/main.node":2}],2:[function(require,module,exports){(function(){"use strict";var __extends=this&&this.__extends||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)};var g;(function(g){var AssetLoadErrorType;(function(AssetLoadErrorType){AssetLoadErrorType[AssetLoadErrorType["Unspecified"]=0]="Unspecified";AssetLoadErrorType[AssetLoadErrorType["RetryLimitExceeded"]=1]="RetryLimitExceeded";AssetLoadErrorType[AssetLoadErrorType["NetworkError"]=2]="NetworkError";AssetLoadErrorType[AssetLoadErrorType["ClientError"]=3]="ClientError";AssetLoadErrorType[AssetLoadErrorType["ServerError"]=4]="ServerError"})(AssetLoadErrorType=g.AssetLoadErrorType||(g.AssetLoadErrorType={}))})(g||(g={}));var g;(function(g){var ExceptionFactory;(function(ExceptionFactory){function createPureVirtualError(methodName,cause){var e=new Error(methodName+" has no implementation.");e.name="PureVirtualError";e.cause=cause;return e}ExceptionFactory.createPureVirtualError=createPureVirtualError;function createAssertionError(message,cause){var e=new Error(message);e.name="AssertionError";e.cause=cause;return e}ExceptionFactory.createAssertionError=createAssertionError;function createTypeMismatchError(methodName,expected,actual,cause){var message="Type mismatch on "+methodName+","+" expected type is "+expected;if(arguments.length>2){try{var actualString;if(actual&&actual.constructor&&actual.constructor.name){actualString=actual.constructor.name}else{actualString=typeof actual}message+=", actual type is "+(actualString.length>40?actualString.substr(0,40):actualString)}catch(ex){}}message+=".";var e=new Error(message);e.name="TypeMismatchError";e.cause=cause;e.expected=expected;e.actual=actual;return e}ExceptionFactory.createTypeMismatchError=createTypeMismatchError;function createAssetLoadError(message,retriable,type,cause){if(retriable===void 0){retriable=true}if(type===void 0){type=g.AssetLoadErrorType.Unspecified}var e=new Error(message);e.name="AssetLoadError";e.cause=cause;e.retriable=retriable;e.type=type;return e}ExceptionFactory.createAssetLoadError=createAssetLoadError})(ExceptionFactory=g.ExceptionFactory||(g.ExceptionFactory={}))})(g||(g={}));var g;(function(g){var ResourceFactory=function(){function ResourceFactory(){}ResourceFactory.prototype.createImageAsset=function(id,assetPath,width,height){throw g.ExceptionFactory.createPureVirtualError("ResourceFactory#createImageAsset")};ResourceFactory.prototype.createVideoAsset=function(id,assetPath,width,height,system,loop,useRealSize){throw g.ExceptionFactory.createPureVirtualError("ResourceFactory#createVideoAsset")};ResourceFactory.prototype.createAudioAsset=function(id,assetPath,duration,system,loop,hint){throw g.ExceptionFactory.createPureVirtualError("ResourceFactory#createAudioAsset")};ResourceFactory.prototype.createTextAsset=function(id,assetPath){throw g.ExceptionFactory.createPureVirtualError("ResourceFactory#createTextAsset")};ResourceFactory.prototype.createAudioPlayer=function(system){throw g.ExceptionFactory.createPureVirtualError("ResourceFactory#createAudioPlayer")};ResourceFactory.prototype.createScriptAsset=function(id,assetPath){throw g.ExceptionFactory.createPureVirtualError("ResourceFactory#createScriptAsset")};ResourceFactory.prototype.createSurface=function(width,height){throw g.ExceptionFactory.createPureVirtualError("ResourceFactory#createSurface")};ResourceFactory.prototype.createGlyphFactory=function(fontFamily,fontSize,baselineHeight,fontColor,strokeWidth,strokeColor,strokeOnly,fontWeight){throw g.ExceptionFactory.createPureVirtualError("ResourceFactory#createGlphFactory")};ResourceFactory.prototype.createSurfaceAtlas=function(width,height){return new g.SurfaceAtlas(this.createSurface(width,height))};return ResourceFactory}();g.ResourceFactory=ResourceFactory})(g||(g={}));var g;(function(g){var RequireCachedValue=function(){function RequireCachedValue(value){this._value=value}RequireCachedValue.prototype._cachedValue=function(){return this._value};return RequireCachedValue}();g.RequireCachedValue=RequireCachedValue})(g||(g={}));var g;(function(g){var RandomGenerator=function(){function RandomGenerator(seed){this.seed=seed}RandomGenerator.prototype.get=function(min,max){throw g.ExceptionFactory.createPureVirtualError("RandomGenerator#get")};RandomGenerator.prototype.serialize=function(){throw g.ExceptionFactory.createPureVirtualError("RandomGenerator#serialize")};return RandomGenerator}();g.RandomGenerator=RandomGenerator})(g||(g={}));var g;(function(g){var Asset=function(){function Asset(id,path){this.id=id;this.originalPath=path;this.path=this._assetPathFilter(path);this.onDestroyed=new g.Trigger}Asset.prototype.destroy=function(){this.onDestroyed.fire(this);this.id=undefined;this.originalPath=undefined;this.path=undefined;this.onDestroyed.destroy();this.onDestroyed=undefined};Asset.prototype.destroyed=function(){return this.id===undefined};Asset.prototype.inUse=function(){return false};Asset.prototype._load=function(loader){throw g.ExceptionFactory.createPureVirtualError("Asset#_load")};Asset.prototype._assetPathFilter=function(path){return path};return Asset}();g.Asset=Asset;var ImageAsset=function(_super){__extends(ImageAsset,_super);function ImageAsset(id,assetPath,width,height){var _this=_super.call(this,id,assetPath)||this;_this.width=width;_this.height=height;return _this}ImageAsset.prototype.asSurface=function(){throw g.ExceptionFactory.createPureVirtualError("ImageAsset#asSurface")};return ImageAsset}(Asset);g.ImageAsset=ImageAsset;var VideoAsset=function(_super){__extends(VideoAsset,_super);function VideoAsset(id,assetPath,width,height,system,loop,useRealSize){var _this=_super.call(this,id,assetPath,width,height)||this;_this.realWidth=0;_this.realHeight=0;_this._system=system;_this._loop=loop;_this._useRealSize=useRealSize;return _this}VideoAsset.prototype.asSurface=function(){throw g.ExceptionFactory.createPureVirtualError("VideoAsset#asSurface")};VideoAsset.prototype.play=function(loop){this.getPlayer().play(this);return this.getPlayer()};VideoAsset.prototype.stop=function(){this.getPlayer().stop()};VideoAsset.prototype.getPlayer=function(){throw g.ExceptionFactory.createPureVirtualError("VideoAsset#getPlayer")};VideoAsset.prototype.destroy=function(){this._system=undefined;_super.prototype.destroy.call(this)};return VideoAsset}(ImageAsset);g.VideoAsset=VideoAsset;var AudioAsset=function(_super){__extends(AudioAsset,_super);function AudioAsset(id,assetPath,duration,system,loop,hint){var _this=_super.call(this,id,assetPath)||this;_this.duration=duration;_this.loop=loop;_this.hint=hint;_this._system=system;_this.data=undefined;return _this}AudioAsset.prototype.play=function(){var player=this._system.createPlayer();player.play(this);this._lastPlayedPlayer=player;return player};AudioAsset.prototype.stop=function(){var players=this._system.findPlayers(this);for(var i=0;i<players.length;++i)players[i].stop()};AudioAsset.prototype.inUse=function(){return this._system.findPlayers(this).length>0};AudioAsset.prototype.destroy=function(){if(this._system)this.stop();this.data=undefined;this._system=undefined;this._lastPlayedPlayer=undefined;_super.prototype.destroy.call(this)};return AudioAsset}(Asset);g.AudioAsset=AudioAsset;var TextAsset=function(_super){__extends(TextAsset,_super);function TextAsset(id,assetPath){var _this=_super.call(this,id,assetPath)||this;_this.data=undefined;return _this}TextAsset.prototype.destroy=function(){this.data=undefined;_super.prototype.destroy.call(this)};return TextAsset}(Asset);g.TextAsset=TextAsset;var ScriptAsset=function(_super){__extends(ScriptAsset,_super);function ScriptAsset(){return _super!==null&&_super.apply(this,arguments)||this}ScriptAsset.prototype.execute=function(execEnv){throw g.ExceptionFactory.createPureVirtualError("ScriptAsset#execute")};ScriptAsset.prototype.destroy=function(){this.script=undefined;_super.prototype.destroy.call(this)};return ScriptAsset}(Asset);g.ScriptAsset=ScriptAsset})(g||(g={}));var g;(function(g){var AssetLoadingInfo=function(){function AssetLoadingInfo(asset,handler){this.asset=asset;this.handlers=[handler];this.errorCount=0;this.loading=false}return AssetLoadingInfo}();function normalizeAudioSystemConfMap(confMap){confMap=confMap||{};var systemDefaults={music:{loop:true,hint:{streaming:true}},sound:{loop:false,hint:{streaming:false}}};for(var key in systemDefaults){if(!(key in confMap)){confMap[key]=systemDefaults[key]}}return confMap}var AssetManager=function(){function AssetManager(game,conf,audioSystemConfMap,moduleMainScripts){this.game=game;this.configuration=this._normalize(conf||{},normalizeAudioSystemConfMap(audioSystemConfMap));this._assets={};this._liveAssetVirtualPathTable={};this._liveAbsolutePathTable={};this._moduleMainScripts=moduleMainScripts?moduleMainScripts:{};this._refCounts={};this._loadings={}}AssetManager.prototype.destroy=function(){var assetIds=Object.keys(this._refCounts);for(var i=0;i<assetIds.length;++i){this._releaseAsset(assetIds[i])}this.game=undefined;this.configuration=undefined;this._assets=undefined;this._liveAssetVirtualPathTable=undefined;this._liveAbsolutePathTable=undefined;this._refCounts=undefined;this._loadings=undefined};AssetManager.prototype.destroyed=function(){return this.game===undefined};AssetManager.prototype.retryLoad=function(asset){if(!this._loadings.hasOwnProperty(asset.id))throw g.ExceptionFactory.createAssertionError("AssetManager#retryLoad: invalid argument.");var loadingInfo=this._loadings[asset.id];if(loadingInfo.errorCount>AssetManager.MAX_ERROR_COUNT){if(!this.configuration[asset.id])return;throw g.ExceptionFactory.createAssertionError("AssetManager#retryLoad: too many retrying.")}if(!loadingInfo.loading){loadingInfo.loading=true;asset._load(this)}};AssetManager.prototype.globalAssetIds=function(){var ret=[];var conf=this.configuration;for(var p in conf){if(!conf.hasOwnProperty(p))continue;if(conf[p].global)ret.push(p)}return ret};AssetManager.prototype.requestAsset=function(assetIdOrConf,handler){var assetId=typeof assetIdOrConf==="string"?assetIdOrConf:assetIdOrConf.id;var waiting=false;var loadingInfo;if(this._assets.hasOwnProperty(assetId)){++this._refCounts[assetId];handler._onAssetLoad(this._assets[assetId])}else if(this._loadings.hasOwnProperty(assetId)){loadingInfo=this._loadings[assetId];loadingInfo.handlers.push(handler);++this._refCounts[assetId];waiting=true}else{var a=this._createAssetFor(assetIdOrConf);loadingInfo=new AssetLoadingInfo(a,handler);this._loadings[assetId]=loadingInfo;this._refCounts[assetId]=1;waiting=true;loadingInfo.loading=true;a._load(this)}return waiting};AssetManager.prototype.unrefAsset=function(assetOrId){var assetId=typeof assetOrId==="string"?assetOrId:assetOrId.id;if(--this._refCounts[assetId]>0)return;this._releaseAsset(assetId)};AssetManager.prototype.requestAssets=function(assetIdOrConfs,handler){var waitingCount=0;for(var i=0,len=assetIdOrConfs.length;i<len;++i){if(this.requestAsset(assetIdOrConfs[i],handler)){++waitingCount}}return waitingCount};AssetManager.prototype.unrefAssets=function(assetOrIds){for(var i=0,len=assetOrIds.length;i<len;++i){this.unrefAsset(assetOrIds[i])}};AssetManager.prototype._normalize=function(configuration,audioSystemConfMap){var ret={};if(!(configuration instanceof Object))throw g.ExceptionFactory.createAssertionError("AssetManager#_normalize: invalid arguments.");for(var p in configuration){if(!configuration.hasOwnProperty(p))continue;var conf=Object.create(configuration[p]);if(!conf.path){throw g.ExceptionFactory.createAssertionError("AssetManager#_normalize: No path given for: "+p)}if(!conf.virtualPath){throw g.ExceptionFactory.createAssertionError("AssetManager#_normalize: No virtualPath given for: "+p)}if(!conf.type){throw g.ExceptionFactory.createAssertionError("AssetManager#_normalize: No type given for: "+p)}if(conf.type==="image"){if(typeof conf.width!=="number")throw g.ExceptionFactory.createAssertionError("AssetManager#_normalize: wrong width given for the image asset: "+p);if(typeof conf.height!=="number")throw g.ExceptionFactory.createAssertionError("AssetManager#_normalize: wrong height given for the image asset: "+p)}if(conf.type==="audio"){if(conf.duration===undefined)conf.duration=0;var audioSystemConf=audioSystemConfMap[conf.systemId];if(conf.loop===undefined){conf.loop=!!audioSystemConf&&!!audioSystemConf.loop}if(conf.hint===undefined){conf.hint=audioSystemConf?audioSystemConf.hint:{}}}if(conf.type==="video"){if(!conf.useRealSize){if(typeof conf.width!=="number")throw g.ExceptionFactory.createAssertionError("AssetManager#_normalize: wrong width given for the video asset: "+p);if(typeof conf.height!=="number")throw g.ExceptionFactory.createAssertionError("AssetManager#_normalize: wrong height given for the video asset: "+p);conf.useRealSize=false}}if(!conf.global)conf.global=false;ret[p]=conf}return ret};AssetManager.prototype._createAssetFor=function(idOrConf){var id;var uri;var conf;if(typeof idOrConf==="string"){id=idOrConf;conf=this.configuration[id];uri=this.configuration[id].path}else{var dynConf=idOrConf;id=dynConf.id;conf=dynConf;uri=dynConf.uri}var resourceFactory=this.game.resourceFactory;if(!conf)throw g.ExceptionFactory.createAssertionError("AssetManager#_createAssetFor: unknown asset ID: "+id);switch(conf.type){case"image":return resourceFactory.createImageAsset(id,uri,conf.width,conf.height);case"audio":var system=conf.systemId?this.game.audio[conf.systemId]:this.game.audio[this.game.defaultAudioSystemId];return resourceFactory.createAudioAsset(id,uri,conf.duration,system,conf.loop,conf.hint);case"text":return resourceFactory.createTextAsset(id,uri);case"script":return resourceFactory.createScriptAsset(id,uri);case"video":return resourceFactory.createVideoAsset(id,uri,conf.width,conf.height,new g.VideoSystem,conf.loop,conf.useRealSize);default:throw g.ExceptionFactory.createAssertionError("AssertionError#_createAssetFor: unknown asset type "+conf.type+" for asset ID: "+id)}};AssetManager.prototype._releaseAsset=function(assetId){var asset=this._assets[assetId]||this._loadings[assetId]&&this._loadings[assetId].asset;var path;if(asset){path=asset.path;if(asset.inUse()){if(asset instanceof g.AudioAsset){asset._system.requestDestroy(asset)}else if(asset instanceof g.VideoAsset){asset.destroy()}else{throw g.ExceptionFactory.createAssertionError("AssetManager#unrefAssets: Unsupported in-use "+asset.constructor.name)}}else{asset.destroy()}}delete this._refCounts[assetId];delete this._loadings[assetId];delete this._assets[assetId];if(this.configuration[assetId]){var virtualPath=this.configuration[assetId].virtualPath;if(virtualPath&&this._liveAssetVirtualPathTable.hasOwnProperty(virtualPath))delete this._liveAssetVirtualPathTable[virtualPath];if(path&&this._liveAbsolutePathTable.hasOwnProperty(path))delete this._liveAbsolutePathTable[path]}};AssetManager.prototype._countLoadingAsset=function(){return Object.keys(this._loadings).length};AssetManager.prototype._onAssetError=function(asset,error){if(this.destroyed()||asset.destroyed())return;var loadingInfo=this._loadings[asset.id];var hs=loadingInfo.handlers;loadingInfo.loading=false;++loadingInfo.errorCount;if(loadingInfo.errorCount>AssetManager.MAX_ERROR_COUNT&&error.retriable){error=g.ExceptionFactory.createAssetLoadError("Retry limit exceeded",false,g.AssetLoadErrorType.RetryLimitExceeded,error)}if(!error.retriable)delete this._loadings[asset.id];for(var i=0;i<hs.length;++i)hs[i]._onAssetError(asset,error,this)};AssetManager.prototype._onAssetLoad=function(asset){if(this.destroyed()||asset.destroyed())return;var loadingInfo=this._loadings[asset.id];loadingInfo.loading=false;delete this._loadings[asset.id];this._assets[asset.id]=asset;if(this.configuration[asset.id]){var virtualPath=this.configuration[asset.id].virtualPath;if(!this._liveAssetVirtualPathTable.hasOwnProperty(virtualPath)){this._liveAssetVirtualPathTable[virtualPath]=asset}else{if(this._liveAssetVirtualPathTable[virtualPath].path!==asset.path)throw g.ExceptionFactory.createAssertionError("AssetManager#_onAssetLoad(): duplicated asset path")}if(!this._liveAbsolutePathTable.hasOwnProperty(asset.path))this._liveAbsolutePathTable[asset.path]=virtualPath}var hs=loadingInfo.handlers;for(var i=0;i<hs.length;++i)hs[i]._onAssetLoad(asset)};return AssetManager}();AssetManager.MAX_ERROR_COUNT=3;g.AssetManager=AssetManager})(g||(g={}));var g;(function(g){function _require(game,path,currentModule){var targetScriptAsset;var resolvedPath;var liveAssetVirtualPathTable=game._assetManager._liveAssetVirtualPathTable;var moduleMainScripts=game._assetManager._moduleMainScripts;if(path.indexOf("/")===-1){if(game._assetManager._assets.hasOwnProperty(path)){targetScriptAsset=game._assetManager._assets[path];resolvedPath=game._assetManager._liveAbsolutePathTable[targetScriptAsset.path]}}if(/^\.\/|^\.\.\/|^\//.test(path)){if(currentModule){if(!currentModule._virtualDirname)throw g.ExceptionFactory.createAssertionError("g._require: require from DynamicAsset is not supported");resolvedPath=g.PathUtil.resolvePath(currentModule._virtualDirname,path)}else{if(!/^\.\//.test(path))throw g.ExceptionFactory.createAssertionError("g._require: entry point path must start with './'");resolvedPath=path.substring(2)}if(game._scriptCaches.hasOwnProperty(resolvedPath)){return game._scriptCaches[resolvedPath]._cachedValue()}else if(game._scriptCaches.hasOwnProperty(resolvedPath+".js")){return game._scriptCaches[resolvedPath+".js"]._cachedValue()}if(!targetScriptAsset)targetScriptAsset=g.Util.findAssetByPathAsFile(resolvedPath,liveAssetVirtualPathTable);if(!targetScriptAsset)targetScriptAsset=g.Util.findAssetByPathAsDirectory(resolvedPath,liveAssetVirtualPathTable)}else{if(moduleMainScripts[path]){resolvedPath=moduleMainScripts[path];targetScriptAsset=game._assetManager._liveAssetVirtualPathTable[resolvedPath]}if(!targetScriptAsset){var dirs=currentModule?currentModule.paths:[];dirs.push("node_modules");for(var i=0;i<dirs.length;++i){var dir=dirs[i];resolvedPath=g.PathUtil.resolvePath(dir,path);targetScriptAsset=g.Util.findAssetByPathAsFile(resolvedPath,liveAssetVirtualPathTable);if(targetScriptAsset)break;targetScriptAsset=g.Util.findAssetByPathAsDirectory(resolvedPath,liveAssetVirtualPathTable);if(targetScriptAsset)break}}}if(targetScriptAsset){if(game._scriptCaches.hasOwnProperty(resolvedPath))return game._scriptCaches[resolvedPath]._cachedValue();if(targetScriptAsset instanceof g.ScriptAsset){var context=new g.ScriptAssetContext(game,targetScriptAsset);game._scriptCaches[resolvedPath]=context;return context._executeScript(currentModule)}else if(targetScriptAsset instanceof g.TextAsset){if(targetScriptAsset&&g.PathUtil.resolveExtname(path)===".json"){var cache=game._scriptCaches[resolvedPath]=new g.RequireCachedValue(JSON.parse(targetScriptAsset.data));return cache._cachedValue()}}}throw g.ExceptionFactory.createAssertionError("g._require: can not find module: "+path)}g._require=_require;var Module=function(){function Module(game,id,path){var _this=this;var dirname=g.PathUtil.resolveDirname(path);var virtualPath=game._assetManager._liveAbsolutePathTable[path];var virtualDirname=virtualPath?g.PathUtil.resolveDirname(virtualPath):undefined;var _g=Object.create(g,{game:{value:game,enumerable:true},filename:{value:path,enumerable:true},dirname:{value:dirname,enumerable:true},module:{value:this,writable:true,enumerable:true,configurable:true}});this.id=id;this.filename=path;this.exports={};this.parent=null;this.loaded=false;this.children=[];this.paths=virtualDirname?g.PathUtil.makeNodeModulePaths(virtualDirname):[];this._dirname=dirname;this._virtualDirname=virtualDirname;this._g=_g;this.require=function(path){return path==="g"?_g:g._require(game,path,_this)}}return Module}();g.Module=Module})(g||(g={}));var g;(function(g){var ScriptAssetContext=function(){function ScriptAssetContext(game,asset){this._game=game;this._asset=asset;this._module=new g.Module(game,asset.path,asset.path);this._g=this._module._g;this._started=false}ScriptAssetContext.prototype._cachedValue=function(){if(!this._started)throw g.ExceptionFactory.createAssertionError("ScriptAssetContext#_cachedValue: not executed yet.");return this._module.exports};ScriptAssetContext.prototype._executeScript=function(currentModule){if(this._started)return this._module.exports;if(currentModule){this._module.parent=currentModule;currentModule.children.push(this._module)}this._started=true;this._asset.execute(this._g);this._module.loaded=true;return this._module.exports};return ScriptAssetContext}();g.ScriptAssetContext=ScriptAssetContext})(g||(g={}));var g;(function(g){var PlainMatrix=function(){function PlainMatrix(widthOrSrc,height,scaleX,scaleY,angle){if(widthOrSrc===undefined){this._modified=false;this._matrix=[1,0,0,1,0,0]}else if(typeof widthOrSrc==="number"){this._modified=false;this._matrix=new Array(6);this.update(widthOrSrc,height,scaleX,scaleY,angle,0,0)}else{this._modified=widthOrSrc._modified;this._matrix=[widthOrSrc._matrix[0],widthOrSrc._matrix[1],widthOrSrc._matrix[2],widthOrSrc._matrix[3],widthOrSrc._matrix[4],widthOrSrc._matrix[5]]}}PlainMatrix.prototype.update=function(width,height,scaleX,scaleY,angle,x,y){var r=angle*Math.PI/180;var _cos=Math.cos(r);var _sin=Math.sin(r);var a=_cos*scaleX;var b=_sin*scaleX;var c=_sin*scaleY;var d=_cos*scaleY;var w=width/2;var h=height/2;this._matrix[0]=a;this._matrix[1]=b;this._matrix[2]=-c;this._matrix[3]=d;this._matrix[4]=-a*w+c*h+w+x;this._matrix[5]=-b*w-d*h+h+y};PlainMatrix.prototype.updateByInverse=function(width,height,scaleX,scaleY,angle,x,y){var r=angle*Math.PI/180;var _cos=Math.cos(r);var _sin=Math.sin(r);var a=_cos/scaleX;var b=_sin/scaleY;var c=_sin/scaleX;var d=_cos/scaleY;var w=width/2;var h=height/2;this._matrix[0]=a;this._matrix[1]=-b;this._matrix[2]=c;this._matrix[3]=d;this._matrix[4]=-a*(w+x)-c*(h+y)+w;this._matrix[5]=b*(w+x)-d*(h+y)+h};PlainMatrix.prototype.multiply=function(matrix){var m1=this._matrix;var m2=matrix._matrix;var m10=m1[0];var m11=m1[1];var m12=m1[2];var m13=m1[3];m1[0]=m10*m2[0]+m12*m2[1];m1[1]=m11*m2[0]+m13*m2[1];m1[2]=m10*m2[2]+m12*m2[3];m1[3]=m11*m2[2]+m13*m2[3];m1[4]=m10*m2[4]+m12*m2[5]+m1[4];m1[5]=m11*m2[4]+m13*m2[5]+m1[5]};PlainMatrix.prototype.multiplyNew=function(matrix){var ret=this.clone();ret.multiply(matrix);return ret};PlainMatrix.prototype.reset=function(x,y){this._matrix[0]=1;this._matrix[1]=0;this._matrix[2]=0;this._matrix[3]=1;this._matrix[4]=x||0;this._matrix[5]=y||0};PlainMatrix.prototype.clone=function(){return new PlainMatrix(this)};PlainMatrix.prototype.multiplyInverseForPoint=function(point){var m=this._matrix;var _id=1/(m[0]*m[3]+m[2]*-m[1]);return{x:m[3]*_id*point.x+-m[2]*_id*point.y+(m[5]*m[2]-m[4]*m[3])*_id,y:m[0]*_id*point.y+-m[1]*_id*point.x+(-m[5]*m[0]+m[4]*m[1])*_id}};PlainMatrix.prototype.scale=function(x,y){var m=this._matrix;m[0]*=x;m[1]*=y;m[2]*=x;m[3]*=y;m[4]*=x;m[5]*=y};PlainMatrix.prototype.multiplyPoint=function(point){var m=this._matrix;var x=m[0]*point.x+m[2]*point.y+m[4];var y=m[1]*point.x+m[3]*point.y+m[5];return{x:x,y:y}};PlainMatrix.prototype.multplyPoint=function(point){return this.multiplyPoint(point)};return PlainMatrix}();g.PlainMatrix=PlainMatrix})(g||(g={}));var g;(function(g){var Util;(function(Util){function distance(p1x,p1y,p2x,p2y){return Math.sqrt(Math.pow(p1x-p2x,2)+Math.pow(p1y-p2y,2))}Util.distance=distance;function distanceBetweenOffsets(p1,p2){return Util.distance(p1.x,p1.y,p2.x,p2.y)}Util.distanceBetweenOffsets=distanceBetweenOffsets;function distanceBetweenAreas(p1,p2){return Util.distance(p1.x-p1.width/2,p1.y-p1.height/2,p2.x-p2.width/2,p2.y-p2.height/2)}Util.distanceBetweenAreas=distanceBetweenAreas;function createMatrix(width,height,scaleX,scaleY,angle){if(width===undefined)return new g.PlainMatrix;return new g.PlainMatrix(width,height,scaleX,scaleY,angle)}Util.createMatrix=createMatrix;function createSpriteFromE(scene,e,camera){var oldX=e.x;var oldY=e.y;var x=0;var y=0;var width=e.width;var height=e.height;var boundingRect=e.calculateBoundingRect(camera);if(!boundingRect){throw g.ExceptionFactory.createAssertionError("Util#createSpriteFromE: camera must look e")}width=boundingRect.right-boundingRect.left;height=boundingRect.bottom-boundingRect.top;if(boundingRect.left<e.x)x=e.x-boundingRect.left;if(boundingRect.top<e.y)y=e.y-boundingRect.top;e.moveTo(x,y);if(e._matrix)e._matrix._modified=true;var surface=scene.game.resourceFactory.createSurface(Math.ceil(width),Math.ceil(height));var renderer=surface.renderer();renderer.begin();e.render(renderer,camera);renderer.end();var s=new g.Sprite({scene:scene,src:surface,width:width,height:height});s.moveTo(boundingRect.left,boundingRect.top);e.moveTo(oldX,oldY);if(e._matrix)e._matrix._modified=true;return s}Util.createSpriteFromE=createSpriteFromE;function createSpriteFromScene(toScene,fromScene,camera){var surface=toScene.game.resourceFactory.createSurface(Math.ceil(fromScene.game.width),Math.ceil(fromScene.game.height));var renderer=surface.renderer();renderer.begin();var children=fromScene.children;for(var i=0;i<children.length;++i)children[i].render(renderer,camera);renderer.end();return new g.Sprite({scene:toScene,src:surface,width:fromScene.game.width,height:fromScene.game.height})}Util.createSpriteFromScene=createSpriteFromScene;function asSurface(src){if(!src)return src;if(src instanceof g.Surface)return src;if(src instanceof g.ImageAsset)return src.asSurface();throw g.ExceptionFactory.createTypeMismatchError("Util#asSurface","ImageAsset|Surface",src)}Util.asSurface=asSurface;function findAssetByPathAsFile(resolvedPath,liveAssetPathTable){if(liveAssetPathTable.hasOwnProperty(resolvedPath))return liveAssetPathTable[resolvedPath];if(liveAssetPathTable.hasOwnProperty(resolvedPath+".js"))return liveAssetPathTable[resolvedPath+".js"];return undefined}Util.findAssetByPathAsFile=findAssetByPathAsFile;function findAssetByPathAsDirectory(resolvedPath,liveAssetPathTable){var path;path=resolvedPath+"/package.json";if(liveAssetPathTable.hasOwnProperty(path)&&liveAssetPathTable[path]instanceof g.TextAsset){var pkg=JSON.parse(liveAssetPathTable[path].data);if(pkg&&typeof pkg.main==="string"){var asset=Util.findAssetByPathAsFile(g.PathUtil.resolvePath(resolvedPath,pkg.main),liveAssetPathTable);if(asset)return asset}}path=resolvedPath+"/index.js";if(liveAssetPathTable.hasOwnProperty(path))return liveAssetPathTable[path];return undefined}Util.findAssetByPathAsDirectory=findAssetByPathAsDirectory;function charCodeAt(str,idx){var code=str.charCodeAt(idx);if(55296<=code&&code<=56319){var hi=code;var low=str.charCodeAt(idx+1);return hi<<16|low}if(56320<=code&&code<=57343){return null}return code}Util.charCodeAt=charCodeAt;function setupAnimatingHandler(animatingHandler,surface){if(surface.isDynamic){surface.animatingStarted.handle(animatingHandler,animatingHandler._onAnimatingStarted);surface.animatingStopped.handle(animatingHandler,animatingHandler._onAnimatingStopped);if(surface.isPlaying()){animatingHandler._onAnimatingStarted()}}}Util.setupAnimatingHandler=setupAnimatingHandler;function migrateAnimatingHandler(animatingHandler,beforeSurface,afterSurface){animatingHandler._onAnimatingStopped();if(!beforeSurface.destroyed()&&beforeSurface.isDynamic){beforeSurface.animatingStarted.remove(animatingHandler,animatingHandler._onAnimatingStarted);beforeSurface.animatingStopped.remove(animatingHandler,animatingHandler._onAnimatingStopped)}if(afterSurface.isDynamic){afterSurface.animatingStarted.handle(animatingHandler,animatingHandler._onAnimatingStarted);afterSurface.animatingStopped.handle(animatingHandler,animatingHandler._onAnimatingStopped);if(afterSurface.isPlaying()){animatingHandler._onAnimatingStarted()}}}Util.migrateAnimatingHandler=migrateAnimatingHandler})(Util=g.Util||(g.Util={}))})(g||(g={}));var g;(function(g){var Collision;(function(Collision){function intersect(x1,y1,width1,height1,x2,y2,width2,height2){return x1<=x2+width2&&x2<=x1+width1&&y1<=y2+height2&&y2<=y1+height1}Collision.intersect=intersect;function intersectAreas(t1,t2){return Collision.intersect(t1.x,t1.y,t1.width,t1.height,t2.x,t2.y,t2.width,t2.height)}Collision.intersectAreas=intersectAreas;function within(t1x,t1y,t2x,t2y,distance){if(distance===void 0){distance=1}return distance>=g.Util.distance(t1x,t1y,t2x,t2y)}Collision.within=within;function withinAreas(t1,t2,distance){if(distance===void 0){distance=1}return distance>=g.Util.distanceBetweenAreas(t1,t2)}Collision.withinAreas=withinAreas})(Collision=g.Collision||(g.Collision={}))})(g||(g={}));var g;(function(g){var Trigger=function(){function Trigger(chain){this.chain=chain;this._handlers=[]}Trigger.prototype.handle=function(owner,handler,name){if(!this._handlers.length)this._activateChain();if(!handler){this._handlers.push({owner:undefined,handler:owner,name:name})}else{this._handlers.push({owner:owner,handler:handler,name:name})}};Trigger.prototype.destroy=function(){this._deactivateChain();this.chain=undefined;this._handlers=undefined};Trigger.prototype.destroyed=function(){return this._handlers===undefined};Trigger.prototype.hasHandler=function(){return this._handlers&&this._handlers.length>0};Trigger.prototype.handleInsert=function(index,owner,handler,name){if(!this._handlers.length)this._activateChain();if(!handler){this._handlers.splice(index,0,{owner:undefined,handler:owner,name:name})}else{this._handlers.splice(index,0,{owner:owner,handler:handler,name:name})}};Trigger.prototype.removeAll=function(owner){var handlers=[];var tmp;while(tmp=this._handlers.shift())if(tmp.owner!==owner)handlers.push(tmp);this._handlers=handlers;if(!this._handlers.length)this._deactivateChain()};Trigger.prototype.removeAllByHandler=function(handler){var handlers=[];var tmp;while(tmp=this._handlers.shift())if(tmp.handler!==handler)handlers.push(tmp);this._handlers=handlers;if(!this._handlers.length)this._deactivateChain()};Trigger.prototype.remove=function(owner,handler){var handlers=[];if(!handler){handler=owner;owner=undefined}for(var i=0;i<this._handlers.length;++i){var tmp=this._handlers[i];if(tmp.handler!==handler||tmp.owner!==owner)handlers.push(tmp)}this._handlers=handlers;if(!this._handlers.length)this._deactivateChain()};Trigger.prototype.removeByName=function(name){var handlers=[];for(var i=0;i<this._handlers.length;++i){var tmp=this._handlers[i];if(tmp.name!==name)handlers.push(tmp)}this._handlers=handlers;if(!this._handlers.length)this._deactivateChain()};Trigger.prototype.isHandled=function(owner,handler){if(!handler){handler=owner;owner=undefined}for(var i=0;i<this._handlers.length;++i){if(this._handlers[i].owner===owner&&this._handlers[i].handler===handler)return true}return false};Trigger.prototype.fire=function(param){if(!this._handlers||!this._handlers.length)return;var handlers=this._handlers.concat();for(var i=0;i<handlers.length;++i){var handler=handlers[i];if(handler.handler.call(handler.owner,param))this._remove(handler)}};Trigger.prototype._reset=function(){this._handlers=[];this._deactivateChain()};Trigger.prototype._activateChain=function(){if(!this.chain)return;if(this.chain.isHandled(this,this._onChainFire))return;this.chain.handle(this,this._onChainFire)};Trigger.prototype._deactivateChain=function(){if(!this.chain)return;if(!this.chain.isHandled(this,this._onChainFire))return;this.chain.remove(this,this._onChainFire)};Trigger.prototype._remove=function(handler){var index=this._handlers.indexOf(handler);if(index===-1)return;this._handlers.splice(index,1);if(!this._handlers.length)this._deactivateChain()};Trigger.prototype._onChainFire=function(e){this.fire(e)};return Trigger}();g.Trigger=Trigger;var ConditionalChainTrigger=function(_super){__extends(ConditionalChainTrigger,_super);function ConditionalChainTrigger(chain,filterOwner,filter){var _this=_super.call(this,chain)||this;_this.filterOwner=filterOwner;_this.filter=filter;return _this}ConditionalChainTrigger.prototype._onChainFire=function(e){if(this.filter&&!this.filter.call(this.filterOwner,e))return;this.fire(e)};return ConditionalChainTrigger}(Trigger);g.ConditionalChainTrigger=ConditionalChainTrigger})(g||(g={}));var g;(function(g){var Timer=function(){function Timer(interval,fps){this.interval=interval;this._scaledInterval=Math.round(interval*fps);this.elapsed=new g.Trigger;this._scaledElapsed=0}Timer.prototype.tick=function(){this._scaledElapsed+=1e3;while(this._scaledElapsed>=this._scaledInterval){if(!this.elapsed){break}this.elapsed.fire();this._scaledElapsed-=this._scaledInterval}};Timer.prototype.canDelete=function(){return!this.elapsed.hasHandler()};Timer.prototype.destroy=function(){this.interval=undefined;this.elapsed.destroy();this.elapsed=undefined;this._scaledInterval=0;this._scaledElapsed=0};Timer.prototype.destroyed=function(){return this.elapsed===undefined};return Timer}();g.Timer=Timer})(g||(g={}));var g;(function(g){var TimerIdentifier=function(){function TimerIdentifier(timer,handler,handlerOwner,fired,firedOwner){this._timer=timer;this._handler=handler;this._handlerOwner=handlerOwner;this._fired=fired;this._firedOwner=firedOwner;this._timer.elapsed.handle(this,this._fire)}TimerIdentifier.prototype.destroy=function(){this._timer.elapsed.remove(this,this._fire);this._timer=undefined;this._handler=undefined;this._handlerOwner=undefined;this._fired=undefined;this._firedOwner=undefined};TimerIdentifier.prototype.destroyed=function(){return this._timer===undefined};TimerIdentifier.prototype._fire=function(){this._handler.call(this._handlerOwner);if(this._fired){this._fired.call(this._firedOwner,this)}};return TimerIdentifier}();g.TimerIdentifier=TimerIdentifier;var TimerManager=function(){function TimerManager(trigger,fps){this._timers=[];this._trigger=trigger;this._identifiers=[];this._fps=fps;this._registered=false}TimerManager.prototype.destroy=function(){for(var i=0;i<this._identifiers.length;++i){this._identifiers[i].destroy()}for(var i=0;i<this._timers.length;++i){this._timers[i].destroy()}this._timers=undefined;this._trigger=undefined;this._identifiers=undefined;this._fps=undefined};TimerManager.prototype.destroyed=function(){return this._timers===undefined};TimerManager.prototype.createTimer=function(interval){if(!this._registered){this._trigger.handle(this,this._tick);this._registered=true}if(interval<0)throw g.ExceptionFactory.createAssertionError("TimerManager#createTimer: invalid interval");if(interval<1)interval=1;var acceptableMargin=Math.min(1e3,interval*this._fps);for(var i=0;i<this._timers.length;++i){if(this._timers[i].interval===interval){if(this._timers[i]._scaledElapsed<acceptableMargin){return this._timers[i]}}}var timer=new g.Timer(interval,this._fps);this._timers.push(timer);return timer};TimerManager.prototype.deleteTimer=function(timer){if(!timer.canDelete())return;var index=this._timers.indexOf(timer);if(index<0)throw g.ExceptionFactory.createAssertionError("TimerManager#deleteTimer: can not find timer");this._timers.splice(index,1);timer.destroy();if(!this._timers.length){if(!this._registered)throw g.ExceptionFactory.createAssertionError("TimerManager#deleteTimer: handler is not handled");this._trigger.remove(this,this._tick);this._registered=false}};TimerManager.prototype.setTimeout=function(milliseconds,owner,handler){if(handler===undefined){handler=owner;owner=null}var timer=this.createTimer(milliseconds);var identifier=new TimerIdentifier(timer,handler,owner,this._onTimeoutFired,this);this._identifiers.push(identifier);return identifier};TimerManager.prototype.clearTimeout=function(identifier){this._clear(identifier)};TimerManager.prototype.setInterval=function(interval,owner,handler){if(handler===undefined){handler=owner;owner=null}var timer=this.createTimer(interval);var identifier=new TimerIdentifier(timer,handler,owner);this._identifiers.push(identifier);return identifier};TimerManager.prototype.clearInterval=function(identifier){this._clear(identifier)};TimerManager.prototype._tick=function(){var timers=this._timers.concat();for(var i=0;i<timers.length;++i)timers[i].tick()};TimerManager.prototype._onTimeoutFired=function(identifier){var index=this._identifiers.indexOf(identifier);if(index<0)throw g.ExceptionFactory.createAssertionError("TimerManager#_onTimeoutFired: can not find identifier");this._identifiers.splice(index,1);var timer=identifier._timer;identifier.destroy();this.deleteTimer(timer)};TimerManager.prototype._clear=function(identifier){var index=this._identifiers.indexOf(identifier);if(index<0)throw g.ExceptionFactory.createAssertionError("TimerManager#_clear: can not find identifier");if(identifier.destroyed())throw g.ExceptionFactory.createAssertionError("TimerManager#_clear: invalid identifier");this._identifiers.splice(index,1);var timer=identifier._timer;identifier.destroy();this.deleteTimer(timer)};return TimerManager}();g.TimerManager=TimerManager})(g||(g={}));var g;(function(g){var AudioPlayer=function(){function AudioPlayer(system){this.played=new g.Trigger;this.stopped=new g.Trigger;this.currentAudio=undefined;this.volume=system.volume;this._muted=system._muted;this._playbackRate=system._playbackRate;this._system=system}AudioPlayer.prototype.play=function(audio){this.currentAudio=audio;this.played.fire({player:this,audio:audio})};AudioPlayer.prototype.stop=function(){var audio=this.currentAudio;if(!audio)return;this.currentAudio=undefined;this.stopped.fire({player:this,audio:audio})};AudioPlayer.prototype.canHandleStopped=function(){return true};AudioPlayer.prototype.changeVolume=function(volume){this.volume=volume};AudioPlayer.prototype._changeMuted=function(muted){this._muted=muted};AudioPlayer.prototype._changePlaybackRate=function(rate){this._playbackRate=rate};AudioPlayer.prototype._supportsPlaybackRate=function(){return false};AudioPlayer.prototype._onVolumeChanged=function(){};return AudioPlayer}();g.AudioPlayer=AudioPlayer})(g||(g={}));var g;(function(g){var AudioSystem=function(){function AudioSystem(id,game){var audioSystemManager=game._audioSystemManager;this.id=id;this.game=game;this._volume=1;this._destroyRequestedAssets={};this._muted=audioSystemManager._muted;this._playbackRate=audioSystemManager._playbackRate}Object.defineProperty(AudioSystem.prototype,"volume",{get:function(){return this._volume},set:function(value){if(value<0||value>1||isNaN(value)||typeof value!=="number")throw g.ExceptionFactory.createAssertionError("AudioSystem#volume: expected: 0.0-1.0, actual: "+value);this._volume=value;this._onVolumeChanged()},enumerable:true,configurable:true});AudioSystem.prototype.stopAll=function(){throw g.ExceptionFactory.createPureVirtualError("AudioSystem#stopAll")};AudioSystem.prototype.findPlayers=function(asset){throw g.ExceptionFactory.createPureVirtualError("AudioSystem#findPlayers")};AudioSystem.prototype.createPlayer=function(){throw g.ExceptionFactory.createPureVirtualError("AudioSystem#createPlayer")};AudioSystem.prototype.requestDestroy=function(asset){this._destroyRequestedAssets[asset.id]=asset};AudioSystem.prototype._reset=function(){this.stopAll();this._volume=1;this._destroyRequestedAssets={};this._muted=this.game._audioSystemManager._muted;this._playbackRate=this.game._audioSystemManager._playbackRate};AudioSystem.prototype._setMuted=function(value){var before=this._muted;this._muted=!!value;if(this._muted!==before){this._onMutedChanged()}};AudioSystem.prototype._setPlaybackRate=function(value){if(value<0||isNaN(value)||typeof value!=="number")throw g.ExceptionFactory.createAssertionError("AudioSystem#playbackRate: expected: greater or equal to 0.0, actual: "+value);var before=this._playbackRate;this._playbackRate=value;if(this._playbackRate!==before){this._onPlaybackRateChanged()}};AudioSystem.prototype._onVolumeChanged=function(){throw g.ExceptionFactory.createPureVirtualError("AudioSystem#_onVolumeChanged")};AudioSystem.prototype._onMutedChanged=function(){throw g.ExceptionFactory.createPureVirtualError("AudioSystem#_onMutedChanged")};AudioSystem.prototype._onPlaybackRateChanged=function(){throw g.ExceptionFactory.createPureVirtualError("AudioSystem#_onPlaybackRateChanged")};return AudioSystem}();g.AudioSystem=AudioSystem;var MusicAudioSystem=function(_super){__extends(MusicAudioSystem,_super);function MusicAudioSystem(id,game){var _this=_super.call(this,id,game)||this;_this._player=undefined;_this._suppressingAudio=undefined;return _this}Object.defineProperty(MusicAudioSystem.prototype,"player",{get:function(){if(!this._player){this._player=this.game.resourceFactory.createAudioPlayer(this);this._player.played.handle(this,this._onPlayerPlayed);this._player.stopped.handle(this,this._onPlayerStopped)}return this._player},set:function(v){this._player=v},enumerable:true,configurable:true});MusicAudioSystem.prototype.findPlayers=function(asset){if(this.player.currentAudio&&this.player.currentAudio.id===asset.id)return[this.player];return[]};MusicAudioSystem.prototype.createPlayer=function(){return this.player};MusicAudioSystem.prototype.stopAll=function(){if(!this._player)return;this._player.stop()};MusicAudioSystem.prototype._reset=function(){_super.prototype._reset.call(this);if(this._player){this._player.played.remove({owner:this,func:this._onPlayerPlayed});this._player.stopped.remove({owner:this,func:this._onPlayerStopped})}this._player=undefined;this._suppressingAudio=undefined};MusicAudioSystem.prototype._onVolumeChanged=function(){this.player.changeVolume(this._volume)};MusicAudioSystem.prototype._onMutedChanged=function(){this.player._changeMuted(this._muted)};MusicAudioSystem.prototype._onPlaybackRateChanged=function(){var player=this.player;player._changePlaybackRate(this._playbackRate);if(!player._supportsPlaybackRate()){this._onUnsupportedPlaybackRateChanged()}};MusicAudioSystem.prototype._onUnsupportedPlaybackRateChanged=function(){if(this._playbackRate===1){if(this._suppressingAudio){var audio=this._suppressingAudio;this._suppressingAudio=undefined;if(!audio.destroyed()){this.player.play(audio)}}}};MusicAudioSystem.prototype._onPlayerPlayed=function(e){if(e.player!==this._player)throw g.ExceptionFactory.createAssertionError("MusicAudioSystem#_onPlayerPlayed: unexpected audio player");if(e.player._supportsPlaybackRate())return;if(this._playbackRate!==1){e.player.stop();this._suppressingAudio=e.audio}};MusicAudioSystem.prototype._onPlayerStopped=function(e){if(this._destroyRequestedAssets[e.audio.id]){delete this._destroyRequestedAssets[e.audio.id];e.audio.destroy()}};return MusicAudioSystem}(AudioSystem);g.MusicAudioSystem=MusicAudioSystem;var SoundAudioSystem=function(_super){__extends(SoundAudioSystem,_super);function SoundAudioSystem(id,game){var _this=_super.call(this,id,game)||this;_this.players=[];return _this}SoundAudioSystem.prototype.createPlayer=function(){var player=this.game.resourceFactory.createAudioPlayer(this);if(player.canHandleStopped())this.players.push(player);player.played.handle(this,this._onPlayerPlayed);player.stopped.handle(this,this._onPlayerStopped);return player};SoundAudioSystem.prototype.findPlayers=function(asset){var ret=[];for(var i=0;i<this.players.length;++i){if(this.players[i].currentAudio&&this.players[i].currentAudio.id===asset.id)ret.push(this.players[i])}return ret};SoundAudioSystem.prototype.stopAll=function(){var players=this.players.concat();for(var i=0;i<players.length;++i){players[i].stop()}};SoundAudioSystem.prototype._reset=function(){_super.prototype._reset.call(this);for(var i=0;i<this.players.length;++i){var player=this.players[i];player.played.remove({owner:this,func:this._onPlayerPlayed});player.stopped.remove({owner:this,func:this._onPlayerStopped})}this.players=[]};SoundAudioSystem.prototype._onMutedChanged=function(){var players=this.players;for(var i=0;i<players.length;++i){players[i]._changeMuted(this._muted)}};SoundAudioSystem.prototype._onPlaybackRateChanged=function(){var players=this.players;for(var i=0;i<players.length;++i){players[i]._changePlaybackRate(this._playbackRate)}};SoundAudioSystem.prototype._onPlayerPlayed=function(e){if(e.player._supportsPlaybackRate())return;if(this._playbackRate!==1){e.player.stop()}};SoundAudioSystem.prototype._onPlayerStopped=function(e){var index=this.players.indexOf(e.player);if(index<0)return;e.player.stopped.remove(this,this._onPlayerStopped);this.players.splice(index,1);if(this._destroyRequestedAssets[e.audio.id]){delete this._destroyRequestedAssets[e.audio.id];e.audio.destroy()}};SoundAudioSystem.prototype._onVolumeChanged=function(){for(var i=0;i<this.players.length;++i){this.players[i].changeVolume(this._volume)}};return SoundAudioSystem}(AudioSystem);g.SoundAudioSystem=SoundAudioSystem})(g||(g={}));var g;(function(g){var VideoPlayer=function(){function VideoPlayer(loop){this._loop=!!loop;this.played=new g.Trigger;this.stopped=new g.Trigger;this.currentVideo=undefined;this.volume=1}VideoPlayer.prototype.play=function(videoAsset){this.currentVideo=videoAsset;this.played.fire({player:this,video:videoAsset});videoAsset.asSurface().animatingStarted.fire()};VideoPlayer.prototype.stop=function(){var videoAsset=this.currentVideo;this.stopped.fire({player:this,video:videoAsset});videoAsset.asSurface().animatingStopped.fire()};VideoPlayer.prototype.changeVolume=function(volume){this.volume=volume};return VideoPlayer}();g.VideoPlayer=VideoPlayer})(g||(g={}));var g;(function(g){var VideoSystem=function(){function VideoSystem(){}return VideoSystem}();g.VideoSystem=VideoSystem})(g||(g={}));var g;(function(g){var Object2D=function(){function Object2D(param){if(!param){this.x=0;this.y=0;this.width=0;this.height=0;this.opacity=1;this.scaleX=1;this.scaleY=1;this.angle=0;this.compositeOperation=undefined;this._matrix=undefined}else{this.x=param.x||0;this.y=param.y||0;this.width=param.width||0;this.height=param.height||0;this.opacity="opacity"in param?param.opacity:1;this.scaleX="scaleX"in param?param.scaleX:1;this.scaleY="scaleY"in param?param.scaleY:1;this.angle=param.angle||0;this.compositeOperation=param.compositeOperation;this._matrix=undefined}}Object2D.prototype.moveTo=function(posOrX,y){if(typeof posOrX==="number"&&typeof y!=="number"){throw g.ExceptionFactory.createAssertionError("Object2D#moveTo: arguments must be CommonOffset or pair of x and y as a number.")}if(typeof posOrX==="number"){this.x=posOrX;this.y=y}else{this.x=posOrX.x;this.y=posOrX.y}};Object2D.prototype.moveBy=function(x,y){this.x+=x;this.y+=y};Object2D.prototype.resizeTo=function(sizeOrWidth,height){if(typeof sizeOrWidth==="number"&&typeof height!=="number"){throw g.ExceptionFactory.createAssertionError("Object2D#resizeTo: arguments must be CommonSize or pair of width and height as a number.")}if(typeof sizeOrWidth==="number"){this.width=sizeOrWidth;this.height=height}else{this.width=sizeOrWidth.width;this.height=sizeOrWidth.height}};Object2D.prototype.resizeBy=function(width,height){this.width+=width;this.height+=height};Object2D.prototype.scale=function(scale){this.scaleX=scale;this.scaleY=scale};Object2D.prototype.getMatrix=function(){if(!this._matrix){this._matrix=g.Util.createMatrix()}else if(!this._matrix._modified){return this._matrix}this._updateMatrix();this._matrix._modified=false;return this._matrix};Object2D.prototype._updateMatrix=function(){if(this.angle||this.scaleX!==1||this.scaleY!==1){this._matrix.update(this.width,this.height,this.scaleX,this.scaleY,this.angle,this.x,this.y)}else{this._matrix.reset(this.x,this.y)}};return Object2D}();g.Object2D=Object2D})(g||(g={}));var g;(function(g){var E=function(_super){__extends(E,_super);function E(sceneOrParam){var _this=this;if(sceneOrParam instanceof g.Scene){var scene=sceneOrParam;_this=_super.call(this)||this;_this.children=undefined;_this.parent=undefined;_this._touchable=false;_this.state=0;_this._hasTouchableChildren=false;_this._update=undefined;_this._message=undefined;_this._pointDown=undefined;_this._pointMove=undefined;_this._pointUp=undefined;_this._targetCameras=undefined;_this.local=scene.local!==g.LocalTickMode.NonLocal;scene.register(_this);scene.game.logger.debug("[deprecated] E or Subclass of E: This constructor is deprecated. "+"Refer to the API documentation and use each constructor(param: ParameterObject) instead.")}else{var param=sceneOrParam;_this=_super.call(this,param)||this;_this.children=undefined;_this.parent=undefined;_this._touchable=false;_this.state=0;_this._hasTouchableChildren=false;_this._update=undefined;_this._message=undefined;_this._pointDown=undefined;_this._pointMove=undefined;_this._pointUp=undefined;_this._targetCameras=undefined;_this.tag=param.tag;_this.local=param.scene.local!==g.LocalTickMode.NonLocal||!!param.local;if(param.children){for(var i=0;i<param.children.length;++i)_this.append(param.children[i])}if(param.parent){param.parent.append(_this)}if(param.targetCameras)_this.targetCameras=param.targetCameras;if("touchable"in param)_this.touchable=param.touchable;if(!!param.hidden)_this.hide();_this.id=param.id;param.scene.register(_this)}return _this}Object.defineProperty(E.prototype,"update",{get:function(){if(!this._update)this._update=new g.Trigger(this.scene.update);return this._update},enumerable:true,configurable:true});Object.defineProperty(E.