@esengine/ecs-framework
Version:
用于Laya、Cocos Creator等JavaScript游戏引擎的高性能ECS框架
3 lines • 349 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ECS={})}(this,function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function n(e,t,n,i,r,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(i,r)}function i(e){return function(){var t=this,i=arguments;return new Promise(function(r,o){var s=e.apply(t,i);function a(e){n(s,r,o,a,c,"next",e)}function c(e){n(s,r,o,a,c,"throw",e)}a(void 0)})}}function r(e,t,n){if(h())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var r=new(e.bind.apply(e,i));return n&&p(r,n.prototype),r}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,m(i.key),i)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,n){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(i)return(i=i.call(e)).next.bind(i);if(Array.isArray(e)||(i=function(e,n){if(e){if("string"==typeof e)return t(e,n);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,n):void 0}}(e))||n){i&&(e=i);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},c.apply(null,arguments)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,p(e,t)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}function d(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var c=i&&i.prototype instanceof a?i:a,u=Object.create(c.prototype);return f(u,"_invoke",function(n,i,r){var o,a,c,u=0,l=r||[],h=!1,d={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,a=0,c=e,d.n=n,s}};function f(n,i){for(a=n,c=i,t=0;!h&&u&&!r&&t<l.length;t++){var r,o=l[t],f=d.p,p=o[2];n>3?(r=p===i)&&(c=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,d.v=i,d.n=o[1]):f<p&&(r=n<3||o[0]>i||i>p)&&(o[4]=n,o[5]=i,d.n=p,a=0))}if(r||n>1)return s;throw h=!0,i}return function(r,l,p){if(u>1)throw TypeError("Generator is already running");for(h&&1===l&&f(l,p),a=l,c=p;(t=a<2?e:c)||!h;){o||(a?a<3?(a>1&&(d.n=-1),f(a,c)):d.n=c:d.v=c);try{if(u=2,o){if(a||(r="next"),t=o[r]){if(!(t=t.call(o,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(c=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=e}else if((t=(h=d.n<0)?c:n.call(i,d))!==s)break}catch(t){o=e,a=1,c=t}finally{u=1}}return{value:t,done:h}}}(n,r,o),!0),u}var s={};function a(){}function c(){}function u(){}t=Object.getPrototypeOf;var l=[][i]?t(t([][i]())):(f(t={},i,function(){return this}),t),h=u.prototype=a.prototype=Object.create(l);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,f(e,r,"GeneratorFunction")),e.prototype=Object.create(h),e}return c.prototype=u,f(h,"constructor",u),f(u,"constructor",c),c.displayName="GeneratorFunction",f(u,r,"GeneratorFunction"),f(h),f(h,r,"Generator"),f(h,i,function(){return this}),f(h,"toString",function(){return"[object Generator]"}),(d=function(){return{w:o,m:p}})()}function f(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}f=function(e,t,n,i){function o(t,n){f(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},f(e,t,n,i)}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function m(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function v(e){var t="function"==typeof Map?new Map:void 0;return v=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return r(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,e)},v(e)}function y(e,t,n,i){var r,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(o<3?r(s):o>3?r(t,n,s):r(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function g(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;var _=function(){function e(){}return e.update=function(e){this.unscaledDeltaTime=e,this.deltaTime=e*this.timeScale,this.unscaledTotalTime+=this.unscaledDeltaTime,this.totalTime+=this.deltaTime,this.frameCount++},e.sceneChanged=function(){this.frameCount=0,this.totalTime=0,this.unscaledTotalTime=0,this.deltaTime=0,this.unscaledDeltaTime=0},e.checkEvery=function(e,t){return this.totalTime-t>=e},e}();_.deltaTime=0,_.unscaledDeltaTime=0,_.totalTime=0,_.unscaledTotalTime=0,_.timeScale=1,_.frameCount=0;var S,C=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}var t=e.prototype;return t.getContext=function(){return this.context},t.reset=function(){this._elapsedTime=0},t.stop=function(){this._isDone=!0},t.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=_.deltaTime,this._isDone},t.initialize=function(e,t,n,i){this._timeInSeconds=e,this._repeats=t,this.context=n,this._onTime=i.bind(n)},t.unload=function(){this.context=null,this._onTime=null},s(e,[{key:"isDone",get:function(){return this._isDone}},{key:"elapsedTime",get:function(){return this._elapsedTime}}])}(),E=new WeakMap,b=new WeakMap;function T(){return function(e){var t=E.get(e);E.set(e,c({injectable:!0,dependencies:[]},(null==t?void 0:t.properties)&&{properties:t.properties}))}}function w(e){return void 0===e&&(e=0),function(t){var n=t.prototype;if(!n||"function"!=typeof n.update)throw new Error("@Updatable() decorator requires class "+t.name+" to implement IUpdatable interface with update() method. Please add 'implements IUpdatable' and define update(deltaTime?: number): void method.");b.set(t,{updatable:!0,priority:e})}}function I(e){return function(t,n){var i=E.get(t.constructor);i||(i={injectable:!0,dependencies:[]},E.set(t.constructor,i)),i.properties||(i.properties=new Map),i.properties.set(n,e)}}function M(e){var t,n=E.get(e);return null!==(t=null==n?void 0:n.injectable)&&void 0!==t&&t}function A(e,t){var n=new e;return k(n,t),n}function k(e,t){var n,i=e.constructor,r=(n=i,E.get(n));if(null!=r&&r.properties&&0!==r.properties.size)for(var o,s=a(r.properties);!(o=s()).done;){var c=o.value,u=c[0],l=c[1],h=t.resolve(l);null!==h&&(e[u]=h)}}function D(e){var t,n=b.get(e);return null!==(t=null==n?void 0:n.updatable)&&void 0!==t&&t}function P(e){return b.get(e)}e.TimerManager=function(){function e(){this._timers=[]}var t=e.prototype;return t.update=function(){for(var e=this._timers.length-1;e>=0;e--)this._timers[e].tick()&&(this._timers[e].unload(),this._timers.splice(e,1))},t.schedule=function(e,t,n,i){var r=new C;return r.initialize(e,t,n,i),this._timers.push(r),r},t.dispose=function(){for(var e,t=a(this._timers);!(e=t()).done;){e.value.unload()}this._timers=[]},e}(),e.TimerManager=y([w()],e.TimerManager),e.PerformanceWarningType=void 0,(S=e.PerformanceWarningType||(e.PerformanceWarningType={})).HIGH_EXECUTION_TIME="high_execution_time",S.HIGH_MEMORY_USAGE="high_memory_usage",S.HIGH_CPU_USAGE="high_cpu_usage",S.FREQUENT_GC="frequent_gc",S.LOW_FPS="low_fps",S.HIGH_ENTITY_COUNT="high_entity_count";var O=function(){function e(){this._systemData=new Map,this._systemStats=new Map,this._isEnabled=!1,this._maxRecentSamples=60}var t=e.prototype;return t.updateFPS=function(e){},t.enable=function(){this._isEnabled=!0},t.disable=function(){this._isEnabled=!1},t.startMonitoring=function(e){return this._isEnabled?performance.now():0},t.endMonitoring=function(e,t,n){if(void 0===n&&(n=0),this._isEnabled&&0!==t){var i=performance.now(),r=i-t,o={name:e,executionTime:r,entityCount:n,averageTimePerEntity:n>0?r/n:0,lastUpdateTime:i};this._systemData.set(e,o),this.updateStats(e,r)}},t.updateStats=function(e,t){var n=this._systemStats.get(e);n||(n={totalTime:0,averageTime:0,minTime:Number.MAX_VALUE,maxTime:0,executionCount:0,recentTimes:[],standardDeviation:0,percentile95:0,percentile99:0},this._systemStats.set(e,n)),n.totalTime+=t,n.executionCount++,n.averageTime=n.totalTime/n.executionCount,n.minTime=Math.min(n.minTime,t),n.maxTime=Math.max(n.maxTime,t),n.recentTimes.push(t),n.recentTimes.length>this._maxRecentSamples&&n.recentTimes.shift(),this.calculateAdvancedStats(n)},t.calculateAdvancedStats=function(e){if(0!==e.recentTimes.length){var t=e.recentTimes.reduce(function(e,t){return e+t},0)/e.recentTimes.length,n=e.recentTimes.reduce(function(e,n){return e+Math.pow(n-t,2)},0)/e.recentTimes.length;e.standardDeviation=Math.sqrt(n);var i=[].concat(e.recentTimes).sort(function(e,t){return e-t}),r=i.length;e.percentile95=i[Math.floor(.95*r)]||0,e.percentile99=i[Math.floor(.99*r)]||0}},t.getSystemData=function(e){return this._systemData.get(e)},t.getSystemStats=function(e){return this._systemStats.get(e)},t.getAllSystemData=function(){return new Map(this._systemData)},t.getAllSystemStats=function(){return new Map(this._systemStats)},t.getPerformanceReport=function(){if(!this._isEnabled)return"Performance monitoring is disabled.";var e=[];e.push("=== ECS Performance Report ==="),e.push("");for(var t,n=a(Array.from(this._systemStats.entries()).sort(function(e,t){return t[1].averageTime-e[1].averageTime}));!(t=n()).done;){var i=t.value,r=i[0],o=i[1],s=this._systemData.get(r);e.push("System: "+r),e.push(" Current: "+(null==s?void 0:s.executionTime.toFixed(2))+"ms ("+(null==s?void 0:s.entityCount)+" entities)"),e.push(" Average: "+o.averageTime.toFixed(2)+"ms"),e.push(" Min/Max: "+o.minTime.toFixed(2)+"ms / "+o.maxTime.toFixed(2)+"ms"),e.push(" Total: "+o.totalTime.toFixed(2)+"ms ("+o.executionCount+" calls)"),null!=s&&s.averageTimePerEntity&&s.averageTimePerEntity>0&&e.push(" Per Entity: "+s.averageTimePerEntity.toFixed(4)+"ms"),e.push("")}var c=Array.from(this._systemData.values()).reduce(function(e,t){return e+t.executionTime},0);return e.push("Total Frame Time: "+c.toFixed(2)+"ms"),e.push("Systems Count: "+this._systemData.size),e.join("\n")},t.reset=function(){this._systemData.clear(),this._systemStats.clear()},t.resetSystem=function(e){this._systemData.delete(e),this._systemStats.delete(e)},t.getPerformanceWarnings=function(e){void 0===e&&(e=16.67);for(var t,n=[],i=a(this._systemData.entries());!(t=i()).done;){var r=t.value,o=r[0],s=r[1];s.executionTime>e&&n.push(o+": "+s.executionTime.toFixed(2)+"ms (>"+e+"ms)")}return n},t.setMaxRecentSamples=function(e){this._maxRecentSamples=e;for(var t,n=a(this._systemStats.values());!(t=n()).done;)for(var i=t.value;i.recentTimes.length>e;)i.recentTimes.shift()},t.dispose=function(){this._systemData.clear(),this._systemStats.clear(),this._isEnabled=!1},s(e,[{key:"isEnabled",get:function(){return this._isEnabled}}])}(),x=function(){function e(e,t,n){void 0===t&&(t=100),void 0===n&&(n=1024),this._objects=[],this._createFn=e,this._maxSize=t,this._objectSize=n,this._stats={size:0,maxSize:t,totalCreated:0,totalObtained:0,totalReleased:0,hitRate:0,estimatedMemoryUsage:0}}e.getPool=function(t,n,i){void 0===n&&(n=100),void 0===i&&(i=1024);var r=this._pools.get(t);return r||(r=new e(function(){return new t},n,i),this._pools.set(t,r)),r};var t=e.prototype;return t.obtain=function(){if(this._stats.totalObtained++,this._objects.length>0){var e=this._objects.pop();return this._stats.size--,this._updateHitRate(),this._updateMemoryUsage(),e}return this._stats.totalCreated++,this._updateHitRate(),this._createFn()},t.release=function(e){e&&(this._stats.totalReleased++,this._stats.size<this._maxSize&&(e.reset(),this._objects.push(e),this._stats.size++,this._updateMemoryUsage()))},t.getStats=function(){return c({},this._stats)},t.clear=function(){for(var e,t=a(this._objects);!(e=t()).done;){e.value.reset()}this._objects.length=0,this._stats.size=0,this._updateMemoryUsage()},t.compact=function(e){for(var t=null!=e?e:Math.floor(this._objects.length/2);this._objects.length>t;){var n=this._objects.pop();n&&(n.reset(),this._stats.size--)}this._updateMemoryUsage()},t.prewarm=function(e){for(var t=Math.min(e,this._maxSize-this._objects.length),n=0;n<t;n++){var i=this._createFn();i.reset(),this._objects.push(i),this._stats.totalCreated++,this._stats.size++}this._updateMemoryUsage()},t.setMaxSize=function(e){this._maxSize=e,this._stats.maxSize=e,this._objects.length>e&&this.compact(e)},t.getAvailableCount=function(){return this._objects.length},t.isEmpty=function(){return 0===this._objects.length},t.isFull=function(){return this._objects.length>=this._maxSize},e.getAllPoolTypes=function(){return Array.from(this._pools.keys())},e.getAllPoolStats=function(){for(var e,t={},n=a(this._pools);!(e=n()).done;){var i=e.value,r=i[0],o=i[1];t[r.name||r.toString()]=o.getStats()}return t},e.compactAllPools=function(){for(var e,t=a(this._pools.values());!(e=t()).done;){e.value.compact()}},e.clearAllPools=function(){for(var e,t=a(this._pools.values());!(e=t()).done;){e.value.clear()}this._pools.clear()},e.getGlobalStatsString=function(){var e=this.getAllPoolStats(),t=["=== Object Pool Global Statistics ===",""];if(0===Object.keys(e).length)return t.push("No pools registered"),t.join("\n");for(var n=0,i=Object.entries(e);n<i.length;n++){var r=i[n],o=r[0],s=r[1];t.push(o+":"),t.push(" Size: "+s.size+"/"+s.maxSize),t.push(" Hit Rate: "+(100*s.hitRate).toFixed(1)+"%"),t.push(" Total Created: "+s.totalCreated),t.push(" Total Obtained: "+s.totalObtained),t.push(" Memory: "+(s.estimatedMemoryUsage/1024).toFixed(1)+" KB"),t.push("")}return t.join("\n")},t._updateHitRate=function(){if(0===this._stats.totalObtained)this._stats.hitRate=0;else{var e=this._stats.totalObtained-this._stats.totalCreated;this._stats.hitRate=e/this._stats.totalObtained}},t._updateMemoryUsage=function(){this._stats.estimatedMemoryUsage=this._stats.size*this._objectSize},e}();x._pools=new Map;var R,N=function(){function e(){this.pools=new Map,this.autoCompactInterval=6e4,this.lastCompactTime=0}var t=e.prototype;return t.registerPool=function(e,t){this.pools.set(e,t)},t.getPool=function(e){return this.pools.get(e)||null},t.update=function(){var e=Date.now();e-this.lastCompactTime>this.autoCompactInterval&&(this.compactAllPools(),this.lastCompactTime=e)},t.createPool=function(e,t,n,i){void 0===n&&(n=100),void 0===i&&(i=1024);var r=this.pools.get(e);return r||(r=new x(t,n,i),this.pools.set(e,r)),r},t.removePool=function(e){var t=this.pools.get(e);return!!t&&(t.clear(),this.pools.delete(e),!0)},t.getPoolNames=function(){return Array.from(this.pools.keys())},t.getPoolCount=function(){return this.pools.size},t.compactAllPools=function(){for(var e,t=a(this.pools.values());!(e=t()).done;){e.value.compact()}},t.clearAllPools=function(){for(var e,t=a(this.pools.values());!(e=t()).done;){e.value.clear()}},t.getAllStats=function(){for(var e,t=new Map,n=a(this.pools);!(e=n()).done;){var i=e.value,r=i[0],o=i[1];t.set(r,o.getStats())}return t},t.getGlobalStats=function(){for(var e,t=0,n=0,i=0,r=0,o=0,s=0,c=a(this.pools.values());!(e=c()).done;){var u=e.value.getStats();t+=u.size,n+=u.maxSize,i+=u.totalCreated,r+=u.totalObtained,o+=u.totalReleased,s+=u.estimatedMemoryUsage}return{size:t,maxSize:n,totalCreated:i,totalObtained:r,totalReleased:o,hitRate:0===r?0:(r-i)/r,estimatedMemoryUsage:s}},t.getStatsString=function(){var e=["=== Pool Manager Statistics ===",""];if(0===this.pools.size)return e.push("No pools registered"),e.join("\n");var t=this.getGlobalStats();e.push("Total Pools: "+this.pools.size),e.push("Global Hit Rate: "+(100*t.hitRate).toFixed(1)+"%"),e.push("Global Memory Usage: "+(t.estimatedMemoryUsage/1024).toFixed(1)+" KB"),e.push("");for(var n,i=a(this.pools);!(n=i()).done;){var r=n.value,o=r[0],s=r[1].getStats();e.push(o+":"),e.push(" Size: "+s.size+"/"+s.maxSize),e.push(" Hit Rate: "+(100*s.hitRate).toFixed(1)+"%"),e.push(" Memory: "+(s.estimatedMemoryUsage/1024).toFixed(1)+" KB"),e.push("")}return e.join("\n")},t.setAutoCompactInterval=function(e){this.autoCompactInterval=e},t.prewarmAllPools=function(){for(var e,t=a(this.pools.values());!(e=t()).done;){var n=e.value,i=n.getStats(),r=Math.floor(.2*i.maxSize);n.prewarm(r)}},t.reset=function(){this.clearAllPools(),this.pools.clear(),this.lastCompactTime=0},t.dispose=function(){this.reset()},e}(),z=Symbol("ComponentTypeName"),F=Symbol("ComponentDependencies"),B=Symbol("ComponentEditorOptions");function L(e){return void 0!==e[z]}function H(e){var t=e[z];return t||(e.name||"UnknownComponent")}function W(e){return H(e.constructor)}function U(e){return e[B]}function G(e){var t,n=U(e);return null!==(t=null==n?void 0:n.hideInInspector)&&void 0!==t&&t}!function(e){e[e.LOW=0]="LOW",e[e.HIGH=1]="HIGH"}(R||(R={}));var j,q=function(){function e(){}return e.create=function(t){if(t<0)throw new Error("Bit index "+t+" out of range [0, ∞)");var n={base:[0,0]};return e.setBit(n,t),n},e.fromNumber=function(e){return{base:[e>>>0,0]}},e.hasAny=function(e,t){var n=t.base,i=e.base,r=t.segments,o=e.segments,s=0!==(i[R.LOW]&n[R.LOW])||0!==(i[R.HIGH]&n[R.HIGH]);return!s&&r&&o?o.some(function(e,t){var n=r[t];return n&&(0!==(e[R.LOW]&n[R.LOW])||0!==(e[R.HIGH]&n[R.HIGH]))}):s},e.hasAll=function(e,t){var n,i=e.base,r=t.base,o=e.segments,s=t.segments,a=(i[R.LOW]&r[R.LOW])===r[R.LOW]&&(i[R.HIGH]&r[R.HIGH])===r[R.HIGH];if(!a||!s)return a;var c=null!==(n=null==o?void 0:o.length)&&void 0!==n?n:0;if(o)for(var u=0;u<Math.min(c,s.length);u++){var l=o[u],h=s[u];if((l[R.LOW]&h[R.LOW])!==h[R.LOW]||(l[R.HIGH]&h[R.HIGH])!==h[R.HIGH])return!1}for(var d=c;d<s.length;d++){var f=s[d];if(0!==f[R.LOW]||0!==f[R.HIGH])return!1}return!0},e.hasNone=function(e,t){var n=e.base,i=t.base,r=e.segments,o=t.segments,s=0===(n[R.LOW]&i[R.LOW])&&0===(n[R.HIGH]&i[R.HIGH]);return r&&s&&o?r.every(function(e,t){var n=o[t];return!n||0===(e[R.LOW]&n[R.LOW])&&0===(e[R.HIGH]&n[R.HIGH])}):s},e.isZero=function(e){var t=0===e.base[R.LOW]&&0===e.base[R.HIGH];return e.segments&&t?e.segments.every(function(e){return 0===e[R.LOW]&&0===e[R.HIGH]}):t},e.equals=function(e,t){var n,i,r=e.base[R.LOW]===t.base[R.LOW]&&e.base[R.HIGH]===t.base[R.HIGH];if(!r||!e.segments&&!t.segments)return r;for(var o=null!==(n=e.segments)&&void 0!==n?n:[],s=null!==(i=t.segments)&&void 0!==i?i:[],a=0;a<Math.max(o.length,s.length);a++){var c=o[a],u=s[a];if(c&&!u){if(0!==c[R.LOW]||0!==c[R.HIGH])return!1}else if(!c&&u){if(0!==u[R.LOW]||0!==u[R.HIGH])return!1}else if(c&&u&&(c[R.LOW]!==u[R.LOW]||c[R.HIGH]!==u[R.HIGH]))return!1}return!0},e.setBit=function(t,n){if(n<0)throw new Error("Bit index "+n+" out of range [0, 63]");var i=e.getSegmentByBitIndex(t,n),r=63&n;r<32?i[R.LOW]|=1<<r:i[R.HIGH]|=1<<r-32},e.getBit=function(t,n){if(n<0)return!1;var i=e.getSegmentByBitIndex(t,n,!1);if(!i)return!1;var r=63&n;return r<32?!!(i[R.LOW]&1<<r):!!(i[R.HIGH]&1<<r-32)},e.clearBit=function(t,n){if(n<0)throw new Error("Bit index "+n+" out of range [0, 63]");var i=e.getSegmentByBitIndex(t,n,!1);if(i){var r=63&n;r<32?i[R.LOW]&=~(1<<r):i[R.HIGH]&=~(1<<r-32)}},e.orInPlace=function(e,t){e.base[R.LOW]|=t.base[R.LOW],e.base[R.HIGH]|=t.base[R.HIGH];var n=t.segments;if(n&&n.length>0){e.segments||(e.segments=[]);for(var i=e.segments;i.length<n.length;)i.push([0,0]);for(var r=0;r<n.length;r++){var o=i[r],s=n[r];o[R.LOW]|=s[R.LOW],o[R.HIGH]|=s[R.HIGH]}}},e.andInPlace=function(e,t){e.base[R.LOW]&=t.base[R.LOW],e.base[R.HIGH]&=t.base[R.HIGH];var n=t.segments;if(n&&n.length>0){e.segments||(e.segments=[]);for(var i=e.segments;i.length<n.length;)i.push([0,0]);for(var r=0;r<n.length;r++){var o=i[r],s=n[r];o[R.LOW]&=s[R.LOW],o[R.HIGH]&=s[R.HIGH]}}},e.xorInPlace=function(e,t){e.base[R.LOW]^=t.base[R.LOW],e.base[R.HIGH]^=t.base[R.HIGH];var n=t.segments;if(n&&0!=n.length){e.segments||(e.segments=[]);for(var i=e.segments;i.length<n.length;)i.push([0,0]);for(var r=0;r<n.length;r++){var o=i[r],s=n[r];o[R.LOW]^=s[R.LOW],o[R.HIGH]^=s[R.HIGH]}}},e.clear=function(e){if(e.base[R.LOW]=0,e.base[R.HIGH]=0,e.segments)for(var t=0;t<e.segments.length;t++){var n=e.segments[t];n[R.LOW]=0,n[R.HIGH]=0}},e.copy=function(t,n){if(e.clear(n),n.base[R.LOW]=t.base[R.LOW],n.base[R.HIGH]=t.base[R.HIGH],t.segments&&0!=t.segments.length)if(n.segments){for(var i=t.segments.length-n.segments.length,r=0;r<i;r++)n.segments.push([0,0]);for(var o=n.segments,s=t.segments,a=0;a<s.length;a++){var c=o[a],u=s[a];c[R.LOW]=u[R.LOW],c[R.HIGH]=u[R.HIGH]}}else n.segments=t.segments.map(function(e){return[].concat(e)})},e.clone=function(e){return c({base:e.base.slice()},e.segments&&{segments:e.segments.map(function(e){return[].concat(e)})})},e.toString=function(e,t,n){var i,r;void 0===t&&(t=2),void 0===n&&(n=!1),2!=t&&16!=t&&(t=2);var o=null!==(i=null===(r=e.segments)||void 0===r?void 0:r.length)&&void 0!==i?i:0,s="";if(n){var a=0;a=2===t?66:19;for(var c=0;c<=o;c++){s+=(0===c?"0 (Base):":c+" ("+64*c+"):").toString().padEnd(a)}s+="\n"}for(var u=-1;u<o;u++){var l="",h=-1==u?e.base:e.segments[u],d=h[R.HIGH],f=h[R.LOW];if(2==t){l=d.toString(2).padStart(32,"0")+"_"+f.toString(2).padStart(32,"0")}else{var p=d?d.toString(16).toUpperCase():"";n&&(p=p.padStart(8,"0"));var m=f.toString(16).toUpperCase();p&&(m=m.padStart(8,"0")),l="0x"+p+m}s+=-1===u?l:" "+l}return s},e.popCount=function(e){for(var t=0,n=-1;n<(null!==(i=null===(r=e.segments)||void 0===r?void 0:r.length)&&void 0!==i?i:0);n++){for(var i,r,o=-1==n?e.base:e.segments[n],s=o[R.LOW],a=o[R.HIGH];s;)s&=s-1,t++;for(;a;)a&=a-1,t++}return t},e.getSegmentByBitIndex=function(e,t,n){if(void 0===n&&(n=!0),t<=63)return e.base;var i,r=e.segments;if(!r){if(!n)return null;r=e.segments=[]}var o=(t>>6)-1;if(r.length<=o){if(!n)return null;for(var s=o-r.length+1,a=0;a<s;a++)r.push([0,0])}return null!==(i=r[o])&&void 0!==i?i:null},e}();q.ZERO={base:[0,0]},e.LogLevel=void 0,(j=e.LogLevel||(e.LogLevel={}))[j.Debug=0]="Debug",j[j.Info=1]="Info",j[j.Warn=2]="Warn",j[j.Error=3]="Error",j[j.Fatal=4]="Fatal",j[j.None=5]="None";var V={BLACK:"[30m",RED:"[31m",GREEN:"[32m",YELLOW:"[33m",BLUE:"[34m",MAGENTA:"[35m",CYAN:"[36m",WHITE:"[37m",BRIGHT_BLACK:"[90m",BRIGHT_RED:"[91m",BRIGHT_GREEN:"[92m",BRIGHT_YELLOW:"[93m",BRIGHT_BLUE:"[94m",BRIGHT_MAGENTA:"[95m",BRIGHT_CYAN:"[96m",BRIGHT_WHITE:"[97m",RESET:"[0m",BOLD:"[1m",UNDERLINE:"[4m"},Q=function(){function t(t){void 0===t&&(t={}),this._config=c({level:e.LogLevel.Info,enableTimestamp:!0,enableColors:"undefined"==typeof window},t)}var n=t.prototype;return n.debug=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];this.log.apply(this,[e.LogLevel.Debug,t].concat(i))},n.info=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];this.log.apply(this,[e.LogLevel.Info,t].concat(i))},n.warn=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];this.log.apply(this,[e.LogLevel.Warn,t].concat(i))},n.error=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];this.log.apply(this,[e.LogLevel.Error,t].concat(i))},n.fatal=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];this.log.apply(this,[e.LogLevel.Fatal,t].concat(i))},n.setLevel=function(e){this._config.level=e},n.setColors=function(e){0===Object.keys(e).length?delete this._config.colors:this._config.colors=c({},this._config.colors,e)},n.setPrefix=function(e){this._config.prefix=e},n.log=function(t,n){if(!(t<this._config.level)){var i=n;if(this._config.enableTimestamp)i="["+(new Date).toISOString()+"] "+i;if(this._config.prefix&&(i="["+this._config.prefix+"] "+i),i="["+e.LogLevel[t].toUpperCase()+"] "+i,this._config.output)this._config.output(t,i);else{for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];this.outputToConsole.apply(this,[t,i].concat(o))}}},n.outputToConsole=function(t,n){for(var i=this._config.enableColors?this.getColors():null,r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];switch(t){case e.LogLevel.Debug:var a,c;if(i)(a=console).debug.apply(a,[""+i.debug+n+i.reset].concat(o));else(c=console).debug.apply(c,[n].concat(o));break;case e.LogLevel.Info:var u,l;if(i)(u=console).info.apply(u,[""+i.info+n+i.reset].concat(o));else(l=console).info.apply(l,[n].concat(o));break;case e.LogLevel.Warn:var h,d;if(i)(h=console).warn.apply(h,[""+i.warn+n+i.reset].concat(o));else(d=console).warn.apply(d,[n].concat(o));break;case e.LogLevel.Error:var f,p;if(i)(f=console).error.apply(f,[""+i.error+n+i.reset].concat(o));else(p=console).error.apply(p,[n].concat(o));break;case e.LogLevel.Fatal:var m,v;if(i)(m=console).error.apply(m,[""+i.fatal+n+i.reset].concat(o));else(v=console).error.apply(v,[n].concat(o))}},n.getColors=function(){return c({},{debug:V.BRIGHT_BLACK,info:V.GREEN,warn:V.YELLOW,error:V.RED,fatal:V.BRIGHT_RED,reset:V.RESET},this._config.colors)},t}(),Y=function(){function t(){this._loggers=new Map,this._defaultLevel=e.LogLevel.Info}var n=t.prototype;return n.createDefaultLogger=function(){return this._loggerFactory?this._loggerFactory():new Q({level:this._defaultLevel})},t.getInstance=function(){return t._instance||(t._instance=new t),t._instance},n.getLogger=function(e){return e?this._loggerFactory?this._loggerFactory(e):(this._loggers.has(e)||this._loggers.set(e,new Q({prefix:e,level:this._defaultLevel})),this._loggers.get(e)):this.defaultLogger},n.setLogger=function(e,t){this._loggers.set(e,t)},n.setGlobalLevel=function(e){this._defaultLevel=e,this._defaultLogger instanceof Q&&this._defaultLogger.setLevel(e);for(var t,n=a(this._loggers.values());!(t=n()).done;){var i=t.value;i instanceof Q&&i.setLevel(e)}},n.createChildLogger=function(e,t){var n=e+"."+t;return this.getLogger(n)},n.setGlobalColors=function(e){this._defaultLogger instanceof Q&&this._defaultLogger.setColors(e);for(var t,n=a(this._loggers.values());!(t=n()).done;){var i=t.value;i instanceof Q&&i.setColors(e)}},n.resetColors=function(){this._defaultLogger instanceof Q&&this._defaultLogger.setColors({});for(var e,t=a(this._loggers.values());!(e=t()).done;){var n=e.value;n instanceof Q&&n.setColors({})}},n.setLoggerFactory=function(e){this._loggerFactory=e,delete this._defaultLogger,this._loggers.clear()},s(t,[{key:"defaultLogger",get:function(){return this._defaultLogger||(this._defaultLogger=this.createDefaultLogger()),this._defaultLogger}}])}(),J=Y.getInstance().getLogger();function Z(e){return Y.getInstance().getLogger(e)}var X,K=Z("ComponentRegistry"),$=function(){function e(){this._componentTypes=new Map,this._bitIndexToType=new Map,this._componentNameToType=new Map,this._componentNameToId=new Map,this._maskCache=new Map,this._nextBitIndex=0,this._hotReloadEnabled=!1,this._warnedComponents=new Set}var t=e.prototype;return t.register=function(e){var t=H(e);if(L(e)||this._warnedComponents.has(e)||(this._warnedComponents.add(e),K.warn('Component "'+t+"\" is missing @ECSComponent decorator. This may cause issues with serialization and code minification. Please add: @ECSComponent('"+t+"') | 组件 \""+t+'" 缺少 @ECSComponent 装饰器,可能导致序列化和代码压缩问题')),this._componentTypes.has(e))return this._componentTypes.get(e);if(this._hotReloadEnabled&&this._componentNameToType.has(t)){var n=this._componentNameToType.get(t);if(n!==e){var i=this._componentTypes.get(n);return this._componentTypes.delete(n),this._componentTypes.set(e,i),this._bitIndexToType.set(i,e),this._componentNameToType.set(t,e),K.debug('Hot reload: replaced component "'+t+'"'),i}}var r=this._nextBitIndex++;return this._componentTypes.set(e,r),this._bitIndexToType.set(r,e),this._componentNameToType.set(t,e),this._componentNameToId.set(t,r),r},t.getBitMask=function(e){var t=this._componentTypes.get(e);if(void 0===t){var n=H(e);throw new Error("Component type "+n+" is not registered")}return q.create(t)},t.getBitIndex=function(e){var t=this._componentTypes.get(e);if(void 0===t){var n=H(e);throw new Error("Component type "+n+" is not registered")}return t},t.isRegistered=function(e){return this._componentTypes.has(e)},t.getTypeByBitIndex=function(e){return this._bitIndexToType.get(e)||null},t.getRegisteredCount=function(){return this._nextBitIndex},t.getComponentType=function(e){return this._componentNameToType.get(e)||null},t.getAllRegisteredTypes=function(){return new Map(this._componentTypes)},t.getAllComponentNames=function(){return new Map(this._componentNameToType)},t.getComponentId=function(e){return this._componentNameToId.get(e)},t.registerComponentByName=function(e){if(this._componentNameToId.has(e))return this._componentNameToId.get(e);var t=this._nextBitIndex++;return this._componentNameToId.set(e,t),t},t.createSingleComponentMask=function(e){var t="single:"+e;if(this._maskCache.has(t))return this._maskCache.get(t);var n=this.getComponentId(e);if(void 0===n)throw new Error("Component type "+e+" is not registered");var i=q.create(n);return this._maskCache.set(t,i),i},t.createComponentMask=function(e){var t="multi:"+[].concat(e).sort().join(",");if(this._maskCache.has(t))return this._maskCache.get(t);for(var n,i=q.clone(q.ZERO),r=a(e);!(n=r()).done;){var o=n.value,s=this.getComponentId(o);if(void 0!==s){var c=q.create(s);q.orInPlace(i,c)}}return this._maskCache.set(t,i),i},t.clearMaskCache=function(){this._maskCache.clear()},t.enableHotReload=function(){this._hotReloadEnabled=!0},t.disableHotReload=function(){this._hotReloadEnabled=!1},t.isHotReloadEnabled=function(){return this._hotReloadEnabled},t.unregister=function(e){var t=this._componentNameToType.get(e);if(t){var n=this._componentTypes.get(t);this._componentTypes.delete(t),void 0!==n&&this._bitIndexToType.delete(n),this._componentNameToType.delete(e),this._componentNameToId.delete(e),this.clearMaskCache(),K.debug("Component unregistered: "+e)}},t.getRegisteredComponents=function(){for(var e,t=[],n=a(this._componentNameToType);!(e=n()).done;){var i=e.value,r=i[0],o=i[1],s=this._componentTypes.get(o);void 0!==s&&t.push({name:r,type:o,bitIndex:s})}return t},t.reset=function(){this._componentTypes.clear(),this._bitIndexToType.clear(),this._componentNameToType.clear(),this._componentNameToId.clear(),this._maskCache.clear(),this._warnedComponents.clear(),this._nextBitIndex=0,this._hotReloadEnabled=!1},t.cloneFrom=function(e){for(var t,n=a(e.getAllRegisteredTypes());!(t=n()).done;){var i=t.value,r=i[0],o=i[1];this._componentTypes.set(r,o),this._bitIndexToType.set(o,r);var s=H(r);this._componentNameToType.set(s,r),this._componentNameToId.set(s,o)}this._nextBitIndex=e.getRegisteredCount(),this._hotReloadEnabled=e.isHotReloadEnabled()},e}(),ee=new $;e.SyncOperation=void 0,(X=e.SyncOperation||(e.SyncOperation={}))[X.FULL=0]="FULL",X[X.DELTA=1]="DELTA",X[X.SPAWN=2]="SPAWN",X[X.DESPAWN=3]="DESPAWN";var te=Symbol("SyncMetadata"),ne=Symbol("ChangeTracker"),ie=Symbol("SystemTypeName");function re(e,t){return function(n){if(!e||"string"!=typeof e)throw new Error("ECSComponent装饰器必须提供有效的类型名称");var i=n;i[z]=e,null!=t&&t.requires&&(i[F]=t.requires),null!=t&&t.editor&&(i[B]=t.editor);var r=n[te];return r&&(r.typeId=e),ee.register(n),n}}function oe(e){return e.__systemMetadata__}function se(e){return oe(e.constructor)}function ae(e){var t=e[ie];return t||(e.name||"UnknownSystem")}function ce(e){return ae(e.constructor)}var ue=function(){function e(e){this._target=e}return e.prototype.deref=function(){return this._target},e}(),le="undefined"!=typeof globalThis&&globalThis.WeakRef||"undefined"!=typeof global&&global.WeakRef||"undefined"!=typeof window&&window.WeakRef||ue,he=new Map;function de(e){var t=he.get(e);return(null==t?void 0:t.deref())||null}var fe=function(){function e(){this._references=new Map}var t=e.prototype;return t.registerReference=function(e,t,n){var i=e.id,r=this._references.get(i);r||(r=new Set,this._references.set(i,r)),this._findRecord(r,t,n)||r.add({component:new le(t),propertyKey:n})},t.unregisterReference=function(e,t,n){var i=e.id,r=this._references.get(i);if(r){var o=this._findRecord(r,t,n);o&&(r.delete(o),0===r.size&&this._references.delete(i))}},t.clearReferencesTo=function(e){var t=this._references.get(e);if(t){for(var n,i=[],r=a(t);!(n=r()).done;){var o=n.value;o.component.deref()&&i.push(o)}for(var s=0,c=i;s<c.length;s++){var u=c[s],l=u.component.deref();l&&(l[u.propertyKey]=null)}this._references.delete(e)}},t.clearComponentReferences=function(e){for(var t,n=a(this._references.entries());!(t=n()).done;){for(var i,r=t.value,o=r[0],s=r[1],c=[],u=a(s);!(i=u()).done;){var l=i.value,h=l.component.deref();h&&h!==e||c.push(l)}for(var d=0,f=c;d<f.length;d++){var p=f[d];s.delete(p)}0===s.size&&this._references.delete(o)}},t.getReferencesTo=function(e){var t=this._references.get(e);if(!t)return[];for(var n,i=[],r=a(t);!(n=r()).done;){var o=n.value;o.component.deref()&&i.push(o)}return i},t.cleanup=function(){for(var e,t=[],n=a(this._references.entries());!(e=n()).done;){for(var i,r=e.value,o=r[0],s=r[1],c=[],u=a(s);!(i=u()).done;){var l=i.value;l.component.deref()||c.push(l)}for(var h=0,d=c;h<d.length;h++){var f=d[h];s.delete(f)}0===s.size&&t.push(o)}for(var p=0,m=t;p<m.length;p++){var v=m[p];this._references.delete(v)}},t.registerEntityScene=function(e,t){he.set(e,new le(t))},t.unregisterEntityScene=function(e){he.delete(e)},t.getDebugInfo=function(){for(var e,t={},n=a(this._references.entries());!(e=n()).done;){for(var i,r=e.value,o=r[0],s=[],c=a(r[1]);!(i=c()).done;){var u=i.value,l=u.component.deref();l&&s.push({componentId:l.id,propertyKey:u.propertyKey})}s.length>0&&(t["entity_"+o]=s)}return t},t._findRecord=function(e,t,n){for(var i,r=a(e);!(i=r()).done;){var o=i.value;if(o.component.deref()===t&&o.propertyKey===n)return o}},e}(),pe=Z("EntityRefDecorator"),me=Symbol("EntityRefMetadata"),ve=Symbol("EntityRefValues");function ye(e){var t=e[ve];return t||(t=new Map,e[ve]=t),t}function ge(e){return e&&("function"==typeof e?e:e.constructor)[me]||null}function _e(e,t){var n=ge(e);return!!n&&n.properties.has(t)}var Se=new WeakMap,Ce=Symbol.for("@esengine/property:metadata");var Ee=Symbol("schedulingMetadata");function be(e){var t=e;return t[Ee]||(t[Ee]={stage:"update",before:[],after:[],sets:[]}),t[Ee]}function Te(e){for(var t=Object.getPrototypeOf(e);t;){var n=t[Ee];if(n)return n;t=Object.getPrototypeOf(t)}}var we=function(){function e(){}return e.getConstructor=function(e){return this.TYPE_CONSTRUCTORS[e]||Float32Array},e.getBytesPerElement=function(e){return this.TYPE_BYTES[e]||4},e.getTypeName=function(e){return e instanceof Float32Array?"float32":e instanceof Float64Array?"float64":e instanceof Int32Array?"int32":e instanceof Uint32Array?"uint32":e instanceof Int16Array?"int16":e instanceof Uint16Array?"uint16":e instanceof Int8Array?"int8":e instanceof Uint8Array?"uint8":e instanceof Uint8ClampedArray?"uint8clamped":"float32"},e.createSameType=function(e,t){var n=this.getTypeName(e);return new(this.getConstructor(n))(t)},e.extractFieldMetadata=function(e){var t=new e,n=new Map,i=e,r=new Map,o=function(e,t){if(e)for(var n,i=a(e);!(n=i()).done;){var o=n.value;r.set(o,t)}};o(i.__float64Fields,"float64"),o(i.__float32Fields,"float32"),o(i.__int32Fields,"int32"),o(i.__uint32Fields,"uint32"),o(i.__int16Fields,"int16"),o(i.__uint16Fields,"uint16"),o(i.__int8Fields,"int8"),o(i.__uint8Fields,"uint8"),o(i.__uint8ClampedFields,"uint8clamped");for(var s,c=Object.keys(t).filter(function(e){return"id"!==e}),u=a(c);!(s=u()).done;){var l,h,d,f,p=s.value,m=typeof t[p];if("function"!==m){var v={name:p,type:m},y=r.get(p);y?v.arrayType=y:"number"===m?v.arrayType="float32":"boolean"===m&&(v.arrayType="uint8"),null!==(l=i.__serializeMapFields)&&void 0!==l&&l.has(p)&&(v.isSerializedMap=!0),null!==(h=i.__serializeSetFields)&&void 0!==h&&h.has(p)&&(v.isSerializedSet=!0),null!==(d=i.__serializeArrayFields)&&void 0!==d&&d.has(p)&&(v.isSerializedArray=!0),null!==(f=i.__deepCopyFields)&&void 0!==f&&f.has(p)&&(v.isDeepCopy=!0),n.set(p,v)}}return n},e}();we.TYPE_CONSTRUCTORS={float32:Float32Array,float64:Float64Array,int32:Int32Array,uint32:Uint32Array,int16:Int16Array,uint16:Uint16Array,int8:Int8Array,uint8:Uint8Array,uint8clamped:Uint8ClampedArray},we.TYPE_BYTES={float32:4,float64:8,int32:4,uint32:4,int16:2,uint16:2,int8:1,uint8:1,uint8clamped:1};var Ie=function(){function e(){}return e.serialize=function(e,t,n){void 0===n&&(n={});try{return n.isMap&&e instanceof Map?JSON.stringify(Array.from(e.entries())):n.isSet&&e instanceof Set?JSON.stringify(Array.from(e)):(n.isArray&&Array.isArray(e),JSON.stringify(e))}catch(e){return this._logger.warn("SoA序列化字段 "+t+" 失败:",e),"{}"}},e.deserialize=function(e,t,n){void 0===n&&(n={});try{var i=JSON.parse(e);return n.isMap?new Map(i):n.isSet?new Set(i):i}catch(e){return this._logger.warn("SoA反序列化字段 "+t+" 失败:",e),null}},e.deepClone=function(e){var t=this;if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(function(e){return t.deepClone(e)});if(e instanceof Map){for(var n,i=new Map,r=a(e.entries());!(n=r()).done;){var o=n.value,s=o[0],c=o[1];i.set(s,this.deepClone(c))}return i}if(e instanceof Set){for(var u,l=new Set,h=a(e.values());!(u=h()).done;){var d=u.value;l.add(this.deepClone(d))}return l}var f={};for(var p in e)Object.prototype.hasOwnProperty.call(e,p)&&(f[p]=this.deepClone(e[p]));return f},e}();function Me(e,t){var n=e.constructor,i=n[t];return i||(i=new Set,n[t]=i),i}function Ae(e,t){Me(e,"__int32Fields").add(String(t))}Ie._logger=Z("SoASerializer");var ke=function(){function e(e){this.fields=new Map,this.stringFields=new Map,this.serializedFields=new Map,this.complexFields=new Map,this.entityToIndex=new Map,this.indexToEntity=[],this.freeIndices=[],this._size=0,this._capacity=1e3,this.fieldTypes=new Map,this.serializeMapFields=new Set,this.serializeSetFields=new Set,this.serializeArrayFields=new Set,this.type=e,this.initializeFields(e)}var t=e.prototype;return t.initializeFields=function(e){var t=new e,n=e,i=n.__float64Fields||new Set,r=n.__float32Fields||new Set,o=n.__int32Fields||new Set,s=n.__uint32Fields||new Set,c=n.__int16Fields||new Set,u=n.__uint16Fields||new Set,l=n.__int8Fields||new Set,h=n.__uint8Fields||new Set,d=n.__uint8ClampedFields||new Set;this.serializeMapFields=n.__serializeMapFields||new Set,this.serializeSetFields=n.__serializeSetFields||new Set,this.serializeArrayFields=n.__serializeArrayFields||new Set;for(var f,p=new Map,m=a(i);!(f=m()).done;){var v=f.value;p.set(v,"float64")}for(var y,g=a(r);!(y=g()).done;){var _=y.value;p.set(_,"float32")}for(var S,C=a(o);!(S=C()).done;){var E=S.value;p.set(E,"int32")}for(var b,T=a(s);!(b=T()).done;){var w=b.value;p.set(w,"uint32")}for(var I,M=a(c);!(I=M()).done;){var A=I.value;p.set(A,"int16")}for(var k,D=a(u);!(k=D()).done;){var P=k.value;p.set(P,"uint16")}for(var O,x=a(l);!(O=x()).done;){var R=O.value;p.set(R,"int8")}for(var N,z=a(h);!(N=z()).done;){var F=N.value;p.set(F,"uint8")}for(var B,L=a(d);!(B=L()).done;){var H=B.value;p.set(H,"uint8clamped")}for(var W,U=Object.keys(t).filter(function(e){return"id"!==e}),G=a(U);!(W=G()).done;){var j=W.value,q=t[j],V=typeof q;if("function"!==V){var Q=p.get(j),Y=Q?"number":V;if(this.fieldTypes.set(j,Y),Q){var J=we.getConstructor(Q);this.fields.set(j,new J(this._capacity))}else"number"===V?this.fields.set(j,new Float32Array(this._capacity)):"boolean"===V?this.fields.set(j,new Uint8Array(this._capacity)):"string"===V?this.stringFields.set(j,new Array(this._capacity)):"object"===V&&null!==q&&(this.serializeMapFields.has(j)||this.serializeSetFields.has(j)||this.serializeArrayFields.has(j))&&this.serializedFields.set(j,new Array(this._capacity))}}},t.addComponent=function(e,t){if(this.entityToIndex.has(e)){var n=this.entityToIndex.get(e);this.updateComponentAtIndex(n,t)}else{var i;this.freeIndices.length>0?i=this.freeIndices.pop():(i=this._size)>=this._capacity&&this.resize(2*this._capacity),this.entityToIndex.set(e,i),this.indexToEntity[i]=e,this.updateComponentAtIndex(i,t),this._size++}},t.updateComponentAtIndex=function(e,t){var n=this.indexToEntity[e],i=new Map,r=this.type,o=r.__highPrecisionFields||new Set,s=r.__serializeMapFields||new Set,a=r.__serializeSetFields||new Set,c=r.__serializeArrayFields||new Set,u=r.__deepCopyFields||new Set,l=t;for(var h in t)if(Object.prototype.hasOwnProperty.call(t,h)&&"id"!==h){var d=l[h],f=typeof d;if("number"===f){var p=d;if(o.has(h)||!this.fields.has(h))i.set(h,p);else this.fields.get(h)[e]=p}else if("boolean"===f&&this.fields.has(h)){this.fields.get(h)[e]=d?1:0}else if(this.stringFields.has(h)){this.stringFields.get(h)[e]=String(d)}else if(this.serializedFields.has(h)){this.serializedFields.get(h)[e]=Ie.serialize(d,h,{isMap:s.has(h),isSet:a.has(h),isArray:c.has(h)})}else u.has(h)?i.set(h,Ie.deepClone(d)):i.set(h,d)}i.size>0&&this.complexFields.set(n,i)},t.getComponent=function(e){var t=this.entityToIndex.get(e);return void 0===t?null:this.createProxyView(e,t)},t.createProxyView=function(e,t){var n=this;return new Proxy({},{get:function(i,r){var o=String(r),s=n.fields.get(o);if(s)return"boolean"===n.getFieldType(o)?1===s[t]:s[t];var a=n.stringFields.get(o);if(a)return a[t];var c=n.serializedFields.get(o);if(c){var u=c[t];return u?Ie.deserialize(u,o,{isMap:n.serializeMapFields.has(o),isSet:n.serializeSetFields.has(o),isArray:n.serializeArrayFields.has(o)}):void 0}var l=n.complexFields.get(e);return null!=l&&l.has(o)?l.get(o):void 0},set:function(i,r,o){var s=String(r);if("entityId"===s)return!1;var a=n.fields.get(s);if(a){var c=n.getFieldType(s);return a[t]="boolean"===c?o?1:0:o,!0}var u=n.stringFields.get(s);if(u)return u[t]=String(o),!0;if(n.serializedFields.has(s))return n.serializedFields.get(s)[t]=Ie.serialize(o,s,{isMap:n.serializeMapFields.has(s),isSet:n.serializeSetFields.has(s),isArray:n.serializeArrayFields.has(s)}),!0;var l=n.complexFields.get(e);return l||(l=new Map,n.complexFields.set(e,l)),l.set(s,o),!0},has:function(t,i){var r,o=String(i);return n.fields.has(o)||n.stringFields.has(o)||n.serializedFields.has(o)||(null===(r=n.complexFields.get(e))||void 0===r?void 0:r.has(o))||!1},ownKeys:function(){for(var t,i=[],r=a(n.fields.keys());!(t=r()).done;){var o=t.value;i.push(o)}for(var s,c=a(n.stringFields.keys());!(s=c()).done;){var u=s.value;i.push(u)}for(var l,h=a(n.serializedFields.keys());!(l=h()).done;){var d=l.value;i.push(d)}var f=n.complexFields.get(e);if(f)for(var p,m=a(f.keys());!(p=m()).done;){var v=p.value;i.push(v)}return i},getOwnPropertyDescriptor:function(t,i){var r,o=String(i);if(n.fields.has(o)||n.stringFields.has(o)||n.serializedFields.has(o)||null!==(r=n.complexFields.get(e))&&void 0!==r&&r.has(o))return{enumerable:!0,configurable:!0,writable:"entityId"!==o}}})},t.getComponentSnapshot=function(e){var t=this.entityToIndex.get(e);if(void 0===t)return null;for(var n,i=new this.type,r=i,o=a(this.fields.entries());!(n=o()).done;){var s=n.value,c=s[0],u=s[1][t],l=this.getFieldType(c);r[c]="boolean"===l?1===u:u}for(var h,d=a(this.stringFields.entries());!(h=d()).done;){var f=h.value,p=f[0],m=f[1];r[p]=m[t]}for(var v,y=a(this.serializedFields.entries());!(v=y()).done;){var g=v.value,_=g[0],S=g[1][t];S&&(r[_]=Ie.deserialize(S,_,{isMap:this.serializeMapFields.has(_),isSet:this.serializeSetFields.has(_),isArray:this.serializeArrayFields.has(_)}))}var C=this.complexFields.get(e);if(C)for(var E,b=a(C.entries());!(E=b()).done;){var T=E.value,w=T[0],I=T[1];r[w]=I}return i},t.getFieldType=function(e){return this.fieldTypes.get(e)||"unknown"},t.hasComponent=function(e){return this.entityToIndex.has(e)},t.removeComponent=function(e){var t=this.entityToIndex.get(e);if(void 0===t)return null;var n=this.getComponent(e);return this.complexFields.delete(e),this.entityToIndex.delete(e),this.freeIndices.push(t),this._size--,n},t.resize=function(e){for(var t,n=a(this.fields.entries());!(t=n()).done;){var i=t.value,r=i[0],o=i[1],s=we.createSameType(o,e);s.set(o),this.fields.set(r,s)}for(var c,u=a(this.stringFields.entries());!(c=u()).done;){for(var l=c.value,h=l[0],d=l[1],f=new Array(e),p=0;p<d.length;p++)f[p]=d[p];this.stringFields.set(h,f)}for(var m,v=a(this.serializedFields.entries());!(m=v()).done;){for(var y=m.value,g=y[0],_=y[1],S=new Array(e),C=0;C<_.length;C++)S[C]=_[C];this.serializedFields.set(g,S)}this._capacity=e},t.getActiveIndices=function(){return Array.from(this.entityToIndex.values())},t.getFieldArray=function(e){return this.fields.get(e)||null},t.getTypedFieldArray=function(e){return this.fields.get(String(e))||null},t.getEntityIndex=function(e){return this.entityToIndex.get(e)},t.getEntityIdByIndex=function(e){return this.indexToEntity[e]},t.size=function(){return this._size},t.clear=function(){this.entityToIndex.clear(),this.indexToEntity=[],this.freeIndices=[],this.complexFields.clear(),this._size=0;for(var e,t=a(this.fields.values());!(e=t()).done;){e.value.fill(0)}for(var n,i=a(this.stringFields.values());!(n=i()).done;)for(var r=n.value,o=0;o<r.length;o++)r[o]=void 0;for(var s,c=a(this.serializedFields.values());!(s=c()).done;)for(var u=s.value,l=0;l<u.length;l++)u[l]=void 0},t.compact=function(){if(0!==this.freeIndices.length){for(var e=Array.from(this.entityToIndex.entries()).sort(function(e,t){return e[1]-t[1]}),t=new Map,n=[],i=0;i<e.length;i++){var r=e[i];if(r){var o=r[0],s=r[1];if(t.set(o,i),n[i]=o,i!==s){for(var c,u=a(this.fields.entries());!(c=u()).done;){var l=c.value[1],h=l[s];void 0!==h&&(l[i]=h)}for(var d,f=a(this.stringFields.entries());!(d=f()).done;){var p=d.value[1],m=p[s];void 0!==m&&(p[i]=m)}for(var v,y=a(this.serializedFields.entries());!(v=y()).done;){var g=v.value[1],_=g[s];void 0!==_&&(g[i]=_)}}}}this.entityToIndex=t,this.indexToEntity=n,this.freeIndices=[],this._size=e.length}},t.getStats=function(){for(var e,t=0,n=new Map,i=a(this.fields.entries());!(e=i()).done;){var r=e.value,o=r[0],s=r[1],c=we.getTypeName(s),u=we.getBytesPerElement(c),l=s.length*u;t+=l,n.set(o,{size:this._size,capacity:s.length,type:c,memory:l})}return{size:this._size,capacity:this._capacity,totalSlots:this._capacity,usedSlots:this._size,freeSlots:this._capacity-this._size,fragmentation:this.freeIndices.length/this._capacity,memoryUsage:t,fieldStats:n}},t.performVectorizedOperation=function(e){var t=this.getActiveIndices();e(this.fields,t)},e}(),De=function(){function e(){this.entityId=null,this._lastWriteEpoch=0,this.id=e._idGenerator++}var t=e.prototype;return t.markDirty=function(e){this._lastWriteEpoch=e},t.onAddedToEntity=function(){},t.onRemovedFromEntity=function(){},t.onDeserialized=function(){},s(e,[{key:"lastWriteEpoch",get:function(){return this._lastWriteEpoch}}])}();De._idGenerator=0,y([Ae,g("design:type",Object)],De.prototype,"entityId",void 0);var Pe=Symbol("SerializableMetadata"),Oe=Symbol("SerializeField"),xe=Symbol("SerializeOptions");function Re(e){return function(t){if(!e||"number"!=typeof e.version)throw new Error("Serializable装饰器必须提供有效的版本号");var n;if(Object.prototype.hasOwnProperty.call(t,Pe))(n=t[Pe]).options=e;else{var i=t[Pe];n={options:e,fields:i?new Map(i.fields):new Map,ignoredFields:i?new Set(i.ignoredFields):new Set},t[Pe]=n}return t}}function Ne(e){return function(t,n){var i,r=t.constructor;if(Object.prototype.hasOwnProperty.call(r,Pe))i=r[Pe];else{var o=r[Pe];i={options:o?c({},o.options):{version:1},fields:o?new Map(o.fields):new Map,ignoredFields:o?new Set(o.ignoredFields):new Set},r[Pe]=i}i.fields.set(n,e||{})}}function ze(e){return e&&("function"==typeof e?e:e.constructor)[Pe]||null}e.HierarchyComponent=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).parentId=null,t.childIds=[],t.depth=0,t.bActiveInHierarchy=!0,t.bCacheDirty=!0,t}return l(t,e),t}(De),y([Ne(),g("design:type",Object)],e.HierarchyComponent.prototype,"parentId",void 0),y([Ne(),g("design:type",Array)],e.HierarchyComponent.prototype,"childIds",void 0),e.HierarchyComponent=y([re("Hierarchy",{editor:{hideInInspector:!0}}),Re({version:1,typeId:"Hierarchy"})],e.HierarchyComponent);var Fe=function(){function e(){this.condition={all:[],any:[],none:[]}}e.all=function(){var t=new e;return t.all.apply(t,arguments)},e.any=function(){var t=new e;return t.any.apply(t,arguments)},e.none=function(){var t=new e;return t.none.apply(t,arguments)},e.byTag=function(t){return(new e).withTag(t)},e.byName=function(t){return(new e).withName(t)},e.byComponent=function(t){ret