excalibur 0.32.0-alpha.1574 → 0.32.0-alpha.1576
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/build/dist/EntityComponentSystem/Entity.d.ts +1 -1
- package/build/dist/excalibur.development.js +6 -5
- package/build/dist/excalibur.js +6 -5
- package/build/dist/excalibur.min.development.js +3 -3
- package/build/dist/excalibur.min.js +3 -3
- package/build/esm/excalibur.development.js +6 -5
- package/build/esm/excalibur.js +6 -5
- package/build/esm/excalibur.min.development.js +16 -16
- package/build/esm/excalibur.min.js +16 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -74,6 +74,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
74
74
|
|
|
75
75
|
### Fixed
|
|
76
76
|
|
|
77
|
+
- Fixed issue where onRemove would sometimes not be called
|
|
77
78
|
- Fixed issue where pointer containment WAS NOT being uses on collision shape geometry, only their bounds
|
|
78
79
|
- Fixed issue where overriding built in uniforms and graphics no longer worked as v0.30.x
|
|
79
80
|
- Fixed issue where clearSchedule during a scheduled callback could cause a cb to be skipped
|
|
@@ -266,7 +266,7 @@ export declare class Entity<TKnownComponents extends Component = any> implements
|
|
|
266
266
|
*/
|
|
267
267
|
_add(engine: Engine): void;
|
|
268
268
|
/**
|
|
269
|
-
* Removes Actor, meant to be called by the Scene when Actor is
|
|
269
|
+
* Removes Actor, meant to be called by the Scene when Actor is removed.
|
|
270
270
|
*
|
|
271
271
|
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
272
272
|
* @internal
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1576+d33ac1f - 2025-11-29
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -5247,7 +5247,7 @@ mask: ${(this.mask >>> 0).toString(2).padStart(32, "0")}
|
|
|
5247
5247
|
}
|
|
5248
5248
|
}
|
|
5249
5249
|
/**
|
|
5250
|
-
* Removes Actor, meant to be called by the Scene when Actor is
|
|
5250
|
+
* Removes Actor, meant to be called by the Scene when Actor is removed.
|
|
5251
5251
|
*
|
|
5252
5252
|
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
5253
5253
|
* @internal
|
|
@@ -5414,7 +5414,7 @@ mask: ${(this.mask >>> 0).toString(2).padStart(32, "0")}
|
|
|
5414
5414
|
}
|
|
5415
5415
|
}
|
|
5416
5416
|
removeEntity(idOrEntity, deferred = true) {
|
|
5417
|
-
var _a, _b;
|
|
5417
|
+
var _a, _b, _c, _d;
|
|
5418
5418
|
let id = 0;
|
|
5419
5419
|
if (idOrEntity instanceof Entity) {
|
|
5420
5420
|
id = idOrEntity.id;
|
|
@@ -5448,7 +5448,8 @@ mask: ${(this.mask >>> 0).toString(2).padStart(32, "0")}
|
|
|
5448
5448
|
entity.childrenRemoved$.unsubscribe(childRemovedHandler);
|
|
5449
5449
|
this._childRemovedHandlerMap.delete(entity);
|
|
5450
5450
|
}
|
|
5451
|
-
|
|
5451
|
+
entity._remove((_b = (_a = this._world) == null ? void 0 : _a.scene) == null ? void 0 : _b.engine);
|
|
5452
|
+
if ((_d = (_c = this._world) == null ? void 0 : _c.scene) == null ? void 0 : _d.engine) {
|
|
5452
5453
|
this._world.scene.engine.stats.currFrame.actors.killed++;
|
|
5453
5454
|
}
|
|
5454
5455
|
}
|
|
@@ -33441,7 +33442,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33441
33442
|
this._count += count;
|
|
33442
33443
|
}
|
|
33443
33444
|
}
|
|
33444
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33445
|
+
const EX_VERSION = "0.32.0-alpha.1576+d33ac1f";
|
|
33445
33446
|
polyfill();
|
|
33446
33447
|
exports2.ActionCompleteEvent = ActionCompleteEvent;
|
|
33447
33448
|
exports2.ActionContext = ActionContext;
|
package/build/dist/excalibur.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1576+d33ac1f - 2025-11-29
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -5247,7 +5247,7 @@ mask: ${(this.mask >>> 0).toString(2).padStart(32, "0")}
|
|
|
5247
5247
|
}
|
|
5248
5248
|
}
|
|
5249
5249
|
/**
|
|
5250
|
-
* Removes Actor, meant to be called by the Scene when Actor is
|
|
5250
|
+
* Removes Actor, meant to be called by the Scene when Actor is removed.
|
|
5251
5251
|
*
|
|
5252
5252
|
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
5253
5253
|
* @internal
|
|
@@ -5414,7 +5414,7 @@ mask: ${(this.mask >>> 0).toString(2).padStart(32, "0")}
|
|
|
5414
5414
|
}
|
|
5415
5415
|
}
|
|
5416
5416
|
removeEntity(idOrEntity, deferred = true) {
|
|
5417
|
-
var _a, _b;
|
|
5417
|
+
var _a, _b, _c, _d;
|
|
5418
5418
|
let id = 0;
|
|
5419
5419
|
if (idOrEntity instanceof Entity) {
|
|
5420
5420
|
id = idOrEntity.id;
|
|
@@ -5448,7 +5448,8 @@ mask: ${(this.mask >>> 0).toString(2).padStart(32, "0")}
|
|
|
5448
5448
|
entity.childrenRemoved$.unsubscribe(childRemovedHandler);
|
|
5449
5449
|
this._childRemovedHandlerMap.delete(entity);
|
|
5450
5450
|
}
|
|
5451
|
-
|
|
5451
|
+
entity._remove((_b = (_a = this._world) == null ? void 0 : _a.scene) == null ? void 0 : _b.engine);
|
|
5452
|
+
if ((_d = (_c = this._world) == null ? void 0 : _c.scene) == null ? void 0 : _d.engine) {
|
|
5452
5453
|
this._world.scene.engine.stats.currFrame.actors.killed++;
|
|
5453
5454
|
}
|
|
5454
5455
|
}
|
|
@@ -33441,7 +33442,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33441
33442
|
this._count += count;
|
|
33442
33443
|
}
|
|
33443
33444
|
}
|
|
33444
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33445
|
+
const EX_VERSION = "0.32.0-alpha.1576+d33ac1f";
|
|
33445
33446
|
polyfill();
|
|
33446
33447
|
exports2.ActionCompleteEvent = ActionCompleteEvent;
|
|
33447
33448
|
exports2.ActionContext = ActionContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1576+d33ac1f - 2025-11-29
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -15,7 +15,7 @@ Licensed BSD-2-Clause
|
|
|
15
15
|
`}}class ne extends w{constructor(t,e){super(t.x,t.y),this.original=t,this.change=e}get x(){return this._x=this.original.x}set x(t){t!==this._x&&(this.change(t,this._y),this._x=this.original.x=t)}get y(){return this._y=this.original.y}set y(t){t!==this._y&&(this.change(this._x,t),this._y=this.original.y=t)}setTo(t,e){this.x=t,this.y=e}}class Kt{constructor(){this._parent=null,this._children=[],this._pos=new ne(b(0,0),()=>{this.flagDirty()}),this._globalPos=new ps({getX:()=>this.matrix.data[4],getY:()=>this.matrix.data[5],setX:t=>{if(this.parent){const{x:e}=this.parent.inverse.multiply(b(t,this.pos.y));this.pos.x=e}else this.pos.x=t;t!==this.matrix.data[4]&&this.flagDirty()},setY:t=>{if(this.parent){const{y:e}=this.parent.inverse.multiply(b(this.pos.x,t));this.pos.y=e}else this.pos.y=t;t!==this.matrix.data[5]&&this.flagDirty()}}),this._rotation=0,this._scale=new ne(b(1,1),()=>{this.flagDirty()}),this._globalScale=new ps({getX:()=>this.parent?this.matrix.getScaleX():this.scale.x,getY:()=>this.parent?this.matrix.getScaleY():this.scale.y,setX:t=>{if(this.parent){const e=this.parent.globalScale.x;this.scale.x=t/e}else this.scale.x=t},setY:t=>{if(this.parent){const e=this.parent.globalScale.y;this.scale.y=t/e}else this.scale.y=t}}),this._z=0,this._isDirty=!1,this._isInverseDirty=!1,this._matrix=Z.identity(),this._inverse=Z.identity(),this._scratch=Z.identity()}get parent(){return this._parent}set parent(t){if(this._parent){const e=this._parent._children.indexOf(this);e>-1&&this._parent._children.splice(e,1)}this._parent=t,this._parent&&this._parent._children.push(this),this.flagDirty()}get children(){return this._children}set pos(t){this._pos.x=t.x,this._pos.y=t.y}get pos(){return this._pos}set globalPos(t){let e=t.clone();this.parent&&(e=this.parent.inverse.multiply(t)),e.equals(this._pos)||(this._pos=e,this.flagDirty())}get globalPos(){return this._globalPos}set rotation(t){const e=Jt(t);e!==this._rotation&&this.flagDirty(),this._rotation=e}get rotation(){return this._rotation}set globalRotation(t){let e=0;this.parent&&(e=this.parent.globalRotation);const i=Jt(t+e);i!==this._rotation&&this.flagDirty(),this._rotation=i}get globalRotation(){return this.parent?this.matrix.getRotation():this.rotation}set scale(t){this._scale.x=t.x,this._scale.y=t.y}get scale(){return this._scale}set globalScale(t){let e=b(1,1);this.parent&&(e=this.parent.globalScale),this.scale=t.scale(b(1/e.x,1/e.y))}get globalScale(){return this._globalScale}set z(t){this._z=t,this.flagDirty()}get z(){return this._z}set globalZ(t){this.parent?this.z=t-this.parent.globalZ:this.z=t}get globalZ(){return this.parent?this.z+this.parent.globalZ:this.z}get matrix(){return this._isDirty&&(this.parent===null?this._calculateMatrix().clone(this._matrix):this.parent.matrix.multiply(this._calculateMatrix()).clone(this._matrix),this._isDirty=!1),this._matrix}get inverse(){return this._isInverseDirty&&(this.matrix.inverse(this._inverse),this._isInverseDirty=!1),this._inverse}_calculateMatrix(){return this._scratch.data[0]=Math.cos(this._rotation),this._scratch.data[1]=Math.sin(this._rotation),this._scratch.data[2]=-Math.sin(this._rotation),this._scratch.data[3]=Math.cos(this.rotation),this._scratch.data[4]=this._pos.x,this._scratch.data[5]=this._pos.y,this._scratch.scale(this._scale.x,this._scale.y),this._scratch}flagDirty(){this._isDirty=!0,this._isInverseDirty=!0;for(let t=0;t<this._children.length;t++)this._children[t].flagDirty()}apply(t){return this.matrix.multiply(t)}applyInverse(t){return this.inverse.multiply(t)}setTransform(t,e,i){this._pos.x=t.x,this._pos.y=t.y,this._rotation=Jt(e),this._scale.x=i.x,this._scale.y=i.y,this.flagDirty()}isMirrored(){const t=V(this.scale.x)>>>31,e=V(this.scale.y)>>>31;return!!(t^e)}clone(t){const e=t!=null?t:new Kt;return this._pos.clone(e._pos),e._z=this._z,e._rotation=this._rotation,this._scale.clone(e._scale),e.flagDirty(),e}cloneWithParent(t){const e=t!=null?t:new Kt;return this._pos.clone(e._pos),e._z=this._z,e._rotation=this._rotation,this._scale.clone(e._scale),e.parent=this.parent,e.flagDirty(),e}toString(){return this.matrix.toString()}}var rt=(r=>(r.World="world",r.Screen="screen",r))(rt||{});class ke{constructor(t,e,i){this.worldPos=t,this.pagePos=e,this.screenPos=i}static fromPagePosition(t,e,i){let s,n,o,a;arguments.length===3?(s=t,n=e,o=new w(s,n),a=i):(o=t,s=o.x,n=o.y,a=e);const h=a.screen.pageToScreenCoordinates(o),l=a.screen.screenToWorldCoordinates(h);return new ke(l,o,h)}}class Q{constructor(t,e){this.begin=t,this.end=e}clone(t){const e=t||new Q(this.begin.clone(),this.end.clone());return e.begin=this.begin.clone(e.begin),e.end=this.end.clone(e.end),e}transform(t,e){const i=e||new Q(w.Zero,w.Zero);return i.begin=t.multiply(this.begin,i.begin),i.end=t.multiply(this.end,i.end),i}get slope(){return(this.end.y-this.begin.y)/(this.end.x-this.begin.x)}get intercept(){return this.begin.y-this.slope*this.begin.x}normal(){return this._normal?this._normal:this._normal=this.end.sub(this.begin).normal()}dir(){return this._dir?this._dir:this._dir=this.end.sub(this.begin)}getPoints(){return[this.begin,this.end]}getSlope(){if(this._slope)return this._slope;const t=this.begin,e=this.end,i=t.distance(e);return this._slope=e.sub(t).scale(1/i)}getEdge(){const t=this.begin;return this.end.sub(t)}getLength(){const t=this.begin,e=this.end;return t.distance(e)}get midpoint(){return this.begin.add(this.end).scale(.5)}flip(){return new Q(this.end,this.begin)}below(t){return(this.end.x-this.begin.x)*(t.y-this.begin.y)-(this.end.y-this.begin.y)*(t.x-this.begin.x)>=0}clip(t,e,i=!0){let s=t;i&&(s=s.normalize());const n=s.dot(this.begin)-e,o=s.dot(this.end)-e,a=[];if(n<=0&&a.push(this.begin),o<=0&&a.push(this.end),n*o<0){const h=n/(n-o);a.push(this.begin.add(this.end.sub(this.begin).scale(h)))}return a.length!==2?null:new Q(a[0],a[1])}distanceToPoint(t,e=!1){const i=t.x,s=t.y,n=this.getLength(),o=this.end.y-this.begin.y,a=this.end.x-this.begin.x,h=(o*i-a*s+this.end.x*this.begin.y-this.end.y*this.begin.x)/n;return e?h:Math.abs(h)}findVectorToPoint(t){const e=this.begin.sub(t),i=this.getSlope();return e.sub(i.scale(e.dot(i)))}findPoint(t=null,e=null){const i=this.slope,s=this.intercept;if(t!==null)return new w(t,i*t+s);if(e!==null)return new w((e-s)/i,e);throw new Error("You must provide an X or a Y value")}hasPoint(){let t,e=0;if(typeof arguments[0]=="number"&&typeof arguments[1]=="number")t=new w(arguments[0],arguments[1]),e=arguments[2]||0;else if(arguments[0]instanceof w)t=arguments[0],e=arguments[1]||0;else throw"Could not determine the arguments for Vector.hasPoint";const i=t.x-this.begin.x,s=t.y-this.begin.y,n=this.end.x-this.begin.x,o=this.end.y-this.begin.y,a=i*o-s*n;return Math.abs(a)>e?!1:Math.abs(n)>=Math.abs(o)?n>0?this.begin.x<=t.x&&t.x<=this.end.x:this.end.x<=t.x&&t.x<=this.begin.x:o>0?this.begin.y<=t.y&&t.y<=this.end.y:this.end.y<=t.y&&t.y<=this.begin.y}}class ei{constructor(t,e){this.min=t,this.max=e}overlaps(t){return this.max>t.min&&t.max>this.min}getOverlap(t){return this.overlaps(t)?this.max>t.max?t.max-this.min:this.max-t.min:0}}class ge{constructor(t,e){this.pos=t,this.dir=e.normalize()}intersect(t){const e=t.begin.sub(this.pos);if(this.dir.cross(t.getSlope())===0&&e.cross(this.dir)!==0)return-1;const i=this.dir.cross(t.getSlope());if(i===0)return-1;const s=e.cross(t.getSlope())/i;if(s>=0){const n=e.cross(this.dir)/i/t.getLength();if(n>=0&&n<=1)return s}return-1}intersectPoint(t){const e=this.intersect(t);return e<0?null:this.getPoint(e)}getPoint(t){return this.pos.add(this.dir.scale(t))}}function ot(r,t,e){return(1-e)*r+t*e}function ms(r,t,e,i){const s=(r-t+it)%it>=Math.PI,n=Math.abs(t-r),o=it-n;let a=0,h=0;n>o?(a=o,h=n):(a=n,h=o);let l=0,c=1;switch(e){case j.ShortestPath:l=a,c=s?1:-1;break;case j.LongestPath:l=h,c=s?-1:1;break;case j.Clockwise:c=1,l=s?a:h;break;case j.CounterClockwise:c=-1,l=s?h:a;break}return r+c*(l*i)}function ii(r,t,e){return r.scale(1-e).add(t.scale(e))}function dr(r,t,e){return(e-r)/(t-r)}function ur(r,t,e){const i=e.sub(r),s=t.sub(r),n=i.x/s.x,o=i.y/s.y;return Math.min(n,o)}function Wt(r,t,e,i,s){const n=dr(r,t,s);return ot(e,i,n)}function qa(r,t,e,i,s){const n=ur(r,t,s);return ii(e,i,n)}class si{constructor(t){this._distLookup=[],this.quality=4;var e;if(t.controlPoints.length!==4)throw new Error("Only cubic bezier curves are supported");this._controlPoints=[...t.controlPoints],this.quality=(e=t.quality)!=null?e:this.quality,this._calculateLookup()}get arcLength(){return this._arcLength}get controlPoints(){return this._controlPoints}set controlPoints(t){this._controlPoints=[...t],this._calculateLookup()}setControlPoint(t,e){this._controlPoints[t]=e,this._calculateLookup()}_calculateLookup(){let t=0;this._distLookup.length=0;let e=this.controlPoints[0];const i=this.controlPoints.length*this.quality;for(let s=0;s<i;s++){const n=s/(i-1),o=this.getPoint(n),a=e.distance(o);t+=a,this._distLookup.push(t),e=o}this._arcLength=t}_getTimeGivenDistance(t){const e=this._distLookup.length,i=this.arcLength;if(t>=0&&t<i){for(let s=0;s<e-1;s++)if(this._distLookup[s]<=t&&t<this._distLookup[s+1])return Wt(this._distLookup[s],this._distLookup[s+1],s/(e-1),(s+1)/(e-1),t)}return t/i}getPoint(t){const e=[...this.controlPoints];for(let i=1;i<e.length;i++)for(let s=0;s<e.length-i;s++)e[s]=ii(e[s],e[s+1],t);return e[0]}getTangent(t){const e=t*t,i=this.controlPoints[0],s=this.controlPoints[1],n=this.controlPoints[2],o=this.controlPoints[3];return i.scale(-3*e+6*t-3).add(s.scale(9*e-12*t+3).add(n.scale(-9*e+6*t).add(o.scale(3*e)))).normalize()}getUniformTangent(t){const e=t*this.arcLength,i=this._getTimeGivenDistance(e);return this.getTangent(i)}getNormal(t){return this.getTangent(t).normal()}getUniformNormal(t){return this.getUniformTangent(t).normal()}getUniformPoint(t){const e=t*this.arcLength,i=this._getTimeGivenDistance(e);return this.getPoint(i)}clone(){return new si({controlPoints:[...this.controlPoints],quality:this.quality})}}class vs{constructor(){this.id=xs.generateUUID(),this._nodes=new Map,this._edges=new Set,this.adjacencyList=new Map}addNode(t,e){let i;return e?i=new _r(t,e):i=new Ti(t),this._nodes.set(i.id,i),this.adjacencyList.set(i.id,new Set),i}addNodes(t){for(const e of t){const i=new Ti(e);this._nodes.set(i.id,i),this.adjacencyList.set(i.id,new Set)}return this._nodes}deleteNode(t){const e=t.edges;for(const i of e)this.deleteEdge(i);return this.adjacencyList.forEach((i,s)=>{i.delete(t.id)}),this._nodes.delete(t.id),this.adjacencyList.delete(t.id),this._nodes}addEdge(t,e,i){var s,n;if(Array.from(this._edges).find(l=>l.source.id===t.id&&l.target.id===e.id))return[];let a;i?a="directed"in i?i.directed:!1:a=!1;const h=new ws(t,e,i);if(this._edges.add(h),t.registerNewEdge(h),e.registerNewEdge(h),(s=this.adjacencyList.get(t.id))==null||s.add(e.id),!a){const l=new ws(e,t,i);return(n=this.adjacencyList.get(e.id))==null||n.add(t.id),this._edges.add(l),e.registerNewEdge(l),t.registerNewEdge(l),h.linkWithPartner(l),l.linkWithPartner(h),[h,l]}return[h]}deleteEdge(t){t.source.breakEdge(t),t.target.breakEdge(t),this._edges.delete(t);const e=t.partnerEdge;e&&(e.source.breakEdge(e),e.target.breakEdge(e),this._edges.delete(e))}get nodes(){return this._nodes}getNode(t){return this._nodes.get(t)}get edges(){return this._edges}getNeighbors(t){var e;return Array.from((e=this.adjacencyList.get(t.id))!=null?e:[]).map(i=>this.nodes.get(i))}areNodesConnected(t,e){var i,s;return(s=(i=this.adjacencyList.get(t.id))==null?void 0:i.has(e.id))!=null?s:!1}bfs(t){if(!this._nodes.has(t.id))return[];const e=[t.id],i=new Set([t.id]);for(;e.length>0;){const s=e.shift(),n=this.adjacencyList.get(s)||new Set;for(const o of n)i.has(o)||(i.add(o),e.push(o))}return Array.from(i)}dfs(t,e=new Set){var i;const s=t.id;if(!this._nodes.has(s))return[];e.add(s);let n=[s];for(const o of(i=this.adjacencyList.get(s))!=null?i:[])e.has(o)||(n=n.concat(this.dfs(this._nodes.get(o),e)));return n}static createGraphFromNodes(t){const e=new vs;return e.addNodes(t),e}dijkstra(t){const e=[],i=[],s=[];this.nodes.forEach(l=>i.push(l)),this.nodes.forEach(l=>s.push({node:l,distance:1/0,previous:null}));const n=s.findIndex(l=>l.node===t);if(n===-1)return[];s[n].distance=0,e.push(t),i.splice(i.indexOf(t),1);let o=t;const a=o.edges,h=Array.from(a).filter(l=>l.target!==o);for(const l of h){const c=s.findIndex(u=>u.node===l.target);if(c===-1)return[];s[c].distance=l.weight,s[c].previous=o}for(;i.length>0;){let l=[],c=[];c=s.filter(m=>i.includes(m.node)),l=c.map(m=>m.node);let u=1/0,_=-1;if(l.length>0)for(let m=0;m<l.length;m++){const p=l[m],x=s.findIndex(v=>v.node===p);s[x].distance<u&&(u=s[x].distance,_=x)}else{u=1/0,_=-1;for(let m=0;m<i.length;m++){const p=i[m],x=s.findIndex(v=>v.node===p);s[x].distance<u&&(u=s[x].distance,_=x)}}if(_===-1)return[];o=s[_].node;let f=Array.from(o.edges);f=f.filter(m=>!e.includes(m.source)&&!e.includes(m.target)&&m.target!==o),e.push(o),i.splice(i.indexOf(o),1);for(let m=0;m<f.length;m++){const p=f[m],x=s.findIndex(S=>S.node===p.target),v=s.findIndex(S=>S.node===p.source),y=s[v].distance+p.weight;y<s[x].distance&&(s[x].distance=y,s[x].previous=o)}}return s}shortestPathDijkstra(t,e){var i,s;const n=this.dijkstra(t);if(n.length===0)return{path:[],distance:1/0};const o=[];let a=e;const h=(i=n.find(l=>l.node===e))==null?void 0:i.distance;for(;a!=null&&(o.push(a),a=(s=n.find(l=>l.node===a))==null?void 0:s.previous,a!=null););return o.reverse(),{path:o,distance:h}}aStar(t,e){if(!("pos"in t)||!("pos"in e))throw new Error("A* algorithm requires PositionNode with position vectors");const i=new Set([t.id]),s=new Set,n=new Set,o=new Map,a=new Map,h=new Map,l=new Map,c=new Map;for(const[u,_]of this._nodes)"pos"in _?c.set(u,_):n.add(u);for(const[u]of c)o.set(u,this._euclideanDistance(c.get(u),t)),a.set(u,this._euclideanDistance(c.get(u),e)),h.set(u,o.get(u)+a.get(u)),l.set(u,null);for(;i.size>0;){let u=null,_=1/0;for(const p of i){const x=h.get(p)||1/0;x<_&&(_=x,u=p)}if(u===null)break;if(u===e.id){const p=[];let x=e.id;for(;x!==null;){const v=this._nodes.get(x);p.unshift(v),x=l.get(x)}return{path:p,pathSteps:p.length-1,distance:o.get(e.id)||1/0,skippedNodes:n}}i.delete(u),s.add(u);const f=this._nodes.get(u),m=this.getNeighbors(f);for(const p of m){const x=p.id;s.has(x)||!("pos"in p)||!Array.from(f.edges).find(y=>y.source.id===u&&y.target.id===x)||(l.set(x,u),i.has(x)||i.add(x))}}return{path:[],pathSteps:0,distance:1/0,skippedNodes:n}}_euclideanDistance(t,e){const i=t.pos,s=e.pos;return Math.sqrt((s.x-i.x)**2+(s.y-i.y)**2)}}class ws{constructor(t,e,i){this._id=xs.generateUUID(),this._weight=0,this._partnerEdge=null,this._source=t,this._target=e,i&&i.weight?this._weight=i.weight:i&&i.useEuclidean?this._weight=t.pos.distance(e.pos):this._weight=0}linkWithPartner(t){this._partnerEdge=t}get id(){return this._id}get source(){return this._source}get target(){return this._target}get weight(){return this._weight}get partnerEdge(){return this._partnerEdge}}class Ti{constructor(t){this._id=xs.generateUUID(),this._data=t,this._edges=new Set}get id(){return this._id}get data(){return this._data}get edges(){return this._edges}registerNewEdge(t){this._edges.add(t)}breakEdge(t){this._edges.delete(t)}getConnectedNodes(){return Array.from(this._edges).map(t=>t.target)}}class _r extends Ti{constructor(t,e){super(t),this.pos=e}}const fr=class Da{static generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const s=Da.rng.next()*16|0;return(i==="x"?s:s&3|8).toString(16)})}};fr.rng=new se;let xs=fr;function Ai(r){return r}function Xa(r,t,e){return r=B((r-t)/(e-t),0,1),r*r*(3-2*r)}function Ya(r,t,e){return r=B((r-t)/(e-t),0,1),r*r*r*(r*(6*r-15)+10)}function $a(r){return-1*Math.cos(r*(Math.PI/2))+1}function Za(r){return Math.sin(r*(Math.PI/2))}function ja(r){return-.5*(Math.cos(Math.PI*r)-1)}function Qa(r){return r*r}function Ja(r){return r*(2-r)}function Ka(r){return r<.5?2*r*r:-1+(4-2*r)*r}function th(r){return r*r*r}function eh(r){const t=r-1;return t*t*t+1}function bs(r){return r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1}function ih(r){return r*r*r*r}function sh(r){const t=r-1;return 1-t*t*t*t}function nh(r){const t=r-1;return r<.5?8*r*r*r*r:1-8*t*t*t*t}function rh(r){return r*r*r*r*r}function oh(r){const t=r-1;return 1+t*t*t*t*t}function ah(r){const t=r-1;return r<.5?16*r*r*r*r*r:1+16*t*t*t*t*t}function hh(r){return r===0?0:Math.pow(2,10*(r-1))}function lh(r){return r===1?1:-Math.pow(2,-10*r)+1}function ch(r){if(r===0||r===1)return r;const t=r*2,e=t-1;return t<1?.5*Math.pow(2,10*e):.5*(-Math.pow(2,-10*e)+2)}function dh(r){const t=r/1;return-1*(Math.sqrt(1-t*r)-1)}function uh(r){const t=r-1;return Math.sqrt(1-t*t)}function _h(r){const t=r*2,e=t-2;return t<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-e*e)+1)}function fh(r,t=1.70158){return r*r*((t+1)*r-t)}function gh(r,t=1.70158){const e=r/1-1;return e*e*((t+1)*e+t)+1}function ph(r,t=1.70158){const e=r*2,i=e-2,s=t*1.525;return e<1?.5*e*e*((s+1)*e-s):.5*(i*i*((s+1)*i+s)+2)}function mh(r,t=.7){if(r===0||r===1)return r;const i=r/1-1,s=1-t,n=s/(2*Math.PI)*Math.asin(1);return-(Math.pow(2,10*i)*Math.sin((i-n)*(2*Math.PI)/s))}function vh(r,t=.7){if(r===0||r===1)return r;const e=1-t,i=r*2,s=e/(2*Math.PI)*Math.asin(1);return Math.pow(2,-10*i)*Math.sin((i-s)*(2*Math.PI)/e)+1}function wh(r,t=.65){if(r===0||r===1)return r;const e=1-t,i=r*2,s=i-1,n=e/(2*Math.PI)*Math.asin(1);return i<1?-.5*(Math.pow(2,10*s)*Math.sin((s-n)*(2*Math.PI)/e)):Math.pow(2,-10*s)*Math.sin((s-n)*(2*Math.PI)/e)*.5+1}function ys(r){const t=r/1;if(t<1/2.75)return 7.5625*t*t;if(t<2/2.75){const e=t-.5454545454545454;return 7.5625*e*e+.75}else if(t<2.5/2.75){const e=t-.8181818181818182;return 7.5625*e*e+.9375}else{const e=t-.9545454545454546;return 7.5625*e*e+.984375}}function gr(r){return 1-ys(1-r)}function xh(r){return r<.5?gr(r*2)*.5:ys(r*2-1)*.5+.5}class T{constructor(t,e,i,s){this.r=t,this.g=e,this.b=i,this.a=s!=null?s:1}static fromRGB(t,e,i,s){return new T(t,e,i,s)}static fromRGBString(t){const e=/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/i;let i=null;if(i=t.match(e)){const s=parseInt(i[1],10),n=parseInt(i[2],10),o=parseInt(i[3],10);let a=1;return i[4]&&(a=parseFloat(i[4])),new T(s,n,o,a)}else throw new Error("Invalid rgb/a string: "+t)}static fromHex(t){const e=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i;let i=null;if(i=t.match(e)){const s=parseInt(i[1],16),n=parseInt(i[2],16),o=parseInt(i[3],16);let a=1;return i[4]&&(a=parseInt(i[4],16)/255),new T(s,n,o,a)}else throw new Error("Invalid hex string: "+t)}static fromHSL(t,e,i,s=1){return new xt(t,e,i,s).toRGBA()}lighten(t=.1){const e=xt.fromRGBA(this.r,this.g,this.b,this.a);return e.l+=(1-e.l)*t,e.toRGBA()}darken(t=.1){const e=xt.fromRGBA(this.r,this.g,this.b,this.a);return e.l-=e.l*t,e.toRGBA()}saturate(t=.1){const e=xt.fromRGBA(this.r,this.g,this.b,this.a);return e.s+=e.s*t,e.toRGBA()}desaturate(t=.1){const e=xt.fromRGBA(this.r,this.g,this.b,this.a);return e.s-=e.s*t,e.toRGBA()}multiply(t){const e=t.r/255*this.r/255*255,i=t.g/255*this.g/255*255,s=t.b/255*this.b/255*255,n=t.a*this.a;return new T(e,i,s,n)}screen(t){const e=t.invert(),i=t.invert();return e.multiply(i).invert()}invert(){return new T(255-this.r,255-this.g,255-this.b,1-this.a)}average(t){const e=(t.r+this.r)/2,i=(t.g+this.g)/2,s=(t.b+this.b)/2,n=(t.a+this.a)/2;return new T(e,i,s,n)}equal(t){return this.toString()===t.toString()}toString(t="rgb"){switch(t){case"rgb":return this.toRGBA();case"hsl":return this.toHSLA();case"hex":return this.toHex();default:throw new Error("Invalid Color format")}}_componentToHex(t){const e=Math.max(Math.round(t),0).toString(16);return e.length===1?"0"+e:e}toHex(){let t="#"+this._componentToHex(this.r)+this._componentToHex(this.g)+this._componentToHex(this.b);return this.a!==1&&(t+=this._componentToHex(this.a*255)),t}toRGBA(){const t=String(this.r.toFixed(0))+", "+String(this.g.toFixed(0))+", "+String(this.b.toFixed(0));return this.a!==void 0||this.a!==null?"rgba("+t+", "+String(this.a)+")":"rgb("+t+")"}toHSLA(){return xt.fromRGBA(this.r,this.g,this.b,this.a).toString()}fillStyle(){return this.toString()}clone(t){const e=t||new T(this.r,this.g,this.b,this.a);return e.r=this.r,e.g=this.g,e.b=this.b,e.a=this.a,e}static lerp(t,e,i){const s=xt.fromRGBA(t.r,t.g,t.b,t.a),n=xt.fromRGBA(e.r,e.g,e.b,e.a);return xt.lerp(s,n,i).toRGBA()}static random(t){const e=t!=null?t:new se;return new T(e.integer(0,255),e.integer(0,255),e.integer(0,255))}static get Black(){return T.fromHex("#000000")}static get White(){return T.fromHex("#FFFFFF")}static get Gray(){return T.fromHex("#808080")}static get LightGray(){return T.fromHex("#D3D3D3")}static get DarkGray(){return T.fromHex("#A9A9A9")}static get Yellow(){return T.fromHex("#FFFF00")}static get Orange(){return T.fromHex("#FFA500")}static get Red(){return T.fromHex("#FF0000")}static get Vermilion(){return T.fromHex("#FF5B31")}static get Rose(){return T.fromHex("#FF007F")}static get Pink(){return T.fromHex("#FFC0CB")}static get Magenta(){return T.fromHex("#FF00FF")}static get Violet(){return T.fromHex("#7F00FF")}static get Purple(){return T.fromHex("#800080")}static get Blue(){return T.fromHex("#0000FF")}static get Azure(){return T.fromHex("#007FFF")}static get Cyan(){return T.fromHex("#00FFFF")}static get Viridian(){return T.fromHex("#59978F")}static get Teal(){return T.fromHex("#008080")}static get Green(){return T.fromHex("#00FF00")}static get Chartreuse(){return T.fromHex("#7FFF00")}static get Transparent(){return T.fromHex("#FFFFFF00")}static get ExcaliburBlue(){return T.fromHex("#176BAA")}static get Brown(){return T.fromHex("#964B00")}}class xt{constructor(t,e,i,s){this.h=t,this.s=e,this.l=i,this.a=s}static hue2rgb(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+(e-t)*6*i:i<1/2?e:i<2/3?t+(e-t)*(2/3-i)*6:t}static fromRGBA(t,e,i,s){t/=255,e/=255,i/=255;const n=Math.max(t,e,i),o=Math.min(t,e,i);let a,h;const l=(n+o)/2;if(n===o)a=h=0;else{const c=n-o;switch(h=l>.5?c/(2-n-o):c/(n+o),n){case t:a=(e-i)/c+(e<i?6:0);break;case e:a=(i-t)/c+2;break;case i:a=(t-e)/c+4;break}a/=6}return new xt(a,h,l,s)}toRGBA(){let t,e,i;if(this.s===0)t=e=i=this.l;else{const s=this.l<.5?this.l*(1+this.s):this.l+this.s-this.l*this.s,n=2*this.l-s;t=xt.hue2rgb(n,s,this.h+1/3),e=xt.hue2rgb(n,s,this.h),i=xt.hue2rgb(n,s,this.h-1/3)}return new T(t*255,e*255,i*255,this.a)}toString(){const t=this.h.toFixed(0),e=this.s.toFixed(0),i=this.l.toFixed(0),s=this.a.toFixed(0);return`hsla(${t}, ${e}, ${i}, ${s})`}static lerp(t,e,i){i=Math.max(0,Math.min(1,i));let s=e.h-t.h;s>.5?s-=1:s<-.5&&(s+=1);const n=(t.h+s*i+1)%1,o=t.s+(e.s-t.s)*i,a=t.l+(e.l-t.l)*i,h=t.a+(e.a-t.a)*i;return new xt(n,o,a,h)}}var Le=(r=>(r[r.Debug=0]="Debug",r[r.Info=1]="Info",r[r.Warn=2]="Warn",r[r.Error=3]="Error",r[r.Fatal=4]="Fatal",r))(Le||{});const pr=class ee{constructor(){if(this._appenders=[],this.defaultLevel=1,this._logOnceSet=new Set,ee._INSTANCE)throw new Error("Logger is a singleton");return ee._INSTANCE=this,ee._INSTANCE.addAppender(new Cs),ee._INSTANCE}static getInstance(){return ee._INSTANCE==null&&(ee._INSTANCE=new ee),ee._INSTANCE}addAppender(t){this._appenders.push(t)}clearAppenders(){this._appenders.length=0}_log(t,e){t==null&&(t=this.defaultLevel);const i=this._appenders.length;for(let s=0;s<i;s++)t>=this.defaultLevel&&this._appenders[s].log(t,e)}_logOnce(t,e){const i=t+e.join("+");this._logOnceSet.has(i)||(this._logOnceSet.add(i),this._log(t,e))}debug(...t){this._log(0,t)}debugOnce(...t){this._logOnce(0,t)}info(...t){this._log(1,t)}infoOnce(...t){this._logOnce(1,t)}warn(...t){this._log(2,t)}warnOnce(...t){this._logOnce(2,t)}error(...t){this._log(3,t)}errorOnce(...t){this._logOnce(3,t)}fatal(...t){this._log(4,t)}fatalOnce(...t){this._logOnce(4,t)}};pr._INSTANCE=null;let R=pr;class Cs{log(t,e){if(!console&&!console.log&&console.warn&&console.error)return;const i=[];i.unshift.apply(i,e),i.unshift("["+Le[t]+"] : "),t<2?console.log.apply?console.log.apply(console,i):console.log(i.join(" ")):t<3?console.warn.apply?console.warn.apply(console,i):console.warn(i.join(" ")):console.error.apply?console.error.apply(console,i):console.error(i.join(" "))}}class mr{constructor(t){this._messages=[],this._pos=10,this._color=T.Black;var e,i;this._options=t,this.canvas=document.createElement("canvas"),this._ctx=this.canvas.getContext("2d"),this.canvas.style.position="absolute",this.canvas.style.zIndex=(i=(e=t.zIndex)==null?void 0:e.toString())!=null?i:"99",this.canvas.style.pointerEvents="none",this.canvas.style.userSelect="none",document.body.appendChild(this.canvas),this._positionScreenAppenderCanvas(),t.engine.screen.events.on("resize",()=>{this._positionScreenAppenderCanvas()})}_positionScreenAppenderCanvas(){var t,e,i,s;const n=this._options;this.canvas.width=(t=n.width)!=null?t:n.engine.screen.resolution.width,this.canvas.height=(e=n.height)!=null?e:n.engine.screen.resolution.height,this.canvas.style.position="absolute";const o=n.engine.screen.screenToPageCoordinates(b(0,0));this.canvas.style.left=o.x+"px",this.canvas.style.top=o.y+"px",this._pos=(i=n.xPos)!=null?i:this._pos,this._color=(s=n.color)!=null?s:this._color}log(t,e){const i=e.join(",");this._ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this._messages.unshift("["+Le[t]+"] : "+i);let s=10;this._messages=this._messages.slice(0,1e3);for(let n=0;n<this._messages.length;n++)this._ctx.fillStyle=this._color.toRGBA(),this._ctx.fillText(this._messages[n],this._pos,s),s+=10}}var M=(r=>(r.PreventCollision="PreventCollision",r.Passive="Passive",r.Active="Active",r.Fixed="Fixed",r))(M||{});function vr(r){return!!r&&!!r.prototype&&!!r.prototype.constructor}function bh(r){return!!(r!=null&&r.clone)}class Dt{constructor(){this.owner=void 0}clone(){const t=new this.constructor;for(const e in this)if(this.hasOwnProperty(e)){const i=this[e];bh(i)&&e!=="owner"&&e!=="clone"?t[e]=i.clone():t[e]=i}return t}}class gt{constructor(){this.observers=[],this.subscriptions=[]}register(t){this.observers.push(t)}subscribe(t){this.subscriptions.push(t)}unregister(t){const e=this.observers.indexOf(t);e!==-1&&this.observers.splice(e,1)}unsubscribe(t){const e=this.subscriptions.indexOf(t);e!==-1&&this.subscriptions.splice(e,1)}notifyAll(t){const e=this.observers.length;for(let s=0;s<e;s++)this.observers[s].notify(t);const i=this.subscriptions.length;for(let s=0;s<i;s++)this.subscriptions[s](t)}clear(){this.observers.length=0,this.subscriptions.length=0}}class P extends Dt{constructor(){super(...arguments),this._logger=R.getInstance(),this._parentComponent=null,this._transform=new Kt,this._addChildTransform=t=>{const e=t.get(P);e&&(e._transform.parent=this._transform,e._parentComponent=this)},this.zIndexChanged$=new gt,this._coordPlane=rt.World}get(){return this._transform}onAdd(t){for(const e of t.children)this._addChildTransform(e);t.childrenAdded$.subscribe(e=>this._addChildTransform(e)),t.childrenRemoved$.subscribe(e=>{const i=e.get(P);i&&(i._transform.parent=null,i._parentComponent=null)})}onRemove(t){this._transform.parent=null,this._parentComponent=null}get z(){return this._transform.z}set z(t){const e=this._transform.z;this._transform.z=t,e!==t&&this.zIndexChanged$.notifyAll(t)}get globalZ(){return this._transform.globalZ}set globalZ(t){this._transform.globalZ=t}get coordPlane(){return this._parentComponent?this._parentComponent.coordPlane:this._coordPlane}set coordPlane(t){var e;this._parentComponent?this._logger.warn(`Cannot set coordinate plane on child entity ${(e=this.owner)==null?void 0:e.name}, children inherit their coordinate plane from their parents.`):this._coordPlane=t}get pos(){return this._transform.pos}set pos(t){this._transform.pos=t}get globalPos(){return this._transform.globalPos}set globalPos(t){this._transform.globalPos=t}get rotation(){return this._transform.rotation}set rotation(t){this._transform.rotation=t}get globalRotation(){return this._transform.globalRotation}set globalRotation(t){this._transform.globalRotation=t}get scale(){return this._transform.scale}set scale(t){this._transform.scale=t}get globalScale(){return this._transform.globalScale}set globalScale(t){this._transform.globalScale=t}applyInverse(t){return this._transform.applyInverse(t)}apply(t){return this._transform.apply(t)}clone(){const t=new P;return t._transform=this._transform.clone(),t}}class O extends Dt{constructor(){super(...arguments),this.vel=w.Zero,this.maxVel=w.One.scaleEqual(1/0),this.acc=w.Zero,this.scaleFactor=w.Zero,this.angularVelocity=0,this.torque=0,this.inertia=1,this.integration={onScreenOnly:!1}}}const pe=class{static create(t,e){if(this._CURRENT_GROUP>this._MAX_GROUPS)throw new Error(`Cannot have more than ${this._MAX_GROUPS} collision groups`);if(this._GROUPS.get(t)){const s=this._GROUPS.get(t);if(s.mask===e)return s;throw new Error(`Collision group ${t} already exists with a different mask!`)}const i=new me(t,this._CURRENT_BIT,e!==void 0?e:~this._CURRENT_BIT);return this._CURRENT_BIT=this._CURRENT_BIT<<1|0,this._CURRENT_GROUP++,this._GROUPS.set(t,i),i}static get groups(){return Array.from(this._GROUPS.values())}static groupByName(t){return this._GROUPS.get(t)}static reset(){this._GROUPS=new Map,this._CURRENT_BIT=this._STARTING_BIT,this._CURRENT_GROUP=1}};pe._STARTING_BIT=1,pe._MAX_GROUPS=32,pe._CURRENT_GROUP=1,pe._CURRENT_BIT=pe._STARTING_BIT,pe._GROUPS=new Map;let Pi=pe;const Ss=class{constructor(t,e,i){this._name=t,this._category=e,this._mask=i}get name(){return this._name}get category(){return this._category}get mask(){return this._mask}canCollide(t){const e=this.category&t.mask,i=this.mask&t.category;return e!==0&&i!==0}invert(){const t=Pi.create("~("+this.name+")",~this.mask|0);return t._category=~this.category,t}static combine(t){const e=t.map(n=>n.name).join("+"),s=~t.reduce((n,o)=>o.category|n,0);return Pi.create(e,s)}static collidesWith(t){const e=`collidesWith(${t.map(s=>s.name).join("+")})`,i=t.reduce((s,n)=>n.category|s,0);return Pi.create(e,i)}toString(){return`
|
|
16
16
|
category: ${this.category.toString(2).padStart(32,"0")}
|
|
17
17
|
mask: ${(this.mask>>>0).toString(2).padStart(32,"0")}
|
|
18
|
-
`}};Ss.All=new Ss("Collide with all groups",-1,-1);let me=Ss;var Ts=(r=>(r.Kill="kill",r.PreKill="prekill",r.PostKill="postkill",r.PreDraw="predraw",r.PostDraw="postdraw",r.PreDebugDraw="predebugdraw",r.PostDebugDraw="postdebugdraw",r.PreUpdate="preupdate",r.PostUpdate="postupdate",r.PreFrame="preframe",r.PostFrame="postframe",r.PreCollision="precollision",r.CollisionStart="collisionstart",r.CollisionEnd="collisionend",r.PostCollision="postcollision",r.Initialize="initialize",r.Activate="activate",r.Deactivate="deactivate",r.ExitViewport="exitviewport",r.EnterViewport="enterviewport",r.ExitTrigger="exit",r.EnterTrigger="enter",r.Connect="connect",r.Disconnect="disconnect",r.Button="button",r.Axis="axis",r.Visible="visible",r.Hidden="hidden",r.Start="start",r.Stop="stop",r.PointerUp="pointerup",r.PointerDown="pointerdown",r.PointerMove="pointermove",r.PointerEnter="pointerenter",r.PointerLeave="pointerleave",r.PointerCancel="pointercancel",r.PointerWheel="pointerwheel",r.Up="up",r.Down="down",r.Move="move",r.Enter="enter",r.Leave="leave",r.Cancel="cancel",r.Wheel="wheel",r.Press="press",r.Release="release",r.Hold="hold",r.PointerDragStart="pointerdragstart",r.PointerDragEnd="pointerdragend",r.PointerDragEnter="pointerdragenter",r.PointerDragLeave="pointerdragleave",r.PointerDragMove="pointerdragmove",r.ActionStart="actionstart",r.ActionComplete="actioncomplete",r.Add="add",r.Remove="remove",r))(Ts||{});class k{constructor(){this.other=null,this._bubbles=!0}get bubbles(){return this._bubbles}set bubbles(t){this._bubbles=t}stopPropagation(){this.bubbles=!1}}class As extends k{constructor(t){super(),this.self=t,this.target=t}}class Ps extends k{constructor(t){super(),this.self=t,this.target=t}}class Es extends k{constructor(t){super(),this.self=t,this.target=t}}class Is extends k{constructor(t){super(),this.self=t,this.target=t}}class Rs extends k{constructor(t){super(),this.self=t,this.target=t}}class Ue extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class ze extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Ms extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Fs extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Ds extends k{constructor(t,e){super(),this.ctx=t,this.self=e,this.target=e}}class Bs extends k{constructor(t,e){super(),this.ctx=t,this.self=e,this.target=e}}class re extends k{constructor(t,e,i){super(),this.engine=t,this.elapsed=e,this.self=i,this.target=i}}class oe extends k{constructor(t,e,i){super(),this.engine=t,this.elapsed=e,this.self=i,this.target=i}}class ks extends k{constructor(t,e){super(),this.engine=t,this.prevStats=e,this.target=t}}class Ls extends k{constructor(t,e){super(),this.engine=t,this.stats=e,this.target=t}}class Us extends k{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class zs extends k{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class Os extends k{constructor(t,e,i,s){super(),this.button=t,this.index=e,this.value=i,this.self=s,this.target=s}}class Hs extends k{constructor(t,e,i){super(),this.axis=t,this.value=e,this.self=i,this.target=i}}class Ns extends k{constructor(t){super(),this.self=t,this.target=t}}class Ws extends k{constructor(t){super(),this.self=t,this.target=t}}class ve extends k{constructor(t,e,i,s,n){super(),this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n,this.target=t}}class we extends k{constructor(t,e,i,s,n){super(),this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n,this.target=t}}class Ei{constructor(t,e,i,s){this.self=t,this.other=e,this.side=i,this.contact=s}}class Ii{constructor(t,e,i,s){this.self=t,this.other=e,this.side=i,this.lastContact=s}}class Ri{constructor(t,e,i,s,n){this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class Mi{constructor(t,e,i,s,n){this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class ni extends k{constructor(t,e,i,s){super(),this.self=t,this.other=e,this.side=i,this.contact=s,this.target=t}}class ri extends k{constructor(t,e,i,s){super(),this.self=t,this.other=e,this.side=i,this.lastContact=s,this.target=t}}class Oe extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}class Gs extends k{constructor(t,e){super(),this.context=t,this.self=e,this.target=e}}class Vs extends k{constructor(t,e){super(),this.context=t,this.self=e,this.target=e}}class qs extends k{constructor(t){super(),this.self=t,this.target=t}}class Xs extends k{constructor(t){super(),this.self=t,this.target=t}}class Ys extends k{constructor(t,e){super(),this.self=t,this.entity=e,this.target=t}}class $s extends k{constructor(t,e){super(),this.self=t,this.entity=e,this.target=t}}class Zs extends k{constructor(t,e){super(),this.action=t,this.self=e,this.target=e}}class js extends k{constructor(t,e){super(),this.action=t,this.self=e,this.target=e}}class Qs extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}class Js extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}const yh=Object.freeze(Object.defineProperty({__proto__:null,ActionCompleteEvent:js,ActionStartEvent:Zs,ActivateEvent:Gs,AddEvent:Qs,CollisionEndEvent:ri,CollisionPostSolveEvent:Mi,CollisionPreSolveEvent:Ri,CollisionStartEvent:ni,ContactEndEvent:Ii,ContactStartEvent:Ei,DeactivateEvent:Vs,EnterTriggerEvent:Ys,EnterViewPortEvent:Xs,EventTypes:Ts,ExitTriggerEvent:$s,ExitViewPortEvent:qs,GameEvent:k,GameStartEvent:Is,GameStopEvent:Rs,GamepadAxisEvent:Hs,GamepadButtonEvent:Os,GamepadConnectEvent:Us,GamepadDisconnectEvent:zs,HiddenEvent:Ws,InitializeEvent:Oe,KillEvent:As,PostCollisionEvent:we,PostDebugDrawEvent:Bs,PostDrawEvent:ze,PostFrameEvent:Ls,PostKillEvent:Es,PostTransformDrawEvent:Fs,PostUpdateEvent:oe,PreCollisionEvent:ve,PreDebugDrawEvent:Ds,PreDrawEvent:Ue,PreFrameEvent:ks,PreKillEvent:Ps,PreTransformDrawEvent:Ms,PreUpdateEvent:re,RemoveEvent:Js,VisibleEvent:Ns},Symbol.toStringTag,{value:"Module"}));function wr(r){if(r.length===0)throw new Error("Cannot find minIndex of array.length == 0");let t=r[0],e=0;for(let i=1;i<r.length;i++)r[i]<t&&(t=r[i],e=i);return e}function oi(r){if(r&&r.getBoundingClientRect){const t=r.getBoundingClientRect();return b(t.x+window.scrollX,t.y+window.scrollY)}return w.Zero}function Ch(r,t){return t.indexOf(r)===-1?(t.push(r),!0):!1}function He(r,t){let e=-1;return(e=t.indexOf(r))>-1?(t.splice(e,1),!0):!1}function xr(r,t){for(let e=0;e<r.length;e++)if(r[e]===t)return!0;return!1}function br(r){throw new Error(r)}function Fi(r,t){var e;const i=new wt;return((e=t==null?void 0:t.schedule.bind(t))!=null?e:setTimeout)(()=>{i.resolve()},r),i.promise}function yr(r,t){const e={};for(const i in r)t.includes(i)||(e[i]=r[i]);return e}function Di(r){return r&&typeof r=="object"&&!Array.isArray(r)}function Bi(r,...t){if(!t.length)return r;const e=t.shift();if(Di(r)&&Di(e))for(const i in e)Di(e[i])?(r[i]||Object.assign(r,{[i]:{}}),Bi(r[i],e[i])):Object.assign(r,{[i]:e[i]});return Bi(r,...t)}class Sh{constructor(t){this.data=t,this.type="Component Added"}}function Th(r){return!!r&&r.type==="Component Added"}class Ah{constructor(t){this.data=t,this.type="Component Removed"}}function Ph(r){return!!r&&r.type==="Component Removed"}const Eh={Add:"add",Remove:"remove",Initialize:"initialize",PreUpdate:"preupdate",PostUpdate:"postupdate",Kill:"kill"},Cr=class sr{constructor(t,e){this.id=sr._ID++,this.name=`Entity#${this.id}`,this.events=new X,this._tags=new Set,this.componentAdded$=new gt,this.componentRemoved$=new gt,this.tagAdded$=new gt,this.tagRemoved$=new gt,this.components=new Map,this.componentValues=[],this._componentsToRemove=[],this.scene=null,this.isActive=!0,this._parent=null,this.childrenAdded$=new gt,this.childrenRemoved$=new gt,this._children=[],this._isInitialized=!1,this._isAdded=!1;let i,s;if(Array.isArray(t))i=t,s=e;else if(t&&typeof t=="object"){const{components:n,name:o}=t;i=n!=null?n:[],s=o}if(s&&(this.name=s),i)for(const n of i)this.addComponent(n)}get active(){return this.isActive}set active(t){this.isActive=t}kill(){this.isActive&&(this.isActive=!1,this.unparent()),this.emit("kill",new As(this))}isKilled(){return!this.isActive}get tags(){return this._tags}hasTag(t){return this._tags.has(t)}addTag(t){return this._tags.add(t),this.tagAdded$.notifyAll(t),this}removeTag(t){return this._tags.delete(t),this.tagRemoved$.notifyAll(t),this}get types(){return Array.from(this.components.keys())}getComponents(){return Array.from(this.components.values())}hasAll(t){for(let e=0;e<t.length;e++)if(!this.components.has(t[e]))return!1;return!0}hasAllTags(t){for(let e=0;e<t.length;e++)if(!this.tags.has(t[e]))return!1;return!0}get(t){return this.components.get(t)}get parent(){return this._parent}get children(){return this._children}unparent(){this._parent&&(this._parent.removeChild(this),this._parent=null)}hasChild(t,e=!1){if(!e)return t.parent===this;for(const i of this.children)if(i===t||e&&i.hasChild(t,!0))return!0;return!1}addChild(t){if(t.parent===null){if(this.getAncestors().includes(t))throw new Error("Cycle detected, cannot add entity");this._children.push(t),t._parent=this,this.childrenAdded$.notifyAll(t)}else throw new Error("Entity already has a parent, cannot add without unparenting");return this}removeChild(t){return t.parent===this&&(He(t,this._children),t._parent=null,this.childrenRemoved$.notifyAll(t)),this}removeAllChildren(){for(let t=this.children.length-1;t>=0;t--)this.removeChild(this.children[t]);return this}getAncestors(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;return t.reverse()}getDescendants(){let t=[this],e=[this];for(;e.length>0;){const i=e.pop();i&&(e=e.concat(i.children),t=t.concat(i.children))}return t}clone(){const t=new sr;for(const e of this.types){const i=this.get(e);i&&t.addComponent(i.clone())}for(const e of this.children)t.addChild(e.clone());return t}addTemplate(t,e=!1){for(const i of t.getComponents())this.addComponent(i.clone(),e);for(const i of t.children)this.addChild(i.clone().addTemplate(i));return this}_getClassHierarchyRoot(t){var e,i;let s=t,n=(e=Object.getPrototypeOf(s.prototype))==null?void 0:e.constructor;for(;n&&n!==Object&&n!==Dt;)s=n,n=(i=Object.getPrototypeOf(s.prototype))==null?void 0:i.constructor;return s}addComponent(t,e=!1){if(this.has(t.constructor))if(e)this.removeComponent(t.constructor,!0);else return this;if(t.dependencies&&t.dependencies.length)for(const s of t.dependencies)this.addComponent(new s);t.owner=this;const i=this._getClassHierarchyRoot(t.constructor);return this.components.set(i,t),this.components.set(t.constructor,t),this.componentValues.push(t),t.onAdd&&t.onAdd(this),this.componentAdded$.notifyAll(t),this}removeComponent(t,e=!1){let i;if(vr(t)?i=t:i=t.constructor,e){const s=this.components.get(i);if(s){this.componentRemoved$.notifyAll(s),s.owner=void 0,s.onRemove&&s.onRemove(this);const o=this.componentValues.indexOf(s);o>-1&&this.componentValues.splice(o,1)}const n=this._getClassHierarchyRoot(i);this.components.delete(n),this.components.delete(i)}else this._componentsToRemove.push(i);return this}clearComponents(){const t=this.types;for(const e of t)this.removeComponent(e)}processComponentRemoval(){for(const t of this._componentsToRemove)this.removeComponent(t,!0);this._componentsToRemove.length=0}has(t){return this.components.has(t)}get isInitialized(){return this._isInitialized}get isAdded(){return this._isAdded}_initialize(t){this.isInitialized||(this.onInitialize(t),this.events.emit("initialize",new Oe(t,this)),this._isInitialized=!0)}_add(t){!this.isAdded&&this.isActive&&(this.onAdd(t),this.events.emit("add",new Qs(t,this)),this._isAdded=!0)}_remove(t){this.isAdded&&!this.isActive&&(this.onRemove(t),this.events.emit("remove",new Js(t,this)),this._isAdded=!1)}_preupdate(t,e){this.events.emit("preupdate",new re(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.events.emit("postupdate",new oe(t,e,this)),this.onPostUpdate(t,e)}onInitialize(t){}onAdd(t){}onRemove(t){}onPreUpdate(t,e){}onPostUpdate(t,e){}update(t,e){this._initialize(t),this._add(t),this._preupdate(t,e);for(const i of this.children)i.update(t,e);this._postupdate(t,e),this._remove(t)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){e?this.events.off(t,e):this.events.off(t)}};Cr._ID=0;let At=Cr;class Sr{constructor(t){this._world=t,this.entities=[],this._entityIndex={},this._childAddedHandlerMap=new Map,this._childRemovedHandlerMap=new Map,this._createChildAddedHandler=()=>e=>{this.addEntity(e)},this._createChildRemovedHandler=()=>e=>{this.removeEntity(e,!1)},this._entitiesToRemove=[]}updateEntities(t,e){for(let i=0;i<this.entities.length;i++){const s=this.entities[i];s.update(t.engine,e),s.isActive||this.removeEntity(s)}}findEntitiesForRemoval(){for(let t=0;t<this.entities.length;t++){const e=this.entities[t];e.isActive||this.removeEntity(e)}}addEntity(t){if(t.isActive=!0,t.scene=this._world.scene,t&&!this._entityIndex[t.id]){this._entityIndex[t.id]=t,this.entities.push(t),this._world.queryManager.addEntity(t),t.children.forEach(s=>{s.scene=t.scene,this.addEntity(s)});const e=this._createChildAddedHandler();this._childAddedHandlerMap.set(t,e);const i=this._createChildRemovedHandler();this._childRemovedHandlerMap.set(t,i),t.childrenAdded$.subscribe(e),t.childrenRemoved$.subscribe(i)}}removeEntity(t,e=!0){var i,s;let n=0;t instanceof At?n=t.id:n=t;const o=this._entityIndex[n];if(o&&o.isActive&&(o.isActive=!1),o&&e){this._entitiesToRemove.push(o);return}if(delete this._entityIndex[n],o){o.scene=null,He(o,this.entities),this._world.queryManager.removeEntity(o),o.children.forEach(l=>{l.scene=null,this.removeEntity(l,e)});const a=this._childAddedHandlerMap.get(o);a&&(o.childrenAdded$.unsubscribe(a),this._childAddedHandlerMap.delete(o));const h=this._childRemovedHandlerMap.get(o);h&&(o.childrenRemoved$.unsubscribe(h),this._childRemovedHandlerMap.delete(o)),(s=(i=this._world)==null?void 0:i.scene)!=null&&s.engine&&this._world.scene.engine.stats.currFrame.actors.killed++}}processEntityRemovals(){for(let t=0;t<this._entitiesToRemove.length;t++){const e=this._entitiesToRemove[t];e.isActive||this.removeEntity(e,!1)}this._entitiesToRemove.length=0}processComponentRemovals(){for(let t=0;t<this.entities.length;t++)this.entities[t].processComponentRemoval()}getById(t){return this._entityIndex[t]}getByName(t){return this.entities.filter(e=>e.name===t)}clear(){for(let t=this.entities.length-1;t>=0;t--)this.removeEntity(this.entities[t])}}class Lt{constructor(t){this._entities=[],this.entitiesSet=new Set,this.entityAdded$=new gt,this.entityRemoved$=new gt,this.filter={components:{all:new Set,any:new Set,not:new Set},tags:{all:new Set,any:new Set,not:new Set}},this._dirty=!1;var e,i,s,n,o,a,h,l,c,u,_,f;Array.isArray(t)&&(t={components:{all:t}}),this.filter.components.all=new Set((i=(e=t.components)==null?void 0:e.all)!=null?i:[]),this.filter.components.any=new Set((n=(s=t.components)==null?void 0:s.any)!=null?n:[]),this.filter.components.not=new Set((a=(o=t.components)==null?void 0:o.not)!=null?a:[]),this.filter.tags.all=new Set((l=(h=t.tags)==null?void 0:h.all)!=null?l:[]),this.filter.tags.any=new Set((u=(c=t.tags)==null?void 0:c.any)!=null?u:[]),this.filter.tags.not=new Set((f=(_=t.tags)==null?void 0:_.not)!=null?f:[]),this.id=Lt.createId(t)}get entities(){return this._dirty&&(this._entities=Array.from(this.entitiesSet),this._dirty=!1),this._entities}static createId(t){var e,i,s,n,o,a,h,l,c,u,_,f;Array.isArray(t)&&(t={components:{all:t}});const m=(e=t.components)!=null&&e.any?`any_${Lt.hashComponents(new Set((i=t.components)==null?void 0:i.any))}`:"",p=(s=t.components)!=null&&s.all?`all_${Lt.hashComponents(new Set((n=t.components)==null?void 0:n.all))}`:"",x=(o=t.components)!=null&&o.not?`not_${Lt.hashComponents(new Set((a=t.components)==null?void 0:a.not))}`:"",v=(h=t.tags)!=null&&h.any?`any_${Lt.hashTags(new Set((l=t.tags)==null?void 0:l.any))}`:"",g=(c=t.tags)!=null&&c.all?`all_${Lt.hashTags(new Set((u=t.tags)==null?void 0:u.all))}`:"",y=(_=t.tags)!=null&&_.not?`not_${Lt.hashTags(new Set((f=t.tags)==null?void 0:f.not))}`:"";return[m,p,x,v,g,y].filter(Boolean).join("-")}static hashTags(t){return Array.from(t).map(e=>`t_${e}`).sort().join("-")}static hashComponents(t){return Array.from(t).map(e=>`c_${e.name}`).sort().join("-")}matchesNotFilter(t,e){for(const i of this.filter.components.not)if(e!==i&&t.has(i))return!0;for(const i of this.filter.tags.not)if(t.hasTag(i))return!0;return!1}matches(t,e){for(const i of this.filter.components.not)if(e!==i&&t.has(i))return!1;for(const i of this.filter.tags.not)if(t.hasTag(i))return!1;for(const i of this.filter.components.all)if(i===e||!t.has(i))return!1;for(const i of this.filter.tags.all)if(!t.hasTag(i))return!1;if(this.filter.components.any.size>0){let i=!1;for(const s of this.filter.components.any)if(t.has(s)){i=!0;break}if(!i)return!1}if(this.filter.tags.any.size>0){let i=!1;for(const s of this.filter.tags.any)if(t.hasTag(s)){i=!0;break}if(!i)return!1}return!0}checkAndModify(t,e){const i=this.entitiesSet.has(t);if(i&&this.matchesNotFilter(t,e))return this.removeEntity(t),!1;const s=this.matches(t,e);return i&&!s?(this.removeEntity(t),!1):!i&&s?(this._dirty=!0,this.entitiesSet.add(t),this.entityAdded$.notifyAll(t),!0):!1}removeEntity(t){this.entitiesSet.delete(t)&&(this._dirty=!0,this.entityRemoved$.notifyAll(t))}getEntities(t){return t&&this.entities.sort(t),this.entities}}class Ks{constructor(t){if(this.requiredTags=t,this.tags=new Set,this.entities=[],this.entityAdded$=new gt,this.entityRemoved$=new gt,t.length===0)throw new Error("Cannot create tag query without tags");for(const e of t)this.tags.add(e);this.id=Ks.createId(t)}static createId(t){return t.slice().sort().join("-")}checkAndAdd(t){return!this.entities.includes(t)&&t.hasAllTags(Array.from(this.tags))?(this.entities.push(t),this.entityAdded$.notifyAll(t),!0):!1}removeEntity(t){const e=this.entities.indexOf(t);e>-1&&(this.entities.splice(e,1),this.entityRemoved$.notifyAll(t))}getEntities(t){return t&&this.entities.sort(t),this.entities}}class Tr{constructor(t){this._world=t,this._queries=new Map,this._addComponentHandlers=new Map,this._removeComponentHandlers=new Map,this._componentToQueriesIndex=new Map,this._tagToQueriesIndex=new Map,this._addTagHandlers=new Map,this._removeTagHandlers=new Map,this._createAddComponentHandler=e=>i=>{this.addComponent(e,i)},this._createRemoveComponentHandler=e=>i=>{this.removeComponent(e,i)},this._createAddTagHandler=e=>i=>{this.addTag(e,i)},this._createRemoveTagHandler=e=>i=>{this.removeTag(e,i)}}createQuery(t){const e=Lt.createId(t);if(this._queries.has(e))return this._queries.get(e);const i=new Lt(t);this._queries.set(i.id,i);for(const s of[...i.filter.components.all,...i.filter.components.any,...i.filter.components.not]){const n=this._componentToQueriesIndex.get(s);n?n.push(i):this._componentToQueriesIndex.set(s,[i])}for(const s of[...i.filter.tags.all,...i.filter.tags.any,...i.filter.tags.not]){const n=this._tagToQueriesIndex.get(s);n?n.push(i):this._tagToQueriesIndex.set(s,[i])}for(const s of this._world.entities)this.addEntity(s);return i}addEntity(t){const e=this._addComponentHandlers.get(t),i=this._removeComponentHandlers.get(t),s=e!=null?e:this._createAddComponentHandler(t),n=i!=null?i:this._createRemoveComponentHandler(t);this._addComponentHandlers.set(t,s),this._removeComponentHandlers.set(t,n);const o=this._addTagHandlers.get(t),a=this._removeTagHandlers.get(t),h=o!=null?o:this._createAddTagHandler(t),l=a!=null?a:this._createRemoveTagHandler(t);this._addTagHandlers.set(t,h),this._removeTagHandlers.set(t,l);for(const c of this._queries.values())c.checkAndModify(t);t.componentAdded$.subscribe(s),t.componentRemoved$.subscribe(n),t.tagAdded$.subscribe(h),t.tagRemoved$.subscribe(l)}removeEntity(t){const e=this._addComponentHandlers.get(t),i=this._removeComponentHandlers.get(t);for(const o of this._queries.values())o.removeEntity(t);e&&(t.componentAdded$.unsubscribe(e),this._addComponentHandlers.delete(t)),i&&(t.componentRemoved$.unsubscribe(i),this._removeComponentHandlers.delete(t));const s=this._addTagHandlers.get(t),n=this._removeTagHandlers.get(t);s&&(t.tagAdded$.unsubscribe(s),this._addTagHandlers.delete(t)),n&&(t.tagRemoved$.unsubscribe(n),this._removeTagHandlers.delete(t))}addComponent(t,e){var i;const s=(i=this._componentToQueriesIndex.get(e.constructor))!=null?i:[];for(const n of s)n.checkAndModify(t)}removeComponent(t,e){var i;const s=(i=this._componentToQueriesIndex.get(e.constructor))!=null?i:[];for(const n of s)n.checkAndModify(t,e.constructor)}addTag(t,e){var i;const s=(i=this._tagToQueriesIndex.get(e))!=null?i:[];for(const n of s)n.checkAndModify(t)}removeTag(t,e){var i;const s=(i=this._tagToQueriesIndex.get(e))!=null?i:[];for(const n of s)n.removeEntity(t),n.checkAndModify(t)}}const Gt={Highest:-1/0,Higher:-5,Average:0,Lower:5,Lowest:1/0};var Pt=(r=>(r.Update="update",r.Draw="draw",r))(Pt||{});class Et{}Et.priority=Gt.Average;function Ar(r){var t,e;return!!(r!=null&&r.prototype)&&!!((e=(t=r==null?void 0:r.prototype)==null?void 0:t.constructor)!=null&&e.name)}class Pr{constructor(t){this._world=t,this.systems=[],this.initialized=!1}get(t){return this.systems.find(e=>e instanceof t)}addSystem(t){let e;t instanceof Et?e=t:e=new t(this._world),this.systems.push(e),this.systems.sort((i,s)=>i.constructor.priority-s.constructor.priority),this.initialized&&e.initialize&&e.initialize(this._world,this._world.scene)}removeSystem(t){He(t,this.systems)}initialize(){if(!this.initialized){this.initialized=!0;for(const t of this.systems)t.initialize&&t.initialize(this._world,this._world.scene)}}updateSystems(t,e,i){const s=this.systems.filter(n=>n.systemType===t);for(const n of s)n.preupdate&&n.preupdate(e,i);for(const n of s)n.update(i);for(const n of s)n.postupdate&&n.postupdate(e,i)}clear(){for(let t=this.systems.length-1;t>=0;t--)this.removeSystem(this.systems[t])}}class Er{constructor(t){this.scene=t,this._logger=R.getInstance(),this.queryManager=new Tr(this),this.entityManager=new Sr(this),this.systemManager=new Pr(this)}query(t){return this.queryManager.createQuery(t)}queryTags(t){return this.queryManager.createQuery({tags:{all:t}})}update(t,e){t===Pt.Update&&this.entityManager.updateEntities(this.scene,e),this.systemManager.updateSystems(t,this.scene,e),this.entityManager.findEntitiesForRemoval(),this.entityManager.processComponentRemovals(),this.entityManager.processEntityRemovals()}add(t){if(t instanceof At){this.entityManager.addEntity(t);return}if(t instanceof Et||Ar(t)){this.systemManager.addSystem(t);return}this._logger.warn(`Could not add entity/system ${t.constructor.name} to Excalibur!
|
|
18
|
+
`}};Ss.All=new Ss("Collide with all groups",-1,-1);let me=Ss;var Ts=(r=>(r.Kill="kill",r.PreKill="prekill",r.PostKill="postkill",r.PreDraw="predraw",r.PostDraw="postdraw",r.PreDebugDraw="predebugdraw",r.PostDebugDraw="postdebugdraw",r.PreUpdate="preupdate",r.PostUpdate="postupdate",r.PreFrame="preframe",r.PostFrame="postframe",r.PreCollision="precollision",r.CollisionStart="collisionstart",r.CollisionEnd="collisionend",r.PostCollision="postcollision",r.Initialize="initialize",r.Activate="activate",r.Deactivate="deactivate",r.ExitViewport="exitviewport",r.EnterViewport="enterviewport",r.ExitTrigger="exit",r.EnterTrigger="enter",r.Connect="connect",r.Disconnect="disconnect",r.Button="button",r.Axis="axis",r.Visible="visible",r.Hidden="hidden",r.Start="start",r.Stop="stop",r.PointerUp="pointerup",r.PointerDown="pointerdown",r.PointerMove="pointermove",r.PointerEnter="pointerenter",r.PointerLeave="pointerleave",r.PointerCancel="pointercancel",r.PointerWheel="pointerwheel",r.Up="up",r.Down="down",r.Move="move",r.Enter="enter",r.Leave="leave",r.Cancel="cancel",r.Wheel="wheel",r.Press="press",r.Release="release",r.Hold="hold",r.PointerDragStart="pointerdragstart",r.PointerDragEnd="pointerdragend",r.PointerDragEnter="pointerdragenter",r.PointerDragLeave="pointerdragleave",r.PointerDragMove="pointerdragmove",r.ActionStart="actionstart",r.ActionComplete="actioncomplete",r.Add="add",r.Remove="remove",r))(Ts||{});class k{constructor(){this.other=null,this._bubbles=!0}get bubbles(){return this._bubbles}set bubbles(t){this._bubbles=t}stopPropagation(){this.bubbles=!1}}class As extends k{constructor(t){super(),this.self=t,this.target=t}}class Ps extends k{constructor(t){super(),this.self=t,this.target=t}}class Es extends k{constructor(t){super(),this.self=t,this.target=t}}class Is extends k{constructor(t){super(),this.self=t,this.target=t}}class Rs extends k{constructor(t){super(),this.self=t,this.target=t}}class Ue extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class ze extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Ms extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Fs extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Ds extends k{constructor(t,e){super(),this.ctx=t,this.self=e,this.target=e}}class Bs extends k{constructor(t,e){super(),this.ctx=t,this.self=e,this.target=e}}class re extends k{constructor(t,e,i){super(),this.engine=t,this.elapsed=e,this.self=i,this.target=i}}class oe extends k{constructor(t,e,i){super(),this.engine=t,this.elapsed=e,this.self=i,this.target=i}}class ks extends k{constructor(t,e){super(),this.engine=t,this.prevStats=e,this.target=t}}class Ls extends k{constructor(t,e){super(),this.engine=t,this.stats=e,this.target=t}}class Us extends k{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class zs extends k{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class Os extends k{constructor(t,e,i,s){super(),this.button=t,this.index=e,this.value=i,this.self=s,this.target=s}}class Hs extends k{constructor(t,e,i){super(),this.axis=t,this.value=e,this.self=i,this.target=i}}class Ns extends k{constructor(t){super(),this.self=t,this.target=t}}class Ws extends k{constructor(t){super(),this.self=t,this.target=t}}class ve extends k{constructor(t,e,i,s,n){super(),this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n,this.target=t}}class we extends k{constructor(t,e,i,s,n){super(),this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n,this.target=t}}class Ei{constructor(t,e,i,s){this.self=t,this.other=e,this.side=i,this.contact=s}}class Ii{constructor(t,e,i,s){this.self=t,this.other=e,this.side=i,this.lastContact=s}}class Ri{constructor(t,e,i,s,n){this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class Mi{constructor(t,e,i,s,n){this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class ni extends k{constructor(t,e,i,s){super(),this.self=t,this.other=e,this.side=i,this.contact=s,this.target=t}}class ri extends k{constructor(t,e,i,s){super(),this.self=t,this.other=e,this.side=i,this.lastContact=s,this.target=t}}class Oe extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}class Gs extends k{constructor(t,e){super(),this.context=t,this.self=e,this.target=e}}class Vs extends k{constructor(t,e){super(),this.context=t,this.self=e,this.target=e}}class qs extends k{constructor(t){super(),this.self=t,this.target=t}}class Xs extends k{constructor(t){super(),this.self=t,this.target=t}}class Ys extends k{constructor(t,e){super(),this.self=t,this.entity=e,this.target=t}}class $s extends k{constructor(t,e){super(),this.self=t,this.entity=e,this.target=t}}class Zs extends k{constructor(t,e){super(),this.action=t,this.self=e,this.target=e}}class js extends k{constructor(t,e){super(),this.action=t,this.self=e,this.target=e}}class Qs extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}class Js extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}const yh=Object.freeze(Object.defineProperty({__proto__:null,ActionCompleteEvent:js,ActionStartEvent:Zs,ActivateEvent:Gs,AddEvent:Qs,CollisionEndEvent:ri,CollisionPostSolveEvent:Mi,CollisionPreSolveEvent:Ri,CollisionStartEvent:ni,ContactEndEvent:Ii,ContactStartEvent:Ei,DeactivateEvent:Vs,EnterTriggerEvent:Ys,EnterViewPortEvent:Xs,EventTypes:Ts,ExitTriggerEvent:$s,ExitViewPortEvent:qs,GameEvent:k,GameStartEvent:Is,GameStopEvent:Rs,GamepadAxisEvent:Hs,GamepadButtonEvent:Os,GamepadConnectEvent:Us,GamepadDisconnectEvent:zs,HiddenEvent:Ws,InitializeEvent:Oe,KillEvent:As,PostCollisionEvent:we,PostDebugDrawEvent:Bs,PostDrawEvent:ze,PostFrameEvent:Ls,PostKillEvent:Es,PostTransformDrawEvent:Fs,PostUpdateEvent:oe,PreCollisionEvent:ve,PreDebugDrawEvent:Ds,PreDrawEvent:Ue,PreFrameEvent:ks,PreKillEvent:Ps,PreTransformDrawEvent:Ms,PreUpdateEvent:re,RemoveEvent:Js,VisibleEvent:Ns},Symbol.toStringTag,{value:"Module"}));function wr(r){if(r.length===0)throw new Error("Cannot find minIndex of array.length == 0");let t=r[0],e=0;for(let i=1;i<r.length;i++)r[i]<t&&(t=r[i],e=i);return e}function oi(r){if(r&&r.getBoundingClientRect){const t=r.getBoundingClientRect();return b(t.x+window.scrollX,t.y+window.scrollY)}return w.Zero}function Ch(r,t){return t.indexOf(r)===-1?(t.push(r),!0):!1}function He(r,t){let e=-1;return(e=t.indexOf(r))>-1?(t.splice(e,1),!0):!1}function xr(r,t){for(let e=0;e<r.length;e++)if(r[e]===t)return!0;return!1}function br(r){throw new Error(r)}function Fi(r,t){var e;const i=new wt;return((e=t==null?void 0:t.schedule.bind(t))!=null?e:setTimeout)(()=>{i.resolve()},r),i.promise}function yr(r,t){const e={};for(const i in r)t.includes(i)||(e[i]=r[i]);return e}function Di(r){return r&&typeof r=="object"&&!Array.isArray(r)}function Bi(r,...t){if(!t.length)return r;const e=t.shift();if(Di(r)&&Di(e))for(const i in e)Di(e[i])?(r[i]||Object.assign(r,{[i]:{}}),Bi(r[i],e[i])):Object.assign(r,{[i]:e[i]});return Bi(r,...t)}class Sh{constructor(t){this.data=t,this.type="Component Added"}}function Th(r){return!!r&&r.type==="Component Added"}class Ah{constructor(t){this.data=t,this.type="Component Removed"}}function Ph(r){return!!r&&r.type==="Component Removed"}const Eh={Add:"add",Remove:"remove",Initialize:"initialize",PreUpdate:"preupdate",PostUpdate:"postupdate",Kill:"kill"},Cr=class sr{constructor(t,e){this.id=sr._ID++,this.name=`Entity#${this.id}`,this.events=new X,this._tags=new Set,this.componentAdded$=new gt,this.componentRemoved$=new gt,this.tagAdded$=new gt,this.tagRemoved$=new gt,this.components=new Map,this.componentValues=[],this._componentsToRemove=[],this.scene=null,this.isActive=!0,this._parent=null,this.childrenAdded$=new gt,this.childrenRemoved$=new gt,this._children=[],this._isInitialized=!1,this._isAdded=!1;let i,s;if(Array.isArray(t))i=t,s=e;else if(t&&typeof t=="object"){const{components:n,name:o}=t;i=n!=null?n:[],s=o}if(s&&(this.name=s),i)for(const n of i)this.addComponent(n)}get active(){return this.isActive}set active(t){this.isActive=t}kill(){this.isActive&&(this.isActive=!1,this.unparent()),this.emit("kill",new As(this))}isKilled(){return!this.isActive}get tags(){return this._tags}hasTag(t){return this._tags.has(t)}addTag(t){return this._tags.add(t),this.tagAdded$.notifyAll(t),this}removeTag(t){return this._tags.delete(t),this.tagRemoved$.notifyAll(t),this}get types(){return Array.from(this.components.keys())}getComponents(){return Array.from(this.components.values())}hasAll(t){for(let e=0;e<t.length;e++)if(!this.components.has(t[e]))return!1;return!0}hasAllTags(t){for(let e=0;e<t.length;e++)if(!this.tags.has(t[e]))return!1;return!0}get(t){return this.components.get(t)}get parent(){return this._parent}get children(){return this._children}unparent(){this._parent&&(this._parent.removeChild(this),this._parent=null)}hasChild(t,e=!1){if(!e)return t.parent===this;for(const i of this.children)if(i===t||e&&i.hasChild(t,!0))return!0;return!1}addChild(t){if(t.parent===null){if(this.getAncestors().includes(t))throw new Error("Cycle detected, cannot add entity");this._children.push(t),t._parent=this,this.childrenAdded$.notifyAll(t)}else throw new Error("Entity already has a parent, cannot add without unparenting");return this}removeChild(t){return t.parent===this&&(He(t,this._children),t._parent=null,this.childrenRemoved$.notifyAll(t)),this}removeAllChildren(){for(let t=this.children.length-1;t>=0;t--)this.removeChild(this.children[t]);return this}getAncestors(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;return t.reverse()}getDescendants(){let t=[this],e=[this];for(;e.length>0;){const i=e.pop();i&&(e=e.concat(i.children),t=t.concat(i.children))}return t}clone(){const t=new sr;for(const e of this.types){const i=this.get(e);i&&t.addComponent(i.clone())}for(const e of this.children)t.addChild(e.clone());return t}addTemplate(t,e=!1){for(const i of t.getComponents())this.addComponent(i.clone(),e);for(const i of t.children)this.addChild(i.clone().addTemplate(i));return this}_getClassHierarchyRoot(t){var e,i;let s=t,n=(e=Object.getPrototypeOf(s.prototype))==null?void 0:e.constructor;for(;n&&n!==Object&&n!==Dt;)s=n,n=(i=Object.getPrototypeOf(s.prototype))==null?void 0:i.constructor;return s}addComponent(t,e=!1){if(this.has(t.constructor))if(e)this.removeComponent(t.constructor,!0);else return this;if(t.dependencies&&t.dependencies.length)for(const s of t.dependencies)this.addComponent(new s);t.owner=this;const i=this._getClassHierarchyRoot(t.constructor);return this.components.set(i,t),this.components.set(t.constructor,t),this.componentValues.push(t),t.onAdd&&t.onAdd(this),this.componentAdded$.notifyAll(t),this}removeComponent(t,e=!1){let i;if(vr(t)?i=t:i=t.constructor,e){const s=this.components.get(i);if(s){this.componentRemoved$.notifyAll(s),s.owner=void 0,s.onRemove&&s.onRemove(this);const o=this.componentValues.indexOf(s);o>-1&&this.componentValues.splice(o,1)}const n=this._getClassHierarchyRoot(i);this.components.delete(n),this.components.delete(i)}else this._componentsToRemove.push(i);return this}clearComponents(){const t=this.types;for(const e of t)this.removeComponent(e)}processComponentRemoval(){for(const t of this._componentsToRemove)this.removeComponent(t,!0);this._componentsToRemove.length=0}has(t){return this.components.has(t)}get isInitialized(){return this._isInitialized}get isAdded(){return this._isAdded}_initialize(t){this.isInitialized||(this.onInitialize(t),this.events.emit("initialize",new Oe(t,this)),this._isInitialized=!0)}_add(t){!this.isAdded&&this.isActive&&(this.onAdd(t),this.events.emit("add",new Qs(t,this)),this._isAdded=!0)}_remove(t){this.isAdded&&!this.isActive&&(this.onRemove(t),this.events.emit("remove",new Js(t,this)),this._isAdded=!1)}_preupdate(t,e){this.events.emit("preupdate",new re(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.events.emit("postupdate",new oe(t,e,this)),this.onPostUpdate(t,e)}onInitialize(t){}onAdd(t){}onRemove(t){}onPreUpdate(t,e){}onPostUpdate(t,e){}update(t,e){this._initialize(t),this._add(t),this._preupdate(t,e);for(const i of this.children)i.update(t,e);this._postupdate(t,e),this._remove(t)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){e?this.events.off(t,e):this.events.off(t)}};Cr._ID=0;let At=Cr;class Sr{constructor(t){this._world=t,this.entities=[],this._entityIndex={},this._childAddedHandlerMap=new Map,this._childRemovedHandlerMap=new Map,this._createChildAddedHandler=()=>e=>{this.addEntity(e)},this._createChildRemovedHandler=()=>e=>{this.removeEntity(e,!1)},this._entitiesToRemove=[]}updateEntities(t,e){for(let i=0;i<this.entities.length;i++){const s=this.entities[i];s.update(t.engine,e),s.isActive||this.removeEntity(s)}}findEntitiesForRemoval(){for(let t=0;t<this.entities.length;t++){const e=this.entities[t];e.isActive||this.removeEntity(e)}}addEntity(t){if(t.isActive=!0,t.scene=this._world.scene,t&&!this._entityIndex[t.id]){this._entityIndex[t.id]=t,this.entities.push(t),this._world.queryManager.addEntity(t),t.children.forEach(s=>{s.scene=t.scene,this.addEntity(s)});const e=this._createChildAddedHandler();this._childAddedHandlerMap.set(t,e);const i=this._createChildRemovedHandler();this._childRemovedHandlerMap.set(t,i),t.childrenAdded$.subscribe(e),t.childrenRemoved$.subscribe(i)}}removeEntity(t,e=!0){var i,s,n,o;let a=0;t instanceof At?a=t.id:a=t;const h=this._entityIndex[a];if(h&&h.isActive&&(h.isActive=!1),h&&e){this._entitiesToRemove.push(h);return}if(delete this._entityIndex[a],h){h.scene=null,He(h,this.entities),this._world.queryManager.removeEntity(h),h.children.forEach(u=>{u.scene=null,this.removeEntity(u,e)});const l=this._childAddedHandlerMap.get(h);l&&(h.childrenAdded$.unsubscribe(l),this._childAddedHandlerMap.delete(h));const c=this._childRemovedHandlerMap.get(h);c&&(h.childrenRemoved$.unsubscribe(c),this._childRemovedHandlerMap.delete(h)),h._remove((s=(i=this._world)==null?void 0:i.scene)==null?void 0:s.engine),(o=(n=this._world)==null?void 0:n.scene)!=null&&o.engine&&this._world.scene.engine.stats.currFrame.actors.killed++}}processEntityRemovals(){for(let t=0;t<this._entitiesToRemove.length;t++){const e=this._entitiesToRemove[t];e.isActive||this.removeEntity(e,!1)}this._entitiesToRemove.length=0}processComponentRemovals(){for(let t=0;t<this.entities.length;t++)this.entities[t].processComponentRemoval()}getById(t){return this._entityIndex[t]}getByName(t){return this.entities.filter(e=>e.name===t)}clear(){for(let t=this.entities.length-1;t>=0;t--)this.removeEntity(this.entities[t])}}class Lt{constructor(t){this._entities=[],this.entitiesSet=new Set,this.entityAdded$=new gt,this.entityRemoved$=new gt,this.filter={components:{all:new Set,any:new Set,not:new Set},tags:{all:new Set,any:new Set,not:new Set}},this._dirty=!1;var e,i,s,n,o,a,h,l,c,u,_,f;Array.isArray(t)&&(t={components:{all:t}}),this.filter.components.all=new Set((i=(e=t.components)==null?void 0:e.all)!=null?i:[]),this.filter.components.any=new Set((n=(s=t.components)==null?void 0:s.any)!=null?n:[]),this.filter.components.not=new Set((a=(o=t.components)==null?void 0:o.not)!=null?a:[]),this.filter.tags.all=new Set((l=(h=t.tags)==null?void 0:h.all)!=null?l:[]),this.filter.tags.any=new Set((u=(c=t.tags)==null?void 0:c.any)!=null?u:[]),this.filter.tags.not=new Set((f=(_=t.tags)==null?void 0:_.not)!=null?f:[]),this.id=Lt.createId(t)}get entities(){return this._dirty&&(this._entities=Array.from(this.entitiesSet),this._dirty=!1),this._entities}static createId(t){var e,i,s,n,o,a,h,l,c,u,_,f;Array.isArray(t)&&(t={components:{all:t}});const m=(e=t.components)!=null&&e.any?`any_${Lt.hashComponents(new Set((i=t.components)==null?void 0:i.any))}`:"",p=(s=t.components)!=null&&s.all?`all_${Lt.hashComponents(new Set((n=t.components)==null?void 0:n.all))}`:"",x=(o=t.components)!=null&&o.not?`not_${Lt.hashComponents(new Set((a=t.components)==null?void 0:a.not))}`:"",v=(h=t.tags)!=null&&h.any?`any_${Lt.hashTags(new Set((l=t.tags)==null?void 0:l.any))}`:"",g=(c=t.tags)!=null&&c.all?`all_${Lt.hashTags(new Set((u=t.tags)==null?void 0:u.all))}`:"",y=(_=t.tags)!=null&&_.not?`not_${Lt.hashTags(new Set((f=t.tags)==null?void 0:f.not))}`:"";return[m,p,x,v,g,y].filter(Boolean).join("-")}static hashTags(t){return Array.from(t).map(e=>`t_${e}`).sort().join("-")}static hashComponents(t){return Array.from(t).map(e=>`c_${e.name}`).sort().join("-")}matchesNotFilter(t,e){for(const i of this.filter.components.not)if(e!==i&&t.has(i))return!0;for(const i of this.filter.tags.not)if(t.hasTag(i))return!0;return!1}matches(t,e){for(const i of this.filter.components.not)if(e!==i&&t.has(i))return!1;for(const i of this.filter.tags.not)if(t.hasTag(i))return!1;for(const i of this.filter.components.all)if(i===e||!t.has(i))return!1;for(const i of this.filter.tags.all)if(!t.hasTag(i))return!1;if(this.filter.components.any.size>0){let i=!1;for(const s of this.filter.components.any)if(t.has(s)){i=!0;break}if(!i)return!1}if(this.filter.tags.any.size>0){let i=!1;for(const s of this.filter.tags.any)if(t.hasTag(s)){i=!0;break}if(!i)return!1}return!0}checkAndModify(t,e){const i=this.entitiesSet.has(t);if(i&&this.matchesNotFilter(t,e))return this.removeEntity(t),!1;const s=this.matches(t,e);return i&&!s?(this.removeEntity(t),!1):!i&&s?(this._dirty=!0,this.entitiesSet.add(t),this.entityAdded$.notifyAll(t),!0):!1}removeEntity(t){this.entitiesSet.delete(t)&&(this._dirty=!0,this.entityRemoved$.notifyAll(t))}getEntities(t){return t&&this.entities.sort(t),this.entities}}class Ks{constructor(t){if(this.requiredTags=t,this.tags=new Set,this.entities=[],this.entityAdded$=new gt,this.entityRemoved$=new gt,t.length===0)throw new Error("Cannot create tag query without tags");for(const e of t)this.tags.add(e);this.id=Ks.createId(t)}static createId(t){return t.slice().sort().join("-")}checkAndAdd(t){return!this.entities.includes(t)&&t.hasAllTags(Array.from(this.tags))?(this.entities.push(t),this.entityAdded$.notifyAll(t),!0):!1}removeEntity(t){const e=this.entities.indexOf(t);e>-1&&(this.entities.splice(e,1),this.entityRemoved$.notifyAll(t))}getEntities(t){return t&&this.entities.sort(t),this.entities}}class Tr{constructor(t){this._world=t,this._queries=new Map,this._addComponentHandlers=new Map,this._removeComponentHandlers=new Map,this._componentToQueriesIndex=new Map,this._tagToQueriesIndex=new Map,this._addTagHandlers=new Map,this._removeTagHandlers=new Map,this._createAddComponentHandler=e=>i=>{this.addComponent(e,i)},this._createRemoveComponentHandler=e=>i=>{this.removeComponent(e,i)},this._createAddTagHandler=e=>i=>{this.addTag(e,i)},this._createRemoveTagHandler=e=>i=>{this.removeTag(e,i)}}createQuery(t){const e=Lt.createId(t);if(this._queries.has(e))return this._queries.get(e);const i=new Lt(t);this._queries.set(i.id,i);for(const s of[...i.filter.components.all,...i.filter.components.any,...i.filter.components.not]){const n=this._componentToQueriesIndex.get(s);n?n.push(i):this._componentToQueriesIndex.set(s,[i])}for(const s of[...i.filter.tags.all,...i.filter.tags.any,...i.filter.tags.not]){const n=this._tagToQueriesIndex.get(s);n?n.push(i):this._tagToQueriesIndex.set(s,[i])}for(const s of this._world.entities)this.addEntity(s);return i}addEntity(t){const e=this._addComponentHandlers.get(t),i=this._removeComponentHandlers.get(t),s=e!=null?e:this._createAddComponentHandler(t),n=i!=null?i:this._createRemoveComponentHandler(t);this._addComponentHandlers.set(t,s),this._removeComponentHandlers.set(t,n);const o=this._addTagHandlers.get(t),a=this._removeTagHandlers.get(t),h=o!=null?o:this._createAddTagHandler(t),l=a!=null?a:this._createRemoveTagHandler(t);this._addTagHandlers.set(t,h),this._removeTagHandlers.set(t,l);for(const c of this._queries.values())c.checkAndModify(t);t.componentAdded$.subscribe(s),t.componentRemoved$.subscribe(n),t.tagAdded$.subscribe(h),t.tagRemoved$.subscribe(l)}removeEntity(t){const e=this._addComponentHandlers.get(t),i=this._removeComponentHandlers.get(t);for(const o of this._queries.values())o.removeEntity(t);e&&(t.componentAdded$.unsubscribe(e),this._addComponentHandlers.delete(t)),i&&(t.componentRemoved$.unsubscribe(i),this._removeComponentHandlers.delete(t));const s=this._addTagHandlers.get(t),n=this._removeTagHandlers.get(t);s&&(t.tagAdded$.unsubscribe(s),this._addTagHandlers.delete(t)),n&&(t.tagRemoved$.unsubscribe(n),this._removeTagHandlers.delete(t))}addComponent(t,e){var i;const s=(i=this._componentToQueriesIndex.get(e.constructor))!=null?i:[];for(const n of s)n.checkAndModify(t)}removeComponent(t,e){var i;const s=(i=this._componentToQueriesIndex.get(e.constructor))!=null?i:[];for(const n of s)n.checkAndModify(t,e.constructor)}addTag(t,e){var i;const s=(i=this._tagToQueriesIndex.get(e))!=null?i:[];for(const n of s)n.checkAndModify(t)}removeTag(t,e){var i;const s=(i=this._tagToQueriesIndex.get(e))!=null?i:[];for(const n of s)n.removeEntity(t),n.checkAndModify(t)}}const Gt={Highest:-1/0,Higher:-5,Average:0,Lower:5,Lowest:1/0};var Pt=(r=>(r.Update="update",r.Draw="draw",r))(Pt||{});class Et{}Et.priority=Gt.Average;function Ar(r){var t,e;return!!(r!=null&&r.prototype)&&!!((e=(t=r==null?void 0:r.prototype)==null?void 0:t.constructor)!=null&&e.name)}class Pr{constructor(t){this._world=t,this.systems=[],this.initialized=!1}get(t){return this.systems.find(e=>e instanceof t)}addSystem(t){let e;t instanceof Et?e=t:e=new t(this._world),this.systems.push(e),this.systems.sort((i,s)=>i.constructor.priority-s.constructor.priority),this.initialized&&e.initialize&&e.initialize(this._world,this._world.scene)}removeSystem(t){He(t,this.systems)}initialize(){if(!this.initialized){this.initialized=!0;for(const t of this.systems)t.initialize&&t.initialize(this._world,this._world.scene)}}updateSystems(t,e,i){const s=this.systems.filter(n=>n.systemType===t);for(const n of s)n.preupdate&&n.preupdate(e,i);for(const n of s)n.update(i);for(const n of s)n.postupdate&&n.postupdate(e,i)}clear(){for(let t=this.systems.length-1;t>=0;t--)this.removeSystem(this.systems[t])}}class Er{constructor(t){this.scene=t,this._logger=R.getInstance(),this.queryManager=new Tr(this),this.entityManager=new Sr(this),this.systemManager=new Pr(this)}query(t){return this.queryManager.createQuery(t)}queryTags(t){return this.queryManager.createQuery({tags:{all:t}})}update(t,e){t===Pt.Update&&this.entityManager.updateEntities(this.scene,e),this.systemManager.updateSystems(t,this.scene,e),this.entityManager.findEntitiesForRemoval(),this.entityManager.processComponentRemovals(),this.entityManager.processEntityRemovals()}add(t){if(t instanceof At){this.entityManager.addEntity(t);return}if(t instanceof Et||Ar(t)){this.systemManager.addSystem(t);return}this._logger.warn(`Could not add entity/system ${t.constructor.name} to Excalibur!
|
|
19
19
|
|
|
20
20
|
If this looks like an Excalibur type, this can be caused by 2 versions of excalibur being included on the page.
|
|
21
21
|
|
|
@@ -928,4 +928,4 @@ If in Firefox, visit about:config
|
|
|
928
928
|
|
|
929
929
|
Read more about this issue at https://excaliburjs.com/docs/performance`),i&&this._toaster.toast("Excalibur is encountering performance issues. It's possible that your browser doesn't have hardware acceleration enabled. Visit [LINK] for more information and potential solutions.","https://excaliburjs.com/docs/performance"),this.useCanvas2DFallback(),this.emit("fallbackgraphicscontext",this.graphicsContext))}}useCanvas2DFallback(){var t,e,i;const s=this.canvas.cloneNode(!1);this.canvas.parentNode.replaceChild(s,this.canvas),this.canvas=s;const n={...this._originalOptions,antialiasing:this.screen.antialiasing},o=this._originalDisplayMode;this.graphicsContext=new Yi({canvasElement:this.canvas,enableTransparency:this.enableCanvasTransparency,antialiasing:n.antialiasing,backgroundColor:n.backgroundColor,snapToPixel:n.snapToPixel,useDrawSorting:n.useDrawSorting}),this.screen&&this.screen.dispose(),this.screen=new kn({canvas:this.canvas,context:this.graphicsContext,antialiasing:(t=n.antialiasing)!=null?t:!0,browser:this.browser,viewport:(e=n.viewport)!=null?e:n.width&&n.height?{width:n.width,height:n.height}:Bn.SVGA,resolution:n.resolution,displayMode:o,pixelRatio:n.suppressHiDPIScaling?1:(i=n.pixelRatio)!=null?i:null}),this.screen.setCurrentCamera(this.currentScene.camera),this.input.pointers.detach();const a=n&&n.pointerScope===Be.Document?document:this.canvas;this.input.pointers=this.input.pointers.recreate(a,this),this.input.pointers.init()}dispose(){this._disposed||(this._disposed=!0,this.stop(),this._garbageCollector.forceCollectAll(),this.input.toggleEnabled(!1),this._hasCreatedCanvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null,this.screen.dispose(),this.graphicsContext.dispose(),this.graphicsContext=null,_e.InstanceCount--)}isDisposed(){return this._disposed}getWorldBounds(){return this.screen.getWorldBounds()}get timescale(){return this._timescale}set timescale(t){if(t<0){R.getInstance().warnOnce("engine.timescale to a value less than 0 are ignored");return}this._timescale=t}addTimer(t){return this.currentScene.addTimer(t)}removeTimer(t){return this.currentScene.removeTimer(t)}addScene(t,e){return this.director.add(t,e),this}removeScene(t){this.director.remove(t)}add(t){if(arguments.length===2){this.director.add(arguments[0],arguments[1]);return}const e=this.director.getDeferredScene();e instanceof Mt?e.add(t):this.currentScene.add(t)}remove(t){t instanceof At&&this.currentScene.remove(t),(t instanceof Mt||jt(t))&&this.removeScene(t),typeof t=="string"&&this.removeScene(t)}async goToScene(t,e){await this.scope(async()=>{await this.director.goToScene(t,e)})}screenToWorldCoordinates(t){return this.screen.screenToWorldCoordinates(t)}worldToScreenCoordinates(t){return this.screen.worldToScreenCoordinates(t)}_initialize(t){var e,i;this.pageScrollPreventionMode=t.scrollPreventionMode;const s=t&&t.pointerScope===Be.Document?document:this.canvas,n=(i=(e=this._originalOptions)==null?void 0:e.grabWindowFocus)!=null?i:!0;this.input=new Yn({global:this.global,pointerTarget:s,grabWindowFocus:n,engine:this}),this.inputMapper=this.input.inputMapper,this.browser.document.on("visibilitychange",()=>{document.visibilityState==="hidden"?(this.events.emit("hidden",new Ws(this)),this._logger.debug("Window hidden")):document.visibilityState==="visible"&&(this.events.emit("visible",new Ns(this)),this._logger.debug("Window visible"))}),!this.canvasElementId&&!t.canvasElement&&document.body.appendChild(this.canvas)}toggleInputEnabled(t){this._inputEnabled=t,this.input.toggleEnabled(this._inputEnabled)}onInitialize(t){}get isInitialized(){return this._isInitialized}async _overrideInitialize(t){this.isInitialized||(await this.director.onInitialize(),await this.onInitialize(t),this.events.emit("initialize",new Oe(t,this)),this._isInitialized=!0)}_update(t){var e;if(this._isLoading){(e=this._loader)==null||e.onUpdate(this,t),this.input.update();return}this.clock.__runScheduledCbs("preupdate"),this._preupdate(t),this.currentScene.update(this,t),this.graphicsContext.updatePostProcessors(t),this.clock.__runScheduledCbs("postupdate"),this._postupdate(t),this.input.update()}_preupdate(t){this.emit("preupdate",new re(this,t,this)),this.onPreUpdate(this,t)}onPreUpdate(t,e){}_postupdate(t){this.emit("postupdate",new oe(this,t,this)),this.onPostUpdate(this,t)}onPostUpdate(t,e){}_draw(t){var e,i;if(this.graphicsContext.backgroundColor=(e=this.currentScene.backgroundColor)!=null?e:this.backgroundColor,this.graphicsContext.beginDrawLifecycle(),this.graphicsContext.clear(),this.clock.__runScheduledCbs("predraw"),this._predraw(this.graphicsContext,t),this._isLoading){this._hideLoader||((i=this._loader)==null||i.canvas.draw(this.graphicsContext,0,0),this.clock.__runScheduledCbs("postdraw"),this.graphicsContext.flush(),this.graphicsContext.endDrawLifecycle());return}this.currentScene.draw(this.graphicsContext,t),this.clock.__runScheduledCbs("postdraw"),this._postdraw(this.graphicsContext,t),this.graphicsContext.flush(),this.graphicsContext.endDrawLifecycle(),this._checkForScreenShots()}_predraw(t,e){this.emit("predraw",new Ue(t,e,this)),this.onPreDraw(t,e)}onPreDraw(t,e){}_postdraw(t,e){this.emit("postdraw",new ze(t,e,this)),this.onPostDraw(t,e)}onPostDraw(t,e){}showDebug(t){this._isDebug=t}toggleDebug(){return this._isDebug=!this._isDebug,this._isDebug}get loadingComplete(){return!this._isLoading}get ready(){return this._isReadyFuture.isCompleted}isReady(){return this._isReadyFuture.promise}async start(t,e){await this.scope(async()=>{if(!this._compatible)throw new Error("Excalibur is incompatible with your browser");this._isLoading=!0;let i;return t instanceof mi?i=t:typeof t=="string"&&(this.director.configureStart(t,e),i=this.director.mainLoader),this._logger.debug("Starting game clock..."),this.browser.resume(),this.clock.start(),this.garbageCollectorConfig&&this._garbageCollector.start(),this._logger.debug("Game clock started"),await this.load(i!=null?i:new Ki),await this._overrideInitialize(this),this._isReadyFuture.resolve(),this.emit("start",new Is(this)),this._isReadyFuture.promise})}_mainloop(t){this.scope(()=>{this.emit("preframe",new ks(this,this.stats.prevFrame));const e=t*this.timescale;this.currentFrameElapsedMs=e;const i=this.stats.prevFrame.id+1;this.stats.currFrame.reset(),this.stats.currFrame.id=i,this.stats.currFrame.elapsedMs=e,this.stats.currFrame.fps=this.clock.fpsSampler.fps,J.clear();const s=this.clock.now(),n=this.fixedUpdateTimestep;if(this.fixedUpdateTimestep)for(this._lagMs+=e;this._lagMs>=n;)this._update(n),this._lagMs-=n;else this._update(e);const o=this.clock.now();this.currentFrameLagMs=this._lagMs,this._draw(e);const a=this.clock.now();this.stats.currFrame.duration.update=o-s,this.stats.currFrame.duration.draw=a-o,this.stats.currFrame.graphics.drawnImages=J.DrawnImagesCount,this.stats.currFrame.graphics.drawCalls=J.DrawCallCount,this.emit("postframe",new Ls(this,this.stats.currFrame)),this.stats.prevFrame.reset(this.stats.currFrame),this._monitorPerformanceThresholdAndTriggerFallback()})}stop(){this.clock.isRunning()&&(this.emit("stop",new Rs(this)),this.browser.pause(),this.clock.stop(),this._garbageCollector.stop(),this._logger.debug("Game stopped"))}isRunning(){return this.clock.isRunning()}screenshot(t=!1){return new Promise(i=>{this._screenShotRequests.push({preserveHiDPIResolution:t,resolve:i})})}_checkForScreenShots(){for(const t of this._screenShotRequests){const e=t.preserveHiDPIResolution?this.canvas.width:this.screen.resolution.width,i=t.preserveHiDPIResolution?this.canvas.height:this.screen.resolution.height,s=document.createElement("canvas");s.width=e,s.height=i;const n=s.getContext("2d");n.imageSmoothingEnabled=this.screen.antialiasing,n.drawImage(this.canvas,0,0,e,i);const o=new Image,a=s.toDataURL("image/png");o.onload=()=>{t.resolve(o)},o.src=a}this._screenShotRequests.length=0}async load(t,e=!1){await this.scope(async()=>{try{if(t.isLoaded())return;this._loader=t,this._isLoading=!0,this._hideLoader=e,t instanceof Ki&&(t.suppressPlayButton=t.suppressPlayButton||this._suppressPlayButton),this._loader.onInitialize(this),await t.load()}catch(i){this._logger.error("Error loading resources, things may not behave properly",i),await Promise.resolve()}finally{this._isLoading=!1,this._hideLoader=!1,this._loader=null}})}};os.Context=ma(),os.InstanceCount=0,os._DEFAULT_ENGINE_OPTIONS={width:0,height:0,enableCanvasTransparency:!0,useDrawSorting:!0,configurePerformanceCanvas2DFallback:{allow:!1,showPlayerMessage:!1,threshold:{fps:20,numberOfFrames:100}},canvasElementId:"",canvasElement:void 0,enableCanvasContextMenu:!1,snapToPixel:!1,antialiasing:!0,pixelArt:!1,garbageCollection:!0,powerPreference:"high-performance",pointerScope:Be.Canvas,suppressConsoleBootMessage:null,suppressMinimumBrowserFeatureDetection:null,suppressHiDPIScaling:null,suppressPlayButton:null,grabWindowFocus:!0,scrollPreventionMode:1,backgroundColor:T.fromHex("#2185d0")};let as=os;class Xl extends kt{constructor(t){super(t),this._font=new Se,this._text=new _i({text:"",font:this._font});const{text:e,pos:i,x:s,y:n,spriteFont:o,font:a,color:h,maxWidth:l}={text:"",...t};this.pos=i!=null?i:s&&n?b(s,n):this.pos,this.text=e!=null?e:this.text,this.font=a!=null?a:this.font,this.maxWidth=l!=null?l:this.maxWidth,this.spriteFont=o!=null?o:this.spriteFont,this._text.color=h!=null?h:this.color;const c=this.get(K);c.anchor=w.Zero,c.use(this._text)}set maxWidth(t){this._text.maxWidth=t}get maxWidth(){return this._text.maxWidth}get font(){return this._font}set font(t){this._font=t,this._text.font=t}get text(){return this._text.text}set text(t){this._text.text=t}get color(){return this._text.color}set color(t){this._text&&(this._text.color=t)}get opacity(){return this.graphics.opacity}set opacity(t){this.graphics.opacity=t}get spriteFont(){return this._spriteFont}set spriteFont(t){t&&(this._spriteFont=t,this._text.font=this._spriteFont)}_initialize(t){super._initialize(t)}getTextWidth(){return this._text.width}}var Ee=(r=>(r.Circle="circle",r.Rectangle="rectangle",r))(Ee||{});class Yl extends kt{constructor(t){var e,i;super({width:(e=t.width)!=null?e:0,height:(i=t.height)!=null?i:0}),this._particlesToEmit=0,this._particlePool=new qe(()=>new $i({}),m=>m,500),this.numParticles=0,this.isEmitting=!0,this.deadParticles=[],this.emitRate=1,this.emitterType=Ee.Rectangle,this.radius=0,this.particle={life:2e3,transform:Xt.Global,graphic:void 0,opacity:1,angularVelocity:0,focus:void 0,focusAccel:void 0,randomRotation:!1},this._activeParticles=[];const{particle:s,x:n,y:o,z:a,pos:h,isEmitting:l,emitRate:c,emitterType:u,radius:_,random:f}={...t};this.particle={...this.particle,...s},this.pos=h!=null?h:b(n!=null?n:0,o!=null?o:0),this.z=a!=null?a:0,this.isEmitting=l!=null?l:this.isEmitting,this.emitRate=c!=null?c:this.emitRate,this.emitterType=u!=null?u:this.emitterType,this.radius=_!=null?_:this.radius,this.body.collisionType=M.PreventCollision,this.random=f!=null?f:new se}removeParticle(t){this.deadParticles.push(t)}emitParticles(t){var e;if(!(t<=0)){t=t|0;for(let i=0;i<t;i++){const s=this._createParticle();(e=this==null?void 0:this.scene)!=null&&e.world&&(this.particle.transform===Xt.Global?this.scene.world.add(s):this.addChild(s)),this._activeParticles.push(s)}}}clearParticles(){for(let t=0;t<this._activeParticles.length;t++)this.removeParticle(this._activeParticles[t])}_createParticle(){let t=0,e=0;const i=Nt(this.particle.minAngle||0,this.particle.maxAngle||Math.PI*2,this.random),s=Nt(this.particle.minSpeed||0,this.particle.maxSpeed||0,this.random),n=this.particle.startSize||Nt(this.particle.minSize||5,this.particle.maxSize||5,this.random),o=s*Math.cos(i),a=s*Math.sin(i);if(this.emitterType===Ee.Rectangle)t=Nt(0,this.width,this.random),e=Nt(0,this.height,this.random);else if(this.emitterType===Ee.Circle){const l=Nt(0,this.radius,this.random);t=l*Math.cos(i),e=l*Math.sin(i)}const h=this._particlePool.rent();return h.unparent(),h.configure({transform:this.particle.transform,life:this.particle.life,opacity:this.particle.opacity,beginColor:this.particle.beginColor,endColor:this.particle.endColor,pos:b(t,e),z:this.particle.transform===Xt.Global?this.z:void 0,vel:b(o,a),acc:this.particle.acc,angularVelocity:this.particle.angularVelocity,startSize:this.particle.startSize,endSize:this.particle.endSize,size:n,graphic:this.particle.graphic,fade:this.particle.fade}),h.registerEmitter(this),this.particle.randomRotation&&(h.transform.rotation=Nt(0,Math.PI*2,this.random)),this.particle.focus&&(h.focus=this.particle.focus.add(b(this.pos.x,this.pos.y)),h.focusAccel=this.particle.focusAccel),h}update(t,e){var i;super.update(t,e),this.isEmitting&&(this._particlesToEmit+=this.emitRate*(e/1e3),this._particlesToEmit>1&&(this.emitParticles(Math.floor(this._particlesToEmit)),this._particlesToEmit=this._particlesToEmit-Math.floor(this._particlesToEmit)));for(let s=0;s<this.deadParticles.length;s++){(i=this==null?void 0:this.scene)!=null&&i.world&&(this.scene.world.remove(this.deadParticles[s],!1),this._particlePool.return(this.deadParticles[s]));const n=this._activeParticles.indexOf(this.deadParticles[s]);n>-1&&this._activeParticles.splice(n,1)}this.deadParticles.length=0}}function Jn(r,t){if(!t())throw new Error(r)}class hs{constructor(t,e,i){this.emitRate=1,this._initialized=!1,this._vaos=[],this._buffers=[],this._drawIndex=0,this._numInputFloats=7,this._particleIndex=0,this._uploadIndex=0,this._wrappedLife=0,this._wrappedParticles=0,this._particleLife=0,this._clearRequested=!1,this._emitted=[];var s;this.emitter=t,this.particle=i,this._particleData=new Float32Array(this.emitter.maxParticles*this._numInputFloats),this._random=e,this._particleLife=(s=this.particle.life)!=null?s:2e3}get isInitialized(){return this._initialized}get maxParticles(){return this.emitter.maxParticles}initialize(t,e){if(this._initialized)return;const i=this.emitter.maxParticles,s=this._numInputFloats,n=this._particleData,o=4,a=t.createBuffer(),h=t.createVertexArray();t.bindVertexArray(h),t.bindBuffer(t.ARRAY_BUFFER,a),t.bufferData(t.ARRAY_BUFFER,i*s*o,t.DYNAMIC_DRAW),t.bufferSubData(t.ARRAY_BUFFER,0,n);let l=0;t.vertexAttribPointer(0,2,t.FLOAT,!1,s*o,0),l+=o*2,t.vertexAttribPointer(1,2,t.FLOAT,!1,s*o,l),l+=o*2,t.vertexAttribPointer(2,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(3,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(4,1,t.FLOAT,!1,s*o,l),l+=o*1,t.enableVertexAttribArray(0),t.enableVertexAttribArray(1),t.enableVertexAttribArray(2),t.enableVertexAttribArray(3),t.enableVertexAttribArray(4),this._vaos.push(h),this._buffers.push(a),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null);const c=t.createBuffer(),u=t.createVertexArray();t.bindVertexArray(u),t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,i*s*o,t.DYNAMIC_DRAW),l=0,t.vertexAttribPointer(0,2,t.FLOAT,!1,s*o,0),l+=o*2,t.vertexAttribPointer(1,2,t.FLOAT,!1,s*o,l),l+=o*2,t.vertexAttribPointer(2,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(3,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(4,1,t.FLOAT,!1,s*o,l),l+=o*1,t.enableVertexAttribArray(0),t.enableVertexAttribArray(1),t.enableVertexAttribArray(2),t.enableVertexAttribArray(3),t.enableVertexAttribArray(4),this._vaos.push(u),this._buffers.push(c),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this._currentVao=this._vaos[this._drawIndex%2],this._currentBuffer=this._buffers[(this._drawIndex+1)%2],this._initialized=!0}clearParticles(){this._particleData.fill(0),this._clearRequested=!0}emitParticles(t){const e=this._particleIndex,i=this.maxParticles*this._numInputFloats,s=t*this._numInputFloats+e;for(let n=e;n<s;n+=this._numInputFloats){let o=this._random.floating(this.particle.minAngle||0,this.particle.maxAngle||it);o+=this.particle.transform===Xt.Local?this.emitter.transform.rotation:this.emitter.transform.globalRotation;const a=this._random.floating(this.particle.minSpeed||0,this.particle.maxSpeed||0),h=this._random.floating(this.particle.minSpeed||0,this.particle.maxSpeed||0),l=a*Math.cos(o),c=h*Math.sin(o);let u=0,_=0;if(this.emitter.emitterType===Ee.Rectangle)u=this._random.floating(-.5,.5)*this.emitter.width,_=this._random.floating(-.5,.5)*this.emitter.height;else{const p=this._random.floating(0,this.emitter.radius);u=p*Math.cos(o),_=p*Math.sin(o)}const f=this.emitter.transform.apply(b(u,_)),m=[this.particle.transform===Xt.Local?u:f.x,this.particle.transform===Xt.Local?_:f.y,l,c,this.particle.randomRotation?Nt(0,it,this._random):this.particle.rotation||0,this.particle.angularVelocity||0,this._particleLife];this._particleData.set(m,n%this._particleData.length)}s>=i?(this._wrappedParticles+=(s-i)/this._numInputFloats,this._wrappedLife=this._particleLife):this._wrappedLife>0&&(this._wrappedParticles+=t),this._particleIndex=s%i,this._emitted.push([this._particleLife,e])}_uploadEmitted(t){this._particleIndex!==this._uploadIndex&&(t.bindBuffer(t.ARRAY_BUFFER,this._buffers[(this._drawIndex+1)%2]),this._particleIndex>=this._uploadIndex?t.bufferSubData(t.ARRAY_BUFFER,this._uploadIndex*4,this._particleData,this._uploadIndex,this._particleIndex-this._uploadIndex):(t.bufferSubData(t.ARRAY_BUFFER,this._uploadIndex*4,this._particleData,this._uploadIndex,this._particleData.length-this._uploadIndex),this._wrappedParticles&&t.bufferSubData(t.ARRAY_BUFFER,0,this._particleData,0,this._wrappedParticles*this._numInputFloats),this._wrappedLife=this._particleLife),t.bindBuffer(t.ARRAY_BUFFER,null)),this._uploadIndex=this._particleIndex%(this.maxParticles*this._numInputFloats)}update(t){var e;if(this._particleLife=(e=this.particle.life)!=null?e:this._particleLife,this._wrappedLife>0?this._wrappedLife-=t:(this._wrappedLife=0,this._wrappedParticles=0),!!this._emitted.length){for(let i=this._emitted.length-1;i>=0;i--){const s=this._emitted[i];s[0]-=t,s[0]<=0&&this._emitted.splice(i,1)}this._emitted.sort((i,s)=>i[0]-s[0])}}draw(t){if(this._initialized){if(this._clearRequested?(t.bindBuffer(t.ARRAY_BUFFER,this._buffers[(this._drawIndex+1)%2]),t.bufferSubData(t.ARRAY_BUFFER,0,this._particleData),t.bindBuffer(t.ARRAY_BUFFER,null),this._clearRequested=!1):this._uploadEmitted(t),t.bindVertexArray(this._currentVao),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer),this._wrappedLife&&this._emitted[0]&&this._emitted[0][1]>0){const e=this._emitted[0][1]/this._numInputFloats;Jn(`midpoint greater than 0, actual: ${e}`,()=>e>0),Jn(`midpoint is less than max, actual: ${e}`,()=>e<this.maxParticles),t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,this._emitted[0][1]*4,(this.maxParticles-e)*this._numInputFloats*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,e,this.maxParticles-e),t.endTransformFeedback(),t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,0,this._emitted[0][1]*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,0,e),t.endTransformFeedback()}else t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,0,this._particleData.length*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,0,this.maxParticles),t.endTransformFeedback();t.bindVertexArray(null),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,0,null),this._currentVao=this._vaos[this._drawIndex%2],this._currentBuffer=this._buffers[(this._drawIndex+1)%2],this._drawIndex=(this._drawIndex+1)%2}}}hs.GPU_MAX_PARTICLES=1e5;class $l extends kt{constructor(t){super({name:"GpuParticleEmitter",width:t.width,height:t.height}),this.particle={life:2e3,transform:Xt.Global,graphic:void 0,opacity:1,angularVelocity:0,focus:void 0,focusAccel:void 0,randomRotation:!1},this.graphics=new K,this.isEmitting=!1,this.emitRate=1,this.emitterType=Ee.Rectangle,this.radius=0,this.maxParticles=2e3,this._particlesToEmit=0,this.addComponent(this.graphics,!0),this.graphics.onPostDraw=this.draw.bind(this);const{particle:e,maxParticles:i,x:s,y:n,z:o,pos:a,isEmitting:h,emitRate:l,emitterType:c,radius:u,random:_}={...t};this.maxParticles=B(i!=null?i:this.maxParticles,0,hs.GPU_MAX_PARTICLES),this.pos=a!=null?a:b(s!=null?s:0,n!=null?n:0),this.z=o!=null?o:0,this.isEmitting=h!=null?h:this.isEmitting,this.emitRate=l!=null?l:this.emitRate,this.emitterType=c!=null?c:this.emitterType,this.radius=u!=null?u:this.radius,this.particle={...this.particle,...e},this.random=_!=null?_:new se,this.renderer=new hs(this,this.random,this.particle)}get pos(){return this.transform.pos}set pos(t){this.transform.pos=t}get z(){return this.transform.z}set z(t){this.transform.z=t}_initialize(t){super._initialize(t);const e=t.graphicsContext;this.renderer.initialize(e.__gl,e)}update(t,e){super.update(t,e),this.isEmitting&&(this._particlesToEmit+=this.emitRate*(e/1e3),this._particlesToEmit>1&&(this.emitParticles(Math.floor(this._particlesToEmit)),this._particlesToEmit=this._particlesToEmit-Math.floor(this._particlesToEmit))),this.renderer.update(e)}emitParticles(t){t<=0||this.renderer.emitParticles(t|0)}clearParticles(){this.renderer.clearParticles()}draw(t,e){t.draw("ex.particle",this.renderer,e)}}class Kn{constructor(t,e){this.id=H(),this._stopped=!1,this._sequenceBuilder=e,this._sequenceContext=new fi(t),this._actionQueue=this._sequenceContext.getQueue(),this._sequenceBuilder(this._sequenceContext)}update(t){this._actionQueue.update(t)}isComplete(){return this._stopped||this._actionQueue.isComplete()}stop(){this._stopped=!0}reset(){this._stopped=!1,this._actionQueue.reset()}clone(t){return new Kn(t,this._sequenceBuilder)}}class Zl{constructor(t){this.id=H(),this._actions=t}update(t){for(let e=0;e<this._actions.length;e++)this._actions[e].update(t)}isComplete(t){return this._actions.every(e=>e.isComplete(t))}reset(){this._actions.forEach(t=>t.reset())}stop(){this._actions.forEach(t=>t.stop())}}function jl(r){return!!r._initialize}function Ql(r){return!!r.onAdd}function Jl(r){return!!r.onRemove}function Kl(r){return!!r.onInitialize}function tc(r){return!!r._preupdate}function ec(r){return!!r.onPreUpdate}function ic(r){return!!r.onPostUpdate}function sc(r){return!!r.onPostUpdate}function nc(r){return!!r.onAdd}function rc(r){return!!r.onRemove}function oc(r){return!!r.onPreDraw}function ac(r){return!!r.onPostDraw}class xa{constructor(t,e){this.soundManager=e}stop(t){if(!t)return;const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)e[i].stop()}setVolume(t,e){const i=this.soundManager.getSoundsForChannel(t);for(const s of i)this.soundManager._isMuted(s)||this.soundManager.setVolume(t,e)}play(t,e){e!=null||(e=this.soundManager.defaultVolume);const i=[],s=new Set,n=this.soundManager.getSoundsForChannel(t);for(const o of n){if(s.has(o)||this.soundManager._isMuted(o))continue;const a=this.soundManager._getEffectiveVolume(o);i.push(o.play(a*e)),s.add(o)}return Promise.all(i)}mute(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._muted.add(e[i]),e[i].pause()}unmute(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._muted.has(e[i])&&(e[i].play(),this.soundManager._muted.delete(e[i]))}toggle(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._isMuted(e[i])?(e[i].play(),this.soundManager._muted.delete(e[i])):(this.soundManager._muted.add(e[i]),e[i].pause())}}class hc{constructor(t){this._channelToConfig=new Map,this._nameToConfig=new Map,this._mix=new Map,this._muted=new Set,this._all=new Set,this._defaultVolume=1;var e;if(this._defaultVolume=(e=t.volume)!=null?e:1,this.channel=new xa(t,this),t.sounds)for(const[i,s]of Object.entries(t.sounds))this.track(i,s)}set defaultVolume(t){this._defaultVolume=B(t,0,1)}get defaultVolume(){return this._defaultVolume}getSounds(){return Array.from(this._all)}getSoundsForChannel(t){const e=this._channelToConfig.get(t);return e?e.sounds:[]}_isMuted(t){return this._muted.has(t)}_getEffectiveVolume(t){var e;if(this._isMuted(t))return 0;let i=this._defaultVolume;return this._mix.has(t)&&(i*=(e=this._mix.get(t))!=null?e:this._defaultVolume),i}play(t,e=this._defaultVolume){const i=this._nameToConfig.get(t);if(!i)return Promise.resolve();const{sound:s}=i;if(this._isMuted(s))return Promise.resolve();const n=e*this._getEffectiveVolume(s);return s.play(n)}getSound(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;return i}setVolume(t,e=this._defaultVolume){const i=this._nameToConfig.get(t);if(!i)return;const{sound:s}=i;this._setMix(s,e)}getVolume(t){var e;const i=this.getSound(t);return i&&(e=this._mix.get(i))!=null?e:0}_setMix(t,e){this._mix.set(t,e),t.volume=e}track(t,e){let i,s,n;e instanceof zn?(i=e,s=this._defaultVolume,n=[]):{sound:i,volume:s,channels:n}=e,this._nameToConfig.set(t,{sound:i,volume:s,channels:n}),this._mix.set(i,s!=null?s:this._defaultVolume),this._all.add(i),n&&this.addChannel(t,n)}untrack(t){this._nameToConfig.delete(t);const e=this.getSound(t);e&&(this._mix.delete(e),this._all.delete(e))}stop(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;i.stop();return}this._all.forEach(e=>e.stop())}mute(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;this._muted.add(i),i.pause();return}this._muted=new Set(this._all),this._muted.forEach(e=>e.pause())}unmute(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;i.play(),this._muted.delete(i);return}this._muted.forEach(e=>e.play()),this._muted.clear()}toggle(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;this._isMuted(i)?this.unmute(t):this.mute(t);return}this._muted.size>0?(this._muted.forEach(e=>e.play()),this._muted.clear()):(this._muted=new Set(this._all),this._muted.forEach(e=>e.pause()))}addChannel(t,e){const i=this.getSound(t);if(!i)return;const s=this._mix.get(i);this._mix.set(i,s!=null?s:this._defaultVolume),this._all.add(i);for(const n of e){let o=this._channelToConfig.get(n);o||(o={sounds:[i]}),o.sounds.indexOf(i)===-1&&o.sounds.push(i),this._channelToConfig.set(n,o)}}removeChannel(t,e){const i=this.getSound(t);if(i)for(const s of e){const n=this._channelToConfig.get(s);if(!n)return;const o=n.sounds.indexOf(i);o>=-1&&n.sounds.splice(o,1),this._channelToConfig.set(s,n)}}}class lc{constructor(t,e=!1){this.path=t,this.width=0,this.height=0,this._images=[],this.data=[],this._sprites=[],this._resource=new li(t,"arraybuffer",e)}get bustCache(){return this._resource.bustCache}set bustCache(t){this._resource.bustCache=t}async load(){const t=await this._resource.load();this._stream=new ba(t),this._gif=new ya(this._stream);const e=this._gif.images.map(i=>new qt(i.src,!1));return await Promise.all(e.map(i=>i.load())),this.data=this._images=e,this._sprites=this._images.map(i=>i.toSprite()),this.data}isLoaded(){return!!this.data}toSprite(t=0){var e;return(e=this._sprites[t])!=null?e:null}toSpriteSheet(){const t=this._sprites;return t.length?new ye({sprites:t}):null}toAnimation(t){var e;const i=(e=this._gif)==null?void 0:e.images;if(i!=null&&i.length){const s=i.map((n,o)=>{var a;return{graphic:this._sprites[o],duration:((a=this._gif)==null?void 0:a.frames[o].delayMs)||void 0}});return this._animation=new zi({frames:s,frameDuration:t}),this._animation}return null}get readCheckBytes(){var t,e;return(e=(t=this._gif)==null?void 0:t.checkBytes)!=null?e:[]}}const ls=r=>r.reduce(function(t,e){return t*2+e},0),tr=r=>{const t=[];for(let e=7;e>=0;e--)t.push(!!(r&1<<e));return t};class ba{constructor(t){if(this.len=0,this.position=0,this.readByte=()=>{if(this.position>=this.data.byteLength)throw new Error("Attempted to read past end of stream.");return this.data[this.position++]},this.readBytes=e=>{const i=[];for(let s=0;s<e;s++)i.push(this.readByte());return i},this.read=e=>{let i="";for(let s=0;s<e;s++)i+=String.fromCharCode(this.readByte());return i},this.readUnsigned=()=>{const e=this.readBytes(2);return(e[1]<<8)+e[0]},this.data=new Uint8Array(t),this.len=this.data.byteLength,this.len===0)throw new Error("No data loaded from file")}}const cc=function(r,t){let e=0;const i=function(_){let f=0;for(let m=0;m<_;m++)t.charCodeAt(e>>3)&1<<(e&7)&&(f|=1<<m),e++;return f},s=[],n=1<<r,o=n+1;let a=r+1,h=[];const l=function(){h=[],a=r+1;for(let _=0;_<n;_++)h[_]=[_];h[n]=[],h[o]=null};let c=0,u=0;for(;;){if(u=c,c=i(a),c===n){l();continue}if(c===o)break;if(c<h.length)u!==n&&h.push(h[u].concat(h[c][0]));else{if(c!==h.length)throw new Error("Invalid LZW code.");h.push(h[u].concat(h[u][0]))}s.push.apply(s,h[c]),h.length===1<<a&&a<12&&a++}return s};class ya{constructor(t){this._handler={},this.frames=[],this.images=[],this.globalColorTableBytes=[],this.checkBytes=[],this.parseColorTableBytes=e=>{const i=[];for(let s=0;s<e;s++){const n=this._st.readBytes(3);i.push(n)}return i},this.readSubBlocks=()=>{let e,i;i="";do e=this._st.readByte(),i+=this._st.read(e);while(e!==0);return i},this.parseHeader=()=>{const e={sig:"",ver:"",width:0,height:0,colorResolution:0,globalColorTableSize:0,gctFlag:!1,sortedFlag:!1,globalColorTable:[],backgroundColorIndex:0,pixelAspectRatio:0};if(e.sig=this._st.read(3),e.ver=this._st.read(3),e.sig!=="GIF")throw new Error("Not a GIF file.");e.width=this._st.readUnsigned(),e.height=this._st.readUnsigned(),this._currentFrameCanvas.width=e.width,this._currentFrameCanvas.height=e.height;const i=tr(this._st.readByte());e.gctFlag=i.shift(),e.colorResolution=ls(i.splice(0,3)),e.sortedFlag=i.shift(),e.globalColorTableSize=ls(i.splice(0,3)),e.backgroundColorIndex=this._st.readByte(),e.pixelAspectRatio=this._st.readByte(),e.gctFlag&&(this.globalColorTableBytes=this.parseColorTableBytes(1<<e.globalColorTableSize+1)),this._handler.hdr&&this._handler.hdr(e)&&this.checkBytes.push(this._handler.hdr)},this.parseExt=e=>{const i=h=>{this.checkBytes.push(this._st.readByte());const l=tr(this._st.readByte());return h.reserved=l.splice(0,3),h.disposalMethod=ls(l.splice(0,3)),h.userInputFlag=l.shift(),h.transparentColorFlag=l.shift(),h.delayTime=this._st.readUnsigned(),h.transparentColorIndex=this._st.readByte(),h.terminator=this._st.readByte(),this._handler.gce&&this._handler.gce(h)&&this.checkBytes.push(this._handler.gce),h},s=h=>{h.comment=this.readSubBlocks(),this._handler.com&&this._handler.com(h)&&this.checkBytes.push(this._handler.com)},n=h=>{this.checkBytes.push(this._st.readByte()),h.ptHeader=this._st.readBytes(12),h.ptData=this.readSubBlocks(),this._handler.pte&&this._handler.pte(h)&&this.checkBytes.push(this._handler.pte)},o=h=>{const l=u=>{this.checkBytes.push(this._st.readByte()),u.unknown=this._st.readByte(),u.iterations=this._st.readUnsigned(),u.terminator=this._st.readByte(),this._handler.app&&this._handler.app.NETSCAPE&&this._handler.app.NETSCAPE(u)&&this.checkBytes.push(this._handler.app)},c=u=>{u.appData=this.readSubBlocks(),this._handler.app&&this._handler.app[u.identifier]&&this._handler.app[u.identifier](u)&&this.checkBytes.push(this._handler.app[u.identifier])};switch(this.checkBytes.push(this._st.readByte()),h.identifier=this._st.read(8),h.authCode=this._st.read(3),h.identifier){case"NETSCAPE":l(h);break;default:c(h);break}},a=h=>{h.data=this.readSubBlocks(),this._handler.unknown&&this._handler.unknown(h)&&this.checkBytes.push(this._handler.unknown)};switch(e.label=this._st.readByte(),e.label){case 249:e.extType="gce",this._gce=i(e);break;case 254:e.extType="com",s(e);break;case 1:e.extType="pte",n(e);break;case 255:e.extType="app",o(e);break;default:e.extType="unknown",a(e);break}},this.parseImg=e=>{var i;const s=(a,h)=>{const l=new Array(a.length),c=a.length/h,u=(p,x)=>{const v=a.slice(x*h,(x+1)*h);l.splice.apply(l,[p*h,h].concat(v))},_=[0,4,2,1],f=[8,8,4,2];let m=0;for(let p=0;p<4;p++)for(let x=_[p];x<c;x+=f[p])u(x,m),m++;return l};e.leftPos=this._st.readUnsigned(),e.topPos=this._st.readUnsigned(),e.width=this._st.readUnsigned(),e.height=this._st.readUnsigned();const n=tr(this._st.readByte());e.lctFlag=n.shift(),e.interlaced=n.shift(),e.sorted=n.shift(),e.reserved=n.splice(0,2),e.lctSize=ls(n.splice(0,3)),e.lctFlag&&(e.lctBytes=this.parseColorTableBytes(1<<e.lctSize+1)),e.lzwMinCodeSize=this._st.readByte();const o=this.readSubBlocks();e.pixels=cc(e.lzwMinCodeSize,o),e.interlaced&&(e.pixels=s(e.pixels,e.width)),(i=this._gce)!=null&&i.delayTime&&(e.delayMs=this._gce.delayTime*10),this.frames.push(e),this.arrayToImage(e,e.lctFlag?e.lctBytes:this.globalColorTableBytes),this._handler.img&&this._handler.img(e)&&this.checkBytes.push(this._handler)},this.parseBlocks=()=>{const e={sentinel:this._st.readByte(),type:""};switch(String.fromCharCode(e.sentinel)){case"!":e.type="ext",this.parseExt(e);break;case",":e.type="img",this.parseImg(e);break;case";":e.type="eof",this._handler.eof&&this._handler.eof(e)&&this.checkBytes.push(this._handler.eof);break;default:throw new Error("Unknown block: 0x"+e.sentinel.toString(16))}e.type!=="eof"&&this.parseBlocks()},this.arrayToImage=(e,i)=>{var s,n,o,a;const h=document.createElement("canvas");h.width=e.width,h.height=e.height;const l=h.getContext("2d"),c=l.getImageData(0,0,h.width,h.height);let u=-1;(s=this._gce)!=null&&s.transparentColorFlag&&(u=this._gce.transparentColorIndex);for(let f=0;f<e.pixels.length;f++){const m=e.pixels[f],p=i[m];m===u?c.data.set([0,0,0,0],f*4):c.data.set([...p,255],f*4)}if(l.putImageData(c,0,0),((n=this._gce)==null?void 0:n.disposalMethod)===1&&this.images.length)this._currentFrameContext.drawImage(this.images[this.images.length-1],0,0);else if(((o=this._gce)==null?void 0:o.disposalMethod)===2&&((a=this._hdr)!=null&&a.gctFlag)){const f=i[this._hdr.backgroundColorIndex];this._currentFrameContext.fillStyle=`rgb(${f[0]}, ${f[1]}, ${f[2]})`,this._currentFrameContext.fillRect(0,0,this._hdr.width,this._hdr.height)}else this._currentFrameContext.clearRect(0,0,this._currentFrameCanvas.width,this._currentFrameCanvas.height);this._currentFrameContext.drawImage(h,e.leftPos,e.topPos,e.width,e.height);const _=new Image;_.src=this._currentFrameCanvas.toDataURL(),this.images.push(_)},this._st=t,this._handler={},this._currentFrameCanvas=document.createElement("canvas"),this._currentFrameContext=this._currentFrameCanvas.getContext("2d"),this.parseHeader(),this.parseBlocks()}}class dc{constructor(t,e,{bustCache:i,...s}={}){this.path=t,this.family=e,this._isLoaded=!1,this._resource=new li(t,"blob",i),this._options=s}async load(){if(this.isLoaded())return this.data;try{const t=await this._resource.load(),e=URL.createObjectURL(t);this.data||(this.data=new FontFace(this.family,`url(${e})`),document.fonts.add(this.data)),await this.data.load(),this._isLoaded=!0}catch(t){throw`Error loading FontSource from path '${this.path}' with error [${t.message}]`}return this.data}isLoaded(){return this._isLoaded}toFont(t){return new Se({family:this.family,...this._options,...t})}}const Ca=ma(),uc=/^\s*(?:function)?\*/;function Sa(r){return typeof r!="function"?!1:uc.test(Function.prototype.toString.call(r))?!0:Object.getPrototypeOf?Object.getPrototypeOf(r)===Object.getPrototypeOf(new Function("return function * () {}")()):!1}function Ta(...r){var t;const e=R.getInstance();let i,s,n,o;Sa(r[0])&&(s=globalThis,i=r[0],n=r[1]),Sa(r[1])&&(s=r[0],i=r[1],n=r[2]),r[1]instanceof as&&(s=r[0],o=r[1],i=r[2],n=r[3]),r[0]instanceof as&&(s=globalThis,o=r[0],i=r[1],n=r[2]);const a=va(Ca),h=n==null?void 0:n.timing,l=a?!1:(t=n==null?void 0:n.autostart)!=null?t:!0;let c;try{c=o!=null?o:as.useEngine()}catch(y){throw Error(`Cannot run coroutine without engine parameter outside of an excalibur lifecycle method.
|
|
930
930
|
Pass an engine parameter to ex.coroutine(engine, function * {...})`)}let u=!1,_=!1,f=!1;const m=i.bind(s),p=m();let x;const v=new Promise((y,S)=>{x=A=>{try{if(f){_=!0,y();return}const{done:I,value:C}=Ca.scope(!0,()=>p.next(A));if(I||f){_=!0,y();return}C instanceof Promise?C.then(()=>{c.clock.schedule(x,0,h)}):C===void 0||C===void 0?c.clock.schedule(x,0,h):c.clock.schedule(x,C||0,h)}catch(I){S(I);return}},l&&(u=!0,x(c.clock.elapsed()))}),g={isRunning:()=>u&&!f&&!_,isComplete:()=>_,cancel:()=>{f=!0},start:()=>(u?e.warn(`.start() was called on a coroutine that was already started, this is probably a bug:
|
|
931
|
-
`,Function.prototype.toString.call(m)):(u=!0,x(c.clock.elapsed())),g),generator:p,done:v,then:v.then.bind(v),[Symbol.iterator]:()=>p};return g}class cs extends At{constructor(t){var e,i,s,n,o;super(),this._logger=R.getInstance(),this.transform=new P,this.graphics=new K,this._completeFuture=new wt,this.started=!1,this._currentDistance=0,this._currentProgress=0,this.done=this._completeFuture.promise,this._useLegacyEasing=!1,this.name=`Transition#${this.id}`,this.duration=t.duration,Te(t.easing)?(this.legacyEasing=(e=t.easing)!=null?e:Rt.Linear,this._useLegacyEasing=!0):this.easing=(i=t.easing)!=null?i:Ai,this.direction=(s=t.direction)!=null?s:"out",this.hideLoader=(n=t.hideLoader)!=null?n:!1,this.blockInput=(o=t.blockInput)!=null?o:!1,this.transform.coordPlane=rt.Screen,this.transform.pos=w.Zero,this.transform.z=1/0,this.graphics.anchor=w.Zero,this.addComponent(this.transform),this.addComponent(this.graphics),this.direction==="out"?this._currentProgress=0:this._currentProgress=1}get progress(){return this._currentProgress}get distance(){return this._currentDistance}get complete(){return this.direction==="out"?this.progress>=1:this.progress<=0}updateTransition(t,e){this.complete||(this._currentDistance+=B(e/this.duration,0,1),this._currentDistance>=1&&(this._currentDistance=1),this.direction==="out"?this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,0,1,1),0,1):this._currentProgress=B(ot(0,1,this.easing(this._currentDistance)),0,1):this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,1,0,1),0,1):this._currentProgress=B(ot(1,0,this.easing(this._currentDistance)),0,1))}async onPreviousSceneDeactivate(t){}onStart(t){}onUpdate(t){}onEnd(t){}onReset(){}reset(){this.started=!1,this._completeFuture=new wt,this.done=this._completeFuture.promise,this._currentDistance=0,this.direction==="out"?this._currentProgress=0:this._currentProgress=1,this.onReset()}_addToTargetScene(t,e){const i=e;if(this.started&&this._logger.warn(`Attempted to add a transition ${this.name} that is already playing.`),i.world.entityManager.getById(this.id))return this._co;this._engine=t,i.add(this);const s=this;return this._co=Ta(t,function*(){for(;!s.complete;){const n=yield;s.updateTransition(s._engine,n),s._execute()}},{autostart:!1}),this._co}async _play(){this.started&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that is already playing, reset transition.`)),(!this._engine||!this._co)&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that hasn't been added`)),this._co&&await this._co.start()}_execute(){this.isInitialized&&(this.started||(this.started=!0,this.onStart(this.progress)),this.onUpdate(this.progress),this.complete&&!this._completeFuture.isCompleted&&(this.onEnd(this.progress),this._completeFuture.resolve()))}}class _c extends cs{constructor(t){var e,i;super({...t,duration:(e=t.duration)!=null?e:2e3}),this.name=`FadeInOut#${this.id}`,this.color=(i=t.color)!=null?i:T.Black}onInitialize(t){this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=new ui({width:t.screen.resolution.width,height:t.screen.resolution.height,color:this.color}),this.graphics.add(this.screenCover),this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=t}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class fc extends cs{constructor(t){super({direction:"in",...t}),this.name=`CrossFade#${this.id}`}async onPreviousSceneDeactivate(t){this.image=await t.engine.screenshot(!0),await this.image.decode()}onInitialize(t){this.engine=t,this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=qt.fromHtmlImageElement(this.image).toSprite(),this.graphics.add(this.screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio),this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class gc extends cs{constructor(t){var e;super({direction:"in",...t}),this._easing=Rt.Linear,this._start=w.Zero,this._end=w.Zero,this.name=`Slide#${this.id}`,this.slideDirection=t.slideDirection,this.transform.coordPlane=rt.Screen,this.graphics.forceOnScreen=!0,this._easing=(e=t.easingFunction)!=null?e:this._easing}async onPreviousSceneDeactivate(t){this._image=await t.engine.screenshot(!0),await this._image.decode(),this._screenCover=qt.fromHtmlImageElement(this._image).toSprite()}onInitialize(t){this._engine=t;let e=t.screen.unsafeArea;switch(e.hasZeroDimensions()&&(e=t.screen.contentArea),this.slideDirection){case"up":{this._directionOffset=b(0,-e.height);break}case"down":{this._directionOffset=b(0,e.height);break}case"left":{this._directionOffset=b(-e.width,0);break}case"right":{this._directionOffset=b(e.width,0);break}}this._camera=this._engine.currentScene.camera,this._destinationCameraPosition=this._camera.pos.clone(),this._camera.pos=this._camera.pos.add(this._directionOffset),this.transform.pos=this.transform.pos.add(this._directionOffset),this._startCameraPosition=this._camera.pos.clone(),this._start=e.topLeft,this._end=this._start.add(this._directionOffset),this.transform.pos=this._start,this.graphics.use(this._screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio)}onStart(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}onUpdate(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}}const pc=Object.freeze(Object.defineProperty({__proto__:null,ConsoleAppender:Cs,DrawUtil:Uh,EasingFunctions:Rt,LogLevel:Le,Logger:R,Observable:gt,ScreenAppender:mr,addItemToArray:Ch,contains:xr,delay:Fi,fail:br,getMinIndex:wr,getPosition:oi,isLegacyEasing:Te,isObject:Di,mergeDeep:Bi,omit:yr,removeItemFromArray:He},Symbol.toStringTag,{value:"Module"})),Aa=5,ti={},mc=()=>{for(const r in ti)ti[r]=0},ds=(r,t)=>{const e=De.isEnabled("suppress-obsolete-message");ti[r]<Aa&&!e&&(R.getInstance().warn(r),console.trace&&t.showStackTrace&&console.trace()),ti[r]++};function vc(r){return r={message:"This feature will be removed in future versions of Excalibur.",alternateMethod:null,showStackTrace:!1,...r},function(t,e,i){if(i&&!(typeof i.value=="function"||typeof i.get=="function"||typeof i.set=="function"))throw new SyntaxError("Only classes/functions/getters/setters can be marked as obsolete");const n=`${`${t.name||""}${t.name&&e?".":""}${e||""}`} is marked obsolete: ${r.message}`+(r.alternateMethod?` Use ${r.alternateMethod} instead`:"");ti[n]||(ti[n]=0);const o=i?{...i}:t;if(!i){class a extends o{constructor(...l){ds(n,r),super(...l)}}return a}return i&&i.value?(o.value=function(){return ds(n,r),i.value.apply(this,arguments)},o):(i&&i.get&&(o.get=function(){return ds(n,r),i.get.apply(this,arguments)}),i&&i.set&&(o.set=function(){return ds(n,r),i.set.apply(this,arguments)}),o)}}class wc{constructor(){this._queue=[]}get length(){return this._queue.length}enqueue(){const t=new wt;return this._queue.push(t),t.promise}dequeue(t){this._queue.shift().resolve(t)}}class xc{constructor(t){this._count=t,this._waitQueue=new wc}get count(){return this._count}get waiting(){return this._waitQueue.length}async enter(){return this._count!==0?(this._count--,Promise.resolve()):this._waitQueue.enqueue()}exit(t=1){if(t!==0){for(;t!==0&&this._waitQueue.length!==0;)this._waitQueue.dequeue(null),t--;this._count+=t}}}const er="0.32.0-alpha.1574+e3aa0be";Fe(),d.ActionCompleteEvent=js,d.ActionContext=fi,d.ActionQueue=eo,d.ActionSequence=Kn,d.ActionStartEvent=Zs,d.ActionsComponent=Qe,d.ActionsSystem=Vn,d.ActivateEvent=Gs,d.Actor=kt,d.ActorEvents=Al,d.AddEvent=Qs,d.AddedComponent=Sh,d.AffineMatrix=Z,d.Animation=zi,d.AnimationDirection=Br,d.AnimationEvents=Dh,d.AnimationStrategy=kr,d.ArcadeSolver=Fn,d.AudioContextFactory=pi,d.Axes=ea,d.Axis=Yo,d.BaseAlign=ln,d.BezierCurve=si,d.Blink=yo,d.BodyComponent=N,d.BoundingBox=F,d.BrowserComponent=$n,d.BrowserEvents=da,d.Buttons=qn,d.Camera=Ko,d.CameraEvents=zl,d.Canvas=Xi,d.ChannelCollection=xa,d.Circle=qi,d.CircleCollider=dt,d.Clock=Zn,d.ClosestLineJumpTable=Vt,d.Collider=ai,d.ColliderComponent=tt,d.CollisionContact=xe,d.CollisionEndEvent=ri,d.CollisionGroup=me,d.CollisionGroupManager=Pi,d.CollisionJumpTable=Ut,d.CollisionPostSolveEvent=Mi,d.CollisionPreSolveEvent=Ri,d.CollisionStartEvent=ni,d.CollisionSystem=Qi,d.CollisionType=M,d.Color=T,d.ColorBlindFlags=la,d.ColorBlindnessMode=$e,d.ColorBlindnessPostProcessor=Qr,d.Component=Dt,d.CompositeCollider=at,d.ConsoleAppender=Cs,d.ContactConstraintPoint=Mo,d.ContactEndEvent=Ii,d.ContactSolveBias=ae,d.ContactStartEvent=Ei,d.CoordPlane=rt,d.CrossFade=fc,d.CurveBy=Eo,d.CurveTo=Po,d.DeactivateEvent=Vs,d.Debug=Tt,d.DebugConfig=ca,d.DebugGraphicsComponent=Wi,d.DebugSystem=Gn,d.DebugText=fn,d.DefaultAntialiasOptions=Or,d.DefaultGarbageCollectionOptions=Qn,d.DefaultLoader=mi,d.DefaultPixelArtOptions=Hr,d.DegreeOfFreedom=le,d.Delay=So,d.Detector=Oo,d.Die=To,d.Direction=dn,d.Director=pa,d.DirectorEvents=ga,d.DisplayMode=gi,d.DynamicTree=en,d.DynamicTreeCollisionProcessor=ki,d.EX_VERSION=er,d.EaseBy=bo,d.EaseTo=xo,d.EasingFunctions=Rt,d.Edge=ws,d.EdgeCollider=St,d.ElasticToActorStrategy=jo,d.EmitterType=Ee,d.Engine=as,d.EngineEvents=ql,d.EnterTriggerEvent=Ys,d.EnterViewPortEvent=Xs,d.Entity=At,d.EntityEvents=Eh,d.EntityManager=Sr,d.EventEmitter=X,d.EventTypes=Ts,d.Events=yh,d.ExResponse=Ln,d.ExcaliburGraphicsContext2DCanvas=Yi,d.ExcaliburGraphicsContextWebGL=$t,d.ExitTriggerEvent=$s,d.ExitViewPortEvent=qs,d.Fade=Co,d.FadeInOut=_c,d.Flags=De,d.Flash=Ao,d.Follow=Pn,d.Font=Se,d.FontCache=Vi,d.FontSource=dc,d.FontStyle=cn,d.FontUnit=an,d.FpsSampler=ua,d.FrameStats=yi,d.Future=wt,d.GameEvent=k,d.GameStartEvent=Is,d.GameStopEvent=Rs,d.Gamepad=ss,d.GamepadAxisEvent=Hs,d.GamepadButtonEvent=Os,d.GamepadConnectEvent=Us,d.GamepadDisconnectEvent=zs,d.Gamepads=is,d.GarbageCollector=wa,d.Gif=lc,d.GifParser=ya,d.GlobalCoordinates=ke,d.GpuParticleEmitter=$l,d.GpuParticleRenderer=hs,d.Graph=vs,d.Graphic=st,d.GraphicsComponent=K,d.GraphicsGroup=We,d.GraphicsSystem=pn,d.HashColliderProxy=Ro,d.HashGridCell=Zt,d.HashGridProxy=In,d.HiddenEvent=Ws,d.HorizontalFirst=nn,d.ImageFiltering=mt,d.ImageSource=qt,d.ImageSourceAttributeConstants=z,d.ImageWrapping=_t,d.InitializeEvent=Oe,d.InputHost=Yn,d.InputMapper=ia,d.IsometricEntityComponent=vi,d.IsometricEntitySystem=Wn,d.IsometricMap=Ul,d.IsometricTile=qo,d.KeyEvent=wi,d.Keyboard=aa,d.Keys=oa,d.KillEvent=As,d.Label=Xl,d.LimitCameraBoundsStrategy=Jo,d.Line=gn,d.LineSegment=Q,d.Loader=Ki,d.LoaderEvents=Fl,d.LockCameraToActorAxisStrategy=Zo,d.LockCameraToActorStrategy=$o,d.LogLevel=Le,d.Logger=R,d.Material=Kr,d.Matrix=Ct,d.MatrixLocations=cr,d.MediaEvent=Un,d.Meet=Zi,d.MotionComponent=O,d.MotionSystem=ji,d.MoveBy=Tn,d.MoveByWithOptions=ro,d.MoveTo=An,d.MoveToWithOptions=ao,d.NativePointerButton=Pe,d.NativeSoundEvent=Ae,d.NativeSoundProcessedEvent=Lo,d.NineSlice=wn,d.NineSliceStretch=zr,d.Node=Ti,d.None=rn,d.Observable=gt,d.OffscreenSystem=mn,d.Pair=pt,d.ParallaxComponent=Gi,d.ParallelActions=Zl,d.Particle=$i,d.ParticleEmitter=Yl,d.ParticleRenderer=Zr,d.ParticleTransform=Xt,d.PhysicsStats=rs,d.PhysicsWorld=Fo,d.PointerAbstraction=Xn,d.PointerButton=ce,d.PointerComponent=he,d.PointerEvent=xi,d.PointerEventReceiver=ns,d.PointerScope=Be,d.PointerSystem=es,d.PointerType=de,d.Polygon=vn,d.PolygonCollider=lt,d.Pool=Ui,d.PositionNode=_r,d.PostCollisionEvent=we,d.PostDebugDrawEvent=Bs,d.PostDrawEvent=ze,d.PostFrameEvent=Ls,d.PostKillEvent=Es,d.PostTransformDrawEvent=Fs,d.PostUpdateEvent=oe,d.PreCollisionEvent=ve,d.PreDebugDrawEvent=Ds,d.PreDrawEvent=Ue,d.PreFrameEvent=ks,d.PreKillEvent=Ps,d.PreLoadEvent=Wl,d.PreTransformDrawEvent=Ms,d.PreUpdateEvent=re,d.Projection=ei,d.QuadIndexBuffer=Ze,d.QuadTree=Je,d.Query=Lt,d.QueryManager=Tr,d.RadiusAroundActorStrategy=Qo,d.Random=se,d.Raster=Ge,d.Ray=ge,d.RealisticSolver=Dn,d.Rectangle=ui,d.RemoveEvent=Js,d.RemovedComponent=Ah,d.RentalPool=qe,d.Repeat=io,d.RepeatForever=so,d.Resolution=Bn,d.Resource=li,d.ResourceEvents=Hh,d.RotateBy=uo,d.RotateByWithOptions=co,d.RotateTo=lo,d.RotateToWithOptions=ho,d.RotationType=j,d.ScaleBy=vo,d.ScaleByWithOptions=mo,d.ScaleTo=go,d.ScaleToWithOptions=fo,d.Scene=Mt,d.SceneEvents=Gl,d.Screen=kn,d.ScreenAppender=mr,d.ScreenElement=Hn,d.ScreenEvents=Pl,d.ScreenShader=jr,d.ScrollPreventionMode=Ke,d.Semaphore=xc,d.SeparatingAxis=Ne,d.SeparationInfo=Mr,d.Shader=Bt,d.Shape=ut,d.Slide=gc,d.SolverStrategy=Li,d.Sound=zn,d.SoundEvents=Rl,d.SoundManager=hc,d.SparseHashGrid=Rn,d.SparseHashGridCollisionProcessor=Mn,d.SpatialPartitionStrategy=hi,d.Sprite=zt,d.SpriteFont=Oi,d.SpriteSheet=ye,d.StandardClock=jn,d.StateMachine=Ji,d.StrategyContainer=Xo,d.Stream=ba,d.System=Et,d.SystemManager=Pr,d.SystemPriority=Gt,d.SystemType=Pt,d.TagQuery=Ks,d.TestClock=_a,d.Text=_i,d.TextAlign=hn,d.TextureLoader=Xe,d.Tile=Vo,d.TileMap=Go,d.TileMapEvents=Ll,d.TiledAnimation=xn,d.TiledSprite=di,d.Timer=ts,d.Toaster=fa,d.Transform=Kt,d.TransformComponent=P,d.Transition=cs,d.TreeNode=tn,d.Trigger=ta,d.TriggerEvents=Ol,d.TwoPI=it,d.UniformBuffer=Nr,d.Util=pc,d.Vector=w,d.VectorView=ps,d.VertexBuffer=Ht,d.VertexLayout=Yt,d.VerticalFirst=sn,d.VisibleEvent=Ns,d.WebAudio=Bo,d.WebAudioInstance=ko,d.WheelDeltaMode=bi,d.WheelEvent=ha,d.World=Er,d.approximatelyEqual=ar,d.assert=Jn,d.canonicalizeAngle=Jt,d.clamp=B,d.coroutine=Ta,d.createId=fe,d.easeInBack=fh,d.easeInBounce=gr,d.easeInCirc=dh,d.easeInCubic=th,d.easeInElastic=mh,d.easeInExpo=hh,d.easeInOutBack=ph,d.easeInOutBounce=xh,d.easeInOutCirc=_h,d.easeInOutCubic=bs,d.easeInOutElastic=wh,d.easeInOutExpo=ch,d.easeInOutQuad=Ka,d.easeInOutQuart=nh,d.easeInOutQuint=ah,d.easeInOutSine=ja,d.easeInQuad=Qa,d.easeInQuart=ih,d.easeInQuint=rh,d.easeInSine=$a,d.easeOutBack=gh,d.easeOutBounce=ys,d.easeOutCirc=uh,d.easeOutCubic=eh,d.easeOutElastic=vh,d.easeOutExpo=lh,d.easeOutQuad=Ja,d.easeOutQuart=sh,d.easeOutQuint=oh,d.easeOutSine=Za,d.frac=Na,d.getDefaultPhysicsConfig=te,d.glTypeToUniformTypeName=Xr,d.hasGraphicsTick=Sn,d.hasOnAdd=nc,d.hasOnInitialize=Kl,d.hasOnPostUpdate=sc,d.hasOnPreUpdate=ec,d.hasOnRemove=rc,d.hasPostDraw=ac,d.hasPreDraw=oc,d.has_add=Ql,d.has_initialize=jl,d.has_postupdate=ic,d.has_preupdate=tc,d.has_remove=Jl,d.inverseLerp=dr,d.inverseLerpVector=ur,d.isActor=Tl,d.isAddedComponent=Th,d.isComponentCtor=vr,d.isLegacyEasing=Te,d.isLoaderConstructor=On,d.isMoveByOptions=no,d.isMoveToOptions=oo,d.isRemovedComponent=Ph,d.isRotateByOptions=Sl,d.isRotateToOptions=Cl,d.isScaleByOptions=po,d.isScaleToOptions=_o,d.isSceneConstructor=jt,d.isScreenElement=Ho,d.isSystemConstructor=Ar,d.lerp=ot,d.lerpAngle=ms,d.lerpVector=ii,d.linear=Ai,d.maxMessages=Aa,d.nextActionId=H,d.obsolete=vc,d.parseImageFiltering=Ve,d.parseImageWrapping=Ot,d.pixelSnapEpsilon=D,d.randomInRange=Nt,d.randomIntInRange=Va,d.range=Ga,d.remap=Wt,d.remapVector=qa,d.resetObsoleteCounter=mc,d.sign=V,d.smootherstep=Ya,d.smoothstep=Xa,d.toDegrees=hr,d.toRadians=Wa,d.vec=b,d.webgl=Yh,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
931
|
+
`,Function.prototype.toString.call(m)):(u=!0,x(c.clock.elapsed())),g),generator:p,done:v,then:v.then.bind(v),[Symbol.iterator]:()=>p};return g}class cs extends At{constructor(t){var e,i,s,n,o;super(),this._logger=R.getInstance(),this.transform=new P,this.graphics=new K,this._completeFuture=new wt,this.started=!1,this._currentDistance=0,this._currentProgress=0,this.done=this._completeFuture.promise,this._useLegacyEasing=!1,this.name=`Transition#${this.id}`,this.duration=t.duration,Te(t.easing)?(this.legacyEasing=(e=t.easing)!=null?e:Rt.Linear,this._useLegacyEasing=!0):this.easing=(i=t.easing)!=null?i:Ai,this.direction=(s=t.direction)!=null?s:"out",this.hideLoader=(n=t.hideLoader)!=null?n:!1,this.blockInput=(o=t.blockInput)!=null?o:!1,this.transform.coordPlane=rt.Screen,this.transform.pos=w.Zero,this.transform.z=1/0,this.graphics.anchor=w.Zero,this.addComponent(this.transform),this.addComponent(this.graphics),this.direction==="out"?this._currentProgress=0:this._currentProgress=1}get progress(){return this._currentProgress}get distance(){return this._currentDistance}get complete(){return this.direction==="out"?this.progress>=1:this.progress<=0}updateTransition(t,e){this.complete||(this._currentDistance+=B(e/this.duration,0,1),this._currentDistance>=1&&(this._currentDistance=1),this.direction==="out"?this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,0,1,1),0,1):this._currentProgress=B(ot(0,1,this.easing(this._currentDistance)),0,1):this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,1,0,1),0,1):this._currentProgress=B(ot(1,0,this.easing(this._currentDistance)),0,1))}async onPreviousSceneDeactivate(t){}onStart(t){}onUpdate(t){}onEnd(t){}onReset(){}reset(){this.started=!1,this._completeFuture=new wt,this.done=this._completeFuture.promise,this._currentDistance=0,this.direction==="out"?this._currentProgress=0:this._currentProgress=1,this.onReset()}_addToTargetScene(t,e){const i=e;if(this.started&&this._logger.warn(`Attempted to add a transition ${this.name} that is already playing.`),i.world.entityManager.getById(this.id))return this._co;this._engine=t,i.add(this);const s=this;return this._co=Ta(t,function*(){for(;!s.complete;){const n=yield;s.updateTransition(s._engine,n),s._execute()}},{autostart:!1}),this._co}async _play(){this.started&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that is already playing, reset transition.`)),(!this._engine||!this._co)&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that hasn't been added`)),this._co&&await this._co.start()}_execute(){this.isInitialized&&(this.started||(this.started=!0,this.onStart(this.progress)),this.onUpdate(this.progress),this.complete&&!this._completeFuture.isCompleted&&(this.onEnd(this.progress),this._completeFuture.resolve()))}}class _c extends cs{constructor(t){var e,i;super({...t,duration:(e=t.duration)!=null?e:2e3}),this.name=`FadeInOut#${this.id}`,this.color=(i=t.color)!=null?i:T.Black}onInitialize(t){this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=new ui({width:t.screen.resolution.width,height:t.screen.resolution.height,color:this.color}),this.graphics.add(this.screenCover),this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=t}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class fc extends cs{constructor(t){super({direction:"in",...t}),this.name=`CrossFade#${this.id}`}async onPreviousSceneDeactivate(t){this.image=await t.engine.screenshot(!0),await this.image.decode()}onInitialize(t){this.engine=t,this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=qt.fromHtmlImageElement(this.image).toSprite(),this.graphics.add(this.screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio),this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class gc extends cs{constructor(t){var e;super({direction:"in",...t}),this._easing=Rt.Linear,this._start=w.Zero,this._end=w.Zero,this.name=`Slide#${this.id}`,this.slideDirection=t.slideDirection,this.transform.coordPlane=rt.Screen,this.graphics.forceOnScreen=!0,this._easing=(e=t.easingFunction)!=null?e:this._easing}async onPreviousSceneDeactivate(t){this._image=await t.engine.screenshot(!0),await this._image.decode(),this._screenCover=qt.fromHtmlImageElement(this._image).toSprite()}onInitialize(t){this._engine=t;let e=t.screen.unsafeArea;switch(e.hasZeroDimensions()&&(e=t.screen.contentArea),this.slideDirection){case"up":{this._directionOffset=b(0,-e.height);break}case"down":{this._directionOffset=b(0,e.height);break}case"left":{this._directionOffset=b(-e.width,0);break}case"right":{this._directionOffset=b(e.width,0);break}}this._camera=this._engine.currentScene.camera,this._destinationCameraPosition=this._camera.pos.clone(),this._camera.pos=this._camera.pos.add(this._directionOffset),this.transform.pos=this.transform.pos.add(this._directionOffset),this._startCameraPosition=this._camera.pos.clone(),this._start=e.topLeft,this._end=this._start.add(this._directionOffset),this.transform.pos=this._start,this.graphics.use(this._screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio)}onStart(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}onUpdate(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}}const pc=Object.freeze(Object.defineProperty({__proto__:null,ConsoleAppender:Cs,DrawUtil:Uh,EasingFunctions:Rt,LogLevel:Le,Logger:R,Observable:gt,ScreenAppender:mr,addItemToArray:Ch,contains:xr,delay:Fi,fail:br,getMinIndex:wr,getPosition:oi,isLegacyEasing:Te,isObject:Di,mergeDeep:Bi,omit:yr,removeItemFromArray:He},Symbol.toStringTag,{value:"Module"})),Aa=5,ti={},mc=()=>{for(const r in ti)ti[r]=0},ds=(r,t)=>{const e=De.isEnabled("suppress-obsolete-message");ti[r]<Aa&&!e&&(R.getInstance().warn(r),console.trace&&t.showStackTrace&&console.trace()),ti[r]++};function vc(r){return r={message:"This feature will be removed in future versions of Excalibur.",alternateMethod:null,showStackTrace:!1,...r},function(t,e,i){if(i&&!(typeof i.value=="function"||typeof i.get=="function"||typeof i.set=="function"))throw new SyntaxError("Only classes/functions/getters/setters can be marked as obsolete");const n=`${`${t.name||""}${t.name&&e?".":""}${e||""}`} is marked obsolete: ${r.message}`+(r.alternateMethod?` Use ${r.alternateMethod} instead`:"");ti[n]||(ti[n]=0);const o=i?{...i}:t;if(!i){class a extends o{constructor(...l){ds(n,r),super(...l)}}return a}return i&&i.value?(o.value=function(){return ds(n,r),i.value.apply(this,arguments)},o):(i&&i.get&&(o.get=function(){return ds(n,r),i.get.apply(this,arguments)}),i&&i.set&&(o.set=function(){return ds(n,r),i.set.apply(this,arguments)}),o)}}class wc{constructor(){this._queue=[]}get length(){return this._queue.length}enqueue(){const t=new wt;return this._queue.push(t),t.promise}dequeue(t){this._queue.shift().resolve(t)}}class xc{constructor(t){this._count=t,this._waitQueue=new wc}get count(){return this._count}get waiting(){return this._waitQueue.length}async enter(){return this._count!==0?(this._count--,Promise.resolve()):this._waitQueue.enqueue()}exit(t=1){if(t!==0){for(;t!==0&&this._waitQueue.length!==0;)this._waitQueue.dequeue(null),t--;this._count+=t}}}const er="0.32.0-alpha.1576+d33ac1f";Fe(),d.ActionCompleteEvent=js,d.ActionContext=fi,d.ActionQueue=eo,d.ActionSequence=Kn,d.ActionStartEvent=Zs,d.ActionsComponent=Qe,d.ActionsSystem=Vn,d.ActivateEvent=Gs,d.Actor=kt,d.ActorEvents=Al,d.AddEvent=Qs,d.AddedComponent=Sh,d.AffineMatrix=Z,d.Animation=zi,d.AnimationDirection=Br,d.AnimationEvents=Dh,d.AnimationStrategy=kr,d.ArcadeSolver=Fn,d.AudioContextFactory=pi,d.Axes=ea,d.Axis=Yo,d.BaseAlign=ln,d.BezierCurve=si,d.Blink=yo,d.BodyComponent=N,d.BoundingBox=F,d.BrowserComponent=$n,d.BrowserEvents=da,d.Buttons=qn,d.Camera=Ko,d.CameraEvents=zl,d.Canvas=Xi,d.ChannelCollection=xa,d.Circle=qi,d.CircleCollider=dt,d.Clock=Zn,d.ClosestLineJumpTable=Vt,d.Collider=ai,d.ColliderComponent=tt,d.CollisionContact=xe,d.CollisionEndEvent=ri,d.CollisionGroup=me,d.CollisionGroupManager=Pi,d.CollisionJumpTable=Ut,d.CollisionPostSolveEvent=Mi,d.CollisionPreSolveEvent=Ri,d.CollisionStartEvent=ni,d.CollisionSystem=Qi,d.CollisionType=M,d.Color=T,d.ColorBlindFlags=la,d.ColorBlindnessMode=$e,d.ColorBlindnessPostProcessor=Qr,d.Component=Dt,d.CompositeCollider=at,d.ConsoleAppender=Cs,d.ContactConstraintPoint=Mo,d.ContactEndEvent=Ii,d.ContactSolveBias=ae,d.ContactStartEvent=Ei,d.CoordPlane=rt,d.CrossFade=fc,d.CurveBy=Eo,d.CurveTo=Po,d.DeactivateEvent=Vs,d.Debug=Tt,d.DebugConfig=ca,d.DebugGraphicsComponent=Wi,d.DebugSystem=Gn,d.DebugText=fn,d.DefaultAntialiasOptions=Or,d.DefaultGarbageCollectionOptions=Qn,d.DefaultLoader=mi,d.DefaultPixelArtOptions=Hr,d.DegreeOfFreedom=le,d.Delay=So,d.Detector=Oo,d.Die=To,d.Direction=dn,d.Director=pa,d.DirectorEvents=ga,d.DisplayMode=gi,d.DynamicTree=en,d.DynamicTreeCollisionProcessor=ki,d.EX_VERSION=er,d.EaseBy=bo,d.EaseTo=xo,d.EasingFunctions=Rt,d.Edge=ws,d.EdgeCollider=St,d.ElasticToActorStrategy=jo,d.EmitterType=Ee,d.Engine=as,d.EngineEvents=ql,d.EnterTriggerEvent=Ys,d.EnterViewPortEvent=Xs,d.Entity=At,d.EntityEvents=Eh,d.EntityManager=Sr,d.EventEmitter=X,d.EventTypes=Ts,d.Events=yh,d.ExResponse=Ln,d.ExcaliburGraphicsContext2DCanvas=Yi,d.ExcaliburGraphicsContextWebGL=$t,d.ExitTriggerEvent=$s,d.ExitViewPortEvent=qs,d.Fade=Co,d.FadeInOut=_c,d.Flags=De,d.Flash=Ao,d.Follow=Pn,d.Font=Se,d.FontCache=Vi,d.FontSource=dc,d.FontStyle=cn,d.FontUnit=an,d.FpsSampler=ua,d.FrameStats=yi,d.Future=wt,d.GameEvent=k,d.GameStartEvent=Is,d.GameStopEvent=Rs,d.Gamepad=ss,d.GamepadAxisEvent=Hs,d.GamepadButtonEvent=Os,d.GamepadConnectEvent=Us,d.GamepadDisconnectEvent=zs,d.Gamepads=is,d.GarbageCollector=wa,d.Gif=lc,d.GifParser=ya,d.GlobalCoordinates=ke,d.GpuParticleEmitter=$l,d.GpuParticleRenderer=hs,d.Graph=vs,d.Graphic=st,d.GraphicsComponent=K,d.GraphicsGroup=We,d.GraphicsSystem=pn,d.HashColliderProxy=Ro,d.HashGridCell=Zt,d.HashGridProxy=In,d.HiddenEvent=Ws,d.HorizontalFirst=nn,d.ImageFiltering=mt,d.ImageSource=qt,d.ImageSourceAttributeConstants=z,d.ImageWrapping=_t,d.InitializeEvent=Oe,d.InputHost=Yn,d.InputMapper=ia,d.IsometricEntityComponent=vi,d.IsometricEntitySystem=Wn,d.IsometricMap=Ul,d.IsometricTile=qo,d.KeyEvent=wi,d.Keyboard=aa,d.Keys=oa,d.KillEvent=As,d.Label=Xl,d.LimitCameraBoundsStrategy=Jo,d.Line=gn,d.LineSegment=Q,d.Loader=Ki,d.LoaderEvents=Fl,d.LockCameraToActorAxisStrategy=Zo,d.LockCameraToActorStrategy=$o,d.LogLevel=Le,d.Logger=R,d.Material=Kr,d.Matrix=Ct,d.MatrixLocations=cr,d.MediaEvent=Un,d.Meet=Zi,d.MotionComponent=O,d.MotionSystem=ji,d.MoveBy=Tn,d.MoveByWithOptions=ro,d.MoveTo=An,d.MoveToWithOptions=ao,d.NativePointerButton=Pe,d.NativeSoundEvent=Ae,d.NativeSoundProcessedEvent=Lo,d.NineSlice=wn,d.NineSliceStretch=zr,d.Node=Ti,d.None=rn,d.Observable=gt,d.OffscreenSystem=mn,d.Pair=pt,d.ParallaxComponent=Gi,d.ParallelActions=Zl,d.Particle=$i,d.ParticleEmitter=Yl,d.ParticleRenderer=Zr,d.ParticleTransform=Xt,d.PhysicsStats=rs,d.PhysicsWorld=Fo,d.PointerAbstraction=Xn,d.PointerButton=ce,d.PointerComponent=he,d.PointerEvent=xi,d.PointerEventReceiver=ns,d.PointerScope=Be,d.PointerSystem=es,d.PointerType=de,d.Polygon=vn,d.PolygonCollider=lt,d.Pool=Ui,d.PositionNode=_r,d.PostCollisionEvent=we,d.PostDebugDrawEvent=Bs,d.PostDrawEvent=ze,d.PostFrameEvent=Ls,d.PostKillEvent=Es,d.PostTransformDrawEvent=Fs,d.PostUpdateEvent=oe,d.PreCollisionEvent=ve,d.PreDebugDrawEvent=Ds,d.PreDrawEvent=Ue,d.PreFrameEvent=ks,d.PreKillEvent=Ps,d.PreLoadEvent=Wl,d.PreTransformDrawEvent=Ms,d.PreUpdateEvent=re,d.Projection=ei,d.QuadIndexBuffer=Ze,d.QuadTree=Je,d.Query=Lt,d.QueryManager=Tr,d.RadiusAroundActorStrategy=Qo,d.Random=se,d.Raster=Ge,d.Ray=ge,d.RealisticSolver=Dn,d.Rectangle=ui,d.RemoveEvent=Js,d.RemovedComponent=Ah,d.RentalPool=qe,d.Repeat=io,d.RepeatForever=so,d.Resolution=Bn,d.Resource=li,d.ResourceEvents=Hh,d.RotateBy=uo,d.RotateByWithOptions=co,d.RotateTo=lo,d.RotateToWithOptions=ho,d.RotationType=j,d.ScaleBy=vo,d.ScaleByWithOptions=mo,d.ScaleTo=go,d.ScaleToWithOptions=fo,d.Scene=Mt,d.SceneEvents=Gl,d.Screen=kn,d.ScreenAppender=mr,d.ScreenElement=Hn,d.ScreenEvents=Pl,d.ScreenShader=jr,d.ScrollPreventionMode=Ke,d.Semaphore=xc,d.SeparatingAxis=Ne,d.SeparationInfo=Mr,d.Shader=Bt,d.Shape=ut,d.Slide=gc,d.SolverStrategy=Li,d.Sound=zn,d.SoundEvents=Rl,d.SoundManager=hc,d.SparseHashGrid=Rn,d.SparseHashGridCollisionProcessor=Mn,d.SpatialPartitionStrategy=hi,d.Sprite=zt,d.SpriteFont=Oi,d.SpriteSheet=ye,d.StandardClock=jn,d.StateMachine=Ji,d.StrategyContainer=Xo,d.Stream=ba,d.System=Et,d.SystemManager=Pr,d.SystemPriority=Gt,d.SystemType=Pt,d.TagQuery=Ks,d.TestClock=_a,d.Text=_i,d.TextAlign=hn,d.TextureLoader=Xe,d.Tile=Vo,d.TileMap=Go,d.TileMapEvents=Ll,d.TiledAnimation=xn,d.TiledSprite=di,d.Timer=ts,d.Toaster=fa,d.Transform=Kt,d.TransformComponent=P,d.Transition=cs,d.TreeNode=tn,d.Trigger=ta,d.TriggerEvents=Ol,d.TwoPI=it,d.UniformBuffer=Nr,d.Util=pc,d.Vector=w,d.VectorView=ps,d.VertexBuffer=Ht,d.VertexLayout=Yt,d.VerticalFirst=sn,d.VisibleEvent=Ns,d.WebAudio=Bo,d.WebAudioInstance=ko,d.WheelDeltaMode=bi,d.WheelEvent=ha,d.World=Er,d.approximatelyEqual=ar,d.assert=Jn,d.canonicalizeAngle=Jt,d.clamp=B,d.coroutine=Ta,d.createId=fe,d.easeInBack=fh,d.easeInBounce=gr,d.easeInCirc=dh,d.easeInCubic=th,d.easeInElastic=mh,d.easeInExpo=hh,d.easeInOutBack=ph,d.easeInOutBounce=xh,d.easeInOutCirc=_h,d.easeInOutCubic=bs,d.easeInOutElastic=wh,d.easeInOutExpo=ch,d.easeInOutQuad=Ka,d.easeInOutQuart=nh,d.easeInOutQuint=ah,d.easeInOutSine=ja,d.easeInQuad=Qa,d.easeInQuart=ih,d.easeInQuint=rh,d.easeInSine=$a,d.easeOutBack=gh,d.easeOutBounce=ys,d.easeOutCirc=uh,d.easeOutCubic=eh,d.easeOutElastic=vh,d.easeOutExpo=lh,d.easeOutQuad=Ja,d.easeOutQuart=sh,d.easeOutQuint=oh,d.easeOutSine=Za,d.frac=Na,d.getDefaultPhysicsConfig=te,d.glTypeToUniformTypeName=Xr,d.hasGraphicsTick=Sn,d.hasOnAdd=nc,d.hasOnInitialize=Kl,d.hasOnPostUpdate=sc,d.hasOnPreUpdate=ec,d.hasOnRemove=rc,d.hasPostDraw=ac,d.hasPreDraw=oc,d.has_add=Ql,d.has_initialize=jl,d.has_postupdate=ic,d.has_preupdate=tc,d.has_remove=Jl,d.inverseLerp=dr,d.inverseLerpVector=ur,d.isActor=Tl,d.isAddedComponent=Th,d.isComponentCtor=vr,d.isLegacyEasing=Te,d.isLoaderConstructor=On,d.isMoveByOptions=no,d.isMoveToOptions=oo,d.isRemovedComponent=Ph,d.isRotateByOptions=Sl,d.isRotateToOptions=Cl,d.isScaleByOptions=po,d.isScaleToOptions=_o,d.isSceneConstructor=jt,d.isScreenElement=Ho,d.isSystemConstructor=Ar,d.lerp=ot,d.lerpAngle=ms,d.lerpVector=ii,d.linear=Ai,d.maxMessages=Aa,d.nextActionId=H,d.obsolete=vc,d.parseImageFiltering=Ve,d.parseImageWrapping=Ot,d.pixelSnapEpsilon=D,d.randomInRange=Nt,d.randomIntInRange=Va,d.range=Ga,d.remap=Wt,d.remapVector=qa,d.resetObsoleteCounter=mc,d.sign=V,d.smootherstep=Ya,d.smoothstep=Xa,d.toDegrees=hr,d.toRadians=Wa,d.vec=b,d.webgl=Yh,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1576+d33ac1f - 2025-11-29
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -15,7 +15,7 @@ Licensed BSD-2-Clause
|
|
|
15
15
|
`}}class ne extends w{constructor(t,e){super(t.x,t.y),this.original=t,this.change=e}get x(){return this._x=this.original.x}set x(t){t!==this._x&&(this.change(t,this._y),this._x=this.original.x=t)}get y(){return this._y=this.original.y}set y(t){t!==this._y&&(this.change(this._x,t),this._y=this.original.y=t)}setTo(t,e){this.x=t,this.y=e}}class Kt{constructor(){this._parent=null,this._children=[],this._pos=new ne(b(0,0),()=>{this.flagDirty()}),this._globalPos=new ps({getX:()=>this.matrix.data[4],getY:()=>this.matrix.data[5],setX:t=>{if(this.parent){const{x:e}=this.parent.inverse.multiply(b(t,this.pos.y));this.pos.x=e}else this.pos.x=t;t!==this.matrix.data[4]&&this.flagDirty()},setY:t=>{if(this.parent){const{y:e}=this.parent.inverse.multiply(b(this.pos.x,t));this.pos.y=e}else this.pos.y=t;t!==this.matrix.data[5]&&this.flagDirty()}}),this._rotation=0,this._scale=new ne(b(1,1),()=>{this.flagDirty()}),this._globalScale=new ps({getX:()=>this.parent?this.matrix.getScaleX():this.scale.x,getY:()=>this.parent?this.matrix.getScaleY():this.scale.y,setX:t=>{if(this.parent){const e=this.parent.globalScale.x;this.scale.x=t/e}else this.scale.x=t},setY:t=>{if(this.parent){const e=this.parent.globalScale.y;this.scale.y=t/e}else this.scale.y=t}}),this._z=0,this._isDirty=!1,this._isInverseDirty=!1,this._matrix=Z.identity(),this._inverse=Z.identity(),this._scratch=Z.identity()}get parent(){return this._parent}set parent(t){if(this._parent){const e=this._parent._children.indexOf(this);e>-1&&this._parent._children.splice(e,1)}this._parent=t,this._parent&&this._parent._children.push(this),this.flagDirty()}get children(){return this._children}set pos(t){this._pos.x=t.x,this._pos.y=t.y}get pos(){return this._pos}set globalPos(t){let e=t.clone();this.parent&&(e=this.parent.inverse.multiply(t)),e.equals(this._pos)||(this._pos=e,this.flagDirty())}get globalPos(){return this._globalPos}set rotation(t){const e=Jt(t);e!==this._rotation&&this.flagDirty(),this._rotation=e}get rotation(){return this._rotation}set globalRotation(t){let e=0;this.parent&&(e=this.parent.globalRotation);const i=Jt(t+e);i!==this._rotation&&this.flagDirty(),this._rotation=i}get globalRotation(){return this.parent?this.matrix.getRotation():this.rotation}set scale(t){this._scale.x=t.x,this._scale.y=t.y}get scale(){return this._scale}set globalScale(t){let e=b(1,1);this.parent&&(e=this.parent.globalScale),this.scale=t.scale(b(1/e.x,1/e.y))}get globalScale(){return this._globalScale}set z(t){this._z=t,this.flagDirty()}get z(){return this._z}set globalZ(t){this.parent?this.z=t-this.parent.globalZ:this.z=t}get globalZ(){return this.parent?this.z+this.parent.globalZ:this.z}get matrix(){return this._isDirty&&(this.parent===null?this._calculateMatrix().clone(this._matrix):this.parent.matrix.multiply(this._calculateMatrix()).clone(this._matrix),this._isDirty=!1),this._matrix}get inverse(){return this._isInverseDirty&&(this.matrix.inverse(this._inverse),this._isInverseDirty=!1),this._inverse}_calculateMatrix(){return this._scratch.data[0]=Math.cos(this._rotation),this._scratch.data[1]=Math.sin(this._rotation),this._scratch.data[2]=-Math.sin(this._rotation),this._scratch.data[3]=Math.cos(this.rotation),this._scratch.data[4]=this._pos.x,this._scratch.data[5]=this._pos.y,this._scratch.scale(this._scale.x,this._scale.y),this._scratch}flagDirty(){this._isDirty=!0,this._isInverseDirty=!0;for(let t=0;t<this._children.length;t++)this._children[t].flagDirty()}apply(t){return this.matrix.multiply(t)}applyInverse(t){return this.inverse.multiply(t)}setTransform(t,e,i){this._pos.x=t.x,this._pos.y=t.y,this._rotation=Jt(e),this._scale.x=i.x,this._scale.y=i.y,this.flagDirty()}isMirrored(){const t=V(this.scale.x)>>>31,e=V(this.scale.y)>>>31;return!!(t^e)}clone(t){const e=t!=null?t:new Kt;return this._pos.clone(e._pos),e._z=this._z,e._rotation=this._rotation,this._scale.clone(e._scale),e.flagDirty(),e}cloneWithParent(t){const e=t!=null?t:new Kt;return this._pos.clone(e._pos),e._z=this._z,e._rotation=this._rotation,this._scale.clone(e._scale),e.parent=this.parent,e.flagDirty(),e}toString(){return this.matrix.toString()}}var rt=(r=>(r.World="world",r.Screen="screen",r))(rt||{});class ke{constructor(t,e,i){this.worldPos=t,this.pagePos=e,this.screenPos=i}static fromPagePosition(t,e,i){let s,n,o,a;arguments.length===3?(s=t,n=e,o=new w(s,n),a=i):(o=t,s=o.x,n=o.y,a=e);const h=a.screen.pageToScreenCoordinates(o),l=a.screen.screenToWorldCoordinates(h);return new ke(l,o,h)}}class Q{constructor(t,e){this.begin=t,this.end=e}clone(t){const e=t||new Q(this.begin.clone(),this.end.clone());return e.begin=this.begin.clone(e.begin),e.end=this.end.clone(e.end),e}transform(t,e){const i=e||new Q(w.Zero,w.Zero);return i.begin=t.multiply(this.begin,i.begin),i.end=t.multiply(this.end,i.end),i}get slope(){return(this.end.y-this.begin.y)/(this.end.x-this.begin.x)}get intercept(){return this.begin.y-this.slope*this.begin.x}normal(){return this._normal?this._normal:this._normal=this.end.sub(this.begin).normal()}dir(){return this._dir?this._dir:this._dir=this.end.sub(this.begin)}getPoints(){return[this.begin,this.end]}getSlope(){if(this._slope)return this._slope;const t=this.begin,e=this.end,i=t.distance(e);return this._slope=e.sub(t).scale(1/i)}getEdge(){const t=this.begin;return this.end.sub(t)}getLength(){const t=this.begin,e=this.end;return t.distance(e)}get midpoint(){return this.begin.add(this.end).scale(.5)}flip(){return new Q(this.end,this.begin)}below(t){return(this.end.x-this.begin.x)*(t.y-this.begin.y)-(this.end.y-this.begin.y)*(t.x-this.begin.x)>=0}clip(t,e,i=!0){let s=t;i&&(s=s.normalize());const n=s.dot(this.begin)-e,o=s.dot(this.end)-e,a=[];if(n<=0&&a.push(this.begin),o<=0&&a.push(this.end),n*o<0){const h=n/(n-o);a.push(this.begin.add(this.end.sub(this.begin).scale(h)))}return a.length!==2?null:new Q(a[0],a[1])}distanceToPoint(t,e=!1){const i=t.x,s=t.y,n=this.getLength(),o=this.end.y-this.begin.y,a=this.end.x-this.begin.x,h=(o*i-a*s+this.end.x*this.begin.y-this.end.y*this.begin.x)/n;return e?h:Math.abs(h)}findVectorToPoint(t){const e=this.begin.sub(t),i=this.getSlope();return e.sub(i.scale(e.dot(i)))}findPoint(t=null,e=null){const i=this.slope,s=this.intercept;if(t!==null)return new w(t,i*t+s);if(e!==null)return new w((e-s)/i,e);throw new Error("You must provide an X or a Y value")}hasPoint(){let t,e=0;if(typeof arguments[0]=="number"&&typeof arguments[1]=="number")t=new w(arguments[0],arguments[1]),e=arguments[2]||0;else if(arguments[0]instanceof w)t=arguments[0],e=arguments[1]||0;else throw"Could not determine the arguments for Vector.hasPoint";const i=t.x-this.begin.x,s=t.y-this.begin.y,n=this.end.x-this.begin.x,o=this.end.y-this.begin.y,a=i*o-s*n;return Math.abs(a)>e?!1:Math.abs(n)>=Math.abs(o)?n>0?this.begin.x<=t.x&&t.x<=this.end.x:this.end.x<=t.x&&t.x<=this.begin.x:o>0?this.begin.y<=t.y&&t.y<=this.end.y:this.end.y<=t.y&&t.y<=this.begin.y}}class ei{constructor(t,e){this.min=t,this.max=e}overlaps(t){return this.max>t.min&&t.max>this.min}getOverlap(t){return this.overlaps(t)?this.max>t.max?t.max-this.min:this.max-t.min:0}}class ge{constructor(t,e){this.pos=t,this.dir=e.normalize()}intersect(t){const e=t.begin.sub(this.pos);if(this.dir.cross(t.getSlope())===0&&e.cross(this.dir)!==0)return-1;const i=this.dir.cross(t.getSlope());if(i===0)return-1;const s=e.cross(t.getSlope())/i;if(s>=0){const n=e.cross(this.dir)/i/t.getLength();if(n>=0&&n<=1)return s}return-1}intersectPoint(t){const e=this.intersect(t);return e<0?null:this.getPoint(e)}getPoint(t){return this.pos.add(this.dir.scale(t))}}function ot(r,t,e){return(1-e)*r+t*e}function ms(r,t,e,i){const s=(r-t+it)%it>=Math.PI,n=Math.abs(t-r),o=it-n;let a=0,h=0;n>o?(a=o,h=n):(a=n,h=o);let l=0,c=1;switch(e){case j.ShortestPath:l=a,c=s?1:-1;break;case j.LongestPath:l=h,c=s?-1:1;break;case j.Clockwise:c=1,l=s?a:h;break;case j.CounterClockwise:c=-1,l=s?h:a;break}return r+c*(l*i)}function ii(r,t,e){return r.scale(1-e).add(t.scale(e))}function dr(r,t,e){return(e-r)/(t-r)}function ur(r,t,e){const i=e.sub(r),s=t.sub(r),n=i.x/s.x,o=i.y/s.y;return Math.min(n,o)}function Wt(r,t,e,i,s){const n=dr(r,t,s);return ot(e,i,n)}function qa(r,t,e,i,s){const n=ur(r,t,s);return ii(e,i,n)}class si{constructor(t){this._distLookup=[],this.quality=4;var e;if(t.controlPoints.length!==4)throw new Error("Only cubic bezier curves are supported");this._controlPoints=[...t.controlPoints],this.quality=(e=t.quality)!=null?e:this.quality,this._calculateLookup()}get arcLength(){return this._arcLength}get controlPoints(){return this._controlPoints}set controlPoints(t){this._controlPoints=[...t],this._calculateLookup()}setControlPoint(t,e){this._controlPoints[t]=e,this._calculateLookup()}_calculateLookup(){let t=0;this._distLookup.length=0;let e=this.controlPoints[0];const i=this.controlPoints.length*this.quality;for(let s=0;s<i;s++){const n=s/(i-1),o=this.getPoint(n),a=e.distance(o);t+=a,this._distLookup.push(t),e=o}this._arcLength=t}_getTimeGivenDistance(t){const e=this._distLookup.length,i=this.arcLength;if(t>=0&&t<i){for(let s=0;s<e-1;s++)if(this._distLookup[s]<=t&&t<this._distLookup[s+1])return Wt(this._distLookup[s],this._distLookup[s+1],s/(e-1),(s+1)/(e-1),t)}return t/i}getPoint(t){const e=[...this.controlPoints];for(let i=1;i<e.length;i++)for(let s=0;s<e.length-i;s++)e[s]=ii(e[s],e[s+1],t);return e[0]}getTangent(t){const e=t*t,i=this.controlPoints[0],s=this.controlPoints[1],n=this.controlPoints[2],o=this.controlPoints[3];return i.scale(-3*e+6*t-3).add(s.scale(9*e-12*t+3).add(n.scale(-9*e+6*t).add(o.scale(3*e)))).normalize()}getUniformTangent(t){const e=t*this.arcLength,i=this._getTimeGivenDistance(e);return this.getTangent(i)}getNormal(t){return this.getTangent(t).normal()}getUniformNormal(t){return this.getUniformTangent(t).normal()}getUniformPoint(t){const e=t*this.arcLength,i=this._getTimeGivenDistance(e);return this.getPoint(i)}clone(){return new si({controlPoints:[...this.controlPoints],quality:this.quality})}}class vs{constructor(){this.id=xs.generateUUID(),this._nodes=new Map,this._edges=new Set,this.adjacencyList=new Map}addNode(t,e){let i;return e?i=new _r(t,e):i=new Ti(t),this._nodes.set(i.id,i),this.adjacencyList.set(i.id,new Set),i}addNodes(t){for(const e of t){const i=new Ti(e);this._nodes.set(i.id,i),this.adjacencyList.set(i.id,new Set)}return this._nodes}deleteNode(t){const e=t.edges;for(const i of e)this.deleteEdge(i);return this.adjacencyList.forEach((i,s)=>{i.delete(t.id)}),this._nodes.delete(t.id),this.adjacencyList.delete(t.id),this._nodes}addEdge(t,e,i){var s,n;if(Array.from(this._edges).find(l=>l.source.id===t.id&&l.target.id===e.id))return[];let a;i?a="directed"in i?i.directed:!1:a=!1;const h=new ws(t,e,i);if(this._edges.add(h),t.registerNewEdge(h),e.registerNewEdge(h),(s=this.adjacencyList.get(t.id))==null||s.add(e.id),!a){const l=new ws(e,t,i);return(n=this.adjacencyList.get(e.id))==null||n.add(t.id),this._edges.add(l),e.registerNewEdge(l),t.registerNewEdge(l),h.linkWithPartner(l),l.linkWithPartner(h),[h,l]}return[h]}deleteEdge(t){t.source.breakEdge(t),t.target.breakEdge(t),this._edges.delete(t);const e=t.partnerEdge;e&&(e.source.breakEdge(e),e.target.breakEdge(e),this._edges.delete(e))}get nodes(){return this._nodes}getNode(t){return this._nodes.get(t)}get edges(){return this._edges}getNeighbors(t){var e;return Array.from((e=this.adjacencyList.get(t.id))!=null?e:[]).map(i=>this.nodes.get(i))}areNodesConnected(t,e){var i,s;return(s=(i=this.adjacencyList.get(t.id))==null?void 0:i.has(e.id))!=null?s:!1}bfs(t){if(!this._nodes.has(t.id))return[];const e=[t.id],i=new Set([t.id]);for(;e.length>0;){const s=e.shift(),n=this.adjacencyList.get(s)||new Set;for(const o of n)i.has(o)||(i.add(o),e.push(o))}return Array.from(i)}dfs(t,e=new Set){var i;const s=t.id;if(!this._nodes.has(s))return[];e.add(s);let n=[s];for(const o of(i=this.adjacencyList.get(s))!=null?i:[])e.has(o)||(n=n.concat(this.dfs(this._nodes.get(o),e)));return n}static createGraphFromNodes(t){const e=new vs;return e.addNodes(t),e}dijkstra(t){const e=[],i=[],s=[];this.nodes.forEach(l=>i.push(l)),this.nodes.forEach(l=>s.push({node:l,distance:1/0,previous:null}));const n=s.findIndex(l=>l.node===t);if(n===-1)return[];s[n].distance=0,e.push(t),i.splice(i.indexOf(t),1);let o=t;const a=o.edges,h=Array.from(a).filter(l=>l.target!==o);for(const l of h){const c=s.findIndex(u=>u.node===l.target);if(c===-1)return[];s[c].distance=l.weight,s[c].previous=o}for(;i.length>0;){let l=[],c=[];c=s.filter(m=>i.includes(m.node)),l=c.map(m=>m.node);let u=1/0,_=-1;if(l.length>0)for(let m=0;m<l.length;m++){const p=l[m],x=s.findIndex(v=>v.node===p);s[x].distance<u&&(u=s[x].distance,_=x)}else{u=1/0,_=-1;for(let m=0;m<i.length;m++){const p=i[m],x=s.findIndex(v=>v.node===p);s[x].distance<u&&(u=s[x].distance,_=x)}}if(_===-1)return[];o=s[_].node;let f=Array.from(o.edges);f=f.filter(m=>!e.includes(m.source)&&!e.includes(m.target)&&m.target!==o),e.push(o),i.splice(i.indexOf(o),1);for(let m=0;m<f.length;m++){const p=f[m],x=s.findIndex(S=>S.node===p.target),v=s.findIndex(S=>S.node===p.source),y=s[v].distance+p.weight;y<s[x].distance&&(s[x].distance=y,s[x].previous=o)}}return s}shortestPathDijkstra(t,e){var i,s;const n=this.dijkstra(t);if(n.length===0)return{path:[],distance:1/0};const o=[];let a=e;const h=(i=n.find(l=>l.node===e))==null?void 0:i.distance;for(;a!=null&&(o.push(a),a=(s=n.find(l=>l.node===a))==null?void 0:s.previous,a!=null););return o.reverse(),{path:o,distance:h}}aStar(t,e){if(!("pos"in t)||!("pos"in e))throw new Error("A* algorithm requires PositionNode with position vectors");const i=new Set([t.id]),s=new Set,n=new Set,o=new Map,a=new Map,h=new Map,l=new Map,c=new Map;for(const[u,_]of this._nodes)"pos"in _?c.set(u,_):n.add(u);for(const[u]of c)o.set(u,this._euclideanDistance(c.get(u),t)),a.set(u,this._euclideanDistance(c.get(u),e)),h.set(u,o.get(u)+a.get(u)),l.set(u,null);for(;i.size>0;){let u=null,_=1/0;for(const p of i){const x=h.get(p)||1/0;x<_&&(_=x,u=p)}if(u===null)break;if(u===e.id){const p=[];let x=e.id;for(;x!==null;){const v=this._nodes.get(x);p.unshift(v),x=l.get(x)}return{path:p,pathSteps:p.length-1,distance:o.get(e.id)||1/0,skippedNodes:n}}i.delete(u),s.add(u);const f=this._nodes.get(u),m=this.getNeighbors(f);for(const p of m){const x=p.id;s.has(x)||!("pos"in p)||!Array.from(f.edges).find(y=>y.source.id===u&&y.target.id===x)||(l.set(x,u),i.has(x)||i.add(x))}}return{path:[],pathSteps:0,distance:1/0,skippedNodes:n}}_euclideanDistance(t,e){const i=t.pos,s=e.pos;return Math.sqrt((s.x-i.x)**2+(s.y-i.y)**2)}}class ws{constructor(t,e,i){this._id=xs.generateUUID(),this._weight=0,this._partnerEdge=null,this._source=t,this._target=e,i&&i.weight?this._weight=i.weight:i&&i.useEuclidean?this._weight=t.pos.distance(e.pos):this._weight=0}linkWithPartner(t){this._partnerEdge=t}get id(){return this._id}get source(){return this._source}get target(){return this._target}get weight(){return this._weight}get partnerEdge(){return this._partnerEdge}}class Ti{constructor(t){this._id=xs.generateUUID(),this._data=t,this._edges=new Set}get id(){return this._id}get data(){return this._data}get edges(){return this._edges}registerNewEdge(t){this._edges.add(t)}breakEdge(t){this._edges.delete(t)}getConnectedNodes(){return Array.from(this._edges).map(t=>t.target)}}class _r extends Ti{constructor(t,e){super(t),this.pos=e}}const fr=class Da{static generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){const s=Da.rng.next()*16|0;return(i==="x"?s:s&3|8).toString(16)})}};fr.rng=new se;let xs=fr;function Ai(r){return r}function Xa(r,t,e){return r=B((r-t)/(e-t),0,1),r*r*(3-2*r)}function Ya(r,t,e){return r=B((r-t)/(e-t),0,1),r*r*r*(r*(6*r-15)+10)}function $a(r){return-1*Math.cos(r*(Math.PI/2))+1}function Za(r){return Math.sin(r*(Math.PI/2))}function ja(r){return-.5*(Math.cos(Math.PI*r)-1)}function Qa(r){return r*r}function Ja(r){return r*(2-r)}function Ka(r){return r<.5?2*r*r:-1+(4-2*r)*r}function th(r){return r*r*r}function eh(r){const t=r-1;return t*t*t+1}function bs(r){return r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1}function ih(r){return r*r*r*r}function sh(r){const t=r-1;return 1-t*t*t*t}function nh(r){const t=r-1;return r<.5?8*r*r*r*r:1-8*t*t*t*t}function rh(r){return r*r*r*r*r}function oh(r){const t=r-1;return 1+t*t*t*t*t}function ah(r){const t=r-1;return r<.5?16*r*r*r*r*r:1+16*t*t*t*t*t}function hh(r){return r===0?0:Math.pow(2,10*(r-1))}function lh(r){return r===1?1:-Math.pow(2,-10*r)+1}function ch(r){if(r===0||r===1)return r;const t=r*2,e=t-1;return t<1?.5*Math.pow(2,10*e):.5*(-Math.pow(2,-10*e)+2)}function dh(r){const t=r/1;return-1*(Math.sqrt(1-t*r)-1)}function uh(r){const t=r-1;return Math.sqrt(1-t*t)}function _h(r){const t=r*2,e=t-2;return t<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-e*e)+1)}function fh(r,t=1.70158){return r*r*((t+1)*r-t)}function gh(r,t=1.70158){const e=r/1-1;return e*e*((t+1)*e+t)+1}function ph(r,t=1.70158){const e=r*2,i=e-2,s=t*1.525;return e<1?.5*e*e*((s+1)*e-s):.5*(i*i*((s+1)*i+s)+2)}function mh(r,t=.7){if(r===0||r===1)return r;const i=r/1-1,s=1-t,n=s/(2*Math.PI)*Math.asin(1);return-(Math.pow(2,10*i)*Math.sin((i-n)*(2*Math.PI)/s))}function vh(r,t=.7){if(r===0||r===1)return r;const e=1-t,i=r*2,s=e/(2*Math.PI)*Math.asin(1);return Math.pow(2,-10*i)*Math.sin((i-s)*(2*Math.PI)/e)+1}function wh(r,t=.65){if(r===0||r===1)return r;const e=1-t,i=r*2,s=i-1,n=e/(2*Math.PI)*Math.asin(1);return i<1?-.5*(Math.pow(2,10*s)*Math.sin((s-n)*(2*Math.PI)/e)):Math.pow(2,-10*s)*Math.sin((s-n)*(2*Math.PI)/e)*.5+1}function ys(r){const t=r/1;if(t<1/2.75)return 7.5625*t*t;if(t<2/2.75){const e=t-.5454545454545454;return 7.5625*e*e+.75}else if(t<2.5/2.75){const e=t-.8181818181818182;return 7.5625*e*e+.9375}else{const e=t-.9545454545454546;return 7.5625*e*e+.984375}}function gr(r){return 1-ys(1-r)}function xh(r){return r<.5?gr(r*2)*.5:ys(r*2-1)*.5+.5}class T{constructor(t,e,i,s){this.r=t,this.g=e,this.b=i,this.a=s!=null?s:1}static fromRGB(t,e,i,s){return new T(t,e,i,s)}static fromRGBString(t){const e=/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/i;let i=null;if(i=t.match(e)){const s=parseInt(i[1],10),n=parseInt(i[2],10),o=parseInt(i[3],10);let a=1;return i[4]&&(a=parseFloat(i[4])),new T(s,n,o,a)}else throw new Error("Invalid rgb/a string: "+t)}static fromHex(t){const e=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i;let i=null;if(i=t.match(e)){const s=parseInt(i[1],16),n=parseInt(i[2],16),o=parseInt(i[3],16);let a=1;return i[4]&&(a=parseInt(i[4],16)/255),new T(s,n,o,a)}else throw new Error("Invalid hex string: "+t)}static fromHSL(t,e,i,s=1){return new xt(t,e,i,s).toRGBA()}lighten(t=.1){const e=xt.fromRGBA(this.r,this.g,this.b,this.a);return e.l+=(1-e.l)*t,e.toRGBA()}darken(t=.1){const e=xt.fromRGBA(this.r,this.g,this.b,this.a);return e.l-=e.l*t,e.toRGBA()}saturate(t=.1){const e=xt.fromRGBA(this.r,this.g,this.b,this.a);return e.s+=e.s*t,e.toRGBA()}desaturate(t=.1){const e=xt.fromRGBA(this.r,this.g,this.b,this.a);return e.s-=e.s*t,e.toRGBA()}multiply(t){const e=t.r/255*this.r/255*255,i=t.g/255*this.g/255*255,s=t.b/255*this.b/255*255,n=t.a*this.a;return new T(e,i,s,n)}screen(t){const e=t.invert(),i=t.invert();return e.multiply(i).invert()}invert(){return new T(255-this.r,255-this.g,255-this.b,1-this.a)}average(t){const e=(t.r+this.r)/2,i=(t.g+this.g)/2,s=(t.b+this.b)/2,n=(t.a+this.a)/2;return new T(e,i,s,n)}equal(t){return this.toString()===t.toString()}toString(t="rgb"){switch(t){case"rgb":return this.toRGBA();case"hsl":return this.toHSLA();case"hex":return this.toHex();default:throw new Error("Invalid Color format")}}_componentToHex(t){const e=Math.max(Math.round(t),0).toString(16);return e.length===1?"0"+e:e}toHex(){let t="#"+this._componentToHex(this.r)+this._componentToHex(this.g)+this._componentToHex(this.b);return this.a!==1&&(t+=this._componentToHex(this.a*255)),t}toRGBA(){const t=String(this.r.toFixed(0))+", "+String(this.g.toFixed(0))+", "+String(this.b.toFixed(0));return this.a!==void 0||this.a!==null?"rgba("+t+", "+String(this.a)+")":"rgb("+t+")"}toHSLA(){return xt.fromRGBA(this.r,this.g,this.b,this.a).toString()}fillStyle(){return this.toString()}clone(t){const e=t||new T(this.r,this.g,this.b,this.a);return e.r=this.r,e.g=this.g,e.b=this.b,e.a=this.a,e}static lerp(t,e,i){const s=xt.fromRGBA(t.r,t.g,t.b,t.a),n=xt.fromRGBA(e.r,e.g,e.b,e.a);return xt.lerp(s,n,i).toRGBA()}static random(t){const e=t!=null?t:new se;return new T(e.integer(0,255),e.integer(0,255),e.integer(0,255))}static get Black(){return T.fromHex("#000000")}static get White(){return T.fromHex("#FFFFFF")}static get Gray(){return T.fromHex("#808080")}static get LightGray(){return T.fromHex("#D3D3D3")}static get DarkGray(){return T.fromHex("#A9A9A9")}static get Yellow(){return T.fromHex("#FFFF00")}static get Orange(){return T.fromHex("#FFA500")}static get Red(){return T.fromHex("#FF0000")}static get Vermilion(){return T.fromHex("#FF5B31")}static get Rose(){return T.fromHex("#FF007F")}static get Pink(){return T.fromHex("#FFC0CB")}static get Magenta(){return T.fromHex("#FF00FF")}static get Violet(){return T.fromHex("#7F00FF")}static get Purple(){return T.fromHex("#800080")}static get Blue(){return T.fromHex("#0000FF")}static get Azure(){return T.fromHex("#007FFF")}static get Cyan(){return T.fromHex("#00FFFF")}static get Viridian(){return T.fromHex("#59978F")}static get Teal(){return T.fromHex("#008080")}static get Green(){return T.fromHex("#00FF00")}static get Chartreuse(){return T.fromHex("#7FFF00")}static get Transparent(){return T.fromHex("#FFFFFF00")}static get ExcaliburBlue(){return T.fromHex("#176BAA")}static get Brown(){return T.fromHex("#964B00")}}class xt{constructor(t,e,i,s){this.h=t,this.s=e,this.l=i,this.a=s}static hue2rgb(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+(e-t)*6*i:i<1/2?e:i<2/3?t+(e-t)*(2/3-i)*6:t}static fromRGBA(t,e,i,s){t/=255,e/=255,i/=255;const n=Math.max(t,e,i),o=Math.min(t,e,i);let a,h;const l=(n+o)/2;if(n===o)a=h=0;else{const c=n-o;switch(h=l>.5?c/(2-n-o):c/(n+o),n){case t:a=(e-i)/c+(e<i?6:0);break;case e:a=(i-t)/c+2;break;case i:a=(t-e)/c+4;break}a/=6}return new xt(a,h,l,s)}toRGBA(){let t,e,i;if(this.s===0)t=e=i=this.l;else{const s=this.l<.5?this.l*(1+this.s):this.l+this.s-this.l*this.s,n=2*this.l-s;t=xt.hue2rgb(n,s,this.h+1/3),e=xt.hue2rgb(n,s,this.h),i=xt.hue2rgb(n,s,this.h-1/3)}return new T(t*255,e*255,i*255,this.a)}toString(){const t=this.h.toFixed(0),e=this.s.toFixed(0),i=this.l.toFixed(0),s=this.a.toFixed(0);return`hsla(${t}, ${e}, ${i}, ${s})`}static lerp(t,e,i){i=Math.max(0,Math.min(1,i));let s=e.h-t.h;s>.5?s-=1:s<-.5&&(s+=1);const n=(t.h+s*i+1)%1,o=t.s+(e.s-t.s)*i,a=t.l+(e.l-t.l)*i,h=t.a+(e.a-t.a)*i;return new xt(n,o,a,h)}}var Le=(r=>(r[r.Debug=0]="Debug",r[r.Info=1]="Info",r[r.Warn=2]="Warn",r[r.Error=3]="Error",r[r.Fatal=4]="Fatal",r))(Le||{});const pr=class ee{constructor(){if(this._appenders=[],this.defaultLevel=1,this._logOnceSet=new Set,ee._INSTANCE)throw new Error("Logger is a singleton");return ee._INSTANCE=this,ee._INSTANCE.addAppender(new Cs),ee._INSTANCE}static getInstance(){return ee._INSTANCE==null&&(ee._INSTANCE=new ee),ee._INSTANCE}addAppender(t){this._appenders.push(t)}clearAppenders(){this._appenders.length=0}_log(t,e){t==null&&(t=this.defaultLevel);const i=this._appenders.length;for(let s=0;s<i;s++)t>=this.defaultLevel&&this._appenders[s].log(t,e)}_logOnce(t,e){const i=t+e.join("+");this._logOnceSet.has(i)||(this._logOnceSet.add(i),this._log(t,e))}debug(...t){this._log(0,t)}debugOnce(...t){this._logOnce(0,t)}info(...t){this._log(1,t)}infoOnce(...t){this._logOnce(1,t)}warn(...t){this._log(2,t)}warnOnce(...t){this._logOnce(2,t)}error(...t){this._log(3,t)}errorOnce(...t){this._logOnce(3,t)}fatal(...t){this._log(4,t)}fatalOnce(...t){this._logOnce(4,t)}};pr._INSTANCE=null;let R=pr;class Cs{log(t,e){if(!console&&!console.log&&console.warn&&console.error)return;const i=[];i.unshift.apply(i,e),i.unshift("["+Le[t]+"] : "),t<2?console.log.apply?console.log.apply(console,i):console.log(i.join(" ")):t<3?console.warn.apply?console.warn.apply(console,i):console.warn(i.join(" ")):console.error.apply?console.error.apply(console,i):console.error(i.join(" "))}}class mr{constructor(t){this._messages=[],this._pos=10,this._color=T.Black;var e,i;this._options=t,this.canvas=document.createElement("canvas"),this._ctx=this.canvas.getContext("2d"),this.canvas.style.position="absolute",this.canvas.style.zIndex=(i=(e=t.zIndex)==null?void 0:e.toString())!=null?i:"99",this.canvas.style.pointerEvents="none",this.canvas.style.userSelect="none",document.body.appendChild(this.canvas),this._positionScreenAppenderCanvas(),t.engine.screen.events.on("resize",()=>{this._positionScreenAppenderCanvas()})}_positionScreenAppenderCanvas(){var t,e,i,s;const n=this._options;this.canvas.width=(t=n.width)!=null?t:n.engine.screen.resolution.width,this.canvas.height=(e=n.height)!=null?e:n.engine.screen.resolution.height,this.canvas.style.position="absolute";const o=n.engine.screen.screenToPageCoordinates(b(0,0));this.canvas.style.left=o.x+"px",this.canvas.style.top=o.y+"px",this._pos=(i=n.xPos)!=null?i:this._pos,this._color=(s=n.color)!=null?s:this._color}log(t,e){const i=e.join(",");this._ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this._messages.unshift("["+Le[t]+"] : "+i);let s=10;this._messages=this._messages.slice(0,1e3);for(let n=0;n<this._messages.length;n++)this._ctx.fillStyle=this._color.toRGBA(),this._ctx.fillText(this._messages[n],this._pos,s),s+=10}}var M=(r=>(r.PreventCollision="PreventCollision",r.Passive="Passive",r.Active="Active",r.Fixed="Fixed",r))(M||{});function vr(r){return!!r&&!!r.prototype&&!!r.prototype.constructor}function bh(r){return!!(r!=null&&r.clone)}class Dt{constructor(){this.owner=void 0}clone(){const t=new this.constructor;for(const e in this)if(this.hasOwnProperty(e)){const i=this[e];bh(i)&&e!=="owner"&&e!=="clone"?t[e]=i.clone():t[e]=i}return t}}class gt{constructor(){this.observers=[],this.subscriptions=[]}register(t){this.observers.push(t)}subscribe(t){this.subscriptions.push(t)}unregister(t){const e=this.observers.indexOf(t);e!==-1&&this.observers.splice(e,1)}unsubscribe(t){const e=this.subscriptions.indexOf(t);e!==-1&&this.subscriptions.splice(e,1)}notifyAll(t){const e=this.observers.length;for(let s=0;s<e;s++)this.observers[s].notify(t);const i=this.subscriptions.length;for(let s=0;s<i;s++)this.subscriptions[s](t)}clear(){this.observers.length=0,this.subscriptions.length=0}}class P extends Dt{constructor(){super(...arguments),this._logger=R.getInstance(),this._parentComponent=null,this._transform=new Kt,this._addChildTransform=t=>{const e=t.get(P);e&&(e._transform.parent=this._transform,e._parentComponent=this)},this.zIndexChanged$=new gt,this._coordPlane=rt.World}get(){return this._transform}onAdd(t){for(const e of t.children)this._addChildTransform(e);t.childrenAdded$.subscribe(e=>this._addChildTransform(e)),t.childrenRemoved$.subscribe(e=>{const i=e.get(P);i&&(i._transform.parent=null,i._parentComponent=null)})}onRemove(t){this._transform.parent=null,this._parentComponent=null}get z(){return this._transform.z}set z(t){const e=this._transform.z;this._transform.z=t,e!==t&&this.zIndexChanged$.notifyAll(t)}get globalZ(){return this._transform.globalZ}set globalZ(t){this._transform.globalZ=t}get coordPlane(){return this._parentComponent?this._parentComponent.coordPlane:this._coordPlane}set coordPlane(t){var e;this._parentComponent?this._logger.warn(`Cannot set coordinate plane on child entity ${(e=this.owner)==null?void 0:e.name}, children inherit their coordinate plane from their parents.`):this._coordPlane=t}get pos(){return this._transform.pos}set pos(t){this._transform.pos=t}get globalPos(){return this._transform.globalPos}set globalPos(t){this._transform.globalPos=t}get rotation(){return this._transform.rotation}set rotation(t){this._transform.rotation=t}get globalRotation(){return this._transform.globalRotation}set globalRotation(t){this._transform.globalRotation=t}get scale(){return this._transform.scale}set scale(t){this._transform.scale=t}get globalScale(){return this._transform.globalScale}set globalScale(t){this._transform.globalScale=t}applyInverse(t){return this._transform.applyInverse(t)}apply(t){return this._transform.apply(t)}clone(){const t=new P;return t._transform=this._transform.clone(),t}}class O extends Dt{constructor(){super(...arguments),this.vel=w.Zero,this.maxVel=w.One.scaleEqual(1/0),this.acc=w.Zero,this.scaleFactor=w.Zero,this.angularVelocity=0,this.torque=0,this.inertia=1,this.integration={onScreenOnly:!1}}}const pe=class{static create(t,e){if(this._CURRENT_GROUP>this._MAX_GROUPS)throw new Error(`Cannot have more than ${this._MAX_GROUPS} collision groups`);if(this._GROUPS.get(t)){const s=this._GROUPS.get(t);if(s.mask===e)return s;throw new Error(`Collision group ${t} already exists with a different mask!`)}const i=new me(t,this._CURRENT_BIT,e!==void 0?e:~this._CURRENT_BIT);return this._CURRENT_BIT=this._CURRENT_BIT<<1|0,this._CURRENT_GROUP++,this._GROUPS.set(t,i),i}static get groups(){return Array.from(this._GROUPS.values())}static groupByName(t){return this._GROUPS.get(t)}static reset(){this._GROUPS=new Map,this._CURRENT_BIT=this._STARTING_BIT,this._CURRENT_GROUP=1}};pe._STARTING_BIT=1,pe._MAX_GROUPS=32,pe._CURRENT_GROUP=1,pe._CURRENT_BIT=pe._STARTING_BIT,pe._GROUPS=new Map;let Pi=pe;const Ss=class{constructor(t,e,i){this._name=t,this._category=e,this._mask=i}get name(){return this._name}get category(){return this._category}get mask(){return this._mask}canCollide(t){const e=this.category&t.mask,i=this.mask&t.category;return e!==0&&i!==0}invert(){const t=Pi.create("~("+this.name+")",~this.mask|0);return t._category=~this.category,t}static combine(t){const e=t.map(n=>n.name).join("+"),s=~t.reduce((n,o)=>o.category|n,0);return Pi.create(e,s)}static collidesWith(t){const e=`collidesWith(${t.map(s=>s.name).join("+")})`,i=t.reduce((s,n)=>n.category|s,0);return Pi.create(e,i)}toString(){return`
|
|
16
16
|
category: ${this.category.toString(2).padStart(32,"0")}
|
|
17
17
|
mask: ${(this.mask>>>0).toString(2).padStart(32,"0")}
|
|
18
|
-
`}};Ss.All=new Ss("Collide with all groups",-1,-1);let me=Ss;var Ts=(r=>(r.Kill="kill",r.PreKill="prekill",r.PostKill="postkill",r.PreDraw="predraw",r.PostDraw="postdraw",r.PreDebugDraw="predebugdraw",r.PostDebugDraw="postdebugdraw",r.PreUpdate="preupdate",r.PostUpdate="postupdate",r.PreFrame="preframe",r.PostFrame="postframe",r.PreCollision="precollision",r.CollisionStart="collisionstart",r.CollisionEnd="collisionend",r.PostCollision="postcollision",r.Initialize="initialize",r.Activate="activate",r.Deactivate="deactivate",r.ExitViewport="exitviewport",r.EnterViewport="enterviewport",r.ExitTrigger="exit",r.EnterTrigger="enter",r.Connect="connect",r.Disconnect="disconnect",r.Button="button",r.Axis="axis",r.Visible="visible",r.Hidden="hidden",r.Start="start",r.Stop="stop",r.PointerUp="pointerup",r.PointerDown="pointerdown",r.PointerMove="pointermove",r.PointerEnter="pointerenter",r.PointerLeave="pointerleave",r.PointerCancel="pointercancel",r.PointerWheel="pointerwheel",r.Up="up",r.Down="down",r.Move="move",r.Enter="enter",r.Leave="leave",r.Cancel="cancel",r.Wheel="wheel",r.Press="press",r.Release="release",r.Hold="hold",r.PointerDragStart="pointerdragstart",r.PointerDragEnd="pointerdragend",r.PointerDragEnter="pointerdragenter",r.PointerDragLeave="pointerdragleave",r.PointerDragMove="pointerdragmove",r.ActionStart="actionstart",r.ActionComplete="actioncomplete",r.Add="add",r.Remove="remove",r))(Ts||{});class k{constructor(){this.other=null,this._bubbles=!0}get bubbles(){return this._bubbles}set bubbles(t){this._bubbles=t}stopPropagation(){this.bubbles=!1}}class As extends k{constructor(t){super(),this.self=t,this.target=t}}class Ps extends k{constructor(t){super(),this.self=t,this.target=t}}class Es extends k{constructor(t){super(),this.self=t,this.target=t}}class Is extends k{constructor(t){super(),this.self=t,this.target=t}}class Rs extends k{constructor(t){super(),this.self=t,this.target=t}}class Ue extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class ze extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Ms extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Fs extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Ds extends k{constructor(t,e){super(),this.ctx=t,this.self=e,this.target=e}}class Bs extends k{constructor(t,e){super(),this.ctx=t,this.self=e,this.target=e}}class re extends k{constructor(t,e,i){super(),this.engine=t,this.elapsed=e,this.self=i,this.target=i}}class oe extends k{constructor(t,e,i){super(),this.engine=t,this.elapsed=e,this.self=i,this.target=i}}class ks extends k{constructor(t,e){super(),this.engine=t,this.prevStats=e,this.target=t}}class Ls extends k{constructor(t,e){super(),this.engine=t,this.stats=e,this.target=t}}class Us extends k{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class zs extends k{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class Os extends k{constructor(t,e,i,s){super(),this.button=t,this.index=e,this.value=i,this.self=s,this.target=s}}class Hs extends k{constructor(t,e,i){super(),this.axis=t,this.value=e,this.self=i,this.target=i}}class Ns extends k{constructor(t){super(),this.self=t,this.target=t}}class Ws extends k{constructor(t){super(),this.self=t,this.target=t}}class ve extends k{constructor(t,e,i,s,n){super(),this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n,this.target=t}}class we extends k{constructor(t,e,i,s,n){super(),this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n,this.target=t}}class Ei{constructor(t,e,i,s){this.self=t,this.other=e,this.side=i,this.contact=s}}class Ii{constructor(t,e,i,s){this.self=t,this.other=e,this.side=i,this.lastContact=s}}class Ri{constructor(t,e,i,s,n){this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class Mi{constructor(t,e,i,s,n){this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class ni extends k{constructor(t,e,i,s){super(),this.self=t,this.other=e,this.side=i,this.contact=s,this.target=t}}class ri extends k{constructor(t,e,i,s){super(),this.self=t,this.other=e,this.side=i,this.lastContact=s,this.target=t}}class Oe extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}class Gs extends k{constructor(t,e){super(),this.context=t,this.self=e,this.target=e}}class Vs extends k{constructor(t,e){super(),this.context=t,this.self=e,this.target=e}}class qs extends k{constructor(t){super(),this.self=t,this.target=t}}class Xs extends k{constructor(t){super(),this.self=t,this.target=t}}class Ys extends k{constructor(t,e){super(),this.self=t,this.entity=e,this.target=t}}class $s extends k{constructor(t,e){super(),this.self=t,this.entity=e,this.target=t}}class Zs extends k{constructor(t,e){super(),this.action=t,this.self=e,this.target=e}}class js extends k{constructor(t,e){super(),this.action=t,this.self=e,this.target=e}}class Qs extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}class Js extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}const yh=Object.freeze(Object.defineProperty({__proto__:null,ActionCompleteEvent:js,ActionStartEvent:Zs,ActivateEvent:Gs,AddEvent:Qs,CollisionEndEvent:ri,CollisionPostSolveEvent:Mi,CollisionPreSolveEvent:Ri,CollisionStartEvent:ni,ContactEndEvent:Ii,ContactStartEvent:Ei,DeactivateEvent:Vs,EnterTriggerEvent:Ys,EnterViewPortEvent:Xs,EventTypes:Ts,ExitTriggerEvent:$s,ExitViewPortEvent:qs,GameEvent:k,GameStartEvent:Is,GameStopEvent:Rs,GamepadAxisEvent:Hs,GamepadButtonEvent:Os,GamepadConnectEvent:Us,GamepadDisconnectEvent:zs,HiddenEvent:Ws,InitializeEvent:Oe,KillEvent:As,PostCollisionEvent:we,PostDebugDrawEvent:Bs,PostDrawEvent:ze,PostFrameEvent:Ls,PostKillEvent:Es,PostTransformDrawEvent:Fs,PostUpdateEvent:oe,PreCollisionEvent:ve,PreDebugDrawEvent:Ds,PreDrawEvent:Ue,PreFrameEvent:ks,PreKillEvent:Ps,PreTransformDrawEvent:Ms,PreUpdateEvent:re,RemoveEvent:Js,VisibleEvent:Ns},Symbol.toStringTag,{value:"Module"}));function wr(r){if(r.length===0)throw new Error("Cannot find minIndex of array.length == 0");let t=r[0],e=0;for(let i=1;i<r.length;i++)r[i]<t&&(t=r[i],e=i);return e}function oi(r){if(r&&r.getBoundingClientRect){const t=r.getBoundingClientRect();return b(t.x+window.scrollX,t.y+window.scrollY)}return w.Zero}function Ch(r,t){return t.indexOf(r)===-1?(t.push(r),!0):!1}function He(r,t){let e=-1;return(e=t.indexOf(r))>-1?(t.splice(e,1),!0):!1}function xr(r,t){for(let e=0;e<r.length;e++)if(r[e]===t)return!0;return!1}function br(r){throw new Error(r)}function Fi(r,t){var e;const i=new wt;return((e=t==null?void 0:t.schedule.bind(t))!=null?e:setTimeout)(()=>{i.resolve()},r),i.promise}function yr(r,t){const e={};for(const i in r)t.includes(i)||(e[i]=r[i]);return e}function Di(r){return r&&typeof r=="object"&&!Array.isArray(r)}function Bi(r,...t){if(!t.length)return r;const e=t.shift();if(Di(r)&&Di(e))for(const i in e)Di(e[i])?(r[i]||Object.assign(r,{[i]:{}}),Bi(r[i],e[i])):Object.assign(r,{[i]:e[i]});return Bi(r,...t)}class Sh{constructor(t){this.data=t,this.type="Component Added"}}function Th(r){return!!r&&r.type==="Component Added"}class Ah{constructor(t){this.data=t,this.type="Component Removed"}}function Ph(r){return!!r&&r.type==="Component Removed"}const Eh={Add:"add",Remove:"remove",Initialize:"initialize",PreUpdate:"preupdate",PostUpdate:"postupdate",Kill:"kill"},Cr=class sr{constructor(t,e){this.id=sr._ID++,this.name=`Entity#${this.id}`,this.events=new X,this._tags=new Set,this.componentAdded$=new gt,this.componentRemoved$=new gt,this.tagAdded$=new gt,this.tagRemoved$=new gt,this.components=new Map,this.componentValues=[],this._componentsToRemove=[],this.scene=null,this.isActive=!0,this._parent=null,this.childrenAdded$=new gt,this.childrenRemoved$=new gt,this._children=[],this._isInitialized=!1,this._isAdded=!1;let i,s;if(Array.isArray(t))i=t,s=e;else if(t&&typeof t=="object"){const{components:n,name:o}=t;i=n!=null?n:[],s=o}if(s&&(this.name=s),i)for(const n of i)this.addComponent(n)}get active(){return this.isActive}set active(t){this.isActive=t}kill(){this.isActive&&(this.isActive=!1,this.unparent()),this.emit("kill",new As(this))}isKilled(){return!this.isActive}get tags(){return this._tags}hasTag(t){return this._tags.has(t)}addTag(t){return this._tags.add(t),this.tagAdded$.notifyAll(t),this}removeTag(t){return this._tags.delete(t),this.tagRemoved$.notifyAll(t),this}get types(){return Array.from(this.components.keys())}getComponents(){return Array.from(this.components.values())}hasAll(t){for(let e=0;e<t.length;e++)if(!this.components.has(t[e]))return!1;return!0}hasAllTags(t){for(let e=0;e<t.length;e++)if(!this.tags.has(t[e]))return!1;return!0}get(t){return this.components.get(t)}get parent(){return this._parent}get children(){return this._children}unparent(){this._parent&&(this._parent.removeChild(this),this._parent=null)}hasChild(t,e=!1){if(!e)return t.parent===this;for(const i of this.children)if(i===t||e&&i.hasChild(t,!0))return!0;return!1}addChild(t){if(t.parent===null){if(this.getAncestors().includes(t))throw new Error("Cycle detected, cannot add entity");this._children.push(t),t._parent=this,this.childrenAdded$.notifyAll(t)}else throw new Error("Entity already has a parent, cannot add without unparenting");return this}removeChild(t){return t.parent===this&&(He(t,this._children),t._parent=null,this.childrenRemoved$.notifyAll(t)),this}removeAllChildren(){for(let t=this.children.length-1;t>=0;t--)this.removeChild(this.children[t]);return this}getAncestors(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;return t.reverse()}getDescendants(){let t=[this],e=[this];for(;e.length>0;){const i=e.pop();i&&(e=e.concat(i.children),t=t.concat(i.children))}return t}clone(){const t=new sr;for(const e of this.types){const i=this.get(e);i&&t.addComponent(i.clone())}for(const e of this.children)t.addChild(e.clone());return t}addTemplate(t,e=!1){for(const i of t.getComponents())this.addComponent(i.clone(),e);for(const i of t.children)this.addChild(i.clone().addTemplate(i));return this}_getClassHierarchyRoot(t){var e,i;let s=t,n=(e=Object.getPrototypeOf(s.prototype))==null?void 0:e.constructor;for(;n&&n!==Object&&n!==Dt;)s=n,n=(i=Object.getPrototypeOf(s.prototype))==null?void 0:i.constructor;return s}addComponent(t,e=!1){if(this.has(t.constructor))if(e)this.removeComponent(t.constructor,!0);else return this;if(t.dependencies&&t.dependencies.length)for(const s of t.dependencies)this.addComponent(new s);t.owner=this;const i=this._getClassHierarchyRoot(t.constructor);return this.components.set(i,t),this.components.set(t.constructor,t),this.componentValues.push(t),t.onAdd&&t.onAdd(this),this.componentAdded$.notifyAll(t),this}removeComponent(t,e=!1){let i;if(vr(t)?i=t:i=t.constructor,e){const s=this.components.get(i);if(s){this.componentRemoved$.notifyAll(s),s.owner=void 0,s.onRemove&&s.onRemove(this);const o=this.componentValues.indexOf(s);o>-1&&this.componentValues.splice(o,1)}const n=this._getClassHierarchyRoot(i);this.components.delete(n),this.components.delete(i)}else this._componentsToRemove.push(i);return this}clearComponents(){const t=this.types;for(const e of t)this.removeComponent(e)}processComponentRemoval(){for(const t of this._componentsToRemove)this.removeComponent(t,!0);this._componentsToRemove.length=0}has(t){return this.components.has(t)}get isInitialized(){return this._isInitialized}get isAdded(){return this._isAdded}_initialize(t){this.isInitialized||(this.onInitialize(t),this.events.emit("initialize",new Oe(t,this)),this._isInitialized=!0)}_add(t){!this.isAdded&&this.isActive&&(this.onAdd(t),this.events.emit("add",new Qs(t,this)),this._isAdded=!0)}_remove(t){this.isAdded&&!this.isActive&&(this.onRemove(t),this.events.emit("remove",new Js(t,this)),this._isAdded=!1)}_preupdate(t,e){this.events.emit("preupdate",new re(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.events.emit("postupdate",new oe(t,e,this)),this.onPostUpdate(t,e)}onInitialize(t){}onAdd(t){}onRemove(t){}onPreUpdate(t,e){}onPostUpdate(t,e){}update(t,e){this._initialize(t),this._add(t),this._preupdate(t,e);for(const i of this.children)i.update(t,e);this._postupdate(t,e),this._remove(t)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){e?this.events.off(t,e):this.events.off(t)}};Cr._ID=0;let At=Cr;class Sr{constructor(t){this._world=t,this.entities=[],this._entityIndex={},this._childAddedHandlerMap=new Map,this._childRemovedHandlerMap=new Map,this._createChildAddedHandler=()=>e=>{this.addEntity(e)},this._createChildRemovedHandler=()=>e=>{this.removeEntity(e,!1)},this._entitiesToRemove=[]}updateEntities(t,e){for(let i=0;i<this.entities.length;i++){const s=this.entities[i];s.update(t.engine,e),s.isActive||this.removeEntity(s)}}findEntitiesForRemoval(){for(let t=0;t<this.entities.length;t++){const e=this.entities[t];e.isActive||this.removeEntity(e)}}addEntity(t){if(t.isActive=!0,t.scene=this._world.scene,t&&!this._entityIndex[t.id]){this._entityIndex[t.id]=t,this.entities.push(t),this._world.queryManager.addEntity(t),t.children.forEach(s=>{s.scene=t.scene,this.addEntity(s)});const e=this._createChildAddedHandler();this._childAddedHandlerMap.set(t,e);const i=this._createChildRemovedHandler();this._childRemovedHandlerMap.set(t,i),t.childrenAdded$.subscribe(e),t.childrenRemoved$.subscribe(i)}}removeEntity(t,e=!0){var i,s;let n=0;t instanceof At?n=t.id:n=t;const o=this._entityIndex[n];if(o&&o.isActive&&(o.isActive=!1),o&&e){this._entitiesToRemove.push(o);return}if(delete this._entityIndex[n],o){o.scene=null,He(o,this.entities),this._world.queryManager.removeEntity(o),o.children.forEach(l=>{l.scene=null,this.removeEntity(l,e)});const a=this._childAddedHandlerMap.get(o);a&&(o.childrenAdded$.unsubscribe(a),this._childAddedHandlerMap.delete(o));const h=this._childRemovedHandlerMap.get(o);h&&(o.childrenRemoved$.unsubscribe(h),this._childRemovedHandlerMap.delete(o)),(s=(i=this._world)==null?void 0:i.scene)!=null&&s.engine&&this._world.scene.engine.stats.currFrame.actors.killed++}}processEntityRemovals(){for(let t=0;t<this._entitiesToRemove.length;t++){const e=this._entitiesToRemove[t];e.isActive||this.removeEntity(e,!1)}this._entitiesToRemove.length=0}processComponentRemovals(){for(let t=0;t<this.entities.length;t++)this.entities[t].processComponentRemoval()}getById(t){return this._entityIndex[t]}getByName(t){return this.entities.filter(e=>e.name===t)}clear(){for(let t=this.entities.length-1;t>=0;t--)this.removeEntity(this.entities[t])}}class Lt{constructor(t){this._entities=[],this.entitiesSet=new Set,this.entityAdded$=new gt,this.entityRemoved$=new gt,this.filter={components:{all:new Set,any:new Set,not:new Set},tags:{all:new Set,any:new Set,not:new Set}},this._dirty=!1;var e,i,s,n,o,a,h,l,c,u,_,f;Array.isArray(t)&&(t={components:{all:t}}),this.filter.components.all=new Set((i=(e=t.components)==null?void 0:e.all)!=null?i:[]),this.filter.components.any=new Set((n=(s=t.components)==null?void 0:s.any)!=null?n:[]),this.filter.components.not=new Set((a=(o=t.components)==null?void 0:o.not)!=null?a:[]),this.filter.tags.all=new Set((l=(h=t.tags)==null?void 0:h.all)!=null?l:[]),this.filter.tags.any=new Set((u=(c=t.tags)==null?void 0:c.any)!=null?u:[]),this.filter.tags.not=new Set((f=(_=t.tags)==null?void 0:_.not)!=null?f:[]),this.id=Lt.createId(t)}get entities(){return this._dirty&&(this._entities=Array.from(this.entitiesSet),this._dirty=!1),this._entities}static createId(t){var e,i,s,n,o,a,h,l,c,u,_,f;Array.isArray(t)&&(t={components:{all:t}});const m=(e=t.components)!=null&&e.any?`any_${Lt.hashComponents(new Set((i=t.components)==null?void 0:i.any))}`:"",p=(s=t.components)!=null&&s.all?`all_${Lt.hashComponents(new Set((n=t.components)==null?void 0:n.all))}`:"",x=(o=t.components)!=null&&o.not?`not_${Lt.hashComponents(new Set((a=t.components)==null?void 0:a.not))}`:"",v=(h=t.tags)!=null&&h.any?`any_${Lt.hashTags(new Set((l=t.tags)==null?void 0:l.any))}`:"",g=(c=t.tags)!=null&&c.all?`all_${Lt.hashTags(new Set((u=t.tags)==null?void 0:u.all))}`:"",y=(_=t.tags)!=null&&_.not?`not_${Lt.hashTags(new Set((f=t.tags)==null?void 0:f.not))}`:"";return[m,p,x,v,g,y].filter(Boolean).join("-")}static hashTags(t){return Array.from(t).map(e=>`t_${e}`).sort().join("-")}static hashComponents(t){return Array.from(t).map(e=>`c_${e.name}`).sort().join("-")}matchesNotFilter(t,e){for(const i of this.filter.components.not)if(e!==i&&t.has(i))return!0;for(const i of this.filter.tags.not)if(t.hasTag(i))return!0;return!1}matches(t,e){for(const i of this.filter.components.not)if(e!==i&&t.has(i))return!1;for(const i of this.filter.tags.not)if(t.hasTag(i))return!1;for(const i of this.filter.components.all)if(i===e||!t.has(i))return!1;for(const i of this.filter.tags.all)if(!t.hasTag(i))return!1;if(this.filter.components.any.size>0){let i=!1;for(const s of this.filter.components.any)if(t.has(s)){i=!0;break}if(!i)return!1}if(this.filter.tags.any.size>0){let i=!1;for(const s of this.filter.tags.any)if(t.hasTag(s)){i=!0;break}if(!i)return!1}return!0}checkAndModify(t,e){const i=this.entitiesSet.has(t);if(i&&this.matchesNotFilter(t,e))return this.removeEntity(t),!1;const s=this.matches(t,e);return i&&!s?(this.removeEntity(t),!1):!i&&s?(this._dirty=!0,this.entitiesSet.add(t),this.entityAdded$.notifyAll(t),!0):!1}removeEntity(t){this.entitiesSet.delete(t)&&(this._dirty=!0,this.entityRemoved$.notifyAll(t))}getEntities(t){return t&&this.entities.sort(t),this.entities}}class Ks{constructor(t){if(this.requiredTags=t,this.tags=new Set,this.entities=[],this.entityAdded$=new gt,this.entityRemoved$=new gt,t.length===0)throw new Error("Cannot create tag query without tags");for(const e of t)this.tags.add(e);this.id=Ks.createId(t)}static createId(t){return t.slice().sort().join("-")}checkAndAdd(t){return!this.entities.includes(t)&&t.hasAllTags(Array.from(this.tags))?(this.entities.push(t),this.entityAdded$.notifyAll(t),!0):!1}removeEntity(t){const e=this.entities.indexOf(t);e>-1&&(this.entities.splice(e,1),this.entityRemoved$.notifyAll(t))}getEntities(t){return t&&this.entities.sort(t),this.entities}}class Tr{constructor(t){this._world=t,this._queries=new Map,this._addComponentHandlers=new Map,this._removeComponentHandlers=new Map,this._componentToQueriesIndex=new Map,this._tagToQueriesIndex=new Map,this._addTagHandlers=new Map,this._removeTagHandlers=new Map,this._createAddComponentHandler=e=>i=>{this.addComponent(e,i)},this._createRemoveComponentHandler=e=>i=>{this.removeComponent(e,i)},this._createAddTagHandler=e=>i=>{this.addTag(e,i)},this._createRemoveTagHandler=e=>i=>{this.removeTag(e,i)}}createQuery(t){const e=Lt.createId(t);if(this._queries.has(e))return this._queries.get(e);const i=new Lt(t);this._queries.set(i.id,i);for(const s of[...i.filter.components.all,...i.filter.components.any,...i.filter.components.not]){const n=this._componentToQueriesIndex.get(s);n?n.push(i):this._componentToQueriesIndex.set(s,[i])}for(const s of[...i.filter.tags.all,...i.filter.tags.any,...i.filter.tags.not]){const n=this._tagToQueriesIndex.get(s);n?n.push(i):this._tagToQueriesIndex.set(s,[i])}for(const s of this._world.entities)this.addEntity(s);return i}addEntity(t){const e=this._addComponentHandlers.get(t),i=this._removeComponentHandlers.get(t),s=e!=null?e:this._createAddComponentHandler(t),n=i!=null?i:this._createRemoveComponentHandler(t);this._addComponentHandlers.set(t,s),this._removeComponentHandlers.set(t,n);const o=this._addTagHandlers.get(t),a=this._removeTagHandlers.get(t),h=o!=null?o:this._createAddTagHandler(t),l=a!=null?a:this._createRemoveTagHandler(t);this._addTagHandlers.set(t,h),this._removeTagHandlers.set(t,l);for(const c of this._queries.values())c.checkAndModify(t);t.componentAdded$.subscribe(s),t.componentRemoved$.subscribe(n),t.tagAdded$.subscribe(h),t.tagRemoved$.subscribe(l)}removeEntity(t){const e=this._addComponentHandlers.get(t),i=this._removeComponentHandlers.get(t);for(const o of this._queries.values())o.removeEntity(t);e&&(t.componentAdded$.unsubscribe(e),this._addComponentHandlers.delete(t)),i&&(t.componentRemoved$.unsubscribe(i),this._removeComponentHandlers.delete(t));const s=this._addTagHandlers.get(t),n=this._removeTagHandlers.get(t);s&&(t.tagAdded$.unsubscribe(s),this._addTagHandlers.delete(t)),n&&(t.tagRemoved$.unsubscribe(n),this._removeTagHandlers.delete(t))}addComponent(t,e){var i;const s=(i=this._componentToQueriesIndex.get(e.constructor))!=null?i:[];for(const n of s)n.checkAndModify(t)}removeComponent(t,e){var i;const s=(i=this._componentToQueriesIndex.get(e.constructor))!=null?i:[];for(const n of s)n.checkAndModify(t,e.constructor)}addTag(t,e){var i;const s=(i=this._tagToQueriesIndex.get(e))!=null?i:[];for(const n of s)n.checkAndModify(t)}removeTag(t,e){var i;const s=(i=this._tagToQueriesIndex.get(e))!=null?i:[];for(const n of s)n.removeEntity(t),n.checkAndModify(t)}}const Gt={Highest:-1/0,Higher:-5,Average:0,Lower:5,Lowest:1/0};var Pt=(r=>(r.Update="update",r.Draw="draw",r))(Pt||{});class Et{}Et.priority=Gt.Average;function Ar(r){var t,e;return!!(r!=null&&r.prototype)&&!!((e=(t=r==null?void 0:r.prototype)==null?void 0:t.constructor)!=null&&e.name)}class Pr{constructor(t){this._world=t,this.systems=[],this.initialized=!1}get(t){return this.systems.find(e=>e instanceof t)}addSystem(t){let e;t instanceof Et?e=t:e=new t(this._world),this.systems.push(e),this.systems.sort((i,s)=>i.constructor.priority-s.constructor.priority),this.initialized&&e.initialize&&e.initialize(this._world,this._world.scene)}removeSystem(t){He(t,this.systems)}initialize(){if(!this.initialized){this.initialized=!0;for(const t of this.systems)t.initialize&&t.initialize(this._world,this._world.scene)}}updateSystems(t,e,i){const s=this.systems.filter(n=>n.systemType===t);for(const n of s)n.preupdate&&n.preupdate(e,i);for(const n of s)n.update(i);for(const n of s)n.postupdate&&n.postupdate(e,i)}clear(){for(let t=this.systems.length-1;t>=0;t--)this.removeSystem(this.systems[t])}}class Er{constructor(t){this.scene=t,this._logger=R.getInstance(),this.queryManager=new Tr(this),this.entityManager=new Sr(this),this.systemManager=new Pr(this)}query(t){return this.queryManager.createQuery(t)}queryTags(t){return this.queryManager.createQuery({tags:{all:t}})}update(t,e){t===Pt.Update&&this.entityManager.updateEntities(this.scene,e),this.systemManager.updateSystems(t,this.scene,e),this.entityManager.findEntitiesForRemoval(),this.entityManager.processComponentRemovals(),this.entityManager.processEntityRemovals()}add(t){if(t instanceof At){this.entityManager.addEntity(t);return}if(t instanceof Et||Ar(t)){this.systemManager.addSystem(t);return}this._logger.warn(`Could not add entity/system ${t.constructor.name} to Excalibur!
|
|
18
|
+
`}};Ss.All=new Ss("Collide with all groups",-1,-1);let me=Ss;var Ts=(r=>(r.Kill="kill",r.PreKill="prekill",r.PostKill="postkill",r.PreDraw="predraw",r.PostDraw="postdraw",r.PreDebugDraw="predebugdraw",r.PostDebugDraw="postdebugdraw",r.PreUpdate="preupdate",r.PostUpdate="postupdate",r.PreFrame="preframe",r.PostFrame="postframe",r.PreCollision="precollision",r.CollisionStart="collisionstart",r.CollisionEnd="collisionend",r.PostCollision="postcollision",r.Initialize="initialize",r.Activate="activate",r.Deactivate="deactivate",r.ExitViewport="exitviewport",r.EnterViewport="enterviewport",r.ExitTrigger="exit",r.EnterTrigger="enter",r.Connect="connect",r.Disconnect="disconnect",r.Button="button",r.Axis="axis",r.Visible="visible",r.Hidden="hidden",r.Start="start",r.Stop="stop",r.PointerUp="pointerup",r.PointerDown="pointerdown",r.PointerMove="pointermove",r.PointerEnter="pointerenter",r.PointerLeave="pointerleave",r.PointerCancel="pointercancel",r.PointerWheel="pointerwheel",r.Up="up",r.Down="down",r.Move="move",r.Enter="enter",r.Leave="leave",r.Cancel="cancel",r.Wheel="wheel",r.Press="press",r.Release="release",r.Hold="hold",r.PointerDragStart="pointerdragstart",r.PointerDragEnd="pointerdragend",r.PointerDragEnter="pointerdragenter",r.PointerDragLeave="pointerdragleave",r.PointerDragMove="pointerdragmove",r.ActionStart="actionstart",r.ActionComplete="actioncomplete",r.Add="add",r.Remove="remove",r))(Ts||{});class k{constructor(){this.other=null,this._bubbles=!0}get bubbles(){return this._bubbles}set bubbles(t){this._bubbles=t}stopPropagation(){this.bubbles=!1}}class As extends k{constructor(t){super(),this.self=t,this.target=t}}class Ps extends k{constructor(t){super(),this.self=t,this.target=t}}class Es extends k{constructor(t){super(),this.self=t,this.target=t}}class Is extends k{constructor(t){super(),this.self=t,this.target=t}}class Rs extends k{constructor(t){super(),this.self=t,this.target=t}}class Ue extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class ze extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Ms extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Fs extends k{constructor(t,e,i){super(),this.ctx=t,this.elapsed=e,this.self=i,this.target=i}}class Ds extends k{constructor(t,e){super(),this.ctx=t,this.self=e,this.target=e}}class Bs extends k{constructor(t,e){super(),this.ctx=t,this.self=e,this.target=e}}class re extends k{constructor(t,e,i){super(),this.engine=t,this.elapsed=e,this.self=i,this.target=i}}class oe extends k{constructor(t,e,i){super(),this.engine=t,this.elapsed=e,this.self=i,this.target=i}}class ks extends k{constructor(t,e){super(),this.engine=t,this.prevStats=e,this.target=t}}class Ls extends k{constructor(t,e){super(),this.engine=t,this.stats=e,this.target=t}}class Us extends k{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class zs extends k{constructor(t,e){super(),this.index=t,this.gamepad=e,this.target=e}}class Os extends k{constructor(t,e,i,s){super(),this.button=t,this.index=e,this.value=i,this.self=s,this.target=s}}class Hs extends k{constructor(t,e,i){super(),this.axis=t,this.value=e,this.self=i,this.target=i}}class Ns extends k{constructor(t){super(),this.self=t,this.target=t}}class Ws extends k{constructor(t){super(),this.self=t,this.target=t}}class ve extends k{constructor(t,e,i,s,n){super(),this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n,this.target=t}}class we extends k{constructor(t,e,i,s,n){super(),this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n,this.target=t}}class Ei{constructor(t,e,i,s){this.self=t,this.other=e,this.side=i,this.contact=s}}class Ii{constructor(t,e,i,s){this.self=t,this.other=e,this.side=i,this.lastContact=s}}class Ri{constructor(t,e,i,s,n){this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class Mi{constructor(t,e,i,s,n){this.self=t,this.other=e,this.side=i,this.intersection=s,this.contact=n}}class ni extends k{constructor(t,e,i,s){super(),this.self=t,this.other=e,this.side=i,this.contact=s,this.target=t}}class ri extends k{constructor(t,e,i,s){super(),this.self=t,this.other=e,this.side=i,this.lastContact=s,this.target=t}}class Oe extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}class Gs extends k{constructor(t,e){super(),this.context=t,this.self=e,this.target=e}}class Vs extends k{constructor(t,e){super(),this.context=t,this.self=e,this.target=e}}class qs extends k{constructor(t){super(),this.self=t,this.target=t}}class Xs extends k{constructor(t){super(),this.self=t,this.target=t}}class Ys extends k{constructor(t,e){super(),this.self=t,this.entity=e,this.target=t}}class $s extends k{constructor(t,e){super(),this.self=t,this.entity=e,this.target=t}}class Zs extends k{constructor(t,e){super(),this.action=t,this.self=e,this.target=e}}class js extends k{constructor(t,e){super(),this.action=t,this.self=e,this.target=e}}class Qs extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}class Js extends k{constructor(t,e){super(),this.engine=t,this.self=e,this.target=e}}const yh=Object.freeze(Object.defineProperty({__proto__:null,ActionCompleteEvent:js,ActionStartEvent:Zs,ActivateEvent:Gs,AddEvent:Qs,CollisionEndEvent:ri,CollisionPostSolveEvent:Mi,CollisionPreSolveEvent:Ri,CollisionStartEvent:ni,ContactEndEvent:Ii,ContactStartEvent:Ei,DeactivateEvent:Vs,EnterTriggerEvent:Ys,EnterViewPortEvent:Xs,EventTypes:Ts,ExitTriggerEvent:$s,ExitViewPortEvent:qs,GameEvent:k,GameStartEvent:Is,GameStopEvent:Rs,GamepadAxisEvent:Hs,GamepadButtonEvent:Os,GamepadConnectEvent:Us,GamepadDisconnectEvent:zs,HiddenEvent:Ws,InitializeEvent:Oe,KillEvent:As,PostCollisionEvent:we,PostDebugDrawEvent:Bs,PostDrawEvent:ze,PostFrameEvent:Ls,PostKillEvent:Es,PostTransformDrawEvent:Fs,PostUpdateEvent:oe,PreCollisionEvent:ve,PreDebugDrawEvent:Ds,PreDrawEvent:Ue,PreFrameEvent:ks,PreKillEvent:Ps,PreTransformDrawEvent:Ms,PreUpdateEvent:re,RemoveEvent:Js,VisibleEvent:Ns},Symbol.toStringTag,{value:"Module"}));function wr(r){if(r.length===0)throw new Error("Cannot find minIndex of array.length == 0");let t=r[0],e=0;for(let i=1;i<r.length;i++)r[i]<t&&(t=r[i],e=i);return e}function oi(r){if(r&&r.getBoundingClientRect){const t=r.getBoundingClientRect();return b(t.x+window.scrollX,t.y+window.scrollY)}return w.Zero}function Ch(r,t){return t.indexOf(r)===-1?(t.push(r),!0):!1}function He(r,t){let e=-1;return(e=t.indexOf(r))>-1?(t.splice(e,1),!0):!1}function xr(r,t){for(let e=0;e<r.length;e++)if(r[e]===t)return!0;return!1}function br(r){throw new Error(r)}function Fi(r,t){var e;const i=new wt;return((e=t==null?void 0:t.schedule.bind(t))!=null?e:setTimeout)(()=>{i.resolve()},r),i.promise}function yr(r,t){const e={};for(const i in r)t.includes(i)||(e[i]=r[i]);return e}function Di(r){return r&&typeof r=="object"&&!Array.isArray(r)}function Bi(r,...t){if(!t.length)return r;const e=t.shift();if(Di(r)&&Di(e))for(const i in e)Di(e[i])?(r[i]||Object.assign(r,{[i]:{}}),Bi(r[i],e[i])):Object.assign(r,{[i]:e[i]});return Bi(r,...t)}class Sh{constructor(t){this.data=t,this.type="Component Added"}}function Th(r){return!!r&&r.type==="Component Added"}class Ah{constructor(t){this.data=t,this.type="Component Removed"}}function Ph(r){return!!r&&r.type==="Component Removed"}const Eh={Add:"add",Remove:"remove",Initialize:"initialize",PreUpdate:"preupdate",PostUpdate:"postupdate",Kill:"kill"},Cr=class sr{constructor(t,e){this.id=sr._ID++,this.name=`Entity#${this.id}`,this.events=new X,this._tags=new Set,this.componentAdded$=new gt,this.componentRemoved$=new gt,this.tagAdded$=new gt,this.tagRemoved$=new gt,this.components=new Map,this.componentValues=[],this._componentsToRemove=[],this.scene=null,this.isActive=!0,this._parent=null,this.childrenAdded$=new gt,this.childrenRemoved$=new gt,this._children=[],this._isInitialized=!1,this._isAdded=!1;let i,s;if(Array.isArray(t))i=t,s=e;else if(t&&typeof t=="object"){const{components:n,name:o}=t;i=n!=null?n:[],s=o}if(s&&(this.name=s),i)for(const n of i)this.addComponent(n)}get active(){return this.isActive}set active(t){this.isActive=t}kill(){this.isActive&&(this.isActive=!1,this.unparent()),this.emit("kill",new As(this))}isKilled(){return!this.isActive}get tags(){return this._tags}hasTag(t){return this._tags.has(t)}addTag(t){return this._tags.add(t),this.tagAdded$.notifyAll(t),this}removeTag(t){return this._tags.delete(t),this.tagRemoved$.notifyAll(t),this}get types(){return Array.from(this.components.keys())}getComponents(){return Array.from(this.components.values())}hasAll(t){for(let e=0;e<t.length;e++)if(!this.components.has(t[e]))return!1;return!0}hasAllTags(t){for(let e=0;e<t.length;e++)if(!this.tags.has(t[e]))return!1;return!0}get(t){return this.components.get(t)}get parent(){return this._parent}get children(){return this._children}unparent(){this._parent&&(this._parent.removeChild(this),this._parent=null)}hasChild(t,e=!1){if(!e)return t.parent===this;for(const i of this.children)if(i===t||e&&i.hasChild(t,!0))return!0;return!1}addChild(t){if(t.parent===null){if(this.getAncestors().includes(t))throw new Error("Cycle detected, cannot add entity");this._children.push(t),t._parent=this,this.childrenAdded$.notifyAll(t)}else throw new Error("Entity already has a parent, cannot add without unparenting");return this}removeChild(t){return t.parent===this&&(He(t,this._children),t._parent=null,this.childrenRemoved$.notifyAll(t)),this}removeAllChildren(){for(let t=this.children.length-1;t>=0;t--)this.removeChild(this.children[t]);return this}getAncestors(){const t=[this];let e=this.parent;for(;e;)t.push(e),e=e.parent;return t.reverse()}getDescendants(){let t=[this],e=[this];for(;e.length>0;){const i=e.pop();i&&(e=e.concat(i.children),t=t.concat(i.children))}return t}clone(){const t=new sr;for(const e of this.types){const i=this.get(e);i&&t.addComponent(i.clone())}for(const e of this.children)t.addChild(e.clone());return t}addTemplate(t,e=!1){for(const i of t.getComponents())this.addComponent(i.clone(),e);for(const i of t.children)this.addChild(i.clone().addTemplate(i));return this}_getClassHierarchyRoot(t){var e,i;let s=t,n=(e=Object.getPrototypeOf(s.prototype))==null?void 0:e.constructor;for(;n&&n!==Object&&n!==Dt;)s=n,n=(i=Object.getPrototypeOf(s.prototype))==null?void 0:i.constructor;return s}addComponent(t,e=!1){if(this.has(t.constructor))if(e)this.removeComponent(t.constructor,!0);else return this;if(t.dependencies&&t.dependencies.length)for(const s of t.dependencies)this.addComponent(new s);t.owner=this;const i=this._getClassHierarchyRoot(t.constructor);return this.components.set(i,t),this.components.set(t.constructor,t),this.componentValues.push(t),t.onAdd&&t.onAdd(this),this.componentAdded$.notifyAll(t),this}removeComponent(t,e=!1){let i;if(vr(t)?i=t:i=t.constructor,e){const s=this.components.get(i);if(s){this.componentRemoved$.notifyAll(s),s.owner=void 0,s.onRemove&&s.onRemove(this);const o=this.componentValues.indexOf(s);o>-1&&this.componentValues.splice(o,1)}const n=this._getClassHierarchyRoot(i);this.components.delete(n),this.components.delete(i)}else this._componentsToRemove.push(i);return this}clearComponents(){const t=this.types;for(const e of t)this.removeComponent(e)}processComponentRemoval(){for(const t of this._componentsToRemove)this.removeComponent(t,!0);this._componentsToRemove.length=0}has(t){return this.components.has(t)}get isInitialized(){return this._isInitialized}get isAdded(){return this._isAdded}_initialize(t){this.isInitialized||(this.onInitialize(t),this.events.emit("initialize",new Oe(t,this)),this._isInitialized=!0)}_add(t){!this.isAdded&&this.isActive&&(this.onAdd(t),this.events.emit("add",new Qs(t,this)),this._isAdded=!0)}_remove(t){this.isAdded&&!this.isActive&&(this.onRemove(t),this.events.emit("remove",new Js(t,this)),this._isAdded=!1)}_preupdate(t,e){this.events.emit("preupdate",new re(t,e,this)),this.onPreUpdate(t,e)}_postupdate(t,e){this.events.emit("postupdate",new oe(t,e,this)),this.onPostUpdate(t,e)}onInitialize(t){}onAdd(t){}onRemove(t){}onPreUpdate(t,e){}onPostUpdate(t,e){}update(t,e){this._initialize(t),this._add(t),this._preupdate(t,e);for(const i of this.children)i.update(t,e);this._postupdate(t,e),this._remove(t)}emit(t,e){this.events.emit(t,e)}on(t,e){return this.events.on(t,e)}once(t,e){return this.events.once(t,e)}off(t,e){e?this.events.off(t,e):this.events.off(t)}};Cr._ID=0;let At=Cr;class Sr{constructor(t){this._world=t,this.entities=[],this._entityIndex={},this._childAddedHandlerMap=new Map,this._childRemovedHandlerMap=new Map,this._createChildAddedHandler=()=>e=>{this.addEntity(e)},this._createChildRemovedHandler=()=>e=>{this.removeEntity(e,!1)},this._entitiesToRemove=[]}updateEntities(t,e){for(let i=0;i<this.entities.length;i++){const s=this.entities[i];s.update(t.engine,e),s.isActive||this.removeEntity(s)}}findEntitiesForRemoval(){for(let t=0;t<this.entities.length;t++){const e=this.entities[t];e.isActive||this.removeEntity(e)}}addEntity(t){if(t.isActive=!0,t.scene=this._world.scene,t&&!this._entityIndex[t.id]){this._entityIndex[t.id]=t,this.entities.push(t),this._world.queryManager.addEntity(t),t.children.forEach(s=>{s.scene=t.scene,this.addEntity(s)});const e=this._createChildAddedHandler();this._childAddedHandlerMap.set(t,e);const i=this._createChildRemovedHandler();this._childRemovedHandlerMap.set(t,i),t.childrenAdded$.subscribe(e),t.childrenRemoved$.subscribe(i)}}removeEntity(t,e=!0){var i,s,n,o;let a=0;t instanceof At?a=t.id:a=t;const h=this._entityIndex[a];if(h&&h.isActive&&(h.isActive=!1),h&&e){this._entitiesToRemove.push(h);return}if(delete this._entityIndex[a],h){h.scene=null,He(h,this.entities),this._world.queryManager.removeEntity(h),h.children.forEach(u=>{u.scene=null,this.removeEntity(u,e)});const l=this._childAddedHandlerMap.get(h);l&&(h.childrenAdded$.unsubscribe(l),this._childAddedHandlerMap.delete(h));const c=this._childRemovedHandlerMap.get(h);c&&(h.childrenRemoved$.unsubscribe(c),this._childRemovedHandlerMap.delete(h)),h._remove((s=(i=this._world)==null?void 0:i.scene)==null?void 0:s.engine),(o=(n=this._world)==null?void 0:n.scene)!=null&&o.engine&&this._world.scene.engine.stats.currFrame.actors.killed++}}processEntityRemovals(){for(let t=0;t<this._entitiesToRemove.length;t++){const e=this._entitiesToRemove[t];e.isActive||this.removeEntity(e,!1)}this._entitiesToRemove.length=0}processComponentRemovals(){for(let t=0;t<this.entities.length;t++)this.entities[t].processComponentRemoval()}getById(t){return this._entityIndex[t]}getByName(t){return this.entities.filter(e=>e.name===t)}clear(){for(let t=this.entities.length-1;t>=0;t--)this.removeEntity(this.entities[t])}}class Lt{constructor(t){this._entities=[],this.entitiesSet=new Set,this.entityAdded$=new gt,this.entityRemoved$=new gt,this.filter={components:{all:new Set,any:new Set,not:new Set},tags:{all:new Set,any:new Set,not:new Set}},this._dirty=!1;var e,i,s,n,o,a,h,l,c,u,_,f;Array.isArray(t)&&(t={components:{all:t}}),this.filter.components.all=new Set((i=(e=t.components)==null?void 0:e.all)!=null?i:[]),this.filter.components.any=new Set((n=(s=t.components)==null?void 0:s.any)!=null?n:[]),this.filter.components.not=new Set((a=(o=t.components)==null?void 0:o.not)!=null?a:[]),this.filter.tags.all=new Set((l=(h=t.tags)==null?void 0:h.all)!=null?l:[]),this.filter.tags.any=new Set((u=(c=t.tags)==null?void 0:c.any)!=null?u:[]),this.filter.tags.not=new Set((f=(_=t.tags)==null?void 0:_.not)!=null?f:[]),this.id=Lt.createId(t)}get entities(){return this._dirty&&(this._entities=Array.from(this.entitiesSet),this._dirty=!1),this._entities}static createId(t){var e,i,s,n,o,a,h,l,c,u,_,f;Array.isArray(t)&&(t={components:{all:t}});const m=(e=t.components)!=null&&e.any?`any_${Lt.hashComponents(new Set((i=t.components)==null?void 0:i.any))}`:"",p=(s=t.components)!=null&&s.all?`all_${Lt.hashComponents(new Set((n=t.components)==null?void 0:n.all))}`:"",x=(o=t.components)!=null&&o.not?`not_${Lt.hashComponents(new Set((a=t.components)==null?void 0:a.not))}`:"",v=(h=t.tags)!=null&&h.any?`any_${Lt.hashTags(new Set((l=t.tags)==null?void 0:l.any))}`:"",g=(c=t.tags)!=null&&c.all?`all_${Lt.hashTags(new Set((u=t.tags)==null?void 0:u.all))}`:"",y=(_=t.tags)!=null&&_.not?`not_${Lt.hashTags(new Set((f=t.tags)==null?void 0:f.not))}`:"";return[m,p,x,v,g,y].filter(Boolean).join("-")}static hashTags(t){return Array.from(t).map(e=>`t_${e}`).sort().join("-")}static hashComponents(t){return Array.from(t).map(e=>`c_${e.name}`).sort().join("-")}matchesNotFilter(t,e){for(const i of this.filter.components.not)if(e!==i&&t.has(i))return!0;for(const i of this.filter.tags.not)if(t.hasTag(i))return!0;return!1}matches(t,e){for(const i of this.filter.components.not)if(e!==i&&t.has(i))return!1;for(const i of this.filter.tags.not)if(t.hasTag(i))return!1;for(const i of this.filter.components.all)if(i===e||!t.has(i))return!1;for(const i of this.filter.tags.all)if(!t.hasTag(i))return!1;if(this.filter.components.any.size>0){let i=!1;for(const s of this.filter.components.any)if(t.has(s)){i=!0;break}if(!i)return!1}if(this.filter.tags.any.size>0){let i=!1;for(const s of this.filter.tags.any)if(t.hasTag(s)){i=!0;break}if(!i)return!1}return!0}checkAndModify(t,e){const i=this.entitiesSet.has(t);if(i&&this.matchesNotFilter(t,e))return this.removeEntity(t),!1;const s=this.matches(t,e);return i&&!s?(this.removeEntity(t),!1):!i&&s?(this._dirty=!0,this.entitiesSet.add(t),this.entityAdded$.notifyAll(t),!0):!1}removeEntity(t){this.entitiesSet.delete(t)&&(this._dirty=!0,this.entityRemoved$.notifyAll(t))}getEntities(t){return t&&this.entities.sort(t),this.entities}}class Ks{constructor(t){if(this.requiredTags=t,this.tags=new Set,this.entities=[],this.entityAdded$=new gt,this.entityRemoved$=new gt,t.length===0)throw new Error("Cannot create tag query without tags");for(const e of t)this.tags.add(e);this.id=Ks.createId(t)}static createId(t){return t.slice().sort().join("-")}checkAndAdd(t){return!this.entities.includes(t)&&t.hasAllTags(Array.from(this.tags))?(this.entities.push(t),this.entityAdded$.notifyAll(t),!0):!1}removeEntity(t){const e=this.entities.indexOf(t);e>-1&&(this.entities.splice(e,1),this.entityRemoved$.notifyAll(t))}getEntities(t){return t&&this.entities.sort(t),this.entities}}class Tr{constructor(t){this._world=t,this._queries=new Map,this._addComponentHandlers=new Map,this._removeComponentHandlers=new Map,this._componentToQueriesIndex=new Map,this._tagToQueriesIndex=new Map,this._addTagHandlers=new Map,this._removeTagHandlers=new Map,this._createAddComponentHandler=e=>i=>{this.addComponent(e,i)},this._createRemoveComponentHandler=e=>i=>{this.removeComponent(e,i)},this._createAddTagHandler=e=>i=>{this.addTag(e,i)},this._createRemoveTagHandler=e=>i=>{this.removeTag(e,i)}}createQuery(t){const e=Lt.createId(t);if(this._queries.has(e))return this._queries.get(e);const i=new Lt(t);this._queries.set(i.id,i);for(const s of[...i.filter.components.all,...i.filter.components.any,...i.filter.components.not]){const n=this._componentToQueriesIndex.get(s);n?n.push(i):this._componentToQueriesIndex.set(s,[i])}for(const s of[...i.filter.tags.all,...i.filter.tags.any,...i.filter.tags.not]){const n=this._tagToQueriesIndex.get(s);n?n.push(i):this._tagToQueriesIndex.set(s,[i])}for(const s of this._world.entities)this.addEntity(s);return i}addEntity(t){const e=this._addComponentHandlers.get(t),i=this._removeComponentHandlers.get(t),s=e!=null?e:this._createAddComponentHandler(t),n=i!=null?i:this._createRemoveComponentHandler(t);this._addComponentHandlers.set(t,s),this._removeComponentHandlers.set(t,n);const o=this._addTagHandlers.get(t),a=this._removeTagHandlers.get(t),h=o!=null?o:this._createAddTagHandler(t),l=a!=null?a:this._createRemoveTagHandler(t);this._addTagHandlers.set(t,h),this._removeTagHandlers.set(t,l);for(const c of this._queries.values())c.checkAndModify(t);t.componentAdded$.subscribe(s),t.componentRemoved$.subscribe(n),t.tagAdded$.subscribe(h),t.tagRemoved$.subscribe(l)}removeEntity(t){const e=this._addComponentHandlers.get(t),i=this._removeComponentHandlers.get(t);for(const o of this._queries.values())o.removeEntity(t);e&&(t.componentAdded$.unsubscribe(e),this._addComponentHandlers.delete(t)),i&&(t.componentRemoved$.unsubscribe(i),this._removeComponentHandlers.delete(t));const s=this._addTagHandlers.get(t),n=this._removeTagHandlers.get(t);s&&(t.tagAdded$.unsubscribe(s),this._addTagHandlers.delete(t)),n&&(t.tagRemoved$.unsubscribe(n),this._removeTagHandlers.delete(t))}addComponent(t,e){var i;const s=(i=this._componentToQueriesIndex.get(e.constructor))!=null?i:[];for(const n of s)n.checkAndModify(t)}removeComponent(t,e){var i;const s=(i=this._componentToQueriesIndex.get(e.constructor))!=null?i:[];for(const n of s)n.checkAndModify(t,e.constructor)}addTag(t,e){var i;const s=(i=this._tagToQueriesIndex.get(e))!=null?i:[];for(const n of s)n.checkAndModify(t)}removeTag(t,e){var i;const s=(i=this._tagToQueriesIndex.get(e))!=null?i:[];for(const n of s)n.removeEntity(t),n.checkAndModify(t)}}const Gt={Highest:-1/0,Higher:-5,Average:0,Lower:5,Lowest:1/0};var Pt=(r=>(r.Update="update",r.Draw="draw",r))(Pt||{});class Et{}Et.priority=Gt.Average;function Ar(r){var t,e;return!!(r!=null&&r.prototype)&&!!((e=(t=r==null?void 0:r.prototype)==null?void 0:t.constructor)!=null&&e.name)}class Pr{constructor(t){this._world=t,this.systems=[],this.initialized=!1}get(t){return this.systems.find(e=>e instanceof t)}addSystem(t){let e;t instanceof Et?e=t:e=new t(this._world),this.systems.push(e),this.systems.sort((i,s)=>i.constructor.priority-s.constructor.priority),this.initialized&&e.initialize&&e.initialize(this._world,this._world.scene)}removeSystem(t){He(t,this.systems)}initialize(){if(!this.initialized){this.initialized=!0;for(const t of this.systems)t.initialize&&t.initialize(this._world,this._world.scene)}}updateSystems(t,e,i){const s=this.systems.filter(n=>n.systemType===t);for(const n of s)n.preupdate&&n.preupdate(e,i);for(const n of s)n.update(i);for(const n of s)n.postupdate&&n.postupdate(e,i)}clear(){for(let t=this.systems.length-1;t>=0;t--)this.removeSystem(this.systems[t])}}class Er{constructor(t){this.scene=t,this._logger=R.getInstance(),this.queryManager=new Tr(this),this.entityManager=new Sr(this),this.systemManager=new Pr(this)}query(t){return this.queryManager.createQuery(t)}queryTags(t){return this.queryManager.createQuery({tags:{all:t}})}update(t,e){t===Pt.Update&&this.entityManager.updateEntities(this.scene,e),this.systemManager.updateSystems(t,this.scene,e),this.entityManager.findEntitiesForRemoval(),this.entityManager.processComponentRemovals(),this.entityManager.processEntityRemovals()}add(t){if(t instanceof At){this.entityManager.addEntity(t);return}if(t instanceof Et||Ar(t)){this.systemManager.addSystem(t);return}this._logger.warn(`Could not add entity/system ${t.constructor.name} to Excalibur!
|
|
19
19
|
|
|
20
20
|
If this looks like an Excalibur type, this can be caused by 2 versions of excalibur being included on the page.
|
|
21
21
|
|
|
@@ -928,4 +928,4 @@ If in Firefox, visit about:config
|
|
|
928
928
|
|
|
929
929
|
Read more about this issue at https://excaliburjs.com/docs/performance`),i&&this._toaster.toast("Excalibur is encountering performance issues. It's possible that your browser doesn't have hardware acceleration enabled. Visit [LINK] for more information and potential solutions.","https://excaliburjs.com/docs/performance"),this.useCanvas2DFallback(),this.emit("fallbackgraphicscontext",this.graphicsContext))}}useCanvas2DFallback(){var t,e,i;const s=this.canvas.cloneNode(!1);this.canvas.parentNode.replaceChild(s,this.canvas),this.canvas=s;const n={...this._originalOptions,antialiasing:this.screen.antialiasing},o=this._originalDisplayMode;this.graphicsContext=new Yi({canvasElement:this.canvas,enableTransparency:this.enableCanvasTransparency,antialiasing:n.antialiasing,backgroundColor:n.backgroundColor,snapToPixel:n.snapToPixel,useDrawSorting:n.useDrawSorting}),this.screen&&this.screen.dispose(),this.screen=new kn({canvas:this.canvas,context:this.graphicsContext,antialiasing:(t=n.antialiasing)!=null?t:!0,browser:this.browser,viewport:(e=n.viewport)!=null?e:n.width&&n.height?{width:n.width,height:n.height}:Bn.SVGA,resolution:n.resolution,displayMode:o,pixelRatio:n.suppressHiDPIScaling?1:(i=n.pixelRatio)!=null?i:null}),this.screen.setCurrentCamera(this.currentScene.camera),this.input.pointers.detach();const a=n&&n.pointerScope===Be.Document?document:this.canvas;this.input.pointers=this.input.pointers.recreate(a,this),this.input.pointers.init()}dispose(){this._disposed||(this._disposed=!0,this.stop(),this._garbageCollector.forceCollectAll(),this.input.toggleEnabled(!1),this._hasCreatedCanvas&&this.canvas.parentNode.removeChild(this.canvas),this.canvas=null,this.screen.dispose(),this.graphicsContext.dispose(),this.graphicsContext=null,_e.InstanceCount--)}isDisposed(){return this._disposed}getWorldBounds(){return this.screen.getWorldBounds()}get timescale(){return this._timescale}set timescale(t){if(t<0){R.getInstance().warnOnce("engine.timescale to a value less than 0 are ignored");return}this._timescale=t}addTimer(t){return this.currentScene.addTimer(t)}removeTimer(t){return this.currentScene.removeTimer(t)}addScene(t,e){return this.director.add(t,e),this}removeScene(t){this.director.remove(t)}add(t){if(arguments.length===2){this.director.add(arguments[0],arguments[1]);return}const e=this.director.getDeferredScene();e instanceof Mt?e.add(t):this.currentScene.add(t)}remove(t){t instanceof At&&this.currentScene.remove(t),(t instanceof Mt||jt(t))&&this.removeScene(t),typeof t=="string"&&this.removeScene(t)}async goToScene(t,e){await this.scope(async()=>{await this.director.goToScene(t,e)})}screenToWorldCoordinates(t){return this.screen.screenToWorldCoordinates(t)}worldToScreenCoordinates(t){return this.screen.worldToScreenCoordinates(t)}_initialize(t){var e,i;this.pageScrollPreventionMode=t.scrollPreventionMode;const s=t&&t.pointerScope===Be.Document?document:this.canvas,n=(i=(e=this._originalOptions)==null?void 0:e.grabWindowFocus)!=null?i:!0;this.input=new Yn({global:this.global,pointerTarget:s,grabWindowFocus:n,engine:this}),this.inputMapper=this.input.inputMapper,this.browser.document.on("visibilitychange",()=>{document.visibilityState==="hidden"?(this.events.emit("hidden",new Ws(this)),this._logger.debug("Window hidden")):document.visibilityState==="visible"&&(this.events.emit("visible",new Ns(this)),this._logger.debug("Window visible"))}),!this.canvasElementId&&!t.canvasElement&&document.body.appendChild(this.canvas)}toggleInputEnabled(t){this._inputEnabled=t,this.input.toggleEnabled(this._inputEnabled)}onInitialize(t){}get isInitialized(){return this._isInitialized}async _overrideInitialize(t){this.isInitialized||(await this.director.onInitialize(),await this.onInitialize(t),this.events.emit("initialize",new Oe(t,this)),this._isInitialized=!0)}_update(t){var e;if(this._isLoading){(e=this._loader)==null||e.onUpdate(this,t),this.input.update();return}this.clock.__runScheduledCbs("preupdate"),this._preupdate(t),this.currentScene.update(this,t),this.graphicsContext.updatePostProcessors(t),this.clock.__runScheduledCbs("postupdate"),this._postupdate(t),this.input.update()}_preupdate(t){this.emit("preupdate",new re(this,t,this)),this.onPreUpdate(this,t)}onPreUpdate(t,e){}_postupdate(t){this.emit("postupdate",new oe(this,t,this)),this.onPostUpdate(this,t)}onPostUpdate(t,e){}_draw(t){var e,i;if(this.graphicsContext.backgroundColor=(e=this.currentScene.backgroundColor)!=null?e:this.backgroundColor,this.graphicsContext.beginDrawLifecycle(),this.graphicsContext.clear(),this.clock.__runScheduledCbs("predraw"),this._predraw(this.graphicsContext,t),this._isLoading){this._hideLoader||((i=this._loader)==null||i.canvas.draw(this.graphicsContext,0,0),this.clock.__runScheduledCbs("postdraw"),this.graphicsContext.flush(),this.graphicsContext.endDrawLifecycle());return}this.currentScene.draw(this.graphicsContext,t),this.clock.__runScheduledCbs("postdraw"),this._postdraw(this.graphicsContext,t),this.graphicsContext.flush(),this.graphicsContext.endDrawLifecycle(),this._checkForScreenShots()}_predraw(t,e){this.emit("predraw",new Ue(t,e,this)),this.onPreDraw(t,e)}onPreDraw(t,e){}_postdraw(t,e){this.emit("postdraw",new ze(t,e,this)),this.onPostDraw(t,e)}onPostDraw(t,e){}showDebug(t){this._isDebug=t}toggleDebug(){return this._isDebug=!this._isDebug,this._isDebug}get loadingComplete(){return!this._isLoading}get ready(){return this._isReadyFuture.isCompleted}isReady(){return this._isReadyFuture.promise}async start(t,e){await this.scope(async()=>{if(!this._compatible)throw new Error("Excalibur is incompatible with your browser");this._isLoading=!0;let i;return t instanceof mi?i=t:typeof t=="string"&&(this.director.configureStart(t,e),i=this.director.mainLoader),this._logger.debug("Starting game clock..."),this.browser.resume(),this.clock.start(),this.garbageCollectorConfig&&this._garbageCollector.start(),this._logger.debug("Game clock started"),await this.load(i!=null?i:new Ki),await this._overrideInitialize(this),this._isReadyFuture.resolve(),this.emit("start",new Is(this)),this._isReadyFuture.promise})}_mainloop(t){this.scope(()=>{this.emit("preframe",new ks(this,this.stats.prevFrame));const e=t*this.timescale;this.currentFrameElapsedMs=e;const i=this.stats.prevFrame.id+1;this.stats.currFrame.reset(),this.stats.currFrame.id=i,this.stats.currFrame.elapsedMs=e,this.stats.currFrame.fps=this.clock.fpsSampler.fps,J.clear();const s=this.clock.now(),n=this.fixedUpdateTimestep;if(this.fixedUpdateTimestep)for(this._lagMs+=e;this._lagMs>=n;)this._update(n),this._lagMs-=n;else this._update(e);const o=this.clock.now();this.currentFrameLagMs=this._lagMs,this._draw(e);const a=this.clock.now();this.stats.currFrame.duration.update=o-s,this.stats.currFrame.duration.draw=a-o,this.stats.currFrame.graphics.drawnImages=J.DrawnImagesCount,this.stats.currFrame.graphics.drawCalls=J.DrawCallCount,this.emit("postframe",new Ls(this,this.stats.currFrame)),this.stats.prevFrame.reset(this.stats.currFrame),this._monitorPerformanceThresholdAndTriggerFallback()})}stop(){this.clock.isRunning()&&(this.emit("stop",new Rs(this)),this.browser.pause(),this.clock.stop(),this._garbageCollector.stop(),this._logger.debug("Game stopped"))}isRunning(){return this.clock.isRunning()}screenshot(t=!1){return new Promise(i=>{this._screenShotRequests.push({preserveHiDPIResolution:t,resolve:i})})}_checkForScreenShots(){for(const t of this._screenShotRequests){const e=t.preserveHiDPIResolution?this.canvas.width:this.screen.resolution.width,i=t.preserveHiDPIResolution?this.canvas.height:this.screen.resolution.height,s=document.createElement("canvas");s.width=e,s.height=i;const n=s.getContext("2d");n.imageSmoothingEnabled=this.screen.antialiasing,n.drawImage(this.canvas,0,0,e,i);const o=new Image,a=s.toDataURL("image/png");o.onload=()=>{t.resolve(o)},o.src=a}this._screenShotRequests.length=0}async load(t,e=!1){await this.scope(async()=>{try{if(t.isLoaded())return;this._loader=t,this._isLoading=!0,this._hideLoader=e,t instanceof Ki&&(t.suppressPlayButton=t.suppressPlayButton||this._suppressPlayButton),this._loader.onInitialize(this),await t.load()}catch(i){this._logger.error("Error loading resources, things may not behave properly",i),await Promise.resolve()}finally{this._isLoading=!1,this._hideLoader=!1,this._loader=null}})}};os.Context=ma(),os.InstanceCount=0,os._DEFAULT_ENGINE_OPTIONS={width:0,height:0,enableCanvasTransparency:!0,useDrawSorting:!0,configurePerformanceCanvas2DFallback:{allow:!1,showPlayerMessage:!1,threshold:{fps:20,numberOfFrames:100}},canvasElementId:"",canvasElement:void 0,enableCanvasContextMenu:!1,snapToPixel:!1,antialiasing:!0,pixelArt:!1,garbageCollection:!0,powerPreference:"high-performance",pointerScope:Be.Canvas,suppressConsoleBootMessage:null,suppressMinimumBrowserFeatureDetection:null,suppressHiDPIScaling:null,suppressPlayButton:null,grabWindowFocus:!0,scrollPreventionMode:1,backgroundColor:T.fromHex("#2185d0")};let as=os;class Xl extends kt{constructor(t){super(t),this._font=new Se,this._text=new _i({text:"",font:this._font});const{text:e,pos:i,x:s,y:n,spriteFont:o,font:a,color:h,maxWidth:l}={text:"",...t};this.pos=i!=null?i:s&&n?b(s,n):this.pos,this.text=e!=null?e:this.text,this.font=a!=null?a:this.font,this.maxWidth=l!=null?l:this.maxWidth,this.spriteFont=o!=null?o:this.spriteFont,this._text.color=h!=null?h:this.color;const c=this.get(K);c.anchor=w.Zero,c.use(this._text)}set maxWidth(t){this._text.maxWidth=t}get maxWidth(){return this._text.maxWidth}get font(){return this._font}set font(t){this._font=t,this._text.font=t}get text(){return this._text.text}set text(t){this._text.text=t}get color(){return this._text.color}set color(t){this._text&&(this._text.color=t)}get opacity(){return this.graphics.opacity}set opacity(t){this.graphics.opacity=t}get spriteFont(){return this._spriteFont}set spriteFont(t){t&&(this._spriteFont=t,this._text.font=this._spriteFont)}_initialize(t){super._initialize(t)}getTextWidth(){return this._text.width}}var Ee=(r=>(r.Circle="circle",r.Rectangle="rectangle",r))(Ee||{});class Yl extends kt{constructor(t){var e,i;super({width:(e=t.width)!=null?e:0,height:(i=t.height)!=null?i:0}),this._particlesToEmit=0,this._particlePool=new qe(()=>new $i({}),m=>m,500),this.numParticles=0,this.isEmitting=!0,this.deadParticles=[],this.emitRate=1,this.emitterType=Ee.Rectangle,this.radius=0,this.particle={life:2e3,transform:Xt.Global,graphic:void 0,opacity:1,angularVelocity:0,focus:void 0,focusAccel:void 0,randomRotation:!1},this._activeParticles=[];const{particle:s,x:n,y:o,z:a,pos:h,isEmitting:l,emitRate:c,emitterType:u,radius:_,random:f}={...t};this.particle={...this.particle,...s},this.pos=h!=null?h:b(n!=null?n:0,o!=null?o:0),this.z=a!=null?a:0,this.isEmitting=l!=null?l:this.isEmitting,this.emitRate=c!=null?c:this.emitRate,this.emitterType=u!=null?u:this.emitterType,this.radius=_!=null?_:this.radius,this.body.collisionType=M.PreventCollision,this.random=f!=null?f:new se}removeParticle(t){this.deadParticles.push(t)}emitParticles(t){var e;if(!(t<=0)){t=t|0;for(let i=0;i<t;i++){const s=this._createParticle();(e=this==null?void 0:this.scene)!=null&&e.world&&(this.particle.transform===Xt.Global?this.scene.world.add(s):this.addChild(s)),this._activeParticles.push(s)}}}clearParticles(){for(let t=0;t<this._activeParticles.length;t++)this.removeParticle(this._activeParticles[t])}_createParticle(){let t=0,e=0;const i=Nt(this.particle.minAngle||0,this.particle.maxAngle||Math.PI*2,this.random),s=Nt(this.particle.minSpeed||0,this.particle.maxSpeed||0,this.random),n=this.particle.startSize||Nt(this.particle.minSize||5,this.particle.maxSize||5,this.random),o=s*Math.cos(i),a=s*Math.sin(i);if(this.emitterType===Ee.Rectangle)t=Nt(0,this.width,this.random),e=Nt(0,this.height,this.random);else if(this.emitterType===Ee.Circle){const l=Nt(0,this.radius,this.random);t=l*Math.cos(i),e=l*Math.sin(i)}const h=this._particlePool.rent();return h.unparent(),h.configure({transform:this.particle.transform,life:this.particle.life,opacity:this.particle.opacity,beginColor:this.particle.beginColor,endColor:this.particle.endColor,pos:b(t,e),z:this.particle.transform===Xt.Global?this.z:void 0,vel:b(o,a),acc:this.particle.acc,angularVelocity:this.particle.angularVelocity,startSize:this.particle.startSize,endSize:this.particle.endSize,size:n,graphic:this.particle.graphic,fade:this.particle.fade}),h.registerEmitter(this),this.particle.randomRotation&&(h.transform.rotation=Nt(0,Math.PI*2,this.random)),this.particle.focus&&(h.focus=this.particle.focus.add(b(this.pos.x,this.pos.y)),h.focusAccel=this.particle.focusAccel),h}update(t,e){var i;super.update(t,e),this.isEmitting&&(this._particlesToEmit+=this.emitRate*(e/1e3),this._particlesToEmit>1&&(this.emitParticles(Math.floor(this._particlesToEmit)),this._particlesToEmit=this._particlesToEmit-Math.floor(this._particlesToEmit)));for(let s=0;s<this.deadParticles.length;s++){(i=this==null?void 0:this.scene)!=null&&i.world&&(this.scene.world.remove(this.deadParticles[s],!1),this._particlePool.return(this.deadParticles[s]));const n=this._activeParticles.indexOf(this.deadParticles[s]);n>-1&&this._activeParticles.splice(n,1)}this.deadParticles.length=0}}function Jn(r,t){if(!t())throw new Error(r)}class hs{constructor(t,e,i){this.emitRate=1,this._initialized=!1,this._vaos=[],this._buffers=[],this._drawIndex=0,this._numInputFloats=7,this._particleIndex=0,this._uploadIndex=0,this._wrappedLife=0,this._wrappedParticles=0,this._particleLife=0,this._clearRequested=!1,this._emitted=[];var s;this.emitter=t,this.particle=i,this._particleData=new Float32Array(this.emitter.maxParticles*this._numInputFloats),this._random=e,this._particleLife=(s=this.particle.life)!=null?s:2e3}get isInitialized(){return this._initialized}get maxParticles(){return this.emitter.maxParticles}initialize(t,e){if(this._initialized)return;const i=this.emitter.maxParticles,s=this._numInputFloats,n=this._particleData,o=4,a=t.createBuffer(),h=t.createVertexArray();t.bindVertexArray(h),t.bindBuffer(t.ARRAY_BUFFER,a),t.bufferData(t.ARRAY_BUFFER,i*s*o,t.DYNAMIC_DRAW),t.bufferSubData(t.ARRAY_BUFFER,0,n);let l=0;t.vertexAttribPointer(0,2,t.FLOAT,!1,s*o,0),l+=o*2,t.vertexAttribPointer(1,2,t.FLOAT,!1,s*o,l),l+=o*2,t.vertexAttribPointer(2,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(3,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(4,1,t.FLOAT,!1,s*o,l),l+=o*1,t.enableVertexAttribArray(0),t.enableVertexAttribArray(1),t.enableVertexAttribArray(2),t.enableVertexAttribArray(3),t.enableVertexAttribArray(4),this._vaos.push(h),this._buffers.push(a),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null);const c=t.createBuffer(),u=t.createVertexArray();t.bindVertexArray(u),t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,i*s*o,t.DYNAMIC_DRAW),l=0,t.vertexAttribPointer(0,2,t.FLOAT,!1,s*o,0),l+=o*2,t.vertexAttribPointer(1,2,t.FLOAT,!1,s*o,l),l+=o*2,t.vertexAttribPointer(2,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(3,1,t.FLOAT,!1,s*o,l),l+=o*1,t.vertexAttribPointer(4,1,t.FLOAT,!1,s*o,l),l+=o*1,t.enableVertexAttribArray(0),t.enableVertexAttribArray(1),t.enableVertexAttribArray(2),t.enableVertexAttribArray(3),t.enableVertexAttribArray(4),this._vaos.push(u),this._buffers.push(c),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this._currentVao=this._vaos[this._drawIndex%2],this._currentBuffer=this._buffers[(this._drawIndex+1)%2],this._initialized=!0}clearParticles(){this._particleData.fill(0),this._clearRequested=!0}emitParticles(t){const e=this._particleIndex,i=this.maxParticles*this._numInputFloats,s=t*this._numInputFloats+e;for(let n=e;n<s;n+=this._numInputFloats){let o=this._random.floating(this.particle.minAngle||0,this.particle.maxAngle||it);o+=this.particle.transform===Xt.Local?this.emitter.transform.rotation:this.emitter.transform.globalRotation;const a=this._random.floating(this.particle.minSpeed||0,this.particle.maxSpeed||0),h=this._random.floating(this.particle.minSpeed||0,this.particle.maxSpeed||0),l=a*Math.cos(o),c=h*Math.sin(o);let u=0,_=0;if(this.emitter.emitterType===Ee.Rectangle)u=this._random.floating(-.5,.5)*this.emitter.width,_=this._random.floating(-.5,.5)*this.emitter.height;else{const p=this._random.floating(0,this.emitter.radius);u=p*Math.cos(o),_=p*Math.sin(o)}const f=this.emitter.transform.apply(b(u,_)),m=[this.particle.transform===Xt.Local?u:f.x,this.particle.transform===Xt.Local?_:f.y,l,c,this.particle.randomRotation?Nt(0,it,this._random):this.particle.rotation||0,this.particle.angularVelocity||0,this._particleLife];this._particleData.set(m,n%this._particleData.length)}s>=i?(this._wrappedParticles+=(s-i)/this._numInputFloats,this._wrappedLife=this._particleLife):this._wrappedLife>0&&(this._wrappedParticles+=t),this._particleIndex=s%i,this._emitted.push([this._particleLife,e])}_uploadEmitted(t){this._particleIndex!==this._uploadIndex&&(t.bindBuffer(t.ARRAY_BUFFER,this._buffers[(this._drawIndex+1)%2]),this._particleIndex>=this._uploadIndex?t.bufferSubData(t.ARRAY_BUFFER,this._uploadIndex*4,this._particleData,this._uploadIndex,this._particleIndex-this._uploadIndex):(t.bufferSubData(t.ARRAY_BUFFER,this._uploadIndex*4,this._particleData,this._uploadIndex,this._particleData.length-this._uploadIndex),this._wrappedParticles&&t.bufferSubData(t.ARRAY_BUFFER,0,this._particleData,0,this._wrappedParticles*this._numInputFloats),this._wrappedLife=this._particleLife),t.bindBuffer(t.ARRAY_BUFFER,null)),this._uploadIndex=this._particleIndex%(this.maxParticles*this._numInputFloats)}update(t){var e;if(this._particleLife=(e=this.particle.life)!=null?e:this._particleLife,this._wrappedLife>0?this._wrappedLife-=t:(this._wrappedLife=0,this._wrappedParticles=0),!!this._emitted.length){for(let i=this._emitted.length-1;i>=0;i--){const s=this._emitted[i];s[0]-=t,s[0]<=0&&this._emitted.splice(i,1)}this._emitted.sort((i,s)=>i[0]-s[0])}}draw(t){if(this._initialized){if(this._clearRequested?(t.bindBuffer(t.ARRAY_BUFFER,this._buffers[(this._drawIndex+1)%2]),t.bufferSubData(t.ARRAY_BUFFER,0,this._particleData),t.bindBuffer(t.ARRAY_BUFFER,null),this._clearRequested=!1):this._uploadEmitted(t),t.bindVertexArray(this._currentVao),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer),this._wrappedLife&&this._emitted[0]&&this._emitted[0][1]>0){const e=this._emitted[0][1]/this._numInputFloats;Jn(`midpoint greater than 0, actual: ${e}`,()=>e>0),Jn(`midpoint is less than max, actual: ${e}`,()=>e<this.maxParticles),t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,this._emitted[0][1]*4,(this.maxParticles-e)*this._numInputFloats*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,e,this.maxParticles-e),t.endTransformFeedback(),t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,0,this._emitted[0][1]*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,0,e),t.endTransformFeedback()}else t.bindBufferRange(t.TRANSFORM_FEEDBACK_BUFFER,0,this._currentBuffer,0,this._particleData.length*4),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,0,this.maxParticles),t.endTransformFeedback();t.bindVertexArray(null),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,0,null),this._currentVao=this._vaos[this._drawIndex%2],this._currentBuffer=this._buffers[(this._drawIndex+1)%2],this._drawIndex=(this._drawIndex+1)%2}}}hs.GPU_MAX_PARTICLES=1e5;class $l extends kt{constructor(t){super({name:"GpuParticleEmitter",width:t.width,height:t.height}),this.particle={life:2e3,transform:Xt.Global,graphic:void 0,opacity:1,angularVelocity:0,focus:void 0,focusAccel:void 0,randomRotation:!1},this.graphics=new K,this.isEmitting=!1,this.emitRate=1,this.emitterType=Ee.Rectangle,this.radius=0,this.maxParticles=2e3,this._particlesToEmit=0,this.addComponent(this.graphics,!0),this.graphics.onPostDraw=this.draw.bind(this);const{particle:e,maxParticles:i,x:s,y:n,z:o,pos:a,isEmitting:h,emitRate:l,emitterType:c,radius:u,random:_}={...t};this.maxParticles=B(i!=null?i:this.maxParticles,0,hs.GPU_MAX_PARTICLES),this.pos=a!=null?a:b(s!=null?s:0,n!=null?n:0),this.z=o!=null?o:0,this.isEmitting=h!=null?h:this.isEmitting,this.emitRate=l!=null?l:this.emitRate,this.emitterType=c!=null?c:this.emitterType,this.radius=u!=null?u:this.radius,this.particle={...this.particle,...e},this.random=_!=null?_:new se,this.renderer=new hs(this,this.random,this.particle)}get pos(){return this.transform.pos}set pos(t){this.transform.pos=t}get z(){return this.transform.z}set z(t){this.transform.z=t}_initialize(t){super._initialize(t);const e=t.graphicsContext;this.renderer.initialize(e.__gl,e)}update(t,e){super.update(t,e),this.isEmitting&&(this._particlesToEmit+=this.emitRate*(e/1e3),this._particlesToEmit>1&&(this.emitParticles(Math.floor(this._particlesToEmit)),this._particlesToEmit=this._particlesToEmit-Math.floor(this._particlesToEmit))),this.renderer.update(e)}emitParticles(t){t<=0||this.renderer.emitParticles(t|0)}clearParticles(){this.renderer.clearParticles()}draw(t,e){t.draw("ex.particle",this.renderer,e)}}class Kn{constructor(t,e){this.id=H(),this._stopped=!1,this._sequenceBuilder=e,this._sequenceContext=new fi(t),this._actionQueue=this._sequenceContext.getQueue(),this._sequenceBuilder(this._sequenceContext)}update(t){this._actionQueue.update(t)}isComplete(){return this._stopped||this._actionQueue.isComplete()}stop(){this._stopped=!0}reset(){this._stopped=!1,this._actionQueue.reset()}clone(t){return new Kn(t,this._sequenceBuilder)}}class Zl{constructor(t){this.id=H(),this._actions=t}update(t){for(let e=0;e<this._actions.length;e++)this._actions[e].update(t)}isComplete(t){return this._actions.every(e=>e.isComplete(t))}reset(){this._actions.forEach(t=>t.reset())}stop(){this._actions.forEach(t=>t.stop())}}function jl(r){return!!r._initialize}function Ql(r){return!!r.onAdd}function Jl(r){return!!r.onRemove}function Kl(r){return!!r.onInitialize}function tc(r){return!!r._preupdate}function ec(r){return!!r.onPreUpdate}function ic(r){return!!r.onPostUpdate}function sc(r){return!!r.onPostUpdate}function nc(r){return!!r.onAdd}function rc(r){return!!r.onRemove}function oc(r){return!!r.onPreDraw}function ac(r){return!!r.onPostDraw}class xa{constructor(t,e){this.soundManager=e}stop(t){if(!t)return;const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)e[i].stop()}setVolume(t,e){const i=this.soundManager.getSoundsForChannel(t);for(const s of i)this.soundManager._isMuted(s)||this.soundManager.setVolume(t,e)}play(t,e){e!=null||(e=this.soundManager.defaultVolume);const i=[],s=new Set,n=this.soundManager.getSoundsForChannel(t);for(const o of n){if(s.has(o)||this.soundManager._isMuted(o))continue;const a=this.soundManager._getEffectiveVolume(o);i.push(o.play(a*e)),s.add(o)}return Promise.all(i)}mute(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._muted.add(e[i]),e[i].pause()}unmute(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._muted.has(e[i])&&(e[i].play(),this.soundManager._muted.delete(e[i]))}toggle(t){const e=this.soundManager.getSoundsForChannel(t);for(let i=0;i<e.length;i++)this.soundManager._isMuted(e[i])?(e[i].play(),this.soundManager._muted.delete(e[i])):(this.soundManager._muted.add(e[i]),e[i].pause())}}class hc{constructor(t){this._channelToConfig=new Map,this._nameToConfig=new Map,this._mix=new Map,this._muted=new Set,this._all=new Set,this._defaultVolume=1;var e;if(this._defaultVolume=(e=t.volume)!=null?e:1,this.channel=new xa(t,this),t.sounds)for(const[i,s]of Object.entries(t.sounds))this.track(i,s)}set defaultVolume(t){this._defaultVolume=B(t,0,1)}get defaultVolume(){return this._defaultVolume}getSounds(){return Array.from(this._all)}getSoundsForChannel(t){const e=this._channelToConfig.get(t);return e?e.sounds:[]}_isMuted(t){return this._muted.has(t)}_getEffectiveVolume(t){var e;if(this._isMuted(t))return 0;let i=this._defaultVolume;return this._mix.has(t)&&(i*=(e=this._mix.get(t))!=null?e:this._defaultVolume),i}play(t,e=this._defaultVolume){const i=this._nameToConfig.get(t);if(!i)return Promise.resolve();const{sound:s}=i;if(this._isMuted(s))return Promise.resolve();const n=e*this._getEffectiveVolume(s);return s.play(n)}getSound(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;return i}setVolume(t,e=this._defaultVolume){const i=this._nameToConfig.get(t);if(!i)return;const{sound:s}=i;this._setMix(s,e)}getVolume(t){var e;const i=this.getSound(t);return i&&(e=this._mix.get(i))!=null?e:0}_setMix(t,e){this._mix.set(t,e),t.volume=e}track(t,e){let i,s,n;e instanceof zn?(i=e,s=this._defaultVolume,n=[]):{sound:i,volume:s,channels:n}=e,this._nameToConfig.set(t,{sound:i,volume:s,channels:n}),this._mix.set(i,s!=null?s:this._defaultVolume),this._all.add(i),n&&this.addChannel(t,n)}untrack(t){this._nameToConfig.delete(t);const e=this.getSound(t);e&&(this._mix.delete(e),this._all.delete(e))}stop(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;i.stop();return}this._all.forEach(e=>e.stop())}mute(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;this._muted.add(i),i.pause();return}this._muted=new Set(this._all),this._muted.forEach(e=>e.pause())}unmute(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;i.play(),this._muted.delete(i);return}this._muted.forEach(e=>e.play()),this._muted.clear()}toggle(t){if(t){const e=this._nameToConfig.get(t);if(!e)return;const{sound:i}=e;this._isMuted(i)?this.unmute(t):this.mute(t);return}this._muted.size>0?(this._muted.forEach(e=>e.play()),this._muted.clear()):(this._muted=new Set(this._all),this._muted.forEach(e=>e.pause()))}addChannel(t,e){const i=this.getSound(t);if(!i)return;const s=this._mix.get(i);this._mix.set(i,s!=null?s:this._defaultVolume),this._all.add(i);for(const n of e){let o=this._channelToConfig.get(n);o||(o={sounds:[i]}),o.sounds.indexOf(i)===-1&&o.sounds.push(i),this._channelToConfig.set(n,o)}}removeChannel(t,e){const i=this.getSound(t);if(i)for(const s of e){const n=this._channelToConfig.get(s);if(!n)return;const o=n.sounds.indexOf(i);o>=-1&&n.sounds.splice(o,1),this._channelToConfig.set(s,n)}}}class lc{constructor(t,e=!1){this.path=t,this.width=0,this.height=0,this._images=[],this.data=[],this._sprites=[],this._resource=new li(t,"arraybuffer",e)}get bustCache(){return this._resource.bustCache}set bustCache(t){this._resource.bustCache=t}async load(){const t=await this._resource.load();this._stream=new ba(t),this._gif=new ya(this._stream);const e=this._gif.images.map(i=>new qt(i.src,!1));return await Promise.all(e.map(i=>i.load())),this.data=this._images=e,this._sprites=this._images.map(i=>i.toSprite()),this.data}isLoaded(){return!!this.data}toSprite(t=0){var e;return(e=this._sprites[t])!=null?e:null}toSpriteSheet(){const t=this._sprites;return t.length?new ye({sprites:t}):null}toAnimation(t){var e;const i=(e=this._gif)==null?void 0:e.images;if(i!=null&&i.length){const s=i.map((n,o)=>{var a;return{graphic:this._sprites[o],duration:((a=this._gif)==null?void 0:a.frames[o].delayMs)||void 0}});return this._animation=new zi({frames:s,frameDuration:t}),this._animation}return null}get readCheckBytes(){var t,e;return(e=(t=this._gif)==null?void 0:t.checkBytes)!=null?e:[]}}const ls=r=>r.reduce(function(t,e){return t*2+e},0),tr=r=>{const t=[];for(let e=7;e>=0;e--)t.push(!!(r&1<<e));return t};class ba{constructor(t){if(this.len=0,this.position=0,this.readByte=()=>{if(this.position>=this.data.byteLength)throw new Error("Attempted to read past end of stream.");return this.data[this.position++]},this.readBytes=e=>{const i=[];for(let s=0;s<e;s++)i.push(this.readByte());return i},this.read=e=>{let i="";for(let s=0;s<e;s++)i+=String.fromCharCode(this.readByte());return i},this.readUnsigned=()=>{const e=this.readBytes(2);return(e[1]<<8)+e[0]},this.data=new Uint8Array(t),this.len=this.data.byteLength,this.len===0)throw new Error("No data loaded from file")}}const cc=function(r,t){let e=0;const i=function(_){let f=0;for(let m=0;m<_;m++)t.charCodeAt(e>>3)&1<<(e&7)&&(f|=1<<m),e++;return f},s=[],n=1<<r,o=n+1;let a=r+1,h=[];const l=function(){h=[],a=r+1;for(let _=0;_<n;_++)h[_]=[_];h[n]=[],h[o]=null};let c=0,u=0;for(;;){if(u=c,c=i(a),c===n){l();continue}if(c===o)break;if(c<h.length)u!==n&&h.push(h[u].concat(h[c][0]));else{if(c!==h.length)throw new Error("Invalid LZW code.");h.push(h[u].concat(h[u][0]))}s.push.apply(s,h[c]),h.length===1<<a&&a<12&&a++}return s};class ya{constructor(t){this._handler={},this.frames=[],this.images=[],this.globalColorTableBytes=[],this.checkBytes=[],this.parseColorTableBytes=e=>{const i=[];for(let s=0;s<e;s++){const n=this._st.readBytes(3);i.push(n)}return i},this.readSubBlocks=()=>{let e,i;i="";do e=this._st.readByte(),i+=this._st.read(e);while(e!==0);return i},this.parseHeader=()=>{const e={sig:"",ver:"",width:0,height:0,colorResolution:0,globalColorTableSize:0,gctFlag:!1,sortedFlag:!1,globalColorTable:[],backgroundColorIndex:0,pixelAspectRatio:0};if(e.sig=this._st.read(3),e.ver=this._st.read(3),e.sig!=="GIF")throw new Error("Not a GIF file.");e.width=this._st.readUnsigned(),e.height=this._st.readUnsigned(),this._currentFrameCanvas.width=e.width,this._currentFrameCanvas.height=e.height;const i=tr(this._st.readByte());e.gctFlag=i.shift(),e.colorResolution=ls(i.splice(0,3)),e.sortedFlag=i.shift(),e.globalColorTableSize=ls(i.splice(0,3)),e.backgroundColorIndex=this._st.readByte(),e.pixelAspectRatio=this._st.readByte(),e.gctFlag&&(this.globalColorTableBytes=this.parseColorTableBytes(1<<e.globalColorTableSize+1)),this._handler.hdr&&this._handler.hdr(e)&&this.checkBytes.push(this._handler.hdr)},this.parseExt=e=>{const i=h=>{this.checkBytes.push(this._st.readByte());const l=tr(this._st.readByte());return h.reserved=l.splice(0,3),h.disposalMethod=ls(l.splice(0,3)),h.userInputFlag=l.shift(),h.transparentColorFlag=l.shift(),h.delayTime=this._st.readUnsigned(),h.transparentColorIndex=this._st.readByte(),h.terminator=this._st.readByte(),this._handler.gce&&this._handler.gce(h)&&this.checkBytes.push(this._handler.gce),h},s=h=>{h.comment=this.readSubBlocks(),this._handler.com&&this._handler.com(h)&&this.checkBytes.push(this._handler.com)},n=h=>{this.checkBytes.push(this._st.readByte()),h.ptHeader=this._st.readBytes(12),h.ptData=this.readSubBlocks(),this._handler.pte&&this._handler.pte(h)&&this.checkBytes.push(this._handler.pte)},o=h=>{const l=u=>{this.checkBytes.push(this._st.readByte()),u.unknown=this._st.readByte(),u.iterations=this._st.readUnsigned(),u.terminator=this._st.readByte(),this._handler.app&&this._handler.app.NETSCAPE&&this._handler.app.NETSCAPE(u)&&this.checkBytes.push(this._handler.app)},c=u=>{u.appData=this.readSubBlocks(),this._handler.app&&this._handler.app[u.identifier]&&this._handler.app[u.identifier](u)&&this.checkBytes.push(this._handler.app[u.identifier])};switch(this.checkBytes.push(this._st.readByte()),h.identifier=this._st.read(8),h.authCode=this._st.read(3),h.identifier){case"NETSCAPE":l(h);break;default:c(h);break}},a=h=>{h.data=this.readSubBlocks(),this._handler.unknown&&this._handler.unknown(h)&&this.checkBytes.push(this._handler.unknown)};switch(e.label=this._st.readByte(),e.label){case 249:e.extType="gce",this._gce=i(e);break;case 254:e.extType="com",s(e);break;case 1:e.extType="pte",n(e);break;case 255:e.extType="app",o(e);break;default:e.extType="unknown",a(e);break}},this.parseImg=e=>{var i;const s=(a,h)=>{const l=new Array(a.length),c=a.length/h,u=(p,x)=>{const v=a.slice(x*h,(x+1)*h);l.splice.apply(l,[p*h,h].concat(v))},_=[0,4,2,1],f=[8,8,4,2];let m=0;for(let p=0;p<4;p++)for(let x=_[p];x<c;x+=f[p])u(x,m),m++;return l};e.leftPos=this._st.readUnsigned(),e.topPos=this._st.readUnsigned(),e.width=this._st.readUnsigned(),e.height=this._st.readUnsigned();const n=tr(this._st.readByte());e.lctFlag=n.shift(),e.interlaced=n.shift(),e.sorted=n.shift(),e.reserved=n.splice(0,2),e.lctSize=ls(n.splice(0,3)),e.lctFlag&&(e.lctBytes=this.parseColorTableBytes(1<<e.lctSize+1)),e.lzwMinCodeSize=this._st.readByte();const o=this.readSubBlocks();e.pixels=cc(e.lzwMinCodeSize,o),e.interlaced&&(e.pixels=s(e.pixels,e.width)),(i=this._gce)!=null&&i.delayTime&&(e.delayMs=this._gce.delayTime*10),this.frames.push(e),this.arrayToImage(e,e.lctFlag?e.lctBytes:this.globalColorTableBytes),this._handler.img&&this._handler.img(e)&&this.checkBytes.push(this._handler)},this.parseBlocks=()=>{const e={sentinel:this._st.readByte(),type:""};switch(String.fromCharCode(e.sentinel)){case"!":e.type="ext",this.parseExt(e);break;case",":e.type="img",this.parseImg(e);break;case";":e.type="eof",this._handler.eof&&this._handler.eof(e)&&this.checkBytes.push(this._handler.eof);break;default:throw new Error("Unknown block: 0x"+e.sentinel.toString(16))}e.type!=="eof"&&this.parseBlocks()},this.arrayToImage=(e,i)=>{var s,n,o,a;const h=document.createElement("canvas");h.width=e.width,h.height=e.height;const l=h.getContext("2d"),c=l.getImageData(0,0,h.width,h.height);let u=-1;(s=this._gce)!=null&&s.transparentColorFlag&&(u=this._gce.transparentColorIndex);for(let f=0;f<e.pixels.length;f++){const m=e.pixels[f],p=i[m];m===u?c.data.set([0,0,0,0],f*4):c.data.set([...p,255],f*4)}if(l.putImageData(c,0,0),((n=this._gce)==null?void 0:n.disposalMethod)===1&&this.images.length)this._currentFrameContext.drawImage(this.images[this.images.length-1],0,0);else if(((o=this._gce)==null?void 0:o.disposalMethod)===2&&((a=this._hdr)!=null&&a.gctFlag)){const f=i[this._hdr.backgroundColorIndex];this._currentFrameContext.fillStyle=`rgb(${f[0]}, ${f[1]}, ${f[2]})`,this._currentFrameContext.fillRect(0,0,this._hdr.width,this._hdr.height)}else this._currentFrameContext.clearRect(0,0,this._currentFrameCanvas.width,this._currentFrameCanvas.height);this._currentFrameContext.drawImage(h,e.leftPos,e.topPos,e.width,e.height);const _=new Image;_.src=this._currentFrameCanvas.toDataURL(),this.images.push(_)},this._st=t,this._handler={},this._currentFrameCanvas=document.createElement("canvas"),this._currentFrameContext=this._currentFrameCanvas.getContext("2d"),this.parseHeader(),this.parseBlocks()}}class dc{constructor(t,e,{bustCache:i,...s}={}){this.path=t,this.family=e,this._isLoaded=!1,this._resource=new li(t,"blob",i),this._options=s}async load(){if(this.isLoaded())return this.data;try{const t=await this._resource.load(),e=URL.createObjectURL(t);this.data||(this.data=new FontFace(this.family,`url(${e})`),document.fonts.add(this.data)),await this.data.load(),this._isLoaded=!0}catch(t){throw`Error loading FontSource from path '${this.path}' with error [${t.message}]`}return this.data}isLoaded(){return this._isLoaded}toFont(t){return new Se({family:this.family,...this._options,...t})}}const Ca=ma(),uc=/^\s*(?:function)?\*/;function Sa(r){return typeof r!="function"?!1:uc.test(Function.prototype.toString.call(r))?!0:Object.getPrototypeOf?Object.getPrototypeOf(r)===Object.getPrototypeOf(new Function("return function * () {}")()):!1}function Ta(...r){var t;const e=R.getInstance();let i,s,n,o;Sa(r[0])&&(s=globalThis,i=r[0],n=r[1]),Sa(r[1])&&(s=r[0],i=r[1],n=r[2]),r[1]instanceof as&&(s=r[0],o=r[1],i=r[2],n=r[3]),r[0]instanceof as&&(s=globalThis,o=r[0],i=r[1],n=r[2]);const a=va(Ca),h=n==null?void 0:n.timing,l=a?!1:(t=n==null?void 0:n.autostart)!=null?t:!0;let c;try{c=o!=null?o:as.useEngine()}catch(y){throw Error(`Cannot run coroutine without engine parameter outside of an excalibur lifecycle method.
|
|
930
930
|
Pass an engine parameter to ex.coroutine(engine, function * {...})`)}let u=!1,_=!1,f=!1;const m=i.bind(s),p=m();let x;const v=new Promise((y,S)=>{x=A=>{try{if(f){_=!0,y();return}const{done:I,value:C}=Ca.scope(!0,()=>p.next(A));if(I||f){_=!0,y();return}C instanceof Promise?C.then(()=>{c.clock.schedule(x,0,h)}):C===void 0||C===void 0?c.clock.schedule(x,0,h):c.clock.schedule(x,C||0,h)}catch(I){S(I);return}},l&&(u=!0,x(c.clock.elapsed()))}),g={isRunning:()=>u&&!f&&!_,isComplete:()=>_,cancel:()=>{f=!0},start:()=>(u?e.warn(`.start() was called on a coroutine that was already started, this is probably a bug:
|
|
931
|
-
`,Function.prototype.toString.call(m)):(u=!0,x(c.clock.elapsed())),g),generator:p,done:v,then:v.then.bind(v),[Symbol.iterator]:()=>p};return g}class cs extends At{constructor(t){var e,i,s,n,o;super(),this._logger=R.getInstance(),this.transform=new P,this.graphics=new K,this._completeFuture=new wt,this.started=!1,this._currentDistance=0,this._currentProgress=0,this.done=this._completeFuture.promise,this._useLegacyEasing=!1,this.name=`Transition#${this.id}`,this.duration=t.duration,Te(t.easing)?(this.legacyEasing=(e=t.easing)!=null?e:Rt.Linear,this._useLegacyEasing=!0):this.easing=(i=t.easing)!=null?i:Ai,this.direction=(s=t.direction)!=null?s:"out",this.hideLoader=(n=t.hideLoader)!=null?n:!1,this.blockInput=(o=t.blockInput)!=null?o:!1,this.transform.coordPlane=rt.Screen,this.transform.pos=w.Zero,this.transform.z=1/0,this.graphics.anchor=w.Zero,this.addComponent(this.transform),this.addComponent(this.graphics),this.direction==="out"?this._currentProgress=0:this._currentProgress=1}get progress(){return this._currentProgress}get distance(){return this._currentDistance}get complete(){return this.direction==="out"?this.progress>=1:this.progress<=0}updateTransition(t,e){this.complete||(this._currentDistance+=B(e/this.duration,0,1),this._currentDistance>=1&&(this._currentDistance=1),this.direction==="out"?this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,0,1,1),0,1):this._currentProgress=B(ot(0,1,this.easing(this._currentDistance)),0,1):this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,1,0,1),0,1):this._currentProgress=B(ot(1,0,this.easing(this._currentDistance)),0,1))}async onPreviousSceneDeactivate(t){}onStart(t){}onUpdate(t){}onEnd(t){}onReset(){}reset(){this.started=!1,this._completeFuture=new wt,this.done=this._completeFuture.promise,this._currentDistance=0,this.direction==="out"?this._currentProgress=0:this._currentProgress=1,this.onReset()}_addToTargetScene(t,e){const i=e;if(this.started&&this._logger.warn(`Attempted to add a transition ${this.name} that is already playing.`),i.world.entityManager.getById(this.id))return this._co;this._engine=t,i.add(this);const s=this;return this._co=Ta(t,function*(){for(;!s.complete;){const n=yield;s.updateTransition(s._engine,n),s._execute()}},{autostart:!1}),this._co}async _play(){this.started&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that is already playing, reset transition.`)),(!this._engine||!this._co)&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that hasn't been added`)),this._co&&await this._co.start()}_execute(){this.isInitialized&&(this.started||(this.started=!0,this.onStart(this.progress)),this.onUpdate(this.progress),this.complete&&!this._completeFuture.isCompleted&&(this.onEnd(this.progress),this._completeFuture.resolve()))}}class _c extends cs{constructor(t){var e,i;super({...t,duration:(e=t.duration)!=null?e:2e3}),this.name=`FadeInOut#${this.id}`,this.color=(i=t.color)!=null?i:T.Black}onInitialize(t){this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=new ui({width:t.screen.resolution.width,height:t.screen.resolution.height,color:this.color}),this.graphics.add(this.screenCover),this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=t}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class fc extends cs{constructor(t){super({direction:"in",...t}),this.name=`CrossFade#${this.id}`}async onPreviousSceneDeactivate(t){this.image=await t.engine.screenshot(!0),await this.image.decode()}onInitialize(t){this.engine=t,this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=qt.fromHtmlImageElement(this.image).toSprite(),this.graphics.add(this.screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio),this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class gc extends cs{constructor(t){var e;super({direction:"in",...t}),this._easing=Rt.Linear,this._start=w.Zero,this._end=w.Zero,this.name=`Slide#${this.id}`,this.slideDirection=t.slideDirection,this.transform.coordPlane=rt.Screen,this.graphics.forceOnScreen=!0,this._easing=(e=t.easingFunction)!=null?e:this._easing}async onPreviousSceneDeactivate(t){this._image=await t.engine.screenshot(!0),await this._image.decode(),this._screenCover=qt.fromHtmlImageElement(this._image).toSprite()}onInitialize(t){this._engine=t;let e=t.screen.unsafeArea;switch(e.hasZeroDimensions()&&(e=t.screen.contentArea),this.slideDirection){case"up":{this._directionOffset=b(0,-e.height);break}case"down":{this._directionOffset=b(0,e.height);break}case"left":{this._directionOffset=b(-e.width,0);break}case"right":{this._directionOffset=b(e.width,0);break}}this._camera=this._engine.currentScene.camera,this._destinationCameraPosition=this._camera.pos.clone(),this._camera.pos=this._camera.pos.add(this._directionOffset),this.transform.pos=this.transform.pos.add(this._directionOffset),this._startCameraPosition=this._camera.pos.clone(),this._start=e.topLeft,this._end=this._start.add(this._directionOffset),this.transform.pos=this._start,this.graphics.use(this._screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio)}onStart(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}onUpdate(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}}const pc=Object.freeze(Object.defineProperty({__proto__:null,ConsoleAppender:Cs,DrawUtil:Uh,EasingFunctions:Rt,LogLevel:Le,Logger:R,Observable:gt,ScreenAppender:mr,addItemToArray:Ch,contains:xr,delay:Fi,fail:br,getMinIndex:wr,getPosition:oi,isLegacyEasing:Te,isObject:Di,mergeDeep:Bi,omit:yr,removeItemFromArray:He},Symbol.toStringTag,{value:"Module"})),Aa=5,ti={},mc=()=>{for(const r in ti)ti[r]=0},ds=(r,t)=>{const e=De.isEnabled("suppress-obsolete-message");ti[r]<Aa&&!e&&(R.getInstance().warn(r),console.trace&&t.showStackTrace&&console.trace()),ti[r]++};function vc(r){return r={message:"This feature will be removed in future versions of Excalibur.",alternateMethod:null,showStackTrace:!1,...r},function(t,e,i){if(i&&!(typeof i.value=="function"||typeof i.get=="function"||typeof i.set=="function"))throw new SyntaxError("Only classes/functions/getters/setters can be marked as obsolete");const n=`${`${t.name||""}${t.name&&e?".":""}${e||""}`} is marked obsolete: ${r.message}`+(r.alternateMethod?` Use ${r.alternateMethod} instead`:"");ti[n]||(ti[n]=0);const o=i?{...i}:t;if(!i){class a extends o{constructor(...l){ds(n,r),super(...l)}}return a}return i&&i.value?(o.value=function(){return ds(n,r),i.value.apply(this,arguments)},o):(i&&i.get&&(o.get=function(){return ds(n,r),i.get.apply(this,arguments)}),i&&i.set&&(o.set=function(){return ds(n,r),i.set.apply(this,arguments)}),o)}}class wc{constructor(){this._queue=[]}get length(){return this._queue.length}enqueue(){const t=new wt;return this._queue.push(t),t.promise}dequeue(t){this._queue.shift().resolve(t)}}class xc{constructor(t){this._count=t,this._waitQueue=new wc}get count(){return this._count}get waiting(){return this._waitQueue.length}async enter(){return this._count!==0?(this._count--,Promise.resolve()):this._waitQueue.enqueue()}exit(t=1){if(t!==0){for(;t!==0&&this._waitQueue.length!==0;)this._waitQueue.dequeue(null),t--;this._count+=t}}}const er="0.32.0-alpha.1574+e3aa0be";Fe(),d.ActionCompleteEvent=js,d.ActionContext=fi,d.ActionQueue=eo,d.ActionSequence=Kn,d.ActionStartEvent=Zs,d.ActionsComponent=Qe,d.ActionsSystem=Vn,d.ActivateEvent=Gs,d.Actor=kt,d.ActorEvents=Al,d.AddEvent=Qs,d.AddedComponent=Sh,d.AffineMatrix=Z,d.Animation=zi,d.AnimationDirection=Br,d.AnimationEvents=Dh,d.AnimationStrategy=kr,d.ArcadeSolver=Fn,d.AudioContextFactory=pi,d.Axes=ea,d.Axis=Yo,d.BaseAlign=ln,d.BezierCurve=si,d.Blink=yo,d.BodyComponent=N,d.BoundingBox=F,d.BrowserComponent=$n,d.BrowserEvents=da,d.Buttons=qn,d.Camera=Ko,d.CameraEvents=zl,d.Canvas=Xi,d.ChannelCollection=xa,d.Circle=qi,d.CircleCollider=dt,d.Clock=Zn,d.ClosestLineJumpTable=Vt,d.Collider=ai,d.ColliderComponent=tt,d.CollisionContact=xe,d.CollisionEndEvent=ri,d.CollisionGroup=me,d.CollisionGroupManager=Pi,d.CollisionJumpTable=Ut,d.CollisionPostSolveEvent=Mi,d.CollisionPreSolveEvent=Ri,d.CollisionStartEvent=ni,d.CollisionSystem=Qi,d.CollisionType=M,d.Color=T,d.ColorBlindFlags=la,d.ColorBlindnessMode=$e,d.ColorBlindnessPostProcessor=Qr,d.Component=Dt,d.CompositeCollider=at,d.ConsoleAppender=Cs,d.ContactConstraintPoint=Mo,d.ContactEndEvent=Ii,d.ContactSolveBias=ae,d.ContactStartEvent=Ei,d.CoordPlane=rt,d.CrossFade=fc,d.CurveBy=Eo,d.CurveTo=Po,d.DeactivateEvent=Vs,d.Debug=Tt,d.DebugConfig=ca,d.DebugGraphicsComponent=Wi,d.DebugSystem=Gn,d.DebugText=fn,d.DefaultAntialiasOptions=Or,d.DefaultGarbageCollectionOptions=Qn,d.DefaultLoader=mi,d.DefaultPixelArtOptions=Hr,d.DegreeOfFreedom=le,d.Delay=So,d.Detector=Oo,d.Die=To,d.Direction=dn,d.Director=pa,d.DirectorEvents=ga,d.DisplayMode=gi,d.DynamicTree=en,d.DynamicTreeCollisionProcessor=ki,d.EX_VERSION=er,d.EaseBy=bo,d.EaseTo=xo,d.EasingFunctions=Rt,d.Edge=ws,d.EdgeCollider=St,d.ElasticToActorStrategy=jo,d.EmitterType=Ee,d.Engine=as,d.EngineEvents=ql,d.EnterTriggerEvent=Ys,d.EnterViewPortEvent=Xs,d.Entity=At,d.EntityEvents=Eh,d.EntityManager=Sr,d.EventEmitter=X,d.EventTypes=Ts,d.Events=yh,d.ExResponse=Ln,d.ExcaliburGraphicsContext2DCanvas=Yi,d.ExcaliburGraphicsContextWebGL=$t,d.ExitTriggerEvent=$s,d.ExitViewPortEvent=qs,d.Fade=Co,d.FadeInOut=_c,d.Flags=De,d.Flash=Ao,d.Follow=Pn,d.Font=Se,d.FontCache=Vi,d.FontSource=dc,d.FontStyle=cn,d.FontUnit=an,d.FpsSampler=ua,d.FrameStats=yi,d.Future=wt,d.GameEvent=k,d.GameStartEvent=Is,d.GameStopEvent=Rs,d.Gamepad=ss,d.GamepadAxisEvent=Hs,d.GamepadButtonEvent=Os,d.GamepadConnectEvent=Us,d.GamepadDisconnectEvent=zs,d.Gamepads=is,d.GarbageCollector=wa,d.Gif=lc,d.GifParser=ya,d.GlobalCoordinates=ke,d.GpuParticleEmitter=$l,d.GpuParticleRenderer=hs,d.Graph=vs,d.Graphic=st,d.GraphicsComponent=K,d.GraphicsGroup=We,d.GraphicsSystem=pn,d.HashColliderProxy=Ro,d.HashGridCell=Zt,d.HashGridProxy=In,d.HiddenEvent=Ws,d.HorizontalFirst=nn,d.ImageFiltering=mt,d.ImageSource=qt,d.ImageSourceAttributeConstants=z,d.ImageWrapping=_t,d.InitializeEvent=Oe,d.InputHost=Yn,d.InputMapper=ia,d.IsometricEntityComponent=vi,d.IsometricEntitySystem=Wn,d.IsometricMap=Ul,d.IsometricTile=qo,d.KeyEvent=wi,d.Keyboard=aa,d.Keys=oa,d.KillEvent=As,d.Label=Xl,d.LimitCameraBoundsStrategy=Jo,d.Line=gn,d.LineSegment=Q,d.Loader=Ki,d.LoaderEvents=Fl,d.LockCameraToActorAxisStrategy=Zo,d.LockCameraToActorStrategy=$o,d.LogLevel=Le,d.Logger=R,d.Material=Kr,d.Matrix=Ct,d.MatrixLocations=cr,d.MediaEvent=Un,d.Meet=Zi,d.MotionComponent=O,d.MotionSystem=ji,d.MoveBy=Tn,d.MoveByWithOptions=ro,d.MoveTo=An,d.MoveToWithOptions=ao,d.NativePointerButton=Pe,d.NativeSoundEvent=Ae,d.NativeSoundProcessedEvent=Lo,d.NineSlice=wn,d.NineSliceStretch=zr,d.Node=Ti,d.None=rn,d.Observable=gt,d.OffscreenSystem=mn,d.Pair=pt,d.ParallaxComponent=Gi,d.ParallelActions=Zl,d.Particle=$i,d.ParticleEmitter=Yl,d.ParticleRenderer=Zr,d.ParticleTransform=Xt,d.PhysicsStats=rs,d.PhysicsWorld=Fo,d.PointerAbstraction=Xn,d.PointerButton=ce,d.PointerComponent=he,d.PointerEvent=xi,d.PointerEventReceiver=ns,d.PointerScope=Be,d.PointerSystem=es,d.PointerType=de,d.Polygon=vn,d.PolygonCollider=lt,d.Pool=Ui,d.PositionNode=_r,d.PostCollisionEvent=we,d.PostDebugDrawEvent=Bs,d.PostDrawEvent=ze,d.PostFrameEvent=Ls,d.PostKillEvent=Es,d.PostTransformDrawEvent=Fs,d.PostUpdateEvent=oe,d.PreCollisionEvent=ve,d.PreDebugDrawEvent=Ds,d.PreDrawEvent=Ue,d.PreFrameEvent=ks,d.PreKillEvent=Ps,d.PreLoadEvent=Wl,d.PreTransformDrawEvent=Ms,d.PreUpdateEvent=re,d.Projection=ei,d.QuadIndexBuffer=Ze,d.QuadTree=Je,d.Query=Lt,d.QueryManager=Tr,d.RadiusAroundActorStrategy=Qo,d.Random=se,d.Raster=Ge,d.Ray=ge,d.RealisticSolver=Dn,d.Rectangle=ui,d.RemoveEvent=Js,d.RemovedComponent=Ah,d.RentalPool=qe,d.Repeat=io,d.RepeatForever=so,d.Resolution=Bn,d.Resource=li,d.ResourceEvents=Hh,d.RotateBy=uo,d.RotateByWithOptions=co,d.RotateTo=lo,d.RotateToWithOptions=ho,d.RotationType=j,d.ScaleBy=vo,d.ScaleByWithOptions=mo,d.ScaleTo=go,d.ScaleToWithOptions=fo,d.Scene=Mt,d.SceneEvents=Gl,d.Screen=kn,d.ScreenAppender=mr,d.ScreenElement=Hn,d.ScreenEvents=Pl,d.ScreenShader=jr,d.ScrollPreventionMode=Ke,d.Semaphore=xc,d.SeparatingAxis=Ne,d.SeparationInfo=Mr,d.Shader=Bt,d.Shape=ut,d.Slide=gc,d.SolverStrategy=Li,d.Sound=zn,d.SoundEvents=Rl,d.SoundManager=hc,d.SparseHashGrid=Rn,d.SparseHashGridCollisionProcessor=Mn,d.SpatialPartitionStrategy=hi,d.Sprite=zt,d.SpriteFont=Oi,d.SpriteSheet=ye,d.StandardClock=jn,d.StateMachine=Ji,d.StrategyContainer=Xo,d.Stream=ba,d.System=Et,d.SystemManager=Pr,d.SystemPriority=Gt,d.SystemType=Pt,d.TagQuery=Ks,d.TestClock=_a,d.Text=_i,d.TextAlign=hn,d.TextureLoader=Xe,d.Tile=Vo,d.TileMap=Go,d.TileMapEvents=Ll,d.TiledAnimation=xn,d.TiledSprite=di,d.Timer=ts,d.Toaster=fa,d.Transform=Kt,d.TransformComponent=P,d.Transition=cs,d.TreeNode=tn,d.Trigger=ta,d.TriggerEvents=Ol,d.TwoPI=it,d.UniformBuffer=Nr,d.Util=pc,d.Vector=w,d.VectorView=ps,d.VertexBuffer=Ht,d.VertexLayout=Yt,d.VerticalFirst=sn,d.VisibleEvent=Ns,d.WebAudio=Bo,d.WebAudioInstance=ko,d.WheelDeltaMode=bi,d.WheelEvent=ha,d.World=Er,d.approximatelyEqual=ar,d.assert=Jn,d.canonicalizeAngle=Jt,d.clamp=B,d.coroutine=Ta,d.createId=fe,d.easeInBack=fh,d.easeInBounce=gr,d.easeInCirc=dh,d.easeInCubic=th,d.easeInElastic=mh,d.easeInExpo=hh,d.easeInOutBack=ph,d.easeInOutBounce=xh,d.easeInOutCirc=_h,d.easeInOutCubic=bs,d.easeInOutElastic=wh,d.easeInOutExpo=ch,d.easeInOutQuad=Ka,d.easeInOutQuart=nh,d.easeInOutQuint=ah,d.easeInOutSine=ja,d.easeInQuad=Qa,d.easeInQuart=ih,d.easeInQuint=rh,d.easeInSine=$a,d.easeOutBack=gh,d.easeOutBounce=ys,d.easeOutCirc=uh,d.easeOutCubic=eh,d.easeOutElastic=vh,d.easeOutExpo=lh,d.easeOutQuad=Ja,d.easeOutQuart=sh,d.easeOutQuint=oh,d.easeOutSine=Za,d.frac=Na,d.getDefaultPhysicsConfig=te,d.glTypeToUniformTypeName=Xr,d.hasGraphicsTick=Sn,d.hasOnAdd=nc,d.hasOnInitialize=Kl,d.hasOnPostUpdate=sc,d.hasOnPreUpdate=ec,d.hasOnRemove=rc,d.hasPostDraw=ac,d.hasPreDraw=oc,d.has_add=Ql,d.has_initialize=jl,d.has_postupdate=ic,d.has_preupdate=tc,d.has_remove=Jl,d.inverseLerp=dr,d.inverseLerpVector=ur,d.isActor=Tl,d.isAddedComponent=Th,d.isComponentCtor=vr,d.isLegacyEasing=Te,d.isLoaderConstructor=On,d.isMoveByOptions=no,d.isMoveToOptions=oo,d.isRemovedComponent=Ph,d.isRotateByOptions=Sl,d.isRotateToOptions=Cl,d.isScaleByOptions=po,d.isScaleToOptions=_o,d.isSceneConstructor=jt,d.isScreenElement=Ho,d.isSystemConstructor=Ar,d.lerp=ot,d.lerpAngle=ms,d.lerpVector=ii,d.linear=Ai,d.maxMessages=Aa,d.nextActionId=H,d.obsolete=vc,d.parseImageFiltering=Ve,d.parseImageWrapping=Ot,d.pixelSnapEpsilon=D,d.randomInRange=Nt,d.randomIntInRange=Va,d.range=Ga,d.remap=Wt,d.remapVector=qa,d.resetObsoleteCounter=mc,d.sign=V,d.smootherstep=Ya,d.smoothstep=Xa,d.toDegrees=hr,d.toRadians=Wa,d.vec=b,d.webgl=Yh,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
931
|
+
`,Function.prototype.toString.call(m)):(u=!0,x(c.clock.elapsed())),g),generator:p,done:v,then:v.then.bind(v),[Symbol.iterator]:()=>p};return g}class cs extends At{constructor(t){var e,i,s,n,o;super(),this._logger=R.getInstance(),this.transform=new P,this.graphics=new K,this._completeFuture=new wt,this.started=!1,this._currentDistance=0,this._currentProgress=0,this.done=this._completeFuture.promise,this._useLegacyEasing=!1,this.name=`Transition#${this.id}`,this.duration=t.duration,Te(t.easing)?(this.legacyEasing=(e=t.easing)!=null?e:Rt.Linear,this._useLegacyEasing=!0):this.easing=(i=t.easing)!=null?i:Ai,this.direction=(s=t.direction)!=null?s:"out",this.hideLoader=(n=t.hideLoader)!=null?n:!1,this.blockInput=(o=t.blockInput)!=null?o:!1,this.transform.coordPlane=rt.Screen,this.transform.pos=w.Zero,this.transform.z=1/0,this.graphics.anchor=w.Zero,this.addComponent(this.transform),this.addComponent(this.graphics),this.direction==="out"?this._currentProgress=0:this._currentProgress=1}get progress(){return this._currentProgress}get distance(){return this._currentDistance}get complete(){return this.direction==="out"?this.progress>=1:this.progress<=0}updateTransition(t,e){this.complete||(this._currentDistance+=B(e/this.duration,0,1),this._currentDistance>=1&&(this._currentDistance=1),this.direction==="out"?this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,0,1,1),0,1):this._currentProgress=B(ot(0,1,this.easing(this._currentDistance)),0,1):this._useLegacyEasing?this._currentProgress=B(this.legacyEasing(this._currentDistance,1,0,1),0,1):this._currentProgress=B(ot(1,0,this.easing(this._currentDistance)),0,1))}async onPreviousSceneDeactivate(t){}onStart(t){}onUpdate(t){}onEnd(t){}onReset(){}reset(){this.started=!1,this._completeFuture=new wt,this.done=this._completeFuture.promise,this._currentDistance=0,this.direction==="out"?this._currentProgress=0:this._currentProgress=1,this.onReset()}_addToTargetScene(t,e){const i=e;if(this.started&&this._logger.warn(`Attempted to add a transition ${this.name} that is already playing.`),i.world.entityManager.getById(this.id))return this._co;this._engine=t,i.add(this);const s=this;return this._co=Ta(t,function*(){for(;!s.complete;){const n=yield;s.updateTransition(s._engine,n),s._execute()}},{autostart:!1}),this._co}async _play(){this.started&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that is already playing, reset transition.`)),(!this._engine||!this._co)&&(this.reset(),this._logger.warn(`Attempted to play a transition ${this.name} that hasn't been added`)),this._co&&await this._co.start()}_execute(){this.isInitialized&&(this.started||(this.started=!0,this.onStart(this.progress)),this.onUpdate(this.progress),this.complete&&!this._completeFuture.isCompleted&&(this.onEnd(this.progress),this._completeFuture.resolve()))}}class _c extends cs{constructor(t){var e,i;super({...t,duration:(e=t.duration)!=null?e:2e3}),this.name=`FadeInOut#${this.id}`,this.color=(i=t.color)!=null?i:T.Black}onInitialize(t){this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=new ui({width:t.screen.resolution.width,height:t.screen.resolution.height,color:this.color}),this.graphics.add(this.screenCover),this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=t}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class fc extends cs{constructor(t){super({direction:"in",...t}),this.name=`CrossFade#${this.id}`}async onPreviousSceneDeactivate(t){this.image=await t.engine.screenshot(!0),await this.image.decode()}onInitialize(t){this.engine=t,this.transform.pos=t.screen.unsafeArea.topLeft,this.screenCover=qt.fromHtmlImageElement(this.image).toSprite(),this.graphics.add(this.screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio),this.graphics.opacity=this.progress}onStart(t){this.graphics.opacity=this.progress}onReset(){this.graphics.opacity=this.progress}onEnd(t){this.graphics.opacity=t}onUpdate(t){this.graphics.opacity=t}}class gc extends cs{constructor(t){var e;super({direction:"in",...t}),this._easing=Rt.Linear,this._start=w.Zero,this._end=w.Zero,this.name=`Slide#${this.id}`,this.slideDirection=t.slideDirection,this.transform.coordPlane=rt.Screen,this.graphics.forceOnScreen=!0,this._easing=(e=t.easingFunction)!=null?e:this._easing}async onPreviousSceneDeactivate(t){this._image=await t.engine.screenshot(!0),await this._image.decode(),this._screenCover=qt.fromHtmlImageElement(this._image).toSprite()}onInitialize(t){this._engine=t;let e=t.screen.unsafeArea;switch(e.hasZeroDimensions()&&(e=t.screen.contentArea),this.slideDirection){case"up":{this._directionOffset=b(0,-e.height);break}case"down":{this._directionOffset=b(0,e.height);break}case"left":{this._directionOffset=b(-e.width,0);break}case"right":{this._directionOffset=b(e.width,0);break}}this._camera=this._engine.currentScene.camera,this._destinationCameraPosition=this._camera.pos.clone(),this._camera.pos=this._camera.pos.add(this._directionOffset),this.transform.pos=this.transform.pos.add(this._directionOffset),this._startCameraPosition=this._camera.pos.clone(),this._start=e.topLeft,this._end=this._start.add(this._directionOffset),this.transform.pos=this._start,this.graphics.use(this._screenCover),this.transform.scale=b(1/t.screen.pixelRatio,1/t.screen.pixelRatio)}onStart(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}onUpdate(t){const e=this._easing(this.distance,0,1,1);this.transform.pos.x=ot(this._start.x,this._end.x,e),this.transform.pos.y=ot(this._start.y,this._end.y,e),this._camera.pos.x=ot(this._startCameraPosition.x,this._destinationCameraPosition.x,e),this._camera.pos.y=ot(this._startCameraPosition.y,this._destinationCameraPosition.y,e)}}const pc=Object.freeze(Object.defineProperty({__proto__:null,ConsoleAppender:Cs,DrawUtil:Uh,EasingFunctions:Rt,LogLevel:Le,Logger:R,Observable:gt,ScreenAppender:mr,addItemToArray:Ch,contains:xr,delay:Fi,fail:br,getMinIndex:wr,getPosition:oi,isLegacyEasing:Te,isObject:Di,mergeDeep:Bi,omit:yr,removeItemFromArray:He},Symbol.toStringTag,{value:"Module"})),Aa=5,ti={},mc=()=>{for(const r in ti)ti[r]=0},ds=(r,t)=>{const e=De.isEnabled("suppress-obsolete-message");ti[r]<Aa&&!e&&(R.getInstance().warn(r),console.trace&&t.showStackTrace&&console.trace()),ti[r]++};function vc(r){return r={message:"This feature will be removed in future versions of Excalibur.",alternateMethod:null,showStackTrace:!1,...r},function(t,e,i){if(i&&!(typeof i.value=="function"||typeof i.get=="function"||typeof i.set=="function"))throw new SyntaxError("Only classes/functions/getters/setters can be marked as obsolete");const n=`${`${t.name||""}${t.name&&e?".":""}${e||""}`} is marked obsolete: ${r.message}`+(r.alternateMethod?` Use ${r.alternateMethod} instead`:"");ti[n]||(ti[n]=0);const o=i?{...i}:t;if(!i){class a extends o{constructor(...l){ds(n,r),super(...l)}}return a}return i&&i.value?(o.value=function(){return ds(n,r),i.value.apply(this,arguments)},o):(i&&i.get&&(o.get=function(){return ds(n,r),i.get.apply(this,arguments)}),i&&i.set&&(o.set=function(){return ds(n,r),i.set.apply(this,arguments)}),o)}}class wc{constructor(){this._queue=[]}get length(){return this._queue.length}enqueue(){const t=new wt;return this._queue.push(t),t.promise}dequeue(t){this._queue.shift().resolve(t)}}class xc{constructor(t){this._count=t,this._waitQueue=new wc}get count(){return this._count}get waiting(){return this._waitQueue.length}async enter(){return this._count!==0?(this._count--,Promise.resolve()):this._waitQueue.enqueue()}exit(t=1){if(t!==0){for(;t!==0&&this._waitQueue.length!==0;)this._waitQueue.dequeue(null),t--;this._count+=t}}}const er="0.32.0-alpha.1576+d33ac1f";Fe(),d.ActionCompleteEvent=js,d.ActionContext=fi,d.ActionQueue=eo,d.ActionSequence=Kn,d.ActionStartEvent=Zs,d.ActionsComponent=Qe,d.ActionsSystem=Vn,d.ActivateEvent=Gs,d.Actor=kt,d.ActorEvents=Al,d.AddEvent=Qs,d.AddedComponent=Sh,d.AffineMatrix=Z,d.Animation=zi,d.AnimationDirection=Br,d.AnimationEvents=Dh,d.AnimationStrategy=kr,d.ArcadeSolver=Fn,d.AudioContextFactory=pi,d.Axes=ea,d.Axis=Yo,d.BaseAlign=ln,d.BezierCurve=si,d.Blink=yo,d.BodyComponent=N,d.BoundingBox=F,d.BrowserComponent=$n,d.BrowserEvents=da,d.Buttons=qn,d.Camera=Ko,d.CameraEvents=zl,d.Canvas=Xi,d.ChannelCollection=xa,d.Circle=qi,d.CircleCollider=dt,d.Clock=Zn,d.ClosestLineJumpTable=Vt,d.Collider=ai,d.ColliderComponent=tt,d.CollisionContact=xe,d.CollisionEndEvent=ri,d.CollisionGroup=me,d.CollisionGroupManager=Pi,d.CollisionJumpTable=Ut,d.CollisionPostSolveEvent=Mi,d.CollisionPreSolveEvent=Ri,d.CollisionStartEvent=ni,d.CollisionSystem=Qi,d.CollisionType=M,d.Color=T,d.ColorBlindFlags=la,d.ColorBlindnessMode=$e,d.ColorBlindnessPostProcessor=Qr,d.Component=Dt,d.CompositeCollider=at,d.ConsoleAppender=Cs,d.ContactConstraintPoint=Mo,d.ContactEndEvent=Ii,d.ContactSolveBias=ae,d.ContactStartEvent=Ei,d.CoordPlane=rt,d.CrossFade=fc,d.CurveBy=Eo,d.CurveTo=Po,d.DeactivateEvent=Vs,d.Debug=Tt,d.DebugConfig=ca,d.DebugGraphicsComponent=Wi,d.DebugSystem=Gn,d.DebugText=fn,d.DefaultAntialiasOptions=Or,d.DefaultGarbageCollectionOptions=Qn,d.DefaultLoader=mi,d.DefaultPixelArtOptions=Hr,d.DegreeOfFreedom=le,d.Delay=So,d.Detector=Oo,d.Die=To,d.Direction=dn,d.Director=pa,d.DirectorEvents=ga,d.DisplayMode=gi,d.DynamicTree=en,d.DynamicTreeCollisionProcessor=ki,d.EX_VERSION=er,d.EaseBy=bo,d.EaseTo=xo,d.EasingFunctions=Rt,d.Edge=ws,d.EdgeCollider=St,d.ElasticToActorStrategy=jo,d.EmitterType=Ee,d.Engine=as,d.EngineEvents=ql,d.EnterTriggerEvent=Ys,d.EnterViewPortEvent=Xs,d.Entity=At,d.EntityEvents=Eh,d.EntityManager=Sr,d.EventEmitter=X,d.EventTypes=Ts,d.Events=yh,d.ExResponse=Ln,d.ExcaliburGraphicsContext2DCanvas=Yi,d.ExcaliburGraphicsContextWebGL=$t,d.ExitTriggerEvent=$s,d.ExitViewPortEvent=qs,d.Fade=Co,d.FadeInOut=_c,d.Flags=De,d.Flash=Ao,d.Follow=Pn,d.Font=Se,d.FontCache=Vi,d.FontSource=dc,d.FontStyle=cn,d.FontUnit=an,d.FpsSampler=ua,d.FrameStats=yi,d.Future=wt,d.GameEvent=k,d.GameStartEvent=Is,d.GameStopEvent=Rs,d.Gamepad=ss,d.GamepadAxisEvent=Hs,d.GamepadButtonEvent=Os,d.GamepadConnectEvent=Us,d.GamepadDisconnectEvent=zs,d.Gamepads=is,d.GarbageCollector=wa,d.Gif=lc,d.GifParser=ya,d.GlobalCoordinates=ke,d.GpuParticleEmitter=$l,d.GpuParticleRenderer=hs,d.Graph=vs,d.Graphic=st,d.GraphicsComponent=K,d.GraphicsGroup=We,d.GraphicsSystem=pn,d.HashColliderProxy=Ro,d.HashGridCell=Zt,d.HashGridProxy=In,d.HiddenEvent=Ws,d.HorizontalFirst=nn,d.ImageFiltering=mt,d.ImageSource=qt,d.ImageSourceAttributeConstants=z,d.ImageWrapping=_t,d.InitializeEvent=Oe,d.InputHost=Yn,d.InputMapper=ia,d.IsometricEntityComponent=vi,d.IsometricEntitySystem=Wn,d.IsometricMap=Ul,d.IsometricTile=qo,d.KeyEvent=wi,d.Keyboard=aa,d.Keys=oa,d.KillEvent=As,d.Label=Xl,d.LimitCameraBoundsStrategy=Jo,d.Line=gn,d.LineSegment=Q,d.Loader=Ki,d.LoaderEvents=Fl,d.LockCameraToActorAxisStrategy=Zo,d.LockCameraToActorStrategy=$o,d.LogLevel=Le,d.Logger=R,d.Material=Kr,d.Matrix=Ct,d.MatrixLocations=cr,d.MediaEvent=Un,d.Meet=Zi,d.MotionComponent=O,d.MotionSystem=ji,d.MoveBy=Tn,d.MoveByWithOptions=ro,d.MoveTo=An,d.MoveToWithOptions=ao,d.NativePointerButton=Pe,d.NativeSoundEvent=Ae,d.NativeSoundProcessedEvent=Lo,d.NineSlice=wn,d.NineSliceStretch=zr,d.Node=Ti,d.None=rn,d.Observable=gt,d.OffscreenSystem=mn,d.Pair=pt,d.ParallaxComponent=Gi,d.ParallelActions=Zl,d.Particle=$i,d.ParticleEmitter=Yl,d.ParticleRenderer=Zr,d.ParticleTransform=Xt,d.PhysicsStats=rs,d.PhysicsWorld=Fo,d.PointerAbstraction=Xn,d.PointerButton=ce,d.PointerComponent=he,d.PointerEvent=xi,d.PointerEventReceiver=ns,d.PointerScope=Be,d.PointerSystem=es,d.PointerType=de,d.Polygon=vn,d.PolygonCollider=lt,d.Pool=Ui,d.PositionNode=_r,d.PostCollisionEvent=we,d.PostDebugDrawEvent=Bs,d.PostDrawEvent=ze,d.PostFrameEvent=Ls,d.PostKillEvent=Es,d.PostTransformDrawEvent=Fs,d.PostUpdateEvent=oe,d.PreCollisionEvent=ve,d.PreDebugDrawEvent=Ds,d.PreDrawEvent=Ue,d.PreFrameEvent=ks,d.PreKillEvent=Ps,d.PreLoadEvent=Wl,d.PreTransformDrawEvent=Ms,d.PreUpdateEvent=re,d.Projection=ei,d.QuadIndexBuffer=Ze,d.QuadTree=Je,d.Query=Lt,d.QueryManager=Tr,d.RadiusAroundActorStrategy=Qo,d.Random=se,d.Raster=Ge,d.Ray=ge,d.RealisticSolver=Dn,d.Rectangle=ui,d.RemoveEvent=Js,d.RemovedComponent=Ah,d.RentalPool=qe,d.Repeat=io,d.RepeatForever=so,d.Resolution=Bn,d.Resource=li,d.ResourceEvents=Hh,d.RotateBy=uo,d.RotateByWithOptions=co,d.RotateTo=lo,d.RotateToWithOptions=ho,d.RotationType=j,d.ScaleBy=vo,d.ScaleByWithOptions=mo,d.ScaleTo=go,d.ScaleToWithOptions=fo,d.Scene=Mt,d.SceneEvents=Gl,d.Screen=kn,d.ScreenAppender=mr,d.ScreenElement=Hn,d.ScreenEvents=Pl,d.ScreenShader=jr,d.ScrollPreventionMode=Ke,d.Semaphore=xc,d.SeparatingAxis=Ne,d.SeparationInfo=Mr,d.Shader=Bt,d.Shape=ut,d.Slide=gc,d.SolverStrategy=Li,d.Sound=zn,d.SoundEvents=Rl,d.SoundManager=hc,d.SparseHashGrid=Rn,d.SparseHashGridCollisionProcessor=Mn,d.SpatialPartitionStrategy=hi,d.Sprite=zt,d.SpriteFont=Oi,d.SpriteSheet=ye,d.StandardClock=jn,d.StateMachine=Ji,d.StrategyContainer=Xo,d.Stream=ba,d.System=Et,d.SystemManager=Pr,d.SystemPriority=Gt,d.SystemType=Pt,d.TagQuery=Ks,d.TestClock=_a,d.Text=_i,d.TextAlign=hn,d.TextureLoader=Xe,d.Tile=Vo,d.TileMap=Go,d.TileMapEvents=Ll,d.TiledAnimation=xn,d.TiledSprite=di,d.Timer=ts,d.Toaster=fa,d.Transform=Kt,d.TransformComponent=P,d.Transition=cs,d.TreeNode=tn,d.Trigger=ta,d.TriggerEvents=Ol,d.TwoPI=it,d.UniformBuffer=Nr,d.Util=pc,d.Vector=w,d.VectorView=ps,d.VertexBuffer=Ht,d.VertexLayout=Yt,d.VerticalFirst=sn,d.VisibleEvent=Ns,d.WebAudio=Bo,d.WebAudioInstance=ko,d.WheelDeltaMode=bi,d.WheelEvent=ha,d.World=Er,d.approximatelyEqual=ar,d.assert=Jn,d.canonicalizeAngle=Jt,d.clamp=B,d.coroutine=Ta,d.createId=fe,d.easeInBack=fh,d.easeInBounce=gr,d.easeInCirc=dh,d.easeInCubic=th,d.easeInElastic=mh,d.easeInExpo=hh,d.easeInOutBack=ph,d.easeInOutBounce=xh,d.easeInOutCirc=_h,d.easeInOutCubic=bs,d.easeInOutElastic=wh,d.easeInOutExpo=ch,d.easeInOutQuad=Ka,d.easeInOutQuart=nh,d.easeInOutQuint=ah,d.easeInOutSine=ja,d.easeInQuad=Qa,d.easeInQuart=ih,d.easeInQuint=rh,d.easeInSine=$a,d.easeOutBack=gh,d.easeOutBounce=ys,d.easeOutCirc=uh,d.easeOutCubic=eh,d.easeOutElastic=vh,d.easeOutExpo=lh,d.easeOutQuad=Ja,d.easeOutQuart=sh,d.easeOutQuint=oh,d.easeOutSine=Za,d.frac=Na,d.getDefaultPhysicsConfig=te,d.glTypeToUniformTypeName=Xr,d.hasGraphicsTick=Sn,d.hasOnAdd=nc,d.hasOnInitialize=Kl,d.hasOnPostUpdate=sc,d.hasOnPreUpdate=ec,d.hasOnRemove=rc,d.hasPostDraw=ac,d.hasPreDraw=oc,d.has_add=Ql,d.has_initialize=jl,d.has_postupdate=ic,d.has_preupdate=tc,d.has_remove=Jl,d.inverseLerp=dr,d.inverseLerpVector=ur,d.isActor=Tl,d.isAddedComponent=Th,d.isComponentCtor=vr,d.isLegacyEasing=Te,d.isLoaderConstructor=On,d.isMoveByOptions=no,d.isMoveToOptions=oo,d.isRemovedComponent=Ph,d.isRotateByOptions=Sl,d.isRotateToOptions=Cl,d.isScaleByOptions=po,d.isScaleToOptions=_o,d.isSceneConstructor=jt,d.isScreenElement=Ho,d.isSystemConstructor=Ar,d.lerp=ot,d.lerpAngle=ms,d.lerpVector=ii,d.linear=Ai,d.maxMessages=Aa,d.nextActionId=H,d.obsolete=vc,d.parseImageFiltering=Ve,d.parseImageWrapping=Ot,d.pixelSnapEpsilon=D,d.randomInRange=Nt,d.randomIntInRange=Va,d.range=Ga,d.remap=Wt,d.remapVector=qa,d.resetObsoleteCounter=mc,d.sign=V,d.smootherstep=Ya,d.smoothstep=Xa,d.toDegrees=hr,d.toRadians=Wa,d.vec=b,d.webgl=Yh,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1576+d33ac1f - 2025-11-29
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -5243,7 +5243,7 @@ const _Entity = class _Entity2 {
|
|
|
5243
5243
|
}
|
|
5244
5244
|
}
|
|
5245
5245
|
/**
|
|
5246
|
-
* Removes Actor, meant to be called by the Scene when Actor is
|
|
5246
|
+
* Removes Actor, meant to be called by the Scene when Actor is removed.
|
|
5247
5247
|
*
|
|
5248
5248
|
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
5249
5249
|
* @internal
|
|
@@ -5410,7 +5410,7 @@ class EntityManager {
|
|
|
5410
5410
|
}
|
|
5411
5411
|
}
|
|
5412
5412
|
removeEntity(idOrEntity, deferred = true) {
|
|
5413
|
-
var _a, _b;
|
|
5413
|
+
var _a, _b, _c, _d;
|
|
5414
5414
|
let id = 0;
|
|
5415
5415
|
if (idOrEntity instanceof Entity) {
|
|
5416
5416
|
id = idOrEntity.id;
|
|
@@ -5444,7 +5444,8 @@ class EntityManager {
|
|
|
5444
5444
|
entity.childrenRemoved$.unsubscribe(childRemovedHandler);
|
|
5445
5445
|
this._childRemovedHandlerMap.delete(entity);
|
|
5446
5446
|
}
|
|
5447
|
-
|
|
5447
|
+
entity._remove((_b = (_a = this._world) == null ? void 0 : _a.scene) == null ? void 0 : _b.engine);
|
|
5448
|
+
if ((_d = (_c = this._world) == null ? void 0 : _c.scene) == null ? void 0 : _d.engine) {
|
|
5448
5449
|
this._world.scene.engine.stats.currFrame.actors.killed++;
|
|
5449
5450
|
}
|
|
5450
5451
|
}
|
|
@@ -33437,7 +33438,7 @@ class Semaphore {
|
|
|
33437
33438
|
this._count += count;
|
|
33438
33439
|
}
|
|
33439
33440
|
}
|
|
33440
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33441
|
+
const EX_VERSION = "0.32.0-alpha.1576+d33ac1f";
|
|
33441
33442
|
polyfill();
|
|
33442
33443
|
export {
|
|
33443
33444
|
ActionCompleteEvent,
|
package/build/esm/excalibur.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1576+d33ac1f - 2025-11-29
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -5243,7 +5243,7 @@ const _Entity = class _Entity2 {
|
|
|
5243
5243
|
}
|
|
5244
5244
|
}
|
|
5245
5245
|
/**
|
|
5246
|
-
* Removes Actor, meant to be called by the Scene when Actor is
|
|
5246
|
+
* Removes Actor, meant to be called by the Scene when Actor is removed.
|
|
5247
5247
|
*
|
|
5248
5248
|
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
5249
5249
|
* @internal
|
|
@@ -5410,7 +5410,7 @@ class EntityManager {
|
|
|
5410
5410
|
}
|
|
5411
5411
|
}
|
|
5412
5412
|
removeEntity(idOrEntity, deferred = true) {
|
|
5413
|
-
var _a, _b;
|
|
5413
|
+
var _a, _b, _c, _d;
|
|
5414
5414
|
let id = 0;
|
|
5415
5415
|
if (idOrEntity instanceof Entity) {
|
|
5416
5416
|
id = idOrEntity.id;
|
|
@@ -5444,7 +5444,8 @@ class EntityManager {
|
|
|
5444
5444
|
entity.childrenRemoved$.unsubscribe(childRemovedHandler);
|
|
5445
5445
|
this._childRemovedHandlerMap.delete(entity);
|
|
5446
5446
|
}
|
|
5447
|
-
|
|
5447
|
+
entity._remove((_b = (_a = this._world) == null ? void 0 : _a.scene) == null ? void 0 : _b.engine);
|
|
5448
|
+
if ((_d = (_c = this._world) == null ? void 0 : _c.scene) == null ? void 0 : _d.engine) {
|
|
5448
5449
|
this._world.scene.engine.stats.currFrame.actors.killed++;
|
|
5449
5450
|
}
|
|
5450
5451
|
}
|
|
@@ -33437,7 +33438,7 @@ class Semaphore {
|
|
|
33437
33438
|
this._count += count;
|
|
33438
33439
|
}
|
|
33439
33440
|
}
|
|
33440
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33441
|
+
const EX_VERSION = "0.32.0-alpha.1576+d33ac1f";
|
|
33441
33442
|
polyfill();
|
|
33442
33443
|
export {
|
|
33443
33444
|
ActionCompleteEvent,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1576+d33ac1f - 2025-11-29
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -3731,7 +3731,7 @@ const Dl = {
|
|
|
3731
3731
|
!this.isAdded && this.isActive && (this.onAdd(t), this.events.emit("add", new Vn(t, this)), this._isAdded = !0);
|
|
3732
3732
|
}
|
|
3733
3733
|
/**
|
|
3734
|
-
* Removes Actor, meant to be called by the Scene when Actor is
|
|
3734
|
+
* Removes Actor, meant to be called by the Scene when Actor is removed.
|
|
3735
3735
|
*
|
|
3736
3736
|
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
3737
3737
|
* @internal
|
|
@@ -3864,22 +3864,22 @@ class go {
|
|
|
3864
3864
|
}
|
|
3865
3865
|
}
|
|
3866
3866
|
removeEntity(t, e = !0) {
|
|
3867
|
-
var i, s;
|
|
3868
|
-
let
|
|
3869
|
-
t instanceof Rt ?
|
|
3870
|
-
const
|
|
3871
|
-
if (
|
|
3872
|
-
this._entitiesToRemove.push(
|
|
3867
|
+
var i, s, n, o;
|
|
3868
|
+
let a = 0;
|
|
3869
|
+
t instanceof Rt ? a = t.id : a = t;
|
|
3870
|
+
const h = this._entityIndex[a];
|
|
3871
|
+
if (h && h.isActive && (h.isActive = !1), h && e) {
|
|
3872
|
+
this._entitiesToRemove.push(h);
|
|
3873
3873
|
return;
|
|
3874
3874
|
}
|
|
3875
|
-
if (delete this._entityIndex[
|
|
3876
|
-
|
|
3877
|
-
|
|
3875
|
+
if (delete this._entityIndex[a], h) {
|
|
3876
|
+
h.scene = null, Be(h, this.entities), this._world.queryManager.removeEntity(h), h.children.forEach((d) => {
|
|
3877
|
+
d.scene = null, this.removeEntity(d, e);
|
|
3878
3878
|
});
|
|
3879
|
-
const
|
|
3880
|
-
|
|
3881
|
-
const
|
|
3882
|
-
|
|
3879
|
+
const l = this._childAddedHandlerMap.get(h);
|
|
3880
|
+
l && (h.childrenAdded$.unsubscribe(l), this._childAddedHandlerMap.delete(h));
|
|
3881
|
+
const c = this._childRemovedHandlerMap.get(h);
|
|
3882
|
+
c && (h.childrenRemoved$.unsubscribe(c), this._childRemovedHandlerMap.delete(h)), h._remove((s = (i = this._world) == null ? void 0 : i.scene) == null ? void 0 : s.engine), (o = (n = this._world) == null ? void 0 : n.scene) != null && o.engine && this._world.scene.engine.stats.currFrame.actors.killed++;
|
|
3883
3883
|
}
|
|
3884
3884
|
}
|
|
3885
3885
|
processEntityRemovals() {
|
|
@@ -22470,7 +22470,7 @@ class Cc {
|
|
|
22470
22470
|
}
|
|
22471
22471
|
}
|
|
22472
22472
|
}
|
|
22473
|
-
const an = "0.32.0-alpha.
|
|
22473
|
+
const an = "0.32.0-alpha.1576+d33ac1f";
|
|
22474
22474
|
hn();
|
|
22475
22475
|
export {
|
|
22476
22476
|
Wn as ActionCompleteEvent,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1576+d33ac1f - 2025-11-29
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -3731,7 +3731,7 @@ const Dl = {
|
|
|
3731
3731
|
!this.isAdded && this.isActive && (this.onAdd(t), this.events.emit("add", new Vn(t, this)), this._isAdded = !0);
|
|
3732
3732
|
}
|
|
3733
3733
|
/**
|
|
3734
|
-
* Removes Actor, meant to be called by the Scene when Actor is
|
|
3734
|
+
* Removes Actor, meant to be called by the Scene when Actor is removed.
|
|
3735
3735
|
*
|
|
3736
3736
|
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
3737
3737
|
* @internal
|
|
@@ -3864,22 +3864,22 @@ class go {
|
|
|
3864
3864
|
}
|
|
3865
3865
|
}
|
|
3866
3866
|
removeEntity(t, e = !0) {
|
|
3867
|
-
var i, s;
|
|
3868
|
-
let
|
|
3869
|
-
t instanceof Rt ?
|
|
3870
|
-
const
|
|
3871
|
-
if (
|
|
3872
|
-
this._entitiesToRemove.push(
|
|
3867
|
+
var i, s, n, o;
|
|
3868
|
+
let a = 0;
|
|
3869
|
+
t instanceof Rt ? a = t.id : a = t;
|
|
3870
|
+
const h = this._entityIndex[a];
|
|
3871
|
+
if (h && h.isActive && (h.isActive = !1), h && e) {
|
|
3872
|
+
this._entitiesToRemove.push(h);
|
|
3873
3873
|
return;
|
|
3874
3874
|
}
|
|
3875
|
-
if (delete this._entityIndex[
|
|
3876
|
-
|
|
3877
|
-
|
|
3875
|
+
if (delete this._entityIndex[a], h) {
|
|
3876
|
+
h.scene = null, Be(h, this.entities), this._world.queryManager.removeEntity(h), h.children.forEach((d) => {
|
|
3877
|
+
d.scene = null, this.removeEntity(d, e);
|
|
3878
3878
|
});
|
|
3879
|
-
const
|
|
3880
|
-
|
|
3881
|
-
const
|
|
3882
|
-
|
|
3879
|
+
const l = this._childAddedHandlerMap.get(h);
|
|
3880
|
+
l && (h.childrenAdded$.unsubscribe(l), this._childAddedHandlerMap.delete(h));
|
|
3881
|
+
const c = this._childRemovedHandlerMap.get(h);
|
|
3882
|
+
c && (h.childrenRemoved$.unsubscribe(c), this._childRemovedHandlerMap.delete(h)), h._remove((s = (i = this._world) == null ? void 0 : i.scene) == null ? void 0 : s.engine), (o = (n = this._world) == null ? void 0 : n.scene) != null && o.engine && this._world.scene.engine.stats.currFrame.actors.killed++;
|
|
3883
3883
|
}
|
|
3884
3884
|
}
|
|
3885
3885
|
processEntityRemovals() {
|
|
@@ -22470,7 +22470,7 @@ class Cc {
|
|
|
22470
22470
|
}
|
|
22471
22471
|
}
|
|
22472
22472
|
}
|
|
22473
|
-
const an = "0.32.0-alpha.
|
|
22473
|
+
const an = "0.32.0-alpha.1576+d33ac1f";
|
|
22474
22474
|
hn();
|
|
22475
22475
|
export {
|
|
22476
22476
|
Wn as ActionCompleteEvent,
|