var gdjs;(function(n){const C=(x,e,t,i)=>{const s=Math.max(t,x-t),r=Math.max(i,e-i);return Math.pow(s,2)+Math.pow(r,2)},A={moveXArray:[],moveYArray:[]},w={result:n.Polygon.makeNewRaycastTestResult()},F=(x,e,t)=>{if(e.length===0)return e.length=0,t.length=0,!1;if(e.length===1)return x.setPosition(x.getX()+e[0],x.getY()+t[0]),e.length=0,t.length=0,!0;let i=0,s=0;for(let f=0;fi&&(i=y,s=f)}const r=Math.sqrt(i),a=e[s]/r,h=-(t[s]/r),m=a;let c=0,g=0;for(let f=0;f{if(!o.isSyncedOverNetwork()&&!e.syncAllBehaviors)return;const h=o.getNetworkSyncData(e);t[o.getName()]=h});const i=this._variables.getNetworkSyncData({}),s={};for(const o in this._rendererEffects)s[o]=this._rendererEffects[o].getNetworkSyncData();const r={};for(const o in this._timers.items)r[o]=this._timers.items[o].getNetworkSyncData();const a={x:this.x,y:this.y,w:this.getWidth(),h:this.getHeight(),zo:this.zOrder,a:this.angle,hid:this.hidden,lay:this.layer,if:this._instantForces.map(o=>o.getNetworkSyncData()),pfx:this._permanentForceX,pfy:this._permanentForceY,beh:t,var:i,eff:s,tim:r};return e.syncObjectIdentifiers&&(a.n=this.name,this.networkId||(this.networkId=n.makeUuid().substring(0,8)),a.networkId=this.networkId),a}updateFromNetworkSyncData(e,t){if(e.x!==void 0&&this.setX(e.x),e.y!==void 0&&this.setY(e.y),e.w!==void 0&&this.setWidth(e.w),e.h!==void 0&&this.setHeight(e.h),e.zo!==void 0&&this.setZOrder(e.zo),e.a!==void 0&&this.setAngle(e.a),e.hid!==void 0&&this.hidden!==e.hid&&this.hide(e.hid),e.lay!==void 0&&this.layer!==e.lay&&this.setLayer(e.lay),e.if){this.clearForces();for(let i=0,s=e.if.length;is()),this.clearEffects()}onDestroyed(){}onScenePaused(e){}onSceneResumed(e){}getRendererObject(){}get3DRendererObject(){}getName(){return this.name}getNameId(){return this._nameId}getUniqueId(){return this.id}getNetworkId(){return this.networkId}setPosition(e,t){this.setX(e),this.setY(t)}setX(e){e!==this.x&&(this.x=e,this.invalidateHitboxes())}invalidateHitboxes(){this.hitBoxesDirty=!0,this._runtimeScene.onChildrenLocationChanged()}getX(){return this.x}setY(e){e!==this.y&&(this.y=e,this.invalidateHitboxes())}getY(){return this.y}getDrawableX(){return this.getX()}getDrawableY(){return this.getY()}rotateTowardPosition(e,t,i){this.rotateTowardAngle(n.toDegrees(Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX()))),i)}rotateTowardObject(e,t){e!==null&&this.rotateTowardPosition(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t)}rotateTowardAngle(e,t){if(t===0){this.setAngle(e);return}const s=n.evtTools.common.angleDifference(this.getAngle(),e)>=0;let r=this.getAngle()+(s?-1:1)*t*this.getElapsedTime()/1e3;n.evtTools.common.angleDifference(r,e)>0^s&&(r=e),this.setAngle(r),this.getAngle()!==r&&this.setAngle(e)}rotate(e){this.setAngle(this.getAngle()+e*this.getElapsedTime()/1e3)}setAngle(e){this.angle!==e&&(this.angle=e,this.invalidateHitboxes())}getAngle(){return this.angle}setLayer(e){if(e===this.layer)return;const t=this._runtimeScene.getLayer(this.layer);this.layer=e;const i=this._runtimeScene.getLayer(this.layer),s=this.getRendererObject();s&&(t.getRenderer().removeRendererObject(s),i.getRenderer().addRendererObject(s,this.zOrder));const r=this.get3DRendererObject();r&&(t.getRenderer().remove3DRendererObject(r),i.getRenderer().add3DRendererObject(r))}getLayer(){return this.layer}isOnLayer(e){return this.layer===e}setZOrder(e){if(e===this.zOrder)return;this.zOrder=e;const t=this.getRendererObject();t&&this._runtimeScene.getLayer(this.layer).getRenderer().changeRendererObjectZOrder(t,e)}getZOrder(){return this.zOrder}getVariables(){return this._variables}static getVariableNumber(e){return e.getAsNumber()}static returnVariable(e){return e}static getVariableString(e){return e.getAsString()}static getVariableChildCount(e){return e.getChildrenCount()}static setVariableNumber(e,t){e.setNumber(t)}static setVariableString(e,t){e.setString(t)}static variableChildExists(e,t){return e.hasChild(t)}static variableRemoveChild(e,t){e.removeChild(t)}static variableClearChildren(e){e.clearChildren()}hasVariable(e){return this._variables.has(e)}getRendererEffects(){return this._rendererEffects}addEffect(e){return this.getRendererObject()?this._runtimeScene.getGame().getEffectsManager().addEffect(e,this._rendererEffects,this):!1}removeEffect(e){return this.getRendererObject()?this._runtimeScene.getGame().getEffectsManager().removeEffect(this._rendererEffects,this,e):!1}clearEffects(){const e=this.getRendererObject();return e?(this._rendererEffects={},this._runtimeScene.getGame().getEffectsManager().clearEffects(e)):!1}setEffectDoubleParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectDoubleParameter(this._rendererEffects,e,t,i)}setEffectStringParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectStringParameter(this._rendererEffects,e,t,i)}setEffectBooleanParameter(e,t,i){return this._runtimeScene.getGame().getEffectsManager().setEffectBooleanParameter(this._rendererEffects,e,t,i)}updateAllEffectParameters(e){return this._runtimeScene.getGame().getEffectsManager().updateAllEffectParameters(this._rendererEffects,e)}enableEffect(e,t){this._runtimeScene.getGame().getEffectsManager().enableEffect(this._rendererEffects,this,e,t)}isEffectEnabled(e){return this._runtimeScene.getGame().getEffectsManager().isEffectEnabled(this._rendererEffects,this,e)}hasEffect(e){return this._runtimeScene.getGame().getEffectsManager().hasEffect(this._rendererEffects,e)}hide(e){e===void 0&&(e=!0),this.hidden=e}isVisible(){return!this.hidden}isHidden(){return this.hidden}getOriginalWidth(){return this.getWidth()}getOriginalHeight(){return this.getHeight()}setWidth(e){}setHeight(e){}getWidth(){return 0}getHeight(){return 0}getCenterX(){return this.getWidth()/2}getCenterY(){return this.getHeight()/2}getCenterXInScene(){return this.getDrawableX()+this.getCenterX()}getCenterYInScene(){return this.getDrawableY()+this.getCenterY()}setCenterPositionInScene(e,t){this.setX(e+this.x-(this.getDrawableX()+this.getCenterX())),this.setY(t+this.y-(this.getDrawableY()+this.getCenterY()))}setCenterXInScene(e){this.setX(e+this.x-(this.getDrawableX()+this.getCenterX()))}setCenterYInScene(e){this.setY(e+this.y-(this.getDrawableY()+this.getCenterY()))}_getRecycledForce(e,t,i){if(l.forcesGarbage.length===0)return new n.Force(e,t,i);{const s=l.forcesGarbage.pop();return s.setX(e),s.setY(t),s.setMultiplier(i),s}}addForce(e,t,i){i===1?(this._permanentForceX+=e,this._permanentForceY+=t):i===0&&this._instantForces.length>0&&this._instantForces[0].getMultiplier()===0?this._instantForces[0].add(e,t):this._instantForces.push(this._getRecycledForce(e,t,i))}addPolarForce(e,t,i){const s=n.toRad(e),r=Math.cos(s)*t,a=Math.sin(s)*t;this.addForce(r,a,i)}addForceTowardPosition(e,t,i,s){const r=Math.atan2(t-(this.getDrawableY()+this.getCenterY()),e-(this.getDrawableX()+this.getCenterX())),a=Math.cos(r)*i,o=Math.sin(r)*i;this.addForce(a,o,s)}addForceTowardObject(e,t,i){e!=null&&this.addForceTowardPosition(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t,i)}clearForces(){l.forcesGarbage.push.apply(l.forcesGarbage,this._instantForces),this._instantForces.length=0,this._permanentForceX=0,this._permanentForceY=0}hasNoForces(){return this._instantForces.length===0&&this._permanentForceX===0&&this._permanentForceY===0}updateForces(e){for(let t=0;t=t:(this._timers.put(e,new n.Timer(e)),!1)}timerPaused(e){return this._timers.containsKey(e)?this._timers.get(e).isPaused():!1}resetTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).reset()}pauseTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).setPaused(!0)}unpauseTimer(e){this._timers.containsKey(e)||this._timers.put(e,new n.Timer(e)),this._timers.get(e).setPaused(!1)}removeTimer(e){this._timers.containsKey(e)&&this._timers.remove(e)}getTimerElapsedTimeInSeconds(e){return this._timers.containsKey(e)?this._timers.get(e).getTime()/1e3:0}getTimerElapsedTimeInSecondsOrNaN(e){return this._timers.containsKey(e)?this._timers.get(e).getTime()/1e3:Number.NaN}separateFromObjects(e,t){let i=A.moveXArray,s=A.moveYArray;i.length=0,s.length=0;const r=this.getHitBoxes();let a=null;for(const o of e){if(o.id===this.id)continue;let h;o.isSpatiallyIndexed()?(a||(a=this.getAABB()),h=o.getHitBoxesAround(a.min[0],a.min[1],a.max[0],a.max[1])):h=o.getHitBoxes();for(const m of r)for(const c of h){const g=n.Polygon.collisionTest(m,c,t);g.collision&&(i.push(g.move_axis[0]),s.push(g.move_axis[1]))}}return F(this,i,s)}separateFromObjectsList(e,t){let i=A.moveXArray,s=A.moveYArray;i.length=0,s.length=0;const r=this.getHitBoxes();let a=null;for(const o in e.items)if(e.items.hasOwnProperty(o)){const h=e.items[o];for(const m of h){if(m.id===this.id)continue;let c=m.getHitBoxes(),g=c;c.length>4&&(a||(a=this.getAABB()),g=m.getHitBoxesAround(a.min[0],a.min[1],a.max[0],a.max[1]));for(const v of r)for(const B of g){const b=n.Polygon.collisionTest(v,B,t);b.collision&&(i.push(b.move_axis[0]),s.push(b.move_axis[1]))}}}return F(this,i,s)}getDistanceToObject(e){return Math.sqrt(this.getSqDistanceToObject(e))}getSqDistanceToObject(e){if(e===null)return 0;const t=this.getDrawableX()+this.getCenterX()-(e.getDrawableX()+e.getCenterX()),i=this.getDrawableY()+this.getCenterY()-(e.getDrawableY()+e.getCenterY());return t*t+i*i}getDistanceToPosition(e,t){return Math.sqrt(this.getSqDistanceToPosition(e,t))}getSqDistanceToPosition(e,t){const i=this.getDrawableX()+this.getCenterX()-e,s=this.getDrawableY()+this.getCenterY()-t;return i*i+s*s}getAngleToObject(e){if(e===null)return 0;const t=this.getDrawableX()+this.getCenterX()-(e.getDrawableX()+e.getCenterX()),i=this.getDrawableY()+this.getCenterY()-(e.getDrawableY()+e.getCenterY());return n.toDegrees(Math.atan2(-i,-t))}getXFromAngleAndDistance(e,t){return this.getDrawableX()+this.getCenterX()+t*Math.cos(n.toRad(e))}getYFromAngleAndDistance(e,t){return this.getDrawableY()+this.getCenterY()+t*Math.sin(n.toRad(e))}getAngleToPosition(e,t){const i=this.getDrawableX()+this.getCenterX()-e,s=this.getDrawableY()+this.getCenterY()-t;return n.toDegrees(Math.atan2(-s,-i))}putAround(e,t,i,s){const r=n.toRad(s);this.setCenterXInScene(e+Math.cos(r)*i),this.setCenterYInScene(t+Math.sin(r)*i)}putAroundObject(e,t,i){!e||this.putAround(e.getDrawableX()+e.getCenterX(),e.getDrawableY()+e.getCenterY(),t,i)}separateObjectsWithoutForces(e){const t=n.staticArray(l.prototype.separateObjectsWithoutForces);t.length=0;const i=n.staticArray2(l.prototype.separateObjectsWithoutForces);e.values(i);for(let s=0,r=i.length;st[s].getDrawableX()+t[s].getWidth()&&this.setX(t[s].getDrawableX()+t[s].getWidth()),this.getDrawableY()t[s].getDrawableY()+t[s].getHeight()&&this.setY(t[s].getDrawableY()+t[s].getHeight()))}separateObjectsWithForces(e){const t=n.staticArray(l.prototype.separateObjectsWithForces);t.length=0;const i=n.staticArray2(l.prototype.separateObjectsWithForces);e.values(i);for(let s=0,r=i.length;so+c)return!1;const _=e.getHitBoxesAround(B-c,b-c,B+c,b+c),d=t.getHitBoxesAround(g-o,v-o,g+o,v+o);for(const y of _)if(y!==s){for(const D of d)if(n.Polygon.collisionTest(y,D,i).collision)return!0}return!1}raycastTest(e,t,i,s,r){const a=this.getCenterX(),o=this.getCenterY(),h=C(this.getWidth(),this.getHeight(),a,o),m=(e+i)/2,c=(t+s)/2,g=(i-e)*(i-e)+(s-t)*(s-t),v=this.getDrawableX()+a-m,B=this.getDrawableY()+o-c;let b=w.result;if(b.collision=!1,v*v+B*B>h+g+2*Math.sqrt(g*h))return b;if(r){let p=Number.MAX_VALUE;const f=this.getHitBoxesAround(e,t,i,s);for(const _ of f){const d=n.Polygon.raycastTest(_,e,t,i,s);d.collision&&d.closeSqDistp&&d.farSqDist<=g&&(p=d.farSqDist,n.Polygon.copyRaycastTestResult(d,b))}}return b}insideObject(e,t){return this.hitBoxesDirty&&(this.updateHitBoxes(),this.updateAABB(),this.hitBoxesDirty=!1),this.aabb.min[0]<=e&&this.aabb.max[0]>=e&&this.aabb.min[1]<=t&&this.aabb.max[1]>=t}static distanceTest(e,t,i){return e.getSqDistanceToObject(t)<=i}cursorOnObject(){const e=n.staticArray(l.prototype.cursorOnObject);e.length=2;const t=this.getInstanceContainer(),i=t.getGame().getInputManager(),s=t.getLayer(this.layer),r=s.convertCoords(i.getCursorX(),i.getCursorY(),0,e);if(this.insideObject(r[0],r[1]))return!0;const a=i.getAllTouchIdentifiers();for(let o=0;o