gdcore-tools 2.0.0-gd-v5.5.221-autobuild → 2.0.0-gd-v5.5.222-autobuild

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.
@@ -2332,9 +2332,9 @@ module.exports = {
2332
2332
  this._pixiObject = new PIXI.Graphics();
2333
2333
  this._pixiContainer.addChild(this._pixiObject);
2334
2334
 
2335
- this._faceResourceNames = ['', '', '', '', '', ''];
2336
- this._faceVisibilities = [true, true, true, true, true, true];
2337
- this._shouldRepeatTextureOnFace = [true, true, true, true, true, true];
2335
+ this._faceResourceNames = new Array(6).fill(null);
2336
+ this._faceVisibilities = new Array(6).fill(null);
2337
+ this._shouldRepeatTextureOnFace = new Array(6).fill(null);
2338
2338
  this._facesOrientation = 'Y';
2339
2339
  this._backFaceUpThroughWhichAxisRotation = 'X';
2340
2340
  this._shouldUseTransparentTexture = false;
@@ -1,2 +1,2 @@
1
- var gdjs;(function(l){class S{constructor(e,t){this.frameTime=0;this.stepped=!1;this.timeScale=1;this._nextJointId=1;this.joints={};this._tempb2Vec2=new Box2D.b2Vec2(0,0);this._tempb2Vec2Sec=new Box2D.b2Vec2(0,0);this._registeredBehaviors=new Set,this.gravityX=t.gravityX,this.gravityY=t.gravityY,this.scaleX=t.scaleX||100,this.scaleY=t.scaleY||100,this.invScaleX=1/this.scaleX,this.invScaleY=1/this.scaleY,this.worldScale=t.worldScale||Math.sqrt(this.scaleX*this.scaleY),this.worldInvScale=1/this.worldScale,this.timeStep=1/60,this.world=new Box2D.b2World(this.b2Vec2(this.gravityX,this.gravityY)),this.world.SetAutoClearForces(!1),this.staticBody=this.world.CreateBody(new Box2D.b2BodyDef),this.contactListener=new Box2D.JSContactListener,this.contactListener.BeginContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactBegin(n),n.onContactBegin(s))},this.contactListener.EndContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactEnd(n),n.onContactEnd(s))},this.contactListener.PreSolve=function(){},this.contactListener.PostSolve=function(){},this.world.SetContactListener(this.contactListener)}b2Vec2(e,t){const i=this._tempb2Vec2;return i.set_x(e),i.set_y(t),i}static getSharedData(e,t){if(!e.physics2SharedData){const i=e.getInitialSharedDataForBehavior(t);e.physics2SharedData=new l.Physics2SharedData(e,i)}return e.physics2SharedData}addToBehaviorsList(e){this._registeredBehaviors.add(e)}removeFromBehaviorsList(e){this._registeredBehaviors.delete(e)}step(e){for(const i of this._registeredBehaviors)i.contactsStartedThisFrame.length=0,i.contactsEndedThisFrame.length=0;for(const i of this._registeredBehaviors)i.updateBodyFromObject();this.frameTime+=e;let t=Math.max(0,Math.round(this.frameTime/this.timeStep));this.frameTime-=t*this.timeStep,t>5&&(t=5);for(let i=0;i<t;i++)this.world.Step(this.timeStep*this.timeScale,8,10);this.world.ClearForces(),this.stepped=!0;for(const i of this._registeredBehaviors)i.updateObjectFromBody()}clearBodyJoints(e){for(const t in this.joints)this.joints.hasOwnProperty(t)&&(this.joints[t].GetBodyA()===e||this.joints[t].GetBodyB()===e)&&this.removeJoint(t)}addJoint(e){return this.joints[this._nextJointId.toString(10)]=e,this._nextJointId++}getJoint(e){return e=e.toString(10),this.joints.hasOwnProperty(e)?this.joints[e]:null}getJointId(e){for(const t in this.joints)if(this.joints.hasOwnProperty(t)&&this.joints[t]===e)return parseInt(t,10);return 0}removeJoint(e){if(e=e.toString(10),this.joints.hasOwnProperty(e)){const t=this.joints[e];if(t.GetType()===Box2D.e_revoluteJoint||t.GetType()===Box2D.e_prismaticJoint)for(const i in this.joints)this.joints.hasOwnProperty(i)&&this.joints[i].GetType()===Box2D.e_gearJoint&&(Box2D.getPointer(this.joints[i].GetJoint1())===Box2D.getPointer(t)||Box2D.getPointer(this.joints[i].GetJoint2())===Box2D.getPointer(t))&&this.removeJoint(parseInt(i,10));this.world.DestroyJoint(t),delete this.joints[e]}}}l.Physics2SharedData=S,l.registerRuntimeSceneUnloadedCallback(function(x){const e=x.physics2SharedData;e&&e.world&&(Box2D.destroy(e.world),Box2D.destroy(e._tempb2Vec2),Box2D.destroy(e._tempb2Vec2Sec))});const B=class extends l.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this.shapeScale=1;this._body=null;this._objectOldX=0;this._objectOldY=0;this._objectOldAngle=0;this._objectOldWidth=0;this._objectOldHeight=0;this._verticesBuffer=0;this.bodyType=t.bodyType,this.bullet=t.bullet,this.fixedRotation=t.fixedRotation,this.canSleep=t.canSleep,this.shape=t.shape,this.shapeDimensionA=t.shapeDimensionA,this.shapeDimensionB=t.shapeDimensionB,this.shapeOffsetX=t.shapeOffsetX,this.shapeOffsetY=t.shapeOffsetY,this.polygonOrigin=t.polygonOrigin,this.polygon=this.shape==="Polygon"?B.getPolygon(t.vertices):null,this.density=t.density,this.friction=t.friction,this.restitution=t.restitution,this.linearDamping=Math.max(0,t.linearDamping),this.angularDamping=Math.max(0,t.angularDamping),this.gravityScale=t.gravityScale,this.layers=t.layers,this.masks=t.masks,this.contactsStartedThisFrame=[],this.contactsEndedThisFrame=[],this.currentContacts=[],this.currentContacts.length=0,this.destroyedDuringFrameLogic=!1,this._sharedData=S.getSharedData(e.getScene(),t.name),this._sharedData.addToBehaviorsList(this)}b2Vec2(e,t){const i=this._sharedData._tempb2Vec2;return i.set_x(e),i.set_y(t),i}b2Vec2Sec(e,t){const i=this._sharedData._tempb2Vec2Sec;return i.set_x(e),i.set_y(t),i}updateFromBehaviorData(e,t){return e.bullet!==t.bullet&&this.setBullet(t.bullet),e.fixedRotation!==t.fixedRotation&&this.setFixedRotation(t.fixedRotation),e.canSleep!==t.canSleep&&this.setSleepingAllowed(t.canSleep),e.shapeDimensionA!==t.shapeDimensionA&&(this.shapeDimensionA=t.shapeDimensionA,this.recreateShape()),e.shapeDimensionB!==t.shapeDimensionB&&(this.shapeDimensionB=t.shapeDimensionB,this.recreateShape()),e.shapeOffsetX!==t.shapeOffsetX&&(this.shapeOffsetX=t.shapeOffsetX,this.recreateShape()),e.shapeOffsetY!==t.shapeOffsetY&&(this.shapeOffsetY=t.shapeOffsetY,this.recreateShape()),e.polygonOrigin!==t.polygonOrigin&&(this.polygonOrigin=t.polygonOrigin,this.recreateShape()),e.density!==t.density&&this.setDensity(t.density),e.friction!==t.friction&&this.setFriction(t.friction),e.restitution!==t.restitution&&this.setRestitution(t.restitution),e.linearDamping!==t.linearDamping&&this.setLinearDamping(t.linearDamping),e.angularDamping!==t.angularDamping&&this.setAngularDamping(t.angularDamping),e.gravityScale!==t.gravityScale&&this.setGravityScale(t.gravityScale),!(e.layers!==t.layers||e.masks!==t.masks||e.vertices!==t.vertices||e.bodyType!==t.bodyType||e.shape!==t.shape)}getNetworkSyncData(){const e=this._body?{tpx:this._body.GetTransform().get_p().get_x(),tpy:this._body.GetTransform().get_p().get_y(),tqa:this._body.GetTransform().get_q().GetAngle(),lvx:this._body.GetLinearVelocity().get_x(),lvy:this._body.GetLinearVelocity().get_y(),av:this._body.GetAngularVelocity(),aw:this._body.IsAwake()}:{tpx:void 0,tpy:void 0,tqa:void 0,lvx:void 0,lvy:void 0,av:void 0,aw:void 0};return{...super.getNetworkSyncData(),props:{...e,layers:this.layers,masks:this.masks}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.tpx!==void 0&&t.tpy!==void 0&&t.tqa!==void 0&&this._body&&this._body.SetTransform(this.b2Vec2(t.tpx,t.tpy),t.tqa),t.lvx!==void 0&&t.lvy!==void 0&&this._body&&this._body.SetLinearVelocity(this.b2Vec2(t.lvx,t.lvy)),t.av!==void 0&&this._body&&this._body.SetAngularVelocity(t.av),t.aw!==void 0&&this._body&&this._body.SetAwake(t.aw),t.layers!==void 0&&(this.layers=t.layers),t.masks!==void 0&&(this.masks=t.masks)}onDeActivate(){this._sharedData.removeFromBehaviorsList(this),this._body!==null&&(this._sharedData.clearBodyJoints(this._body),this._verticesBuffer&&(Box2D._free(this._verticesBuffer),this._verticesBuffer=0),this._sharedData.world.DestroyBody(this._body),this._body=null),this.contactsEndedThisFrame.length=0,this.contactsStartedThisFrame.length=0,this.currentContacts.length=0}onActivate(){this._sharedData.addToBehaviorsList(this),this.contactsEndedThisFrame.length=0,this.contactsStartedThisFrame.length=0,this.currentContacts.length=0,this.updateBodyFromObject()}onDestroy(){this.destroyedDuringFrameLogic=!0,this.onDeActivate()}static getPolygon(e){if(!e)return null;const t=new l.Polygon,i=8;for(let o=0,s=e.length;o<Math.min(s,i);o++)t.vertices.push([e[o].x,e[o].y]);return t}static isPolygonConvex(e){if(!e.isConvex())return!1;let t=!0,i=!0;for(let o=0;o<e.vertices.length-1;++o){for(let s=o+1;s<e.vertices.length;++s)if(e.vertices[o][0]===e.vertices[s][0]&&e.vertices[o][1]===e.vertices[s][1])return!1;e.vertices[o][0]!==e.vertices[o+1][0]&&(t=!1),e.vertices[o][1]!==e.vertices[o+1][1]&&(i=!1)}return!(t||i)}createShape(){const e=this.shapeOffsetX?this.shapeOffsetX*this.shapeScale*this._sharedData.worldInvScale:0,t=this.shapeOffsetY?this.shapeOffsetY*this.shapeScale*this._sharedData.worldInvScale:0;let i;if(this.shape==="Circle"){if(i=new Box2D.b2CircleShape,this.shapeDimensionA>0)i.set_m_radius(Math.max(.1,this.shapeDimensionA)*this.shapeScale*this._sharedData.worldInvScale);else{const n=(Math.max(.1,this.owner.getWidth())*this._sharedData.worldInvScale+Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale)/4;i.set_m_radius(n)}i.set_m_p(this.b2Vec2(e,t))}else if(this.shape==="Polygon")if(i=new Box2D.b2PolygonShape,!this.polygon||!B.isPolygonConvex(this.polygon)){const n=Math.max(.1,this.owner.getWidth())*this._sharedData.worldInvScale,a=Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}else{let n=0,a=0;if(this.polygonOrigin==="Origin"?(n=(this.owner.getWidth()>0?-this.owner.getWidth()/2:0)+(this.owner.getX()-this.owner.getDrawableX()),a=(this.owner.getHeight()>0?-this.owner.getHeight()/2:0)+(this.owner.getY()-this.owner.getDrawableY())):this.polygonOrigin==="TopLeft"&&(n=this.owner.getWidth()>0?-this.owner.getWidth()/2:0,a=this.owner.getHeight()>0?-this.owner.getHeight()/2:0),!this._verticesBuffer){const c=Box2D._malloc(this.polygon.vertices.length*8,"float",Box2D.ALLOC_STACK);this._verticesBuffer=c}let h=0;for(let c=0,u=this.polygon.vertices.length;c<u;c++)Box2D.HEAPF32[this._verticesBuffer+h>>2]=(this.polygon.vertices[c][0]*this.shapeScale+n)*this._sharedData.worldInvScale+e,Box2D.HEAPF32[this._verticesBuffer+(h+4)>>2]=(this.polygon.vertices[c][1]*this.shapeScale+a)*this._sharedData.worldInvScale+t,h+=8;const d=Box2D.wrapPointer(this._verticesBuffer,Box2D.b2Vec2);i.Set(d,this.polygon.vertices.length)}else if(this.shape==="Edge"){i=new Box2D.b2EdgeShape;const n=(this.shapeDimensionA>0?Math.max(.1,this.shapeDimensionA*this.shapeScale):Math.max(.1,this.owner.getWidth()))*this._sharedData.worldInvScale,a=Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale,h=this.shapeDimensionB?l.toRad(this.shapeDimensionB):0;i.Set(this.b2Vec2(-n/2*Math.cos(h)+e,a/2-n/2*Math.sin(h)+t),this.b2Vec2Sec(n/2*Math.cos(h)+e,a/2+n/2*Math.sin(h)+t))}else{i=new Box2D.b2PolygonShape;const n=(this.shapeDimensionA>0?Math.max(.1,this.shapeDimensionA*this.shapeScale):Math.max(.1,this.owner.getWidth()))*this._sharedData.worldInvScale,a=(this.shapeDimensionB>0?Math.max(.1,this.shapeDimensionB*this.shapeScale):Math.max(.1,this.owner.getHeight()))*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}const o=new Box2D.b2Filter;o.set_categoryBits(this.layers),o.set_maskBits(this.masks);const s=new Box2D.b2FixtureDef;return s.set_shape(i),s.set_filter(o),this.density<0&&(this.density=0),s.set_density(this.density),this.friction<0&&(this.friction=0),s.set_friction(this.friction),this.restitution<0&&(this.restitution=0),s.set_restitution(this.restitution),s}recreateShape(){if(this._body===null&&!this.createBody())return;const e=this._body;e.DestroyFixture(e.GetFixtureList()),e.CreateFixture(this.createShape()),this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight()}getShapeScale(){return this.shapeScale}setShapeScale(e){e!==this.shapeScale&&e>0&&(this.shapeScale=e,this.recreateShape())}getBody(){return this._body===null&&this.createBody(),this._body}createBody(){if(!this.activated()||this.destroyedDuringFrameLogic)return!1;const e=new Box2D.b2BodyDef,t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale;e.set_position(this.b2Vec2(Number.isFinite(t)?t:0,Number.isFinite(i)?i:0));const o=l.toRad(this.owner.getAngle());return Number.isFinite(o)&&e.set_angle(o),e.set_type(this.bodyType==="Static"?Box2D.b2_staticBody:this.bodyType==="Kinematic"?Box2D.b2_kinematicBody:Box2D.b2_dynamicBody),e.set_bullet(this.bullet),e.set_fixedRotation(this.fixedRotation),e.set_allowSleep(this.canSleep),e.set_linearDamping(this.linearDamping),e.set_angularDamping(this.angularDamping),e.set_gravityScale(this.gravityScale),this._body=this._sharedData.world.CreateBody(e),this._body.CreateFixture(this.createShape()),this._body.gdjsAssociatedBehavior=this,this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight(),!0}doStepPreEvents(e){!this._sharedData.stepped&&!e.getScene().getTimeManager().isFirstFrame()&&this._sharedData.step(e.getScene().getTimeManager().getElapsedTime()/1e3)}doStepPostEvents(e){this._sharedData.stepped=!1}onObjectHotReloaded(){this.updateBodyFromObject()}updateObjectFromBody(){this._body!==null&&(this.owner.setX(this._body.GetPosition().get_x()*this._sharedData.worldScale-this.owner.getWidth()/2+this.owner.getX()-this.owner.getDrawableX()),this.owner.setY(this._body.GetPosition().get_y()*this._sharedData.worldScale-this.owner.getHeight()/2+this.owner.getY()-this.owner.getDrawableY()),this.owner.setAngle(l.toDegrees(this._body.GetAngle()))),this._objectOldX=this.owner.getX(),this._objectOldY=this.owner.getY(),this._objectOldAngle=this.owner.getAngle()}updateBodyFromObject(){if(this._body===null&&!this.createBody())return;const e=this._body;if((this._objectOldWidth!==this.owner.getWidth()&&this.shapeDimensionA<=0||this._objectOldHeight!==this.owner.getHeight()&&this.shape!=="Edge"&&!(this.shape==="Box"&&this.shapeDimensionB>0)&&!(this.shape==="Circle"&&this.shapeDimensionA>0))&&this.recreateShape(),this._objectOldX!==this.owner.getX()||this._objectOldY!==this.owner.getY()||this._objectOldAngle!==this.owner.getAngle()){const t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale,o=this.b2Vec2(Number.isFinite(t)?t:e.GetPosition().x,Number.isFinite(i)?i:e.GetPosition().y),s=l.toRad(this.owner.getAngle());e.SetTransform(o,Number.isFinite(s)?s:e.GetAngle()),e.SetAwake(!0)}}getWorldScale(){return this._sharedData.worldScale}getGravityX(){return this._sharedData.gravityX}getGravityY(){return this._sharedData.gravityY}setGravity(e,t){this._sharedData.gravityX===e&&this._sharedData.gravityY===t||(this._sharedData.gravityX=e,this._sharedData.gravityY=t,this._sharedData.world.SetGravity(this.b2Vec2(this._sharedData.gravityX,this._sharedData.gravityY)))}getTimeScale(){return this._sharedData.timeScale}setTimeScale(e){e<0||(this._sharedData.timeScale=e)}static setTimeScaleFromObject(e,t,i){e===null||!e.hasBehavior(t)||e.getBehavior(t).setTimeScale(i)}isDynamic(){return this.bodyType==="Dynamic"}setDynamic(){if(this.bodyType==="Dynamic"||(this.bodyType="Dynamic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_dynamicBody),e.SetAwake(!0)}isStatic(){return this.bodyType==="Static"}setStatic(){if(this.bodyType==="Static"||(this.bodyType="Static",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_staticBody),e.SetAwake(!0)}isKinematic(){return this.bodyType==="Kinematic"}setKinematic(){if(this.bodyType==="Kinematic"||(this.bodyType="Kinematic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_kinematicBody),e.SetAwake(!0)}isBullet(){return this.bullet}setBullet(e){if(this.bullet===e||(this.bullet=e,this._body===null&&!this.createBody()))return;this._body.SetBullet(this.bullet)}hasFixedRotation(){return this.fixedRotation}setFixedRotation(e){if(this.fixedRotation=e,this._body===null&&!this.createBody())return;this._body.SetFixedRotation(this.fixedRotation)}isSleepingAllowed(){return this.canSleep}setSleepingAllowed(e){if(this.canSleep=e,this._body===null&&!this.createBody())return;this._body.SetSleepingAllowed(this.canSleep)}isSleeping(){return this._body===null&&!this.createBody()?!0:!this._body.IsAwake()}getDensity(){return this.density}setDensity(e){if(e<0&&(e=0),this.density===e||(this.density=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetDensity(this.density),t.ResetMassData()}getFriction(){return this.friction}setFriction(e){if(e<0&&(e=0),this.friction===e||(this.friction=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetFriction(this.friction);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetFriction(),i=i.get_next()}getRestitution(){return this.restitution}setRestitution(e){if(e<0&&(e=0),this.restitution===e||(this.restitution=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetRestitution(this.restitution);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetRestitution(),i=i.get_next()}getLinearDamping(){return this.linearDamping}setLinearDamping(e){if(e<0&&(e=0),this.linearDamping===e||(this.linearDamping=e,this._body===null&&!this.createBody()))return;this._body.SetLinearDamping(this.linearDamping)}getAngularDamping(){return this.angularDamping}setAngularDamping(e){if(e<0&&(e=0),this.angularDamping===e||(this.angularDamping=e,this._body===null&&!this.createBody()))return;this._body.SetAngularDamping(this.angularDamping)}getGravityScale(){return this.gravityScale}setGravityScale(e){if(this.gravityScale===e||(this.gravityScale=e,this._body===null&&!this.createBody()))return;this._body.SetGravityScale(this.gravityScale)}layerEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.layers&1<<e-1)}enableLayer(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.layers|=1<<e-1:this.layers&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_categoryBits(this.layers),i.GetFixtureList().SetFilterData(o)}maskEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.masks&1<<e-1)}enableMask(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.masks|=1<<e-1:this.masks&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_maskBits(this.masks),i.GetFixtureList().SetFilterData(o)}getLinearVelocityX(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_x()*this._sharedData.worldScale}setLinearVelocityX(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(e*this._sharedData.worldInvScale,t.GetLinearVelocity().get_y()))}getLinearVelocityY(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_y()*this._sharedData.worldScale}setLinearVelocityY(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(t.GetLinearVelocity().get_x(),e*this._sharedData.worldInvScale))}getLinearVelocityLength(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return this.b2Vec2(e.GetLinearVelocity().get_x()*this._sharedData.worldScale,e.GetLinearVelocity().get_y()*this._sharedData.worldScale).Length()}getLinearVelocityAngle(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(Math.atan2(e.GetLinearVelocity().get_y()*this._sharedData.worldScale,e.GetLinearVelocity().get_x()*this._sharedData.worldScale))}setLinearVelocityAngle(e,t){if(this._body===null&&!this.createBody())return;const i=this._body;e=l.toRad(e),i.SetLinearVelocity(this.b2Vec2(t*Math.cos(e)*this._sharedData.worldInvScale,t*Math.sin(e)*this._sharedData.worldInvScale))}isLinearVelocityAngleAround(e,t){return Math.abs(l.evtTools.common.angleDifference(this.getLinearVelocityAngle(),e))<=t}getAngularVelocity(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(e.GetAngularVelocity())}setAngularVelocity(e){if(this._body===null&&!this.createBody())return;this._body.SetAngularVelocity(l.toRad(e))}applyForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyForce(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyForce(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyForceTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyForce(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyLinearImpulse(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyLinearImpulse(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyImpulseTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyLinearImpulse(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyTorque(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyTorque(e,!1)}applyAngularImpulse(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyAngularImpulse(e,!1)}getMass(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetMass()}getInertia(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetInertia()}getMassCenterX(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_x()*this._sharedData.worldScale}getMassCenterY(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_y()*this._sharedData.worldScale}isJointFirstObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyA()===this._body}isJointSecondObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyB()===this._body}getJointFirstAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_x()}getJointFirstAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_y()}getJointSecondAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_x()}getJointSecondAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_y()}getJointReactionForce(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionForce(1/this._sharedData.timeStep).Length()}getJointReactionTorque(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionTorque(1/this._sharedData.timeStep)}removeJoint(e){this._sharedData.removeJoint(e)}addDistanceJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body;if(i==null||!i.hasBehavior(this.name))return;const r=i.getBehavior(this.name).getBody();if(this._body===r)return;const f=new Box2D.b2DistanceJointDef;f.set_bodyA(u),f.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(r),f.set_localAnchorB(r.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_length(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),f.set_frequencyHz(a>=0?a:0),f.set_dampingRatio(h>=0?h:1),f.set_collideConnected(d);const D=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2DistanceJoint));c.setNumber(D)}getDistanceJointLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetLength()*this._sharedData.worldScale}setDistanceJointLength(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||(i.SetLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getDistanceJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetFrequency()}setDistanceJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||i.SetFrequency(t)}getDistanceJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetDampingRatio()}setDistanceJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint,i.SetDampingRatio(t)}addRevoluteJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body,r=new Box2D.b2RevoluteJointDef;if(r.set_bodyA(this._sharedData.staticBody),r.set_localAnchorA(this._sharedData.staticBody.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(u),r.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_enableLimit(i),r.set_referenceAngle(l.toRad(o)),n<s){const D=s;s=n,n=D}r.set_lowerAngle(l.toRad(s)),r.set_upperAngle(l.toRad(n)),r.set_enableMotor(a),r.set_motorSpeed(l.toRad(h)),r.set_maxMotorTorque(d>=0?d:0),r.set_collideConnected(!1);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2RevoluteJoint));c.setNumber(f)}addRevoluteJointBetweenTwoBodies(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const y=this._body,g=new Box2D.b2RevoluteJointDef;if(g.set_bodyA(y),g.set_localAnchorA(y.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(b),g.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_enableLimit(n),g.set_referenceAngle(l.toRad(a)),d<h){const J=h;h=d,d=J}g.set_lowerAngle(l.toRad(h)),g.set_upperAngle(l.toRad(d)),g.set_enableMotor(c),g.set_motorSpeed(l.toRad(u)),g.set_maxMotorTorque(r>=0?r:0),g.set_collideConnected(f);const _=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2RevoluteJoint));D.setNumber(_)}getRevoluteJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetReferenceAngle())}getRevoluteJointAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointAngle())}getRevoluteJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointSpeed())}isRevoluteJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsLimitEnabled()}enableRevoluteJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableLimit(t)}getRevoluteJointMinAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetLowerLimit())}getRevoluteJointMaxAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetUpperLimit())}setRevoluteJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_revoluteJoint)){if(i<t){const s=t;t=i,i=s}o.SetLimits(l.toRad(t),l.toRad(i))}}isRevoluteJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsMotorEnabled()}enableRevoluteJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableMotor(t)}getRevoluteJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetMotorSpeed())}setRevoluteJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMotorSpeed(l.toRad(t))}getRevoluteJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMaxMotorTorque()}setRevoluteJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMaxMotorTorque(t)}getRevoluteJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}addPrismaticJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D,b){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const y=i.getBehavior(this.name).getBody();if(this._body===y)return;const g=this._body,_=new Box2D.b2PrismaticJointDef;if(_.set_bodyA(g),_.set_localAnchorA(g.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),_.set_bodyB(y),_.set_localAnchorB(y.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-g.GetAngle(),_.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),_.set_referenceAngle(l.toRad(a)),_.set_enableLimit(h),c<d){const m=d;d=c,c=m}_.set_lowerTranslation(d<0?d*this._sharedData.worldInvScale:0),_.set_upperTranslation(c>0?c*this._sharedData.worldInvScale:0),_.set_enableMotor(u),_.set_motorSpeed(r*this._sharedData.worldInvScale),_.set_maxMotorForce(f),_.set_collideConnected(D);const J=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(_),Box2D.b2PrismaticJoint));b.setNumber(J)}getPrismaticJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getPrismaticJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(t.GetReferenceAngle())}getPrismaticJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getPrismaticJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointSpeed()*this._sharedData.worldScale}isPrismaticJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsLimitEnabled()}enablePrismaticJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableLimit(t)}getPrismaticJointMinTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetLowerLimit()*this._sharedData.worldScale}getPrismaticJointMaxTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetUpperLimit()*this._sharedData.worldScale}setPrismaticJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_prismaticJoint)){if(i<t){const s=t;t=i,i=s}t=t<0?t:0,i=i>0?i:0,o.SetLimits(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)}}isPrismaticJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsMotorEnabled()}enablePrismaticJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableMotor(t)}getPrismaticJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorSpeed()*this._sharedData.worldScale}setPrismaticJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMotorSpeed(t*this._sharedData.worldInvScale)}getPrismaticJointMaxMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMaxMotorForce()}setPrismaticJointMaxMotorForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMaxMotorForce(t)}getPrismaticJointMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorForce(1/this._sharedData.timeStep)}addPulleyJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody())return;const b=this._body;if(i==null||!i.hasBehavior(this.name))return;const y=i.getBehavior(this.name).getBody();if(this._body===y)return;const g=new Box2D.b2PulleyJointDef;g.set_bodyA(b),g.set_localAnchorA(b.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(y),g.set_localAnchorB(y.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_groundAnchorA(this.b2Vec2(n*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale)),g.set_groundAnchorB(this.b2Vec2(h*this._sharedData.worldInvScale,d*this._sharedData.worldInvScale)),g.set_lengthA(c>0?c*this._sharedData.worldInvScale:this.b2Vec2((n-e)*this._sharedData.worldInvScale,(a-t)*this._sharedData.worldInvScale).Length()),g.set_lengthB(u>0?u*this._sharedData.worldInvScale:this.b2Vec2((h-o)*this._sharedData.worldInvScale,(d-s)*this._sharedData.worldInvScale).Length()),g.set_ratio(r>0?r:1),g.set_collideConnected(f);const _=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2PulleyJoint));D.setNumber(_)}getPulleyJointFirstGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_x()*this._sharedData.worldScale}getPulleyJointFirstGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_y()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_x()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_y()*this._sharedData.worldScale}getPulleyJointFirstLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthA()*this._sharedData.worldScale}getPulleyJointSecondLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthB()*this._sharedData.worldScale}getPulleyJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetRatio()}addGearJoint(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body,a=this._sharedData.getJoint(e);if(a===null||a.GetType()!==Box2D.e_revoluteJoint&&a.GetType()!==Box2D.e_prismaticJoint)return;const h=this._sharedData.getJoint(t);if(h===null||h.GetType()!==Box2D.e_revoluteJoint&&h.GetType()!==Box2D.e_prismaticJoint||a===h)return;const d=new Box2D.b2GearJointDef;d.set_bodyA(this._sharedData.staticBody),d.set_bodyB(n),d.set_joint1(a),d.set_joint2(h),d.set_ratio(i),d.set_collideConnected(o);const c=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(d),Box2D.b2GearJoint));s.setNumber(c)}getGearJointFirstJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint1())}getGearJointSecondJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint2())}getGearJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:t.GetRatio()}setGearJointRatio(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_gearJoint||(i.SetRatio(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addMouseJoint(e,t,i,o,s,n){if(this._body===null&&!this.createBody())return;const a=this._body,h=new Box2D.b2MouseJointDef;h.set_bodyA(this._sharedData.staticBody),h.set_bodyB(a),h.set_target(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale)),h.set_maxForce(i>=0?i:0),h.set_frequencyHz(o>0?o:1),h.set_dampingRatio(s>=0?s:0);const d=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(h),Box2D.b2MouseJoint));n.setNumber(d)}getMouseJointTargetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_x()*this._sharedData.worldScale}getMouseJointTargetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_y()*this._sharedData.worldScale}setMouseJointTarget(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_mouseJoint||(o.SetTarget(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),o.GetBodyB().SetAwake(!0))}getMouseJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetMaxForce()}setMouseJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetMaxForce(t)}getMouseJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetFrequency()}setMouseJointFrequency(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetFrequency(t)}getMouseJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetDampingRatio()}setMouseJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetDampingRatio(t)}addWheelJoint(e,t,i,o,s,n,a,h,d,c,u,r,f){if(this._body===null&&!this.createBody())return;const D=this._body;if(i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const y=new Box2D.b2WheelJointDef;y.set_bodyA(D),y.set_localAnchorA(D.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),y.set_bodyB(b),y.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-D.GetAngle(),y.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),y.set_frequencyHz(a>0?a:1),y.set_dampingRatio(h>=0?h:0),y.set_enableMotor(d),y.set_motorSpeed(l.toRad(c)),y.set_maxMotorTorque(u),y.set_collideConnected(r);const g=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(y),Box2D.b2WheelJoint));f.setNumber(g)}getWheelJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getWheelJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getWheelJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetJointSpeed())}isWheelJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?!1:t.IsMotorEnabled()}enableWheelJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.EnableMotor(t)}getWheelJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetMotorSpeed())}setWheelJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMotorSpeed(l.toRad(t))}getWheelJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMaxMotorTorque()}setWheelJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMaxMotorTorque(t)}getWheelJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}getWheelJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringFrequencyHz()}setWheelJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringFrequencyHz(t)}getWheelJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringDampingRatio()}setWheelJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringDampingRatio(t)}addWeldJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const u=i.getBehavior(this.name).getBody();if(this._body===u)return;const r=this._body,f=new Box2D.b2WeldJointDef;f.set_bodyA(r),f.set_localAnchorA(r.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(u),f.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_referenceAngle(l.toRad(n)),f.set_frequencyHz(a>0?a:1),f.set_dampingRatio(h>=0?h:0),f.set_collideConnected(d);const D=Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2WeldJoint);D.referenceAngle=f.get_referenceAngle(),c.setNumber(this._sharedData.addJoint(D))}getWeldJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:l.toDegrees(t.referenceAngle)}getWeldJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetFrequency()}setWeldJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetFrequency(t)}getWeldJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetDampingRatio()}setWeldJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetDampingRatio(t)}addRopeJoint(e,t,i,o,s,n,a,h){if(this._body===null&&!this.createBody())return;const d=this._body;if(i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=new Box2D.b2RopeJointDef;u.set_bodyA(d),u.set_localAnchorA(d.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),u.set_bodyB(c),u.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),u.set_maxLength(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),u.set_collideConnected(a);const r=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(u),Box2D.b2RopeJoint));h.setNumber(r)}getRopeJointMaxLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_ropeJoint?0:t.GetMaxLength()*this._sharedData.worldScale}setRopeJointMaxLength(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_ropeJoint||(i.SetMaxLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addFrictionJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=this._body,r=new Box2D.b2FrictionJointDef;r.set_bodyA(u),r.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(c),r.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),r.set_maxForce(n>=0?n:0),r.set_maxTorque(a>=0?a:0),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2FrictionJoint));d.setNumber(f)}getFrictionJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxForce()}setFrictionJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxForce(t)}getFrictionJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxTorque()}setFrictionJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxTorque(t)}addMotorJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody())return;const c=this._body;if(e==null||!e.hasBehavior(this.name))return;const u=e.getBehavior(this.name).getBody();if(this._body===u)return;const r=new Box2D.b2MotorJointDef;r.set_bodyA(c),r.set_bodyB(u),r.set_linearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),r.set_angularOffset(l.toRad(o)),r.set_maxForce(s>=0?s:0),r.set_maxTorque(n>=0?n:0),r.set_correctionFactor(a<0?0:a>1?1:a),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2MotorJoint));d.setNumber(f)}getMotorJointOffsetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_x()*this._sharedData.worldScale}getMotorJointOffsetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_y()*this._sharedData.worldScale}setMotorJointOffset(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_motorJoint||o.SetLinearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale))}getMotorJointAngularOffset(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:l.toDegrees(t.GetAngularOffset())}setMotorJointAngularOffset(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetAngularOffset(l.toRad(t))}getMotorJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxForce()}setMotorJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetMaxForce(t)}getMotorJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxTorque()}setMotorJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetMaxTorque(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getMotorJointCorrectionFactor(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetCorrectionFactor()}setMotorJointCorrectionFactor(e,t){if(t<0||t>1)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetCorrectionFactor(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}onContactBegin(e){this.currentContacts.push(e);let t=this.contactsEndedThisFrame.indexOf(e);t!==-1?this.contactsEndedThisFrame.splice(t,1):this.contactsStartedThisFrame.push(e)}onContactEnd(e){this.contactsEndedThisFrame.push(e);const t=this.currentContacts.indexOf(e);t!==-1&&this.currentContacts.splice(t,1)}static areObjectsColliding(e,t,i){const o=e.getBehavior(i);return o?!!(o.currentContacts.some(s=>s.owner===t)||o.contactsStartedThisFrame.some(s=>s.owner===t)):!1}static hasCollisionStartedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsStartedThisFrame.some(s=>s.owner===t):!1}static hasCollisionStoppedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsEndedThisFrame.some(s=>s.owner===t):!1}};let p=B;p.collisionTest=B.areObjectsColliding,l.Physics2RuntimeBehavior=p,l.registerBehavior("Physics2::Physics2Behavior",l.Physics2RuntimeBehavior)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(l){class S{constructor(e,t){this.frameTime=0;this.stepped=!1;this.timeScale=1;this._nextJointId=1;this.joints={};this._tempb2Vec2=new Box2D.b2Vec2(0,0);this._tempb2Vec2Sec=new Box2D.b2Vec2(0,0);this._registeredBehaviors=new Set,this.gravityX=t.gravityX,this.gravityY=t.gravityY,this.scaleX=t.scaleX||100,this.scaleY=t.scaleY||100,this.invScaleX=1/this.scaleX,this.invScaleY=1/this.scaleY,this.worldScale=t.worldScale||Math.sqrt(this.scaleX*this.scaleY),this.worldInvScale=1/this.worldScale,this.timeStep=1/60,this.world=new Box2D.b2World(this.b2Vec2(this.gravityX,this.gravityY)),this.world.SetAutoClearForces(!1),this.staticBody=this.world.CreateBody(new Box2D.b2BodyDef),this.contactListener=new Box2D.JSContactListener,this.contactListener.BeginContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactBegin(n),n.onContactBegin(s))},this.contactListener.EndContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactEnd(n),n.onContactEnd(s))},this.contactListener.PreSolve=function(){},this.contactListener.PostSolve=function(){},this.world.SetContactListener(this.contactListener)}b2Vec2(e,t){const i=this._tempb2Vec2;return i.set_x(e),i.set_y(t),i}static getSharedData(e,t){if(!e.physics2SharedData){const i=e.getInitialSharedDataForBehavior(t);e.physics2SharedData=new l.Physics2SharedData(e,i)}return e.physics2SharedData}addToBehaviorsList(e){this._registeredBehaviors.add(e)}removeFromBehaviorsList(e){this._registeredBehaviors.delete(e)}step(e){for(const i of this._registeredBehaviors)i.contactsStartedThisFrame.length=0,i.contactsEndedThisFrame.length=0;for(const i of this._registeredBehaviors)i.updateBodyFromObject();this.frameTime+=e;let t=Math.max(0,Math.round(this.frameTime/this.timeStep));this.frameTime-=t*this.timeStep,t>5&&(t=5);for(let i=0;i<t;i++)this.world.Step(this.timeStep*this.timeScale,8,10);this.world.ClearForces(),this.stepped=!0;for(const i of this._registeredBehaviors)i.updateObjectFromBody()}clearBodyJoints(e){for(const t in this.joints)this.joints.hasOwnProperty(t)&&(this.joints[t].GetBodyA()===e||this.joints[t].GetBodyB()===e)&&this.removeJoint(t)}addJoint(e){return this.joints[this._nextJointId.toString(10)]=e,this._nextJointId++}getJoint(e){return e=e.toString(10),this.joints.hasOwnProperty(e)?this.joints[e]:null}getJointId(e){for(const t in this.joints)if(this.joints.hasOwnProperty(t)&&this.joints[t]===e)return parseInt(t,10);return 0}removeJoint(e){if(e=e.toString(10),this.joints.hasOwnProperty(e)){const t=this.joints[e];if(t.GetType()===Box2D.e_revoluteJoint||t.GetType()===Box2D.e_prismaticJoint)for(const i in this.joints)this.joints.hasOwnProperty(i)&&this.joints[i].GetType()===Box2D.e_gearJoint&&(Box2D.getPointer(this.joints[i].GetJoint1())===Box2D.getPointer(t)||Box2D.getPointer(this.joints[i].GetJoint2())===Box2D.getPointer(t))&&this.removeJoint(parseInt(i,10));this.world.DestroyJoint(t),delete this.joints[e]}}}l.Physics2SharedData=S,l.registerRuntimeSceneUnloadedCallback(function(x){const e=x.physics2SharedData;e&&e.world&&(Box2D.destroy(e.world),Box2D.destroy(e._tempb2Vec2),Box2D.destroy(e._tempb2Vec2Sec))});const B=class extends l.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this.shapeScale=1;this._body=null;this._objectOldX=0;this._objectOldY=0;this._objectOldAngle=0;this._objectOldWidth=0;this._objectOldHeight=0;this._verticesBuffer=0;this.bodyType=t.bodyType,this.bullet=t.bullet,this.fixedRotation=t.fixedRotation,this.canSleep=t.canSleep,this.shape=t.shape,this.shapeDimensionA=t.shapeDimensionA,this.shapeDimensionB=t.shapeDimensionB,this.shapeOffsetX=t.shapeOffsetX,this.shapeOffsetY=t.shapeOffsetY,this.polygonOrigin=t.polygonOrigin,this.polygon=this.shape==="Polygon"?B.getPolygon(t.vertices):null,this.density=t.density,this.friction=t.friction,this.restitution=t.restitution,this.linearDamping=Math.max(0,t.linearDamping),this.angularDamping=Math.max(0,t.angularDamping),this.gravityScale=t.gravityScale,this.layers=t.layers,this.masks=t.masks,this.contactsStartedThisFrame=[],this.contactsEndedThisFrame=[],this.currentContacts=[],this.currentContacts.length=0,this.destroyedDuringFrameLogic=!1,this._sharedData=S.getSharedData(e.getScene(),t.name),this._sharedData.addToBehaviorsList(this)}b2Vec2(e,t){const i=this._sharedData._tempb2Vec2;return i.set_x(e),i.set_y(t),i}b2Vec2Sec(e,t){const i=this._sharedData._tempb2Vec2Sec;return i.set_x(e),i.set_y(t),i}updateFromBehaviorData(e,t){return e.bullet!==t.bullet&&this.setBullet(t.bullet),e.fixedRotation!==t.fixedRotation&&this.setFixedRotation(t.fixedRotation),e.canSleep!==t.canSleep&&this.setSleepingAllowed(t.canSleep),e.shapeDimensionA!==t.shapeDimensionA&&(this.shapeDimensionA=t.shapeDimensionA,this.recreateShape()),e.shapeDimensionB!==t.shapeDimensionB&&(this.shapeDimensionB=t.shapeDimensionB,this.recreateShape()),e.shapeOffsetX!==t.shapeOffsetX&&(this.shapeOffsetX=t.shapeOffsetX,this.recreateShape()),e.shapeOffsetY!==t.shapeOffsetY&&(this.shapeOffsetY=t.shapeOffsetY,this.recreateShape()),e.polygonOrigin!==t.polygonOrigin&&(this.polygonOrigin=t.polygonOrigin,this.recreateShape()),e.density!==t.density&&this.setDensity(t.density),e.friction!==t.friction&&this.setFriction(t.friction),e.restitution!==t.restitution&&this.setRestitution(t.restitution),e.linearDamping!==t.linearDamping&&this.setLinearDamping(t.linearDamping),e.angularDamping!==t.angularDamping&&this.setAngularDamping(t.angularDamping),e.gravityScale!==t.gravityScale&&this.setGravityScale(t.gravityScale),!(e.layers!==t.layers||e.masks!==t.masks||e.vertices!==t.vertices||e.bodyType!==t.bodyType||e.shape!==t.shape)}getNetworkSyncData(){const e=this._body?{tpx:this._body.GetTransform().get_p().get_x(),tpy:this._body.GetTransform().get_p().get_y(),tqa:this._body.GetTransform().get_q().GetAngle(),lvx:this._body.GetLinearVelocity().get_x(),lvy:this._body.GetLinearVelocity().get_y(),av:this._body.GetAngularVelocity(),aw:this._body.IsAwake()}:{tpx:void 0,tpy:void 0,tqa:void 0,lvx:void 0,lvy:void 0,av:void 0,aw:void 0};return{...super.getNetworkSyncData(),props:{...e,layers:this.layers,masks:this.masks}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.tpx!==void 0&&t.tpy!==void 0&&t.tqa!==void 0&&this._body&&this._body.SetTransform(this.b2Vec2(t.tpx,t.tpy),t.tqa),t.lvx!==void 0&&t.lvy!==void 0&&this._body&&this._body.SetLinearVelocity(this.b2Vec2(t.lvx,t.lvy)),t.av!==void 0&&this._body&&this._body.SetAngularVelocity(t.av),t.aw!==void 0&&this._body&&this._body.SetAwake(t.aw),t.layers!==void 0&&(this.layers=t.layers),t.masks!==void 0&&(this.masks=t.masks)}onDeActivate(){this._sharedData.removeFromBehaviorsList(this),this._body!==null&&(this._sharedData.clearBodyJoints(this._body),this._verticesBuffer&&(Box2D._free(this._verticesBuffer),this._verticesBuffer=0),this._sharedData.world.DestroyBody(this._body),this._body=null),this.contactsEndedThisFrame.length=0,this.contactsStartedThisFrame.length=0,this.currentContacts.length=0}onActivate(){this._sharedData.addToBehaviorsList(this),this.contactsEndedThisFrame.length=0,this.contactsStartedThisFrame.length=0,this.currentContacts.length=0,this.updateBodyFromObject()}onDestroy(){this.destroyedDuringFrameLogic=!0,this.onDeActivate()}static getPolygon(e){if(!e)return null;const t=new l.Polygon,i=8;for(let o=0,s=e.length;o<Math.min(s,i);o++)t.vertices.push([e[o].x,e[o].y]);return t}static isPolygonConvex(e){if(!e.isConvex())return!1;let t=!0,i=!0;for(let o=0;o<e.vertices.length-1;++o){for(let s=o+1;s<e.vertices.length;++s)if(e.vertices[o][0]===e.vertices[s][0]&&e.vertices[o][1]===e.vertices[s][1])return!1;e.vertices[o][0]!==e.vertices[o+1][0]&&(t=!1),e.vertices[o][1]!==e.vertices[o+1][1]&&(i=!1)}return!(t||i)}createShape(){const e=this.shapeOffsetX?this.shapeOffsetX*this.shapeScale*this._sharedData.worldInvScale:0,t=this.shapeOffsetY?this.shapeOffsetY*this.shapeScale*this._sharedData.worldInvScale:0;let i;if(this.shape==="Circle"){if(i=new Box2D.b2CircleShape,this.shapeDimensionA>0)i.set_m_radius(Math.max(.1,this.shapeDimensionA)*this.shapeScale*this._sharedData.worldInvScale);else{const n=(Math.max(.1,this.owner.getWidth())*this._sharedData.worldInvScale+Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale)/4;i.set_m_radius(n)}i.set_m_p(this.b2Vec2(e,t))}else if(this.shape==="Polygon")if(i=new Box2D.b2PolygonShape,!this.polygon||!B.isPolygonConvex(this.polygon)){const n=Math.max(.1,this.owner.getWidth())*this._sharedData.worldInvScale,a=Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}else{let n=0,a=0;if(this.polygonOrigin==="Origin"?(n=(this.owner.getWidth()>0?-this.owner.getWidth()/2:0)+(this.owner.getX()-this.owner.getDrawableX()),a=(this.owner.getHeight()>0?-this.owner.getHeight()/2:0)+(this.owner.getY()-this.owner.getDrawableY())):this.polygonOrigin==="TopLeft"&&(n=this.owner.getWidth()>0?-this.owner.getWidth()/2:0,a=this.owner.getHeight()>0?-this.owner.getHeight()/2:0),!this._verticesBuffer){const c=Box2D._malloc(this.polygon.vertices.length*8,"float",Box2D.ALLOC_STACK);this._verticesBuffer=c}let h=0;for(let c=0,u=this.polygon.vertices.length;c<u;c++)Box2D.HEAPF32[this._verticesBuffer+h>>2]=(this.polygon.vertices[c][0]*this.shapeScale+n)*this._sharedData.worldInvScale+e,Box2D.HEAPF32[this._verticesBuffer+(h+4)>>2]=(this.polygon.vertices[c][1]*this.shapeScale+a)*this._sharedData.worldInvScale+t,h+=8;const d=Box2D.wrapPointer(this._verticesBuffer,Box2D.b2Vec2);i.Set(d,this.polygon.vertices.length)}else if(this.shape==="Edge"){i=new Box2D.b2EdgeShape;const n=(this.shapeDimensionA>0?Math.max(.1,this.shapeDimensionA*this.shapeScale):Math.max(.1,this.owner.getWidth()))*this._sharedData.worldInvScale,a=Math.max(.1,this.owner.getHeight())*this._sharedData.worldInvScale,h=this.shapeDimensionB?l.toRad(this.shapeDimensionB):0;i.Set(this.b2Vec2(-n/2*Math.cos(h)+e,a/2-n/2*Math.sin(h)+t),this.b2Vec2Sec(n/2*Math.cos(h)+e,a/2+n/2*Math.sin(h)+t))}else{i=new Box2D.b2PolygonShape;const n=(this.shapeDimensionA>0?Math.max(.1,this.shapeDimensionA*this.shapeScale):Math.max(.1,this.owner.getWidth()))*this._sharedData.worldInvScale,a=(this.shapeDimensionB>0?Math.max(.1,this.shapeDimensionB*this.shapeScale):Math.max(.1,this.owner.getHeight()))*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}const o=new Box2D.b2Filter;o.set_categoryBits(this.layers),o.set_maskBits(this.masks);const s=new Box2D.b2FixtureDef;return s.set_shape(i),s.set_filter(o),this.density<0&&(this.density=0),s.set_density(this.density),this.friction<0&&(this.friction=0),s.set_friction(this.friction),this.restitution<0&&(this.restitution=0),s.set_restitution(this.restitution),s}recreateShape(){if(this._body===null&&!this.createBody())return;const e=this._body;e.DestroyFixture(e.GetFixtureList()),e.CreateFixture(this.createShape()),this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight()}getShapeScale(){return this.shapeScale}setShapeScale(e){e!==this.shapeScale&&e>0&&(this.shapeScale=e,this.recreateShape())}getBody(){return this._body===null&&this.createBody(),this._body}createBody(){if(!this.activated()||this.destroyedDuringFrameLogic)return!1;const e=new Box2D.b2BodyDef,t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale;e.set_position(this.b2Vec2(Number.isFinite(t)?t:0,Number.isFinite(i)?i:0));const o=l.toRad(this.owner.getAngle());return Number.isFinite(o)&&e.set_angle(o),e.set_type(this.bodyType==="Static"?Box2D.b2_staticBody:this.bodyType==="Kinematic"?Box2D.b2_kinematicBody:Box2D.b2_dynamicBody),e.set_bullet(this.bullet),e.set_fixedRotation(this.fixedRotation),e.set_allowSleep(this.canSleep),e.set_linearDamping(this.linearDamping),e.set_angularDamping(this.angularDamping),e.set_gravityScale(this.gravityScale),this._body=this._sharedData.world.CreateBody(e),this._body.CreateFixture(this.createShape()),this._body.gdjsAssociatedBehavior=this,this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight(),!0}doStepPreEvents(e){!this._sharedData.stepped&&!e.getScene().getTimeManager().isFirstFrame()&&this._sharedData.step(e.getScene().getTimeManager().getElapsedTime()/1e3)}doStepPostEvents(e){this._sharedData.stepped=!1}onObjectHotReloaded(){this.updateBodyFromObject()}updateObjectFromBody(){this._body!==null&&!this.isStatic()&&this._body.IsAwake()&&(this.owner.setX(this._body.GetPosition().get_x()*this._sharedData.worldScale-this.owner.getWidth()/2+this.owner.getX()-this.owner.getDrawableX()),this.owner.setY(this._body.GetPosition().get_y()*this._sharedData.worldScale-this.owner.getHeight()/2+this.owner.getY()-this.owner.getDrawableY()),this.owner.setAngle(l.toDegrees(this._body.GetAngle()))),this._objectOldX=this.owner.getX(),this._objectOldY=this.owner.getY(),this._objectOldAngle=this.owner.getAngle()}updateBodyFromObject(){if(this._body===null&&!this.createBody())return;const e=this._body;if((this._objectOldWidth!==this.owner.getWidth()&&this.shapeDimensionA<=0||this._objectOldHeight!==this.owner.getHeight()&&this.shape!=="Edge"&&!(this.shape==="Box"&&this.shapeDimensionB>0)&&!(this.shape==="Circle"&&this.shapeDimensionA>0))&&this.recreateShape(),this._objectOldX!==this.owner.getX()||this._objectOldY!==this.owner.getY()||this._objectOldAngle!==this.owner.getAngle()){const t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale,o=this.b2Vec2(Number.isFinite(t)?t:e.GetPosition().x,Number.isFinite(i)?i:e.GetPosition().y),s=l.toRad(this.owner.getAngle());e.SetTransform(o,Number.isFinite(s)?s:e.GetAngle()),e.SetAwake(!0)}}getWorldScale(){return this._sharedData.worldScale}getGravityX(){return this._sharedData.gravityX}getGravityY(){return this._sharedData.gravityY}setGravity(e,t){this._sharedData.gravityX===e&&this._sharedData.gravityY===t||(this._sharedData.gravityX=e,this._sharedData.gravityY=t,this._sharedData.world.SetGravity(this.b2Vec2(this._sharedData.gravityX,this._sharedData.gravityY)))}getTimeScale(){return this._sharedData.timeScale}setTimeScale(e){e<0||(this._sharedData.timeScale=e)}static setTimeScaleFromObject(e,t,i){e===null||!e.hasBehavior(t)||e.getBehavior(t).setTimeScale(i)}isDynamic(){return this.bodyType==="Dynamic"}setDynamic(){if(this.bodyType==="Dynamic"||(this.bodyType="Dynamic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_dynamicBody),e.SetAwake(!0)}isStatic(){return this.bodyType==="Static"}setStatic(){if(this.bodyType==="Static"||(this.bodyType="Static",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_staticBody),e.SetAwake(!0)}isKinematic(){return this.bodyType==="Kinematic"}setKinematic(){if(this.bodyType==="Kinematic"||(this.bodyType="Kinematic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_kinematicBody),e.SetAwake(!0)}isBullet(){return this.bullet}setBullet(e){if(this.bullet===e||(this.bullet=e,this._body===null&&!this.createBody()))return;this._body.SetBullet(this.bullet)}hasFixedRotation(){return this.fixedRotation}setFixedRotation(e){if(this.fixedRotation=e,this._body===null&&!this.createBody())return;this._body.SetFixedRotation(this.fixedRotation)}isSleepingAllowed(){return this.canSleep}setSleepingAllowed(e){if(this.canSleep=e,this._body===null&&!this.createBody())return;this._body.SetSleepingAllowed(this.canSleep)}isSleeping(){return this._body===null&&!this.createBody()?!0:!this._body.IsAwake()}getDensity(){return this.density}setDensity(e){if(e<0&&(e=0),this.density===e||(this.density=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetDensity(this.density),t.ResetMassData()}getFriction(){return this.friction}setFriction(e){if(e<0&&(e=0),this.friction===e||(this.friction=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetFriction(this.friction);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetFriction(),i=i.get_next()}getRestitution(){return this.restitution}setRestitution(e){if(e<0&&(e=0),this.restitution===e||(this.restitution=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetRestitution(this.restitution);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetRestitution(),i=i.get_next()}getLinearDamping(){return this.linearDamping}setLinearDamping(e){if(e<0&&(e=0),this.linearDamping===e||(this.linearDamping=e,this._body===null&&!this.createBody()))return;this._body.SetLinearDamping(this.linearDamping)}getAngularDamping(){return this.angularDamping}setAngularDamping(e){if(e<0&&(e=0),this.angularDamping===e||(this.angularDamping=e,this._body===null&&!this.createBody()))return;this._body.SetAngularDamping(this.angularDamping)}getGravityScale(){return this.gravityScale}setGravityScale(e){if(this.gravityScale===e||(this.gravityScale=e,this._body===null&&!this.createBody()))return;this._body.SetGravityScale(this.gravityScale)}layerEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.layers&1<<e-1)}enableLayer(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.layers|=1<<e-1:this.layers&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_categoryBits(this.layers),i.GetFixtureList().SetFilterData(o)}maskEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.masks&1<<e-1)}enableMask(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.masks|=1<<e-1:this.masks&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_maskBits(this.masks),i.GetFixtureList().SetFilterData(o)}getLinearVelocityX(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_x()*this._sharedData.worldScale}setLinearVelocityX(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(e*this._sharedData.worldInvScale,t.GetLinearVelocity().get_y()))}getLinearVelocityY(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_y()*this._sharedData.worldScale}setLinearVelocityY(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(t.GetLinearVelocity().get_x(),e*this._sharedData.worldInvScale))}getLinearVelocityLength(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return this.b2Vec2(e.GetLinearVelocity().get_x()*this._sharedData.worldScale,e.GetLinearVelocity().get_y()*this._sharedData.worldScale).Length()}getLinearVelocityAngle(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(Math.atan2(e.GetLinearVelocity().get_y()*this._sharedData.worldScale,e.GetLinearVelocity().get_x()*this._sharedData.worldScale))}setLinearVelocityAngle(e,t){if(this._body===null&&!this.createBody())return;const i=this._body;e=l.toRad(e),i.SetLinearVelocity(this.b2Vec2(t*Math.cos(e)*this._sharedData.worldInvScale,t*Math.sin(e)*this._sharedData.worldInvScale))}isLinearVelocityAngleAround(e,t){return Math.abs(l.evtTools.common.angleDifference(this.getLinearVelocityAngle(),e))<=t}getAngularVelocity(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(e.GetAngularVelocity())}setAngularVelocity(e){if(this._body===null&&!this.createBody())return;this._body.SetAngularVelocity(l.toRad(e))}applyForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyForce(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyForce(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyForceTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyForce(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyLinearImpulse(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyLinearImpulse(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyImpulseTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyLinearImpulse(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyTorque(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyTorque(e,!1)}applyAngularImpulse(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyAngularImpulse(e,!1)}getMass(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetMass()}getInertia(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetInertia()}getMassCenterX(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_x()*this._sharedData.worldScale}getMassCenterY(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_y()*this._sharedData.worldScale}isJointFirstObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyA()===this._body}isJointSecondObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyB()===this._body}getJointFirstAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_x()}getJointFirstAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_y()}getJointSecondAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_x()}getJointSecondAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_y()}getJointReactionForce(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionForce(1/this._sharedData.timeStep).Length()}getJointReactionTorque(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionTorque(1/this._sharedData.timeStep)}removeJoint(e){this._sharedData.removeJoint(e)}addDistanceJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body;if(i==null||!i.hasBehavior(this.name))return;const r=i.getBehavior(this.name).getBody();if(this._body===r)return;const f=new Box2D.b2DistanceJointDef;f.set_bodyA(u),f.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(r),f.set_localAnchorB(r.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_length(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),f.set_frequencyHz(a>=0?a:0),f.set_dampingRatio(h>=0?h:1),f.set_collideConnected(d);const D=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2DistanceJoint));c.setNumber(D)}getDistanceJointLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetLength()*this._sharedData.worldScale}setDistanceJointLength(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||(i.SetLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getDistanceJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetFrequency()}setDistanceJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||i.SetFrequency(t)}getDistanceJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetDampingRatio()}setDistanceJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint,i.SetDampingRatio(t)}addRevoluteJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body,r=new Box2D.b2RevoluteJointDef;if(r.set_bodyA(this._sharedData.staticBody),r.set_localAnchorA(this._sharedData.staticBody.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(u),r.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_enableLimit(i),r.set_referenceAngle(l.toRad(o)),n<s){const D=s;s=n,n=D}r.set_lowerAngle(l.toRad(s)),r.set_upperAngle(l.toRad(n)),r.set_enableMotor(a),r.set_motorSpeed(l.toRad(h)),r.set_maxMotorTorque(d>=0?d:0),r.set_collideConnected(!1);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2RevoluteJoint));c.setNumber(f)}addRevoluteJointBetweenTwoBodies(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const y=this._body,g=new Box2D.b2RevoluteJointDef;if(g.set_bodyA(y),g.set_localAnchorA(y.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(b),g.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_enableLimit(n),g.set_referenceAngle(l.toRad(a)),d<h){const J=h;h=d,d=J}g.set_lowerAngle(l.toRad(h)),g.set_upperAngle(l.toRad(d)),g.set_enableMotor(c),g.set_motorSpeed(l.toRad(u)),g.set_maxMotorTorque(r>=0?r:0),g.set_collideConnected(f);const _=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2RevoluteJoint));D.setNumber(_)}getRevoluteJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetReferenceAngle())}getRevoluteJointAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointAngle())}getRevoluteJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointSpeed())}isRevoluteJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsLimitEnabled()}enableRevoluteJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableLimit(t)}getRevoluteJointMinAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetLowerLimit())}getRevoluteJointMaxAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetUpperLimit())}setRevoluteJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_revoluteJoint)){if(i<t){const s=t;t=i,i=s}o.SetLimits(l.toRad(t),l.toRad(i))}}isRevoluteJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsMotorEnabled()}enableRevoluteJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableMotor(t)}getRevoluteJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetMotorSpeed())}setRevoluteJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMotorSpeed(l.toRad(t))}getRevoluteJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMaxMotorTorque()}setRevoluteJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMaxMotorTorque(t)}getRevoluteJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}addPrismaticJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D,b){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const y=i.getBehavior(this.name).getBody();if(this._body===y)return;const g=this._body,_=new Box2D.b2PrismaticJointDef;if(_.set_bodyA(g),_.set_localAnchorA(g.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),_.set_bodyB(y),_.set_localAnchorB(y.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-g.GetAngle(),_.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),_.set_referenceAngle(l.toRad(a)),_.set_enableLimit(h),c<d){const m=d;d=c,c=m}_.set_lowerTranslation(d<0?d*this._sharedData.worldInvScale:0),_.set_upperTranslation(c>0?c*this._sharedData.worldInvScale:0),_.set_enableMotor(u),_.set_motorSpeed(r*this._sharedData.worldInvScale),_.set_maxMotorForce(f),_.set_collideConnected(D);const J=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(_),Box2D.b2PrismaticJoint));b.setNumber(J)}getPrismaticJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getPrismaticJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(t.GetReferenceAngle())}getPrismaticJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getPrismaticJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointSpeed()*this._sharedData.worldScale}isPrismaticJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsLimitEnabled()}enablePrismaticJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableLimit(t)}getPrismaticJointMinTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetLowerLimit()*this._sharedData.worldScale}getPrismaticJointMaxTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetUpperLimit()*this._sharedData.worldScale}setPrismaticJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_prismaticJoint)){if(i<t){const s=t;t=i,i=s}t=t<0?t:0,i=i>0?i:0,o.SetLimits(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)}}isPrismaticJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsMotorEnabled()}enablePrismaticJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableMotor(t)}getPrismaticJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorSpeed()*this._sharedData.worldScale}setPrismaticJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMotorSpeed(t*this._sharedData.worldInvScale)}getPrismaticJointMaxMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMaxMotorForce()}setPrismaticJointMaxMotorForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMaxMotorForce(t)}getPrismaticJointMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorForce(1/this._sharedData.timeStep)}addPulleyJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody())return;const b=this._body;if(i==null||!i.hasBehavior(this.name))return;const y=i.getBehavior(this.name).getBody();if(this._body===y)return;const g=new Box2D.b2PulleyJointDef;g.set_bodyA(b),g.set_localAnchorA(b.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(y),g.set_localAnchorB(y.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_groundAnchorA(this.b2Vec2(n*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale)),g.set_groundAnchorB(this.b2Vec2(h*this._sharedData.worldInvScale,d*this._sharedData.worldInvScale)),g.set_lengthA(c>0?c*this._sharedData.worldInvScale:this.b2Vec2((n-e)*this._sharedData.worldInvScale,(a-t)*this._sharedData.worldInvScale).Length()),g.set_lengthB(u>0?u*this._sharedData.worldInvScale:this.b2Vec2((h-o)*this._sharedData.worldInvScale,(d-s)*this._sharedData.worldInvScale).Length()),g.set_ratio(r>0?r:1),g.set_collideConnected(f);const _=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2PulleyJoint));D.setNumber(_)}getPulleyJointFirstGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_x()*this._sharedData.worldScale}getPulleyJointFirstGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_y()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_x()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_y()*this._sharedData.worldScale}getPulleyJointFirstLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthA()*this._sharedData.worldScale}getPulleyJointSecondLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthB()*this._sharedData.worldScale}getPulleyJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetRatio()}addGearJoint(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body,a=this._sharedData.getJoint(e);if(a===null||a.GetType()!==Box2D.e_revoluteJoint&&a.GetType()!==Box2D.e_prismaticJoint)return;const h=this._sharedData.getJoint(t);if(h===null||h.GetType()!==Box2D.e_revoluteJoint&&h.GetType()!==Box2D.e_prismaticJoint||a===h)return;const d=new Box2D.b2GearJointDef;d.set_bodyA(this._sharedData.staticBody),d.set_bodyB(n),d.set_joint1(a),d.set_joint2(h),d.set_ratio(i),d.set_collideConnected(o);const c=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(d),Box2D.b2GearJoint));s.setNumber(c)}getGearJointFirstJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint1())}getGearJointSecondJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint2())}getGearJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:t.GetRatio()}setGearJointRatio(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_gearJoint||(i.SetRatio(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addMouseJoint(e,t,i,o,s,n){if(this._body===null&&!this.createBody())return;const a=this._body,h=new Box2D.b2MouseJointDef;h.set_bodyA(this._sharedData.staticBody),h.set_bodyB(a),h.set_target(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale)),h.set_maxForce(i>=0?i:0),h.set_frequencyHz(o>0?o:1),h.set_dampingRatio(s>=0?s:0);const d=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(h),Box2D.b2MouseJoint));n.setNumber(d)}getMouseJointTargetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_x()*this._sharedData.worldScale}getMouseJointTargetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_y()*this._sharedData.worldScale}setMouseJointTarget(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_mouseJoint||(o.SetTarget(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),o.GetBodyB().SetAwake(!0))}getMouseJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetMaxForce()}setMouseJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetMaxForce(t)}getMouseJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetFrequency()}setMouseJointFrequency(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetFrequency(t)}getMouseJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetDampingRatio()}setMouseJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetDampingRatio(t)}addWheelJoint(e,t,i,o,s,n,a,h,d,c,u,r,f){if(this._body===null&&!this.createBody())return;const D=this._body;if(i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const y=new Box2D.b2WheelJointDef;y.set_bodyA(D),y.set_localAnchorA(D.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),y.set_bodyB(b),y.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-D.GetAngle(),y.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),y.set_frequencyHz(a>0?a:1),y.set_dampingRatio(h>=0?h:0),y.set_enableMotor(d),y.set_motorSpeed(l.toRad(c)),y.set_maxMotorTorque(u),y.set_collideConnected(r);const g=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(y),Box2D.b2WheelJoint));f.setNumber(g)}getWheelJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getWheelJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getWheelJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetJointSpeed())}isWheelJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?!1:t.IsMotorEnabled()}enableWheelJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.EnableMotor(t)}getWheelJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetMotorSpeed())}setWheelJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMotorSpeed(l.toRad(t))}getWheelJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMaxMotorTorque()}setWheelJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMaxMotorTorque(t)}getWheelJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}getWheelJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringFrequencyHz()}setWheelJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringFrequencyHz(t)}getWheelJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringDampingRatio()}setWheelJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringDampingRatio(t)}addWeldJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const u=i.getBehavior(this.name).getBody();if(this._body===u)return;const r=this._body,f=new Box2D.b2WeldJointDef;f.set_bodyA(r),f.set_localAnchorA(r.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(u),f.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_referenceAngle(l.toRad(n)),f.set_frequencyHz(a>0?a:1),f.set_dampingRatio(h>=0?h:0),f.set_collideConnected(d);const D=Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2WeldJoint);D.referenceAngle=f.get_referenceAngle(),c.setNumber(this._sharedData.addJoint(D))}getWeldJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:l.toDegrees(t.referenceAngle)}getWeldJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetFrequency()}setWeldJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetFrequency(t)}getWeldJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetDampingRatio()}setWeldJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetDampingRatio(t)}addRopeJoint(e,t,i,o,s,n,a,h){if(this._body===null&&!this.createBody())return;const d=this._body;if(i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=new Box2D.b2RopeJointDef;u.set_bodyA(d),u.set_localAnchorA(d.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),u.set_bodyB(c),u.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),u.set_maxLength(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),u.set_collideConnected(a);const r=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(u),Box2D.b2RopeJoint));h.setNumber(r)}getRopeJointMaxLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_ropeJoint?0:t.GetMaxLength()*this._sharedData.worldScale}setRopeJointMaxLength(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_ropeJoint||(i.SetMaxLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addFrictionJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=this._body,r=new Box2D.b2FrictionJointDef;r.set_bodyA(u),r.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(c),r.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),r.set_maxForce(n>=0?n:0),r.set_maxTorque(a>=0?a:0),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2FrictionJoint));d.setNumber(f)}getFrictionJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxForce()}setFrictionJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxForce(t)}getFrictionJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxTorque()}setFrictionJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxTorque(t)}addMotorJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody())return;const c=this._body;if(e==null||!e.hasBehavior(this.name))return;const u=e.getBehavior(this.name).getBody();if(this._body===u)return;const r=new Box2D.b2MotorJointDef;r.set_bodyA(c),r.set_bodyB(u),r.set_linearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),r.set_angularOffset(l.toRad(o)),r.set_maxForce(s>=0?s:0),r.set_maxTorque(n>=0?n:0),r.set_correctionFactor(a<0?0:a>1?1:a),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2MotorJoint));d.setNumber(f)}getMotorJointOffsetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_x()*this._sharedData.worldScale}getMotorJointOffsetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_y()*this._sharedData.worldScale}setMotorJointOffset(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_motorJoint||o.SetLinearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale))}getMotorJointAngularOffset(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:l.toDegrees(t.GetAngularOffset())}setMotorJointAngularOffset(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetAngularOffset(l.toRad(t))}getMotorJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxForce()}setMotorJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetMaxForce(t)}getMotorJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxTorque()}setMotorJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetMaxTorque(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getMotorJointCorrectionFactor(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetCorrectionFactor()}setMotorJointCorrectionFactor(e,t){if(t<0||t>1)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetCorrectionFactor(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}onContactBegin(e){this.currentContacts.push(e);let t=this.contactsEndedThisFrame.indexOf(e);t!==-1?this.contactsEndedThisFrame.splice(t,1):this.contactsStartedThisFrame.push(e)}onContactEnd(e){this.contactsEndedThisFrame.push(e);const t=this.currentContacts.indexOf(e);t!==-1&&this.currentContacts.splice(t,1)}static areObjectsColliding(e,t,i){const o=e.getBehavior(i);return o?!!(o.currentContacts.some(s=>s.owner===t)||o.contactsStartedThisFrame.some(s=>s.owner===t)):!1}static hasCollisionStartedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsStartedThisFrame.some(s=>s.owner===t):!1}static hasCollisionStoppedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsEndedThisFrame.some(s=>s.owner===t):!1}};let p=B;p.collisionTest=B.areObjectsColliding,l.Physics2RuntimeBehavior=p,l.registerBehavior("Physics2::Physics2Behavior",l.Physics2RuntimeBehavior)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=physics2runtimebehavior.js.map