UNPKG

@esengine/ecs-framework

Version:

用于Laya、Cocos Creator等JavaScript游戏引擎的高性能ECS框架

3 lines 352 kB
"use strict";function e(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 t(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 n(e){return function(){var n=this,i=arguments;return new Promise(function(r,o){var s=e.apply(n,i);function a(e){t(s,r,o,a,c,"next",e)}function c(e){t(s,r,o,a,c,"throw",e)}a(void 0)})}}function i(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var r=new(e.bind.apply(e,i));return n&&f(r,n.prototype),r}function r(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,p(i.key),i)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(t,n){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}(t))||n){i&&(t=i);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[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 a(){return a=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},a.apply(null,arguments)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,f(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function h(){ /*! 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 d(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]())):(d(t={},i,function(){return this}),t),f=u.prototype=a.prototype=Object.create(l);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,d(e,r,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=u,d(f,"constructor",u),d(u,"constructor",c),c.displayName="GeneratorFunction",d(u,r,"GeneratorFunction"),d(f),d(f,r,"Generator"),d(f,i,function(){return this}),d(f,"toString",function(){return"[object Generator]"}),(h=function(){return{w:o,m:p}})()}function d(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}d=function(e,t,n,i){function o(t,n){d(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))},d(e,t,n,i)}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}function p(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 m(e){var t="function"==typeof Map?new Map:void 0;return m=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 i(e,arguments,c(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)},m(e)}function v(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 y=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}();y.deltaTime=0,y.unscaledDeltaTime=0,y.totalTime=0,y.unscaledTotalTime=0,y.timeScale=1,y.frameCount=0;var _,S=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+=y.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},o(e,[{key:"isDone",get:function(){return this._isDone}},{key:"elapsedTime",get:function(){return this._elapsedTime}}])}(),C=new WeakMap,E=new WeakMap;function b(){return function(e){var t=C.get(e);C.set(e,a({injectable:!0,dependencies:[]},(null==t?void 0:t.properties)&&{properties:t.properties}))}}function T(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.");E.set(t,{updatable:!0,priority:e})}}function w(e){return function(t,n){var i=C.get(t.constructor);i||(i={injectable:!0,dependencies:[]},C.set(t.constructor,i)),i.properties||(i.properties=new Map),i.properties.set(n,e)}}function x(e){var t,n=C.get(e);return null!==(t=null==n?void 0:n.injectable)&&void 0!==t&&t}function I(e,t){var n=new e;return M(n,t),n}function M(e,t){var n,i=e.constructor,r=(n=i,C.get(n));if(null!=r&&r.properties&&0!==r.properties.size)for(var o,a=s(r.properties);!(o=a()).done;){var c=o.value,u=c[0],l=c[1],h=t.resolve(l);null!==h&&(e[u]=h)}}function A(e){var t,n=E.get(e);return null!==(t=null==n?void 0:n.updatable)&&void 0!==t&&t}function k(e){return E.get(e)}exports.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 S;return r.initialize(e,t,n,i),this._timers.push(r),r},t.dispose=function(){for(var e,t=s(this._timers);!(e=t()).done;){e.value.unload()}this._timers=[]},e}(),exports.TimerManager=v([T()],exports.TimerManager),exports.PerformanceWarningType=void 0,(_=exports.PerformanceWarningType||(exports.PerformanceWarningType={})).HIGH_EXECUTION_TIME="high_execution_time",_.HIGH_MEMORY_USAGE="high_memory_usage",_.HIGH_CPU_USAGE="high_cpu_usage",_.FREQUENT_GC="frequent_gc",_.LOW_FPS="low_fps",_.HIGH_ENTITY_COUNT="high_entity_count";var D=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=s(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],a=this._systemData.get(r);e.push("System: "+r),e.push(" Current: "+(null==a?void 0:a.executionTime.toFixed(2))+"ms ("+(null==a?void 0:a.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!=a&&a.averageTimePerEntity&&a.averageTimePerEntity>0&&e.push(" Per Entity: "+a.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=s(this._systemData.entries());!(t=i()).done;){var r=t.value,o=r[0],a=r[1];a.executionTime>e&&n.push(o+": "+a.executionTime.toFixed(2)+"ms (>"+e+"ms)")}return n},t.setMaxRecentSamples=function(e){this._maxRecentSamples=e;for(var t,n=s(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},o(e,[{key:"isEnabled",get:function(){return this._isEnabled}}])}(),P=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 a({},this._stats)},t.clear=function(){for(var e,t=s(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=s(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=s(this._pools.values());!(e=t()).done;){e.value.compact()}},e.clearAllPools=function(){for(var e,t=s(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}();P._pools=new Map;var O,R=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 P(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=s(this.pools.values());!(e=t()).done;){e.value.compact()}},t.clearAllPools=function(){for(var e,t=s(this.pools.values());!(e=t()).done;){e.value.clear()}},t.getAllStats=function(){for(var e,t=new Map,n=s(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,a=0,c=s(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,a+=u.estimatedMemoryUsage}return{size:t,maxSize:n,totalCreated:i,totalObtained:r,totalReleased:o,hitRate:0===r?0:(r-i)/r,estimatedMemoryUsage:a}},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=s(this.pools);!(n=i()).done;){var r=n.value,o=r[0],a=r[1].getStats();e.push(o+":"),e.push(" Size: "+a.size+"/"+a.maxSize),e.push(" Hit Rate: "+(100*a.hitRate).toFixed(1)+"%"),e.push(" Memory: "+(a.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=s(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}(),N=Symbol("ComponentTypeName"),z=Symbol("ComponentDependencies"),F=Symbol("ComponentEditorOptions");function B(e){return void 0!==e[N]}function L(e){var t=e[N];return t||(e.name||"UnknownComponent")}function H(e){return L(e.constructor)}function W(e){return e[F]}function U(e){var t,n=W(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"}(O||(O={}));var G,j=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[O.LOW]&n[O.LOW])||0!==(i[O.HIGH]&n[O.HIGH]);return!s&&r&&o?o.some(function(e,t){var n=r[t];return n&&(0!==(e[O.LOW]&n[O.LOW])||0!==(e[O.HIGH]&n[O.HIGH]))}):s},e.hasAll=function(e,t){var n,i=e.base,r=t.base,o=e.segments,s=t.segments,a=(i[O.LOW]&r[O.LOW])===r[O.LOW]&&(i[O.HIGH]&r[O.HIGH])===r[O.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[O.LOW]&h[O.LOW])!==h[O.LOW]||(l[O.HIGH]&h[O.HIGH])!==h[O.HIGH])return!1}for(var d=c;d<s.length;d++){var f=s[d];if(0!==f[O.LOW]||0!==f[O.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[O.LOW]&i[O.LOW])&&0===(n[O.HIGH]&i[O.HIGH]);return r&&s&&o?r.every(function(e,t){var n=o[t];return!n||0===(e[O.LOW]&n[O.LOW])&&0===(e[O.HIGH]&n[O.HIGH])}):s},e.isZero=function(e){var t=0===e.base[O.LOW]&&0===e.base[O.HIGH];return e.segments&&t?e.segments.every(function(e){return 0===e[O.LOW]&&0===e[O.HIGH]}):t},e.equals=function(e,t){var n,i,r=e.base[O.LOW]===t.base[O.LOW]&&e.base[O.HIGH]===t.base[O.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[O.LOW]||0!==c[O.HIGH])return!1}else if(!c&&u){if(0!==u[O.LOW]||0!==u[O.HIGH])return!1}else if(c&&u&&(c[O.LOW]!==u[O.LOW]||c[O.HIGH]!==u[O.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[O.LOW]|=1<<r:i[O.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[O.LOW]&1<<r):!!(i[O.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[O.LOW]&=~(1<<r):i[O.HIGH]&=~(1<<r-32)}},e.orInPlace=function(e,t){e.base[O.LOW]|=t.base[O.LOW],e.base[O.HIGH]|=t.base[O.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[O.LOW]|=s[O.LOW],o[O.HIGH]|=s[O.HIGH]}}},e.andInPlace=function(e,t){e.base[O.LOW]&=t.base[O.LOW],e.base[O.HIGH]&=t.base[O.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[O.LOW]&=s[O.LOW],o[O.HIGH]&=s[O.HIGH]}}},e.xorInPlace=function(e,t){e.base[O.LOW]^=t.base[O.LOW],e.base[O.HIGH]^=t.base[O.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[O.LOW]^=s[O.LOW],o[O.HIGH]^=s[O.HIGH]}}},e.clear=function(e){if(e.base[O.LOW]=0,e.base[O.HIGH]=0,e.segments)for(var t=0;t<e.segments.length;t++){var n=e.segments[t];n[O.LOW]=0,n[O.HIGH]=0}},e.copy=function(t,n){if(e.clear(n),n.base[O.LOW]=t.base[O.LOW],n.base[O.HIGH]=t.base[O.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[O.LOW]=u[O.LOW],c[O.HIGH]=u[O.HIGH]}}else n.segments=t.segments.map(function(e){return[].concat(e)})},e.clone=function(e){return a({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[O.HIGH],f=h[O.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[O.LOW],a=o[O.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}();j.ZERO={base:[0,0]},exports.LogLevel=void 0,(G=exports.LogLevel||(exports.LogLevel={}))[G.Debug=0]="Debug",G[G.Info=1]="Info",G[G.Warn=2]="Warn",G[G.Error=3]="Error",G[G.Fatal=4]="Fatal",G[G.None=5]="None";var q={BLACK:"",RED:"",GREEN:"",YELLOW:"",BLUE:"",MAGENTA:"",CYAN:"",WHITE:"",BRIGHT_BLACK:"",BRIGHT_RED:"",BRIGHT_GREEN:"",BRIGHT_YELLOW:"",BRIGHT_BLUE:"",BRIGHT_MAGENTA:"",BRIGHT_CYAN:"",BRIGHT_WHITE:"",RESET:"",BOLD:"",UNDERLINE:""},V=function(){function e(e){void 0===e&&(e={}),this._config=a({level:exports.LogLevel.Info,enableTimestamp:!0,enableColors:"undefined"==typeof window},e)}var t=e.prototype;return t.debug=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.log.apply(this,[exports.LogLevel.Debug,e].concat(n))},t.info=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.log.apply(this,[exports.LogLevel.Info,e].concat(n))},t.warn=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.log.apply(this,[exports.LogLevel.Warn,e].concat(n))},t.error=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.log.apply(this,[exports.LogLevel.Error,e].concat(n))},t.fatal=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.log.apply(this,[exports.LogLevel.Fatal,e].concat(n))},t.setLevel=function(e){this._config.level=e},t.setColors=function(e){0===Object.keys(e).length?delete this._config.colors:this._config.colors=a({},this._config.colors,e)},t.setPrefix=function(e){this._config.prefix=e},t.log=function(e,t){if(!(e<this._config.level)){var n=t;if(this._config.enableTimestamp)n="["+(new Date).toISOString()+"] "+n;if(this._config.prefix&&(n="["+this._config.prefix+"] "+n),n="["+exports.LogLevel[e].toUpperCase()+"] "+n,this._config.output)this._config.output(e,n);else{for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];this.outputToConsole.apply(this,[e,n].concat(r))}}},t.outputToConsole=function(e,t){for(var n=this._config.enableColors?this.getColors():null,i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];switch(e){case exports.LogLevel.Debug:var s,a;if(n)(s=console).debug.apply(s,[""+n.debug+t+n.reset].concat(r));else(a=console).debug.apply(a,[t].concat(r));break;case exports.LogLevel.Info:var c,u;if(n)(c=console).info.apply(c,[""+n.info+t+n.reset].concat(r));else(u=console).info.apply(u,[t].concat(r));break;case exports.LogLevel.Warn:var l,h;if(n)(l=console).warn.apply(l,[""+n.warn+t+n.reset].concat(r));else(h=console).warn.apply(h,[t].concat(r));break;case exports.LogLevel.Error:var d,f;if(n)(d=console).error.apply(d,[""+n.error+t+n.reset].concat(r));else(f=console).error.apply(f,[t].concat(r));break;case exports.LogLevel.Fatal:var p,m;if(n)(p=console).error.apply(p,[""+n.fatal+t+n.reset].concat(r));else(m=console).error.apply(m,[t].concat(r))}},t.getColors=function(){return a({},{debug:q.BRIGHT_BLACK,info:q.GREEN,warn:q.YELLOW,error:q.RED,fatal:q.BRIGHT_RED,reset:q.RESET},this._config.colors)},e}(),Q=function(){function e(){this._loggers=new Map,this._defaultLevel=exports.LogLevel.Info}var t=e.prototype;return t.createDefaultLogger=function(){return this._loggerFactory?this._loggerFactory():new V({level:this._defaultLevel})},e.getInstance=function(){return e._instance||(e._instance=new e),e._instance},t.getLogger=function(e){return e?this._loggerFactory?this._loggerFactory(e):(this._loggers.has(e)||this._loggers.set(e,new V({prefix:e,level:this._defaultLevel})),this._loggers.get(e)):this.defaultLogger},t.setLogger=function(e,t){this._loggers.set(e,t)},t.setGlobalLevel=function(e){this._defaultLevel=e,this._defaultLogger instanceof V&&this._defaultLogger.setLevel(e);for(var t,n=s(this._loggers.values());!(t=n()).done;){var i=t.value;i instanceof V&&i.setLevel(e)}},t.createChildLogger=function(e,t){var n=e+"."+t;return this.getLogger(n)},t.setGlobalColors=function(e){this._defaultLogger instanceof V&&this._defaultLogger.setColors(e);for(var t,n=s(this._loggers.values());!(t=n()).done;){var i=t.value;i instanceof V&&i.setColors(e)}},t.resetColors=function(){this._defaultLogger instanceof V&&this._defaultLogger.setColors({});for(var e,t=s(this._loggers.values());!(e=t()).done;){var n=e.value;n instanceof V&&n.setColors({})}},t.setLoggerFactory=function(e){this._loggerFactory=e,delete this._defaultLogger,this._loggers.clear()},o(e,[{key:"defaultLogger",get:function(){return this._defaultLogger||(this._defaultLogger=this.createDefaultLogger()),this._defaultLogger}}])}(),Y=Q.getInstance().getLogger();function J(e){return Q.getInstance().getLogger(e)}var Z,X=J("ComponentRegistry"),K=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=L(e);if(B(e)||this._warnedComponents.has(e)||(this._warnedComponents.add(e),X.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),X.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=L(e);throw new Error("Component type "+n+" is not registered")}return j.create(t)},t.getBitIndex=function(e){var t=this._componentTypes.get(e);if(void 0===t){var n=L(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=j.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=j.clone(j.ZERO),r=s(e);!(n=r()).done;){var o=n.value,a=this.getComponentId(o);if(void 0!==a){var c=j.create(a);j.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(),X.debug("Component unregistered: "+e)}},t.getRegisteredComponents=function(){for(var e,t=[],n=s(this._componentNameToType);!(e=n()).done;){var i=e.value,r=i[0],o=i[1],a=this._componentTypes.get(o);void 0!==a&&t.push({name:r,type:o,bitIndex:a})}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=s(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 a=L(r);this._componentNameToType.set(a,r),this._componentNameToId.set(a,o)}this._nextBitIndex=e.getRegisteredCount(),this._hotReloadEnabled=e.isHotReloadEnabled()},e}(),$=new K;exports.SyncOperation=void 0,(Z=exports.SyncOperation||(exports.SyncOperation={}))[Z.FULL=0]="FULL",Z[Z.DELTA=1]="DELTA",Z[Z.SPAWN=2]="SPAWN",Z[Z.DESPAWN=3]="DESPAWN";var ee=Symbol("SyncMetadata"),te=Symbol("ChangeTracker"),ne=Symbol("SystemTypeName");function ie(e,t){return function(n){if(!e||"string"!=typeof e)throw new Error("ECSComponent装饰器必须提供有效的类型名称");var i=n;i[N]=e,null!=t&&t.requires&&(i[z]=t.requires),null!=t&&t.editor&&(i[F]=t.editor);var r=n[ee];return r&&(r.typeId=e),$.register(n),n}}function re(e){return e.__systemMetadata__}function oe(e){return re(e.constructor)}function se(e){var t=e[ne];return t||(e.name||"UnknownSystem")}function ae(e){return se(e.constructor)}var ce=function(){function e(e){this._target=e}return e.prototype.deref=function(){return this._target},e}(),ue="undefined"!=typeof globalThis&&globalThis.WeakRef||"undefined"!=typeof global&&global.WeakRef||"undefined"!=typeof window&&window.WeakRef||ce,le=new Map;function he(e){var t=le.get(e);return(null==t?void 0:t.deref())||null}var de=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 ue(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=s(t);!(n=r()).done;){var o=n.value;o.component.deref()&&i.push(o)}for(var a=0,c=i;a<c.length;a++){var u=c[a],l=u.component.deref();l&&(l[u.propertyKey]=null)}this._references.delete(e)}},t.clearComponentReferences=function(e){for(var t,n=s(this._references.entries());!(t=n()).done;){for(var i,r=t.value,o=r[0],a=r[1],c=[],u=s(a);!(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];a.delete(p)}0===a.size&&this._references.delete(o)}},t.getReferencesTo=function(e){var t=this._references.get(e);if(!t)return[];for(var n,i=[],r=s(t);!(n=r()).done;){var o=n.value;o.component.deref()&&i.push(o)}return i},t.cleanup=function(){for(var e,t=[],n=s(this._references.entries());!(e=n()).done;){for(var i,r=e.value,o=r[0],a=r[1],c=[],u=s(a);!(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];a.delete(f)}0===a.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){le.set(e,new ue(t))},t.unregisterEntityScene=function(e){le.delete(e)},t.getDebugInfo=function(){for(var e,t={},n=s(this._references.entries());!(e=n()).done;){for(var i,r=e.value,o=r[0],a=[],c=s(r[1]);!(i=c()).done;){var u=i.value,l=u.component.deref();l&&a.push({componentId:l.id,propertyKey:u.propertyKey})}a.length>0&&(t["entity_"+o]=a)}return t},t._findRecord=function(e,t,n){for(var i,r=s(e);!(i=r()).done;){var o=i.value;if(o.component.deref()===t&&o.propertyKey===n)return o}},e}(),fe=J("EntityRefDecorator"),pe=Symbol("EntityRefMetadata"),me=Symbol("EntityRefValues");function ve(e){var t=e[me];return t||(t=new Map,e[me]=t),t}function ge(e){return e&&("function"==typeof e?e:e.constructor)[pe]||null}function ye(e,t){var n=ge(e);return!!n&&n.properties.has(t)}var _e=new WeakMap,Se=Symbol.for("@esengine/property:metadata");var Ce=Symbol("schedulingMetadata");function Ee(e){var t=e;return t[Ce]||(t[Ce]={stage:"update",before:[],after:[],sets:[]}),t[Ce]}function be(e){for(var t=Object.getPrototypeOf(e);t;){var n=t[Ce];if(n)return n;t=Object.getPrototypeOf(t)}}var Te=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=s(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 a,c=Object.keys(t).filter(function(e){return"id"!==e}),u=s(c);!(a=u()).done;){var l,h,d,f,p=a.value,m=typeof t[p];if("function"!==m){var v={name:p,type:m},g=r.get(p);g?v.arrayType=g:"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}();Te.TYPE_CONSTRUCTORS={float32:Float32Array,float64:Float64Array,int32:Int32Array,uint32:Uint32Array,int16:Int16Array,uint16:Uint16Array,int8:Int8Array,uint8:Uint8Array,uint8clamped:Uint8ClampedArray},Te.TYPE_BYTES={float32:4,float64:8,int32:4,uint32:4,int16:2,uint16:2,int8:1,uint8:1,uint8clamped:1};var we=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=s(e.entries());!(n=r()).done;){var o=n.value,a=o[0],c=o[1];i.set(a,this.deepClone(c))}return i}if(e instanceof Set){for(var u,l=new Set,h=s(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 xe(e,t){var n=e.constructor,i=n[t];return i||(i=new Set,n[t]=i),i}function Ie(e,t){xe(e,"__int32Fields").add(String(t))}we._logger=J("SoASerializer");var Me=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,a=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=s(i);!(f=m()).done;){var v=f.value;p.set(v,"float64")}for(var g,y=s(r);!(g=y()).done;){var _=g.value;p.set(_,"float32")}for(var S,C=s(o);!(S=C()).done;){var E=S.value;p.set(E,"int32")}for(var b,T=s(a);!(b=T()).done;){var w=b.value;p.set(w,"uint32")}for(var x,I=s(c);!(x=I()).done;){var M=x.value;p.set(M,"int16")}for(var A,k=s(u);!(A=k()).done;){var D=A.value;p.set(D,"uint16")}for(var P,O=s(l);!(P=O()).done;){var R=P.value;p.set(R,"int8")}for(var N,z=s(h);!(N=z()).done;){var F=N.value;p.set(F,"uint8")}for(var B,L=s(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=s(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=Te.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]=we.serialize(d,h,{isMap:s.has(h),isSet:a.has(h),isArray:c.has(h)})}else u.has(h)?i.set(h,we.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?we.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]=we.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=s(n.fields.keys());!(t=r()).done;){var o=t.value;i.push(o)}for(var a,c=s(n.stringFields.keys());!(a=c()).done;){var u=a.value;i.push(u)}for(var l,h=s(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=s(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=s(this.fields.entries());!(n=o()).done;){var a=n.value,c=a[0],u=a[1][t],l=this.getFieldType(c);r[c]="boolean"===l?1===u:u}for(var h,d=s(this.stringFields.entries());!(h=d()).done;){var f=h.value,p=f[0],m=f[1];r[p]=m[t]}for(var v,g=s(this.serializedFields.entries());!(v=g()).done;){var y=v.value,_=y[0],S=y[1][t];S&&(r[_]=we.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=s(C.entries());!(E=b()).done;){var T=E.value,w=T[0],x=T[1];r[w]=x}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=s(this.fields.entries());!(t=n()).done;){var i=t.value,r=i[0],o=i[1],a=Te.createSameType(o,e);a.set(o),this.fields.set(r,a)}for(var c,u=s(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=s(this.serializedFields.entries());!(m=v()).done;){for(var g=m.value,y=g[0],_=g[1],S=new Array(e),C=0;C<_.length;C++)S[C]=_[C];this.serializedFields.set(y,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=s(this.fields.values());!(e=t()).done;){e.value.fill(0)}for(var n,i=s(this.stringFields.values());!(n=i()).done;)for(var r=n.value,o=0;o<r.length;o++)r[o]=void 0;for(var a,c=s(this.serializedFields.values());!(a=c()).done;)for(var u=a.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],a=r[1];if(t.set(o,i),n[i]=o,i!==a){for(var c,u=s(this.fields.entries());!(c=u()).done;){var l=c.value[1],h=l[a];void 0!==h&&(l[i]=h)}for(var d,f=s(this.stringFields.entries());!(d=f()).done;){var p=d.value[1],m=p[a];void 0!==m&&(p[i]=m)}for(var v,g=s(this.serializedFields.entries());!(v=g()).done;){var y=v.value[1],_=y[a];void 0!==_&&(y[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=s(this.fields.entries());!(e=i()).done;){var r=e.value,o=r[0],a=r[1],c=Te.getTypeName(a),u=Te.getBytesPerElement(c),l=a.length*u;t+=l,n.set(o,{size:this._size,capacity:a.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}(),Ae=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(){},o(e,[{key:"lastWriteEpoch",get:function(){return this._lastWriteEpoch}}])}();Ae._idGenerator=0,v([Ie,g("design:type",Object)],Ae.prototype,"entityId",void 0);var ke=Symbol("SerializableMetadata"),De=Symbol("SerializeField"),Pe=Symbol("SerializeOptions");function Oe(e){return function(t){if(!e||"number"!=typeof e.version)throw new Error("Serializable装饰器必须提供有效的版本号");var n;if(Object.prototype.hasOwnProperty.call(t,ke))(n=t[ke]).options=e;else{var i=t[ke];n={options:e,fields:i?new Map(i.fields):new Map,ignoredFields:i?new Set(i.ignoredFields):new Set},t[ke]=n}return t}}function Re(e){return function(t,n){var i,r=t.constructor;if(Object.prototype.hasOwnProperty.call(r,ke))i=r[ke];else{var o=r[ke];i={options:o?a({},o.options):{version:1},fields:o?new Map(o.fields):new Map,ignoredFields:o?new Set(o.ignoredFields):new Set},r[ke]=i}i.fields.set(n,e||{})}}function Ne(e){return e&&("function"==typeof e?e:e.constructor)[ke]||null}exports.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 u(t,e),t}(Ae),v([Re(),g("design:type",Object)],exports.HierarchyComponent.prototype,"parentId",void 0),v([Re(),g("design:type",Array)],exports.HierarchyComponent.prototype,"childIds",void 0),exports.HierarchyComponent=v([ie("Hierarchy",{editor:{hideInInspector:!0}}),Oe({version:1,typeId:"Hierarchy"})],exports.HierarchyComponent);var ze=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){return(new e).withComponent(t)},e.complex=func