var gdjs;(function(a){class c{constructor(t,i){this.center={x:0,y:0};this.origin={x:0,y:0};this.hasCustomHitBoxes=!1;this.customHitBoxes=[];this.image=t?t.image:"",this.texture=i.getAnimationFrameTexture(this.image),this.points=new Hashtable,this.reinitialize(t,i)}reinitialize(t,i){this.image=t.image,this.texture=i.getAnimationFrameTexture(this.image),this.points.clear();for(let n=0,o=t.points.length;n=this.customHitBoxes.length&&this.customHitBoxes.push(new a.Polygon);let s=0;for(const u=m.length;s=this.customHitBoxes[n].vertices.length&&this.customHitBoxes[n].vertices.push([0,0]),this.customHitBoxes[n].vertices[s][0]=l.x,this.customHitBoxes[n].vertices[s][1]=l.y}this.customHitBoxes[n].vertices.length=s}this.customHitBoxes.length=n}else this.customHitBoxes.length=0}getPoint(t){return t==="Centre"||t==="Center"?this.center:t==="Origin"?this.origin:this.points.containsKey(t)?this.points.get(t):this.origin}}a.SpriteAnimationFrame=c;class _{constructor(t,i){this.frames=[];this.timeBetweenFrames=t?t.timeBetweenFrames:1,this.loop=!!t.looping,this.reinitialize(t,i)}reinitialize(t,i){this.timeBetweenFrames=t?t.timeBetweenFrames:1,this.loop=!!t.looping;let e=0;for(const r=t.sprites.length;e=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!1;const i=this._animations[this._currentAnimation].directions[this._currentDirection],e=this.getAnimationDuration();if(!this._animationPaused&&(i.loop||this._animationElapsedTime!==e)&&i.timeBetweenFrames){const r=this._animationElapsedTime+t*this._animationSpeedScale;return this.setAnimationElapsedTime(i.loop?a.evtTools.common.mod(r,e):a.evtTools.common.clamp(r,0,e))}return!1}setOnFrameChangeCallback(t){this._onFrameChange=t}getAnimationIndex(){return this._currentAnimation}setAnimationIndex(t){return t=t|0,t=0?(this._currentAnimation=t,this._currentFrameIndex=0,this._animationElapsedTime=0,this.invalidateFrame(),!0):!1}getAnimationName(){return this._currentAnimation>=this._animations.length?"":this._animations[this._currentAnimation].name}setAnimationName(t){if(!t)return!1;for(let i=0;i=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!0;const t=this._animations[this._currentAnimation].directions[this._currentDirection];return t.loop?!1:this._currentFrameIndex===t.frames.length-1&&this._animationElapsedTime===t.frames.length*t.timeBetweenFrames}isAnimationPaused(){return this._animationPaused}pauseAnimation(){this._animationPaused=!0}resumeAnimation(){this._animationPaused=!1}getAnimationSpeedScale(){return this._animationSpeedScale}setAnimationSpeedScale(t){this._animationSpeedScale=t}setAnimationFrameIndex(t){if(this._currentAnimation>=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!1;const i=this._animations[this._currentAnimation].directions[this._currentDirection];return t>=0&&t=this._animations.length)return 0;const t=this._animations[this._currentAnimation];return this._currentDirection>=t.directions.length?0:t.directions[this._currentDirection].frames.length}setDirectionOrAngle(t,i){if(this._currentAnimation>=this._animations.length)return null;const e=this._animations[this._currentAnimation];return e.hasMultipleDirections?(i=i|0,i===this._currentDirection||i>=e.directions.length||e.directions[i].frames.length===0?null:(this._currentDirection=i,this._currentFrameIndex=0,this._animationElapsedTime=0,this.invalidateFrame(),0)):t===i?null:i}getDirectionOrAngle(t){return this._currentAnimation>=this._animations.length?0:this._animations[this._currentAnimation].hasMultipleDirections?this._currentDirection:t}getAngle(t){return this._currentAnimation>=this._animations.length?0:this._animations[this._currentAnimation].hasMultipleDirections?this._currentDirection*45:t}setAngle(t,i){return this._currentAnimation>=this._animations.length?null:this._animations[this._currentAnimation].hasMultipleDirections?(i=i%360,i<0&&(i+=360),this.setDirectionOrAngle(t,Math.round(i/45)%8)):t===i?null:i}hasAnimationEndedLegacy(){if(this._currentAnimation>=this._animations.length||this._currentDirection>=this._animations[this._currentAnimation].directions.length)return!0;const t=this._animations[this._currentAnimation].directions[this._currentDirection];return t.loop?!1:this._currentFrameIndex===t.frames.length-1}}a.SpriteAnimator=g})(gdjs||(gdjs={})); //# sourceMappingURL=SpriteAnimator.js.map