gdcore-tools 2.0.0-gd-v5.5.230-autobuild → 2.0.0-gd-v5.5.232-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.
Files changed (61) hide show
  1. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  2. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject2D.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject2D.js.map +2 -2
  5. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
  6. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  8. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js +1 -1
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/JsExtension.js +6 -2
  12. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
  13. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
  14. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  15. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  16. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  17. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  18. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js +1 -1
  19. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
  20. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  21. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  22. package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +1047 -3
  23. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  24. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  25. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +2 -0
  26. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +7 -0
  27. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  28. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  29. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.d.ts +94 -9
  30. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js +1 -1
  31. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js.map +2 -2
  32. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.wasm +0 -0
  33. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  34. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  35. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
  36. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  37. package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +1 -1
  38. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
  39. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
  40. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  41. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  42. package/dist/Runtime/debugger-client/hot-reloader.js +3 -2
  43. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  44. package/dist/Runtime/events-tools/cameratools.js +1 -1
  45. package/dist/Runtime/events-tools/cameratools.js.map +2 -2
  46. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  47. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  48. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
  49. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  50. package/dist/Runtime/runtimeobject.js +1 -1
  51. package/dist/Runtime/runtimeobject.js.map +2 -2
  52. package/dist/Runtime/runtimescene.js +1 -1
  53. package/dist/Runtime/runtimescene.js.map +2 -2
  54. package/dist/Runtime/spriteruntimeobject.js +1 -1
  55. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  56. package/dist/Runtime/types/project-data.d.ts +1 -1
  57. package/dist/lib/libGD.cjs +1 -1
  58. package/dist/lib/libGD.wasm +0 -0
  59. package/dist/loaders.cjs +3 -3
  60. package/gd.d.ts +7 -0
  61. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- var gdjs;(function(l){class p extends l.RuntimeBehavior{constructor(t,e,d){super(t,e,d);this._angle=0;this._xVelocity=0;this._yVelocity=0;this._angularSpeed=0;this._leftKey=!1;this._rightKey=!1;this._upKey=!1;this._downKey=!1;this._leftKeyPressedDuration=0;this._rightKeyPressedDuration=0;this._upKeyPressedDuration=0;this._downKeyPressedDuration=0;this._wasStickUsed=!1;this._stickAngle=0;this._stickForce=0;this._dontClearInputsBetweenFrames=!1;this._ignoreDefaultControlsAsSyncedByNetwork=!1;this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasUpKeyPressed=!1;this._wasDownKeyPressed=!1;this._temporaryPointForTransformations=[0,0];this._topDownMovementHooks=[];this._allowDiagonals=e.allowDiagonals,this._acceleration=e.acceleration,this._deceleration=e.deceleration,this._maxSpeed=e.maxSpeed,this._angularMaxSpeed=e.angularMaxSpeed,this._rotateObject=e.rotateObject,this._angleOffset=e.angleOffset,this._ignoreDefaultControls=e.ignoreDefaultControls,this.setViewpoint(e.viewpoint,e.customIsometryAngle),this._movementAngleOffset=e.movementAngleOffset||0}getNetworkSyncData(){return this._dontClearInputsBetweenFrames=!1,this._ignoreDefaultControlsAsSyncedByNetwork=!1,{...super.getNetworkSyncData(),props:{a:this._angle,xv:this._xVelocity,yv:this._yVelocity,as:this._angularSpeed,lk:this._wasLeftKeyPressed,rk:this._wasRightKeyPressed,uk:this._wasUpKeyPressed,dk:this._wasDownKeyPressed,wsu:this._wasStickUsed,sa:this._stickAngle,sf:this._stickForce}}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t);const e=t.props;e.a!==void 0&&(this._angle=e.a),e.xv!==void 0&&(this._xVelocity=e.xv),e.yv!==void 0&&(this._yVelocity=e.yv),e.as!==void 0&&(this._angularSpeed=e.as),e.lk!==void 0&&(this._leftKey=e.lk),e.rk!==void 0&&(this._rightKey=e.rk),e.uk!==void 0&&(this._upKey=e.uk),e.dk!==void 0&&(this._downKey=e.dk),e.wsu!==void 0&&(this._wasStickUsed=e.wsu),e.sa!==void 0&&(this._stickAngle=e.sa),e.sf!==void 0&&(this._stickForce=e.sf),this._dontClearInputsBetweenFrames=!0,this._ignoreDefaultControlsAsSyncedByNetwork=!0}updateFromBehaviorData(t,e){return t.allowDiagonals!==e.allowDiagonals&&(this._allowDiagonals=e.allowDiagonals),t.acceleration!==e.acceleration&&(this._acceleration=e.acceleration),t.deceleration!==e.deceleration&&(this._deceleration=e.deceleration),t.maxSpeed!==e.maxSpeed&&(this._maxSpeed=e.maxSpeed),t.angularMaxSpeed!==e.angularMaxSpeed&&(this._angularMaxSpeed=e.angularMaxSpeed),t.rotateObject!==e.rotateObject&&(this._rotateObject=e.rotateObject),t.angleOffset!==e.angleOffset&&(this._angleOffset=e.angleOffset),t.ignoreDefaultControls!==e.ignoreDefaultControls&&(this._ignoreDefaultControls=e.ignoreDefaultControls),(t.platformType!==e.platformType||t.customIsometryAngle!==e.customIsometryAngle)&&this.setViewpoint(e.platformType,e.customIsometryAngle),t.movementAngleOffset!==e.movementAngleOffset&&(this._movementAngleOffset=e.movementAngleOffset),!0}setViewpoint(t,e){t==="PixelIsometry"?this._basisTransformation=new l.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.atan(.5)):t==="TrueIsometry"?this._basisTransformation=new l.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.PI/6):t==="CustomIsometry"?this._basisTransformation=new l.TopDownMovementRuntimeBehavior.IsometryTransformation(e*Math.PI/180):this._basisTransformation=null}setAcceleration(t){this._acceleration=t}getAcceleration(){return this._acceleration}setDeceleration(t){this._deceleration=t}getDeceleration(){return this._deceleration}setMaxSpeed(t){this._maxSpeed=t}getMaxSpeed(){return this._maxSpeed}setAngularMaxSpeed(t){this._angularMaxSpeed=t}getAngularMaxSpeed(){return this._angularMaxSpeed}setAngleOffset(t){this._angleOffset=t}getAngleOffset(){return this._angleOffset}allowDiagonals(t){this._allowDiagonals=t}diagonalsAllowed(){return this._allowDiagonals}setRotateObject(t){this._rotateObject=t}isObjectRotated(){return this._rotateObject}isMoving(){return this._xVelocity!==0||this._yVelocity!==0}getSpeed(){return Math.sqrt(this._xVelocity*this._xVelocity+this._yVelocity*this._yVelocity)}getXVelocity(){return this._xVelocity}setXVelocity(t){this._xVelocity=t}getYVelocity(){return this._yVelocity}setYVelocity(t){this._yVelocity=t}getAngle(){return this._angle}isMovementAngleAround(t,e){return Math.abs(l.evtTools.common.angleDifference(this._angle,t))<=e}setMovementAngleOffset(t){this._movementAngleOffset=t}getMovementAngleOffset(){return this._movementAngleOffset}doStepPreEvents(t){const e=37,d=38,u=39,r=40;this._leftKey||(this._leftKey=!this.shouldIgnoreDefaultControls()&&t.getGame().getInputManager().isKeyPressed(e)),this._rightKey||(this._rightKey=!this.shouldIgnoreDefaultControls()&&t.getGame().getInputManager().isKeyPressed(u)),this._downKey||(this._downKey=!this.shouldIgnoreDefaultControls()&&t.getGame().getInputManager().isKeyPressed(r)),this._upKey||(this._upKey=!this.shouldIgnoreDefaultControls()&&t.getGame().getInputManager().isKeyPressed(d));const _=this.owner.getElapsedTime();this._leftKey?this._leftKeyPressedDuration+=_:this._leftKeyPressedDuration=0,this._rightKey?this._rightKeyPressedDuration+=_:this._rightKeyPressedDuration=0,this._downKey?this._downKeyPressedDuration+=_:this._downKeyPressedDuration=0,this._upKey?this._upKeyPressedDuration+=_:this._upKeyPressedDuration=0;let s=-1;this._allowDiagonals?this._upKey&&!this._downKey?this._leftKey&&!this._rightKey?s=5:!this._leftKey&&this._rightKey?s=7:s=6:!this._upKey&&this._downKey?this._leftKey&&!this._rightKey?s=3:!this._leftKey&&this._rightKey?s=1:s=2:this._leftKey&&!this._rightKey?s=4:!this._leftKey&&this._rightKey&&(s=0):(this._upKey&&!this._downKey?s=6:!this._upKey&&this._downKey&&(s=2),this._leftKey&&!this._rightKey&&(this._upKey===this._downKey||this._upKey&&this._leftKeyPressedDuration<this._upKeyPressedDuration||this._downKey&&this._leftKeyPressedDuration<this._downKeyPressedDuration)?s=4:this._rightKey&&!this._leftKey&&(this._upKey===this._downKey||this._upKey&&this._rightKeyPressedDuration<this._upKeyPressedDuration||this._downKey&&this._rightKeyPressedDuration<this._downKeyPressedDuration)&&(s=0));const h=l.TopDownMovementRuntimeBehavior._topDownMovementHookContext;for(const o of this._topDownMovementHooks)h._setDirection(s),s=o.overrideDirection(h);h._setDirection(s);for(const o of this._topDownMovementHooks)o.beforeSpeedUpdate(h);const a=this.owner,y=this.owner.getElapsedTime()/1e3,w=this._xVelocity,v=this._yVelocity;this._wasStickUsed=!1;let f=0,c=0,i=1,n=0;if(s!==-1)f=(s+this._movementAngleOffset/45)*Math.PI/4,c=s*45+this._movementAngleOffset,i=Math.cos(f),n=Math.sin(f),(i===-1||i===1)&&(n=0),(n===-1||n===1)&&(i=0),this._xVelocity+=this._acceleration*y*i,this._yVelocity+=this._acceleration*y*n;else if(this._stickForce!==0){this._allowDiagonals||(this._stickAngle=90*Math.floor((this._stickAngle+45)/90)),c=this._stickAngle+this._movementAngleOffset,f=c*Math.PI/180;const o=this._acceleration*y*this._stickForce;i=Math.cos(f),n=Math.sin(f),(i===-1||i===1)&&(n=0),(n===-1||n===1)&&(i=0),this._xVelocity+=o*i,this._yVelocity+=o*n,this._wasStickUsed=!0,this._stickForce=0}else if(this._yVelocity!==0||this._xVelocity!==0){f=Math.atan2(this._yVelocity,this._xVelocity),c=f*180/Math.PI;const o=this._xVelocity>=0,M=this._yVelocity>=0;i=Math.cos(f),n=Math.sin(f),(i===-1||i===1)&&(n=0),(n===-1||n===1)&&(i=0),this._xVelocity-=this._deceleration*y*i,this._yVelocity-=this._deceleration*y*n,this._xVelocity>0!==o&&(this._xVelocity=0),this._yVelocity>0!==M&&(this._yVelocity=0)}this._xVelocity*this._xVelocity+this._yVelocity*this._yVelocity>this._maxSpeed*this._maxSpeed&&(this._xVelocity=this._maxSpeed*i,this._yVelocity=this._maxSpeed*n),this._angularSpeed=this._angularMaxSpeed;for(const o of this._topDownMovementHooks)o.beforePositionUpdate(h);const g=(w+this._xVelocity)/2*y,m=(v+this._yVelocity)/2*y;if(this._basisTransformation===null)a.setX(a.getX()+g),a.setY(a.getY()+m);else{const o=this._temporaryPointForTransformations;o[0]=g,o[1]=m,this._basisTransformation.toScreen(o,o),a.setX(a.getX()+o[0]),a.setY(a.getY()+o[1])}(this._xVelocity!==0||this._yVelocity!==0)&&(this._angle=c,this._rotateObject&&a.rotateTowardAngle(c+this._angleOffset,this._angularSpeed)),this._wasLeftKeyPressed=this._leftKey,this._wasRightKeyPressed=this._rightKey,this._wasUpKeyPressed=this._upKey,this._wasDownKeyPressed=this._downKey,this._dontClearInputsBetweenFrames||(this._leftKey=!1,this._rightKey=!1,this._upKey=!1,this._downKey=!1)}simulateControl(t){t==="Left"?this._leftKey=!0:t==="Right"?this._rightKey=!0:t==="Up"?this._upKey=!0:t==="Down"&&(this._downKey=!0)}ignoreDefaultControls(t){this._ignoreDefaultControls=t}shouldIgnoreDefaultControls(){return this._ignoreDefaultControls||this._ignoreDefaultControlsAsSyncedByNetwork}simulateLeftKey(){this._leftKey=!0}simulateRightKey(){this._rightKey=!0}simulateUpKey(){this._upKey=!0}simulateDownKey(){this._downKey=!0}simulateStick(t,e){this._stickAngle=t%360,this._stickForce=Math.max(0,Math.min(1,e))}isUsingControl(t){return t==="Left"?this._leftKeyPressedDuration>0:t==="Right"?this._rightKeyPressedDuration>0:t==="Up"?this._upKeyPressedDuration>0:t==="Down"?this._downKeyPressedDuration>0:t==="Stick"?this._wasStickUsed:!1}getLastStickInputAngle(){return this._stickAngle}registerHook(t){this._topDownMovementHooks.push(t)}}l.TopDownMovementRuntimeBehavior=p,function(d){class K{constructor(){this.direction=-1}getDirection(){return this.direction}_setDirection(r){this.direction=r}}d.TopDownMovementHookContext=K,d._topDownMovementHookContext=new l.TopDownMovementRuntimeBehavior.TopDownMovementHookContext;class e{constructor(r){if(r<=0||r>=Math.PI/4)throw new RangeError("An isometry angle must be in ]0; pi/4] but was: "+r);const _=Math.asin(Math.tan(r)),s=Math.sin(_),h=Math.cos(Math.PI/4),a=h;this._screen=[[h,-a],[s*a,s*h]]}toScreen(r,_){const s=this._screen[0][0]*r[0]+this._screen[0][1]*r[1],h=this._screen[1][0]*r[0]+this._screen[1][1]*r[1];_[0]=s,_[1]=h}}d.IsometryTransformation=e}(p=l.TopDownMovementRuntimeBehavior||(l.TopDownMovementRuntimeBehavior={})),l.registerBehavior("TopDownMovementBehavior::TopDownMovementBehavior",l.TopDownMovementRuntimeBehavior)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(r){class c extends r.RuntimeBehavior{constructor(e,t,f){super(e,t,f);this._angle=0;this._xVelocity=0;this._yVelocity=0;this._angularSpeed=0;this._leftKey=!1;this._rightKey=!1;this._upKey=!1;this._downKey=!1;this._leftKeyPressedDuration=0;this._rightKeyPressedDuration=0;this._upKeyPressedDuration=0;this._downKeyPressedDuration=0;this._wasStickUsed=!1;this._stickAngle=0;this._stickForce=0;this._dontClearInputsBetweenFrames=!1;this._ignoreDefaultControlsAsSyncedByNetwork=!1;this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasUpKeyPressed=!1;this._wasDownKeyPressed=!1;this._temporaryPointForTransformations=[0,0];this._topDownMovementHooks=[];this._allowDiagonals=t.allowDiagonals,this._acceleration=t.acceleration,this._deceleration=t.deceleration,this._maxSpeed=t.maxSpeed,this._angularMaxSpeed=t.angularMaxSpeed,this._rotateObject=t.rotateObject,this._angleOffset=t.angleOffset,this._ignoreDefaultControls=t.ignoreDefaultControls,this.setViewpoint(t.viewpoint,t.customIsometryAngle),this._movementAngleOffset=t.movementAngleOffset||0,this._useLegacyTurnBack=t.useLegacyTurnBack===void 0?!0:t.useLegacyTurnBack}getNetworkSyncData(){return this._dontClearInputsBetweenFrames=!1,this._ignoreDefaultControlsAsSyncedByNetwork=!1,{...super.getNetworkSyncData(),props:{a:this._angle,xv:this._xVelocity,yv:this._yVelocity,as:this._angularSpeed,lk:this._wasLeftKeyPressed,rk:this._wasRightKeyPressed,uk:this._wasUpKeyPressed,dk:this._wasDownKeyPressed,wsu:this._wasStickUsed,sa:this._stickAngle,sf:this._stickForce}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.a!==void 0&&(this._angle=t.a),t.xv!==void 0&&(this._xVelocity=t.xv),t.yv!==void 0&&(this._yVelocity=t.yv),t.as!==void 0&&(this._angularSpeed=t.as),t.lk!==void 0&&(this._leftKey=t.lk),t.rk!==void 0&&(this._rightKey=t.rk),t.uk!==void 0&&(this._upKey=t.uk),t.dk!==void 0&&(this._downKey=t.dk),t.wsu!==void 0&&(this._wasStickUsed=t.wsu),t.sa!==void 0&&(this._stickAngle=t.sa),t.sf!==void 0&&(this._stickForce=t.sf),this._dontClearInputsBetweenFrames=!0,this._ignoreDefaultControlsAsSyncedByNetwork=!0}updateFromBehaviorData(e,t){return e.allowDiagonals!==t.allowDiagonals&&(this._allowDiagonals=t.allowDiagonals),e.acceleration!==t.acceleration&&(this._acceleration=t.acceleration),e.deceleration!==t.deceleration&&(this._deceleration=t.deceleration),e.maxSpeed!==t.maxSpeed&&(this._maxSpeed=t.maxSpeed),e.angularMaxSpeed!==t.angularMaxSpeed&&(this._angularMaxSpeed=t.angularMaxSpeed),e.rotateObject!==t.rotateObject&&(this._rotateObject=t.rotateObject),e.angleOffset!==t.angleOffset&&(this._angleOffset=t.angleOffset),e.ignoreDefaultControls!==t.ignoreDefaultControls&&(this._ignoreDefaultControls=t.ignoreDefaultControls),(e.platformType!==t.platformType||e.customIsometryAngle!==t.customIsometryAngle)&&this.setViewpoint(t.platformType,t.customIsometryAngle),e.movementAngleOffset!==t.movementAngleOffset&&(this._movementAngleOffset=t.movementAngleOffset),!0}setViewpoint(e,t){e==="PixelIsometry"?this._basisTransformation=new r.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.atan(.5)):e==="TrueIsometry"?this._basisTransformation=new r.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.PI/6):e==="CustomIsometry"?this._basisTransformation=new r.TopDownMovementRuntimeBehavior.IsometryTransformation(t*Math.PI/180):this._basisTransformation=null}setAcceleration(e){this._acceleration=e}getAcceleration(){return this._acceleration}setDeceleration(e){this._deceleration=e}getDeceleration(){return this._deceleration}setMaxSpeed(e){this._maxSpeed=e}getMaxSpeed(){return this._maxSpeed}setAngularMaxSpeed(e){this._angularMaxSpeed=e}getAngularMaxSpeed(){return this._angularMaxSpeed}setAngleOffset(e){this._angleOffset=e}getAngleOffset(){return this._angleOffset}allowDiagonals(e){this._allowDiagonals=e}diagonalsAllowed(){return this._allowDiagonals}setRotateObject(e){this._rotateObject=e}isObjectRotated(){return this._rotateObject}isMoving(){return this._xVelocity!==0||this._yVelocity!==0}getSpeed(){return Math.hypot(this._xVelocity,this._yVelocity)}getXVelocity(){return this._xVelocity}setXVelocity(e){this._xVelocity=e}getYVelocity(){return this._yVelocity}setYVelocity(e){this._yVelocity=e}getAngle(){return this._angle}isMovementAngleAround(e,t){return Math.abs(r.evtTools.common.angleDifference(this._angle,e))<=t}setMovementAngleOffset(e){this._movementAngleOffset=e}getMovementAngleOffset(){return this._movementAngleOffset}doStepPreEvents(e){const t=37,f=38,h=39,i=40;this._leftKey||(this._leftKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(t)),this._rightKey||(this._rightKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(h)),this._downKey||(this._downKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(i)),this._upKey||(this._upKey=!this.shouldIgnoreDefaultControls()&&e.getGame().getInputManager().isKeyPressed(f));const o=this.owner.getElapsedTime();this._leftKey?this._leftKeyPressedDuration+=o:this._leftKeyPressedDuration=0,this._rightKey?this._rightKeyPressedDuration+=o:this._rightKeyPressedDuration=0,this._downKey?this._downKeyPressedDuration+=o:this._downKeyPressedDuration=0,this._upKey?this._upKeyPressedDuration+=o:this._upKeyPressedDuration=0;let s=-1;this._allowDiagonals?this._upKey&&!this._downKey?this._leftKey&&!this._rightKey?s=5:!this._leftKey&&this._rightKey?s=7:s=6:!this._upKey&&this._downKey?this._leftKey&&!this._rightKey?s=3:!this._leftKey&&this._rightKey?s=1:s=2:this._leftKey&&!this._rightKey?s=4:!this._leftKey&&this._rightKey&&(s=0):(this._upKey&&!this._downKey?s=6:!this._upKey&&this._downKey&&(s=2),this._leftKey&&!this._rightKey&&(this._upKey===this._downKey||this._upKey&&this._leftKeyPressedDuration<this._upKeyPressedDuration||this._downKey&&this._leftKeyPressedDuration<this._downKeyPressedDuration)?s=4:this._rightKey&&!this._leftKey&&(this._upKey===this._downKey||this._upKey&&this._rightKeyPressedDuration<this._upKeyPressedDuration||this._downKey&&this._rightKeyPressedDuration<this._downKeyPressedDuration)&&(s=0));const a=r.TopDownMovementRuntimeBehavior._topDownMovementHookContext;for(const n of this._topDownMovementHooks)a._setDirection(s),s=n.overrideDirection(a);a._setDirection(s);for(const n of this._topDownMovementHooks)n.beforeSpeedUpdate(a);const l=this.owner,p=this.owner.getElapsedTime()/1e3,x=this._xVelocity,P=this._yVelocity;this._wasStickUsed=!1;let _=0,y=0,g=!1,m=0;if(s!==-1?(g=!0,_=(s+this._movementAngleOffset/45)*Math.PI/4,y=s*45+this._movementAngleOffset,m=this._maxSpeed):this._stickForce!==0?(g=!0,this._allowDiagonals||(this._stickAngle=90*Math.floor((this._stickAngle+45)/90)),y=this._stickAngle+this._movementAngleOffset,_=y*Math.PI/180,m=this._maxSpeed*this._stickForce,this._wasStickUsed=!0):(this._yVelocity!==0||this._xVelocity!==0)&&(g=!0,_=Math.atan2(this._yVelocity,this._xVelocity),y=_*180/Math.PI),g){let n=Math.cos(_),u=Math.sin(_);(n===-1||n===1)&&(u=0),(u===-1||u===1)&&(n=0);const D=this._useLegacyTurnBack?c.getLegacyAcceleratedSpeed:c.getAcceleratedSpeed;let M=Math.hypot(this._xVelocity,this._yVelocity);const v=this._xVelocity*n+this._yVelocity*u;v<0&&(M=v);const k=D(M,m,this._maxSpeed,this._acceleration,this._deceleration,p);this._xVelocity=k*n,this._yVelocity=k*u}const d=this._xVelocity*this._xVelocity+this._yVelocity*this._yVelocity;if(d>this._maxSpeed*this._maxSpeed){const n=this._maxSpeed/Math.sqrt(d);this._xVelocity*=n,this._yVelocity*=n}this._angularSpeed=this._angularMaxSpeed;for(const n of this._topDownMovementHooks)n.beforePositionUpdate(a);const K=(x+this._xVelocity)/2*p,w=(P+this._yVelocity)/2*p;if(this._basisTransformation===null)l.setX(l.getX()+K),l.setY(l.getY()+w);else{const n=this._temporaryPointForTransformations;n[0]=K,n[1]=w,this._basisTransformation.toScreen(n,n),l.setX(l.getX()+n[0]),l.setY(l.getY()+n[1])}(this._xVelocity!==0||this._yVelocity!==0)&&(this._angle=y,this._rotateObject&&l.rotateTowardAngle(y+this._angleOffset,this._angularSpeed)),this._wasLeftKeyPressed=this._leftKey,this._wasRightKeyPressed=this._rightKey,this._wasUpKeyPressed=this._upKey,this._wasDownKeyPressed=this._downKey,this._dontClearInputsBetweenFrames||(this._leftKey=!1,this._rightKey=!1,this._upKey=!1,this._downKey=!1,this._stickForce=0)}static getAcceleratedSpeed(e,t,f,h,i,o){let s=e;const a=Math.max(h,i);return t<0?e<=t?s=Math.min(t,e+a*o):e<=0?s-=Math.max(-f,h*o):s=Math.max(t,e-a*o):t>0?e>=t?s=Math.max(t,e-a*o):e>=0?s=Math.min(f,e+h*o):s=Math.min(t,e+a*o):(e<0&&(s=Math.min(e+i*o,0)),e>0&&(s=Math.max(e-i*o,0))),s}static getLegacyAcceleratedSpeed(e,t,f,h,i,o){let s=e;return t<0?e<=t?s=Math.min(t,e+i*o):e<=0?s-=Math.max(-f,h*o):s=Math.max(t,e-i*o):t>0?e>=t?s=Math.max(t,e-i*o):e>=0?s=Math.min(f,e+h*o):s=Math.min(t,e+i*o):(e<0&&(s=Math.min(e+i*o,0)),e>0&&(s=Math.max(e-i*o,0))),s}simulateControl(e){e==="Left"?this._leftKey=!0:e==="Right"?this._rightKey=!0:e==="Up"?this._upKey=!0:e==="Down"&&(this._downKey=!0)}ignoreDefaultControls(e){this._ignoreDefaultControls=e}shouldIgnoreDefaultControls(){return this._ignoreDefaultControls||this._ignoreDefaultControlsAsSyncedByNetwork}simulateLeftKey(){this._leftKey=!0}simulateRightKey(){this._rightKey=!0}simulateUpKey(){this._upKey=!0}simulateDownKey(){this._downKey=!0}simulateStick(e,t){this._stickAngle=e%360,this._stickForce=Math.max(0,Math.min(1,t))}isUsingControl(e){return e==="Left"?this._leftKeyPressedDuration>0:e==="Right"?this._rightKeyPressedDuration>0:e==="Up"?this._upKeyPressedDuration>0:e==="Down"?this._downKeyPressedDuration>0:e==="Stick"?this._wasStickUsed:!1}getLastStickInputAngle(){return this._stickAngle}registerHook(e){this._topDownMovementHooks.push(e)}}r.TopDownMovementRuntimeBehavior=c,function(f){class T{constructor(){this.direction=-1}getDirection(){return this.direction}_setDirection(i){this.direction=i}}f.TopDownMovementHookContext=T,f._topDownMovementHookContext=new r.TopDownMovementRuntimeBehavior.TopDownMovementHookContext;class t{constructor(i){if(i<=0||i>=Math.PI/4)throw new RangeError("An isometry angle must be in ]0; pi/4] but was: "+i);const o=Math.asin(Math.tan(i)),s=Math.sin(o),a=Math.cos(Math.PI/4),l=a;this._screen=[[a,-l],[s*l,s*a]]}toScreen(i,o){const s=this._screen[0][0]*i[0]+this._screen[0][1]*i[1],a=this._screen[1][0]*i[0]+this._screen[1][1]*i[1];o[0]=s,o[1]=a}}f.IsometryTransformation=t}(c=r.TopDownMovementRuntimeBehavior||(r.TopDownMovementRuntimeBehavior={})),r.registerBehavior("TopDownMovementBehavior::TopDownMovementBehavior",r.TopDownMovementRuntimeBehavior)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=topdownmovementruntimebehavior.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.ts"],
4
- "sourcesContent": ["/*\nGDevelop - Top-down movement Behavior Extension\nCopyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n interface TopDownMovementNetworkSyncDataType {\n a: float;\n xv: float;\n yv: float;\n as: float;\n lk: boolean;\n rk: boolean;\n uk: boolean;\n dk: boolean;\n wsu: boolean;\n sa: float;\n sf: float;\n }\n\n export interface TopDownMovementNetworkSyncData\n extends BehaviorNetworkSyncData {\n props: TopDownMovementNetworkSyncDataType;\n }\n /**\n * Allows an object to move in 4 or 8 directions, with customizable speed, accelerations\n * and rotation.\n */\n export class TopDownMovementRuntimeBehavior extends gdjs.RuntimeBehavior {\n //Behavior configuration:\n private _allowDiagonals: boolean;\n private _acceleration: float;\n private _deceleration: float;\n private _maxSpeed: float;\n private _angularMaxSpeed: float;\n private _rotateObject: boolean;\n private _angleOffset: float;\n private _ignoreDefaultControls: boolean;\n private _movementAngleOffset: float;\n\n /** The latest angle of movement, in degrees. */\n private _angle: float = 0;\n\n //Attributes used when moving\n private _xVelocity: float = 0;\n private _yVelocity: float = 0;\n private _angularSpeed: float = 0;\n\n // Inputs\n private _leftKey: boolean = false;\n private _rightKey: boolean = false;\n private _upKey: boolean = false;\n private _downKey: boolean = false;\n private _leftKeyPressedDuration: float = 0;\n private _rightKeyPressedDuration: float = 0;\n private _upKeyPressedDuration: float = 0;\n private _downKeyPressedDuration: float = 0;\n private _wasStickUsed: boolean = false;\n private _stickAngle: float = 0;\n private _stickForce: float = 0;\n\n // This is useful when the object is synchronized by an external source\n // like in a multiplayer game, and we want to be able to predict the\n // movement of the object, even if the inputs are not updated every frame.\n _dontClearInputsBetweenFrames: boolean = false;\n // This is useful when the object is synchronized over the network,\n // object is controlled by the network and we want to ensure the current player\n // cannot control it.\n _ignoreDefaultControlsAsSyncedByNetwork: boolean = false;\n\n // This is useful for extensions that need to know\n // which keys were pressed and doesn't know the mapping\n // done by the scene events.\n private _wasLeftKeyPressed: boolean = false;\n private _wasRightKeyPressed: boolean = false;\n private _wasUpKeyPressed: boolean = false;\n private _wasDownKeyPressed: boolean = false;\n\n // @ts-ignore The setter \"setViewpoint\" is not detected as an affectation.\n private _basisTransformation: gdjs.TopDownMovementRuntimeBehavior.BasisTransformation | null;\n private _temporaryPointForTransformations: FloatPoint = [0, 0];\n\n private _topDownMovementHooks: Array<gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook> =\n [];\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._allowDiagonals = behaviorData.allowDiagonals;\n this._acceleration = behaviorData.acceleration;\n this._deceleration = behaviorData.deceleration;\n this._maxSpeed = behaviorData.maxSpeed;\n this._angularMaxSpeed = behaviorData.angularMaxSpeed;\n this._rotateObject = behaviorData.rotateObject;\n this._angleOffset = behaviorData.angleOffset;\n this._ignoreDefaultControls = behaviorData.ignoreDefaultControls;\n this.setViewpoint(\n behaviorData.viewpoint,\n behaviorData.customIsometryAngle\n );\n this._movementAngleOffset = behaviorData.movementAngleOffset || 0;\n }\n\n getNetworkSyncData(): TopDownMovementNetworkSyncData {\n // This method is called, so we are synchronizing this object.\n // Let's clear the inputs between frames as we control it.\n this._dontClearInputsBetweenFrames = false;\n this._ignoreDefaultControlsAsSyncedByNetwork = false;\n\n return {\n ...super.getNetworkSyncData(),\n props: {\n a: this._angle,\n xv: this._xVelocity,\n yv: this._yVelocity,\n as: this._angularSpeed,\n lk: this._wasLeftKeyPressed,\n rk: this._wasRightKeyPressed,\n uk: this._wasUpKeyPressed,\n dk: this._wasDownKeyPressed,\n wsu: this._wasStickUsed,\n sa: this._stickAngle,\n sf: this._stickForce,\n },\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TopDownMovementNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n if (behaviorSpecificProps.a !== undefined) {\n this._angle = behaviorSpecificProps.a;\n }\n if (behaviorSpecificProps.xv !== undefined) {\n this._xVelocity = behaviorSpecificProps.xv;\n }\n if (behaviorSpecificProps.yv !== undefined) {\n this._yVelocity = behaviorSpecificProps.yv;\n }\n if (behaviorSpecificProps.as !== undefined) {\n this._angularSpeed = behaviorSpecificProps.as;\n }\n if (behaviorSpecificProps.lk !== undefined) {\n this._leftKey = behaviorSpecificProps.lk;\n }\n if (behaviorSpecificProps.rk !== undefined) {\n this._rightKey = behaviorSpecificProps.rk;\n }\n if (behaviorSpecificProps.uk !== undefined) {\n this._upKey = behaviorSpecificProps.uk;\n }\n if (behaviorSpecificProps.dk !== undefined) {\n this._downKey = behaviorSpecificProps.dk;\n }\n if (behaviorSpecificProps.wsu !== undefined) {\n this._wasStickUsed = behaviorSpecificProps.wsu;\n }\n if (behaviorSpecificProps.sa !== undefined) {\n this._stickAngle = behaviorSpecificProps.sa;\n }\n if (behaviorSpecificProps.sf !== undefined) {\n this._stickForce = behaviorSpecificProps.sf;\n }\n\n // When the object is synchronized from the network, the inputs must not be cleared.\n this._dontClearInputsBetweenFrames = true;\n // And we are not using the default controls.\n this._ignoreDefaultControlsAsSyncedByNetwork = true;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.allowDiagonals !== newBehaviorData.allowDiagonals) {\n this._allowDiagonals = newBehaviorData.allowDiagonals;\n }\n if (oldBehaviorData.acceleration !== newBehaviorData.acceleration) {\n this._acceleration = newBehaviorData.acceleration;\n }\n if (oldBehaviorData.deceleration !== newBehaviorData.deceleration) {\n this._deceleration = newBehaviorData.deceleration;\n }\n if (oldBehaviorData.maxSpeed !== newBehaviorData.maxSpeed) {\n this._maxSpeed = newBehaviorData.maxSpeed;\n }\n if (oldBehaviorData.angularMaxSpeed !== newBehaviorData.angularMaxSpeed) {\n this._angularMaxSpeed = newBehaviorData.angularMaxSpeed;\n }\n if (oldBehaviorData.rotateObject !== newBehaviorData.rotateObject) {\n this._rotateObject = newBehaviorData.rotateObject;\n }\n if (oldBehaviorData.angleOffset !== newBehaviorData.angleOffset) {\n this._angleOffset = newBehaviorData.angleOffset;\n }\n if (\n oldBehaviorData.ignoreDefaultControls !==\n newBehaviorData.ignoreDefaultControls\n ) {\n this._ignoreDefaultControls = newBehaviorData.ignoreDefaultControls;\n }\n if (\n oldBehaviorData.platformType !== newBehaviorData.platformType ||\n oldBehaviorData.customIsometryAngle !==\n newBehaviorData.customIsometryAngle\n ) {\n this.setViewpoint(\n newBehaviorData.platformType,\n newBehaviorData.customIsometryAngle\n );\n }\n if (\n oldBehaviorData.movementAngleOffset !==\n newBehaviorData.movementAngleOffset\n ) {\n this._movementAngleOffset = newBehaviorData.movementAngleOffset;\n }\n return true;\n }\n\n setViewpoint(viewpoint: string, customIsometryAngle: float): void {\n if (viewpoint === 'PixelIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n Math.atan(0.5)\n );\n } else if (viewpoint === 'TrueIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n Math.PI / 6\n );\n } else if (viewpoint === 'CustomIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n (customIsometryAngle * Math.PI) / 180\n );\n } else {\n this._basisTransformation = null;\n }\n }\n\n setAcceleration(acceleration: float): void {\n this._acceleration = acceleration;\n }\n\n getAcceleration() {\n return this._acceleration;\n }\n\n setDeceleration(deceleration: float): void {\n this._deceleration = deceleration;\n }\n\n getDeceleration() {\n return this._deceleration;\n }\n\n setMaxSpeed(maxSpeed: float): void {\n this._maxSpeed = maxSpeed;\n }\n\n getMaxSpeed() {\n return this._maxSpeed;\n }\n\n setAngularMaxSpeed(angularMaxSpeed: float): void {\n this._angularMaxSpeed = angularMaxSpeed;\n }\n\n getAngularMaxSpeed() {\n return this._angularMaxSpeed;\n }\n\n setAngleOffset(angleOffset: float): void {\n this._angleOffset = angleOffset;\n }\n\n getAngleOffset() {\n return this._angleOffset;\n }\n\n allowDiagonals(allow: boolean) {\n this._allowDiagonals = allow;\n }\n\n diagonalsAllowed() {\n return this._allowDiagonals;\n }\n\n setRotateObject(allow: boolean): void {\n this._rotateObject = allow;\n }\n\n isObjectRotated(): boolean {\n return this._rotateObject;\n }\n\n isMoving(): boolean {\n return this._xVelocity !== 0 || this._yVelocity !== 0;\n }\n\n getSpeed(): float {\n return Math.sqrt(\n this._xVelocity * this._xVelocity + this._yVelocity * this._yVelocity\n );\n }\n\n getXVelocity(): float {\n return this._xVelocity;\n }\n\n setXVelocity(velocityX: float): void {\n this._xVelocity = velocityX;\n }\n\n getYVelocity(): float {\n return this._yVelocity;\n }\n\n setYVelocity(velocityY: float): void {\n this._yVelocity = velocityY;\n }\n\n getAngle(): float {\n return this._angle;\n }\n\n isMovementAngleAround(degreeAngle: float, tolerance: float) {\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(this._angle, degreeAngle)\n ) <= tolerance\n );\n }\n\n setMovementAngleOffset(movementAngleOffset: float): void {\n this._movementAngleOffset = movementAngleOffset;\n }\n\n getMovementAngleOffset() {\n return this._movementAngleOffset;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const LEFTKEY = 37;\n const UPKEY = 38;\n const RIGHTKEY = 39;\n const DOWNKEY = 40;\n\n //Get the player input:\n this._leftKey ||\n (this._leftKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(LEFTKEY));\n this._rightKey ||\n (this._rightKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(RIGHTKEY));\n this._downKey ||\n (this._downKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(DOWNKEY));\n this._upKey ||\n (this._upKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(UPKEY));\n\n const elapsedTime = this.owner.getElapsedTime();\n\n if (!this._leftKey) {\n this._leftKeyPressedDuration = 0;\n } else {\n this._leftKeyPressedDuration += elapsedTime;\n }\n if (!this._rightKey) {\n this._rightKeyPressedDuration = 0;\n } else {\n this._rightKeyPressedDuration += elapsedTime;\n }\n if (!this._downKey) {\n this._downKeyPressedDuration = 0;\n } else {\n this._downKeyPressedDuration += elapsedTime;\n }\n if (!this._upKey) {\n this._upKeyPressedDuration = 0;\n } else {\n this._upKeyPressedDuration += elapsedTime;\n }\n\n let direction = -1;\n if (!this._allowDiagonals) {\n if (this._upKey && !this._downKey) {\n direction = 6;\n } else if (!this._upKey && this._downKey) {\n direction = 2;\n }\n // when 2 keys are pressed for diagonals the most recently pressed win\n if (\n this._leftKey &&\n !this._rightKey &&\n (this._upKey === this._downKey ||\n (this._upKey &&\n this._leftKeyPressedDuration < this._upKeyPressedDuration) ||\n (this._downKey &&\n this._leftKeyPressedDuration < this._downKeyPressedDuration))\n ) {\n direction = 4;\n } else if (\n this._rightKey &&\n !this._leftKey &&\n (this._upKey === this._downKey ||\n (this._upKey &&\n this._rightKeyPressedDuration < this._upKeyPressedDuration) ||\n (this._downKey &&\n this._rightKeyPressedDuration < this._downKeyPressedDuration))\n ) {\n direction = 0;\n }\n } else {\n if (this._upKey && !this._downKey) {\n if (this._leftKey && !this._rightKey) {\n direction = 5;\n } else if (!this._leftKey && this._rightKey) {\n direction = 7;\n } else {\n direction = 6;\n }\n } else if (!this._upKey && this._downKey) {\n if (this._leftKey && !this._rightKey) {\n direction = 3;\n } else if (!this._leftKey && this._rightKey) {\n direction = 1;\n } else {\n direction = 2;\n }\n } else {\n if (this._leftKey && !this._rightKey) {\n direction = 4;\n } else if (!this._leftKey && this._rightKey) {\n direction = 0;\n }\n }\n }\n\n const hookContext =\n gdjs.TopDownMovementRuntimeBehavior._topDownMovementHookContext;\n for (const topDownMovementHook of this._topDownMovementHooks) {\n hookContext._setDirection(direction);\n direction = topDownMovementHook.overrideDirection(hookContext);\n }\n hookContext._setDirection(direction);\n for (const topDownMovementHook of this._topDownMovementHooks) {\n topDownMovementHook.beforeSpeedUpdate(hookContext);\n }\n\n const object = this.owner;\n const timeDelta = this.owner.getElapsedTime() / 1000;\n const previousVelocityX = this._xVelocity;\n const previousVelocityY = this._yVelocity;\n this._wasStickUsed = false;\n\n // These 4 values are not actually used.\n // JavaScript doesn't allow to declare\n // variables without assigning them a value.\n let directionInRad = 0;\n let directionInDeg = 0;\n let cos = 1;\n let sin = 0;\n\n // Update the speed of the object:\n if (direction !== -1) {\n directionInRad =\n ((direction + this._movementAngleOffset / 45) * Math.PI) / 4.0;\n directionInDeg = direction * 45 + this._movementAngleOffset;\n // This makes the trigo resilient to rounding errors on directionInRad.\n cos = Math.cos(directionInRad);\n sin = Math.sin(directionInRad);\n if (cos === -1 || cos === 1) {\n sin = 0;\n }\n if (sin === -1 || sin === 1) {\n cos = 0;\n }\n this._xVelocity += this._acceleration * timeDelta * cos;\n this._yVelocity += this._acceleration * timeDelta * sin;\n } else if (this._stickForce !== 0) {\n if (!this._allowDiagonals) {\n this._stickAngle = 90 * Math.floor((this._stickAngle + 45) / 90);\n }\n directionInDeg = this._stickAngle + this._movementAngleOffset;\n directionInRad = (directionInDeg * Math.PI) / 180;\n const norm = this._acceleration * timeDelta * this._stickForce;\n // This makes the trigo resilient to rounding errors on directionInRad.\n cos = Math.cos(directionInRad);\n sin = Math.sin(directionInRad);\n if (cos === -1 || cos === 1) {\n sin = 0;\n }\n if (sin === -1 || sin === 1) {\n cos = 0;\n }\n this._xVelocity += norm * cos;\n this._yVelocity += norm * sin;\n\n this._wasStickUsed = true;\n this._stickForce = 0;\n } else if (this._yVelocity !== 0 || this._xVelocity !== 0) {\n directionInRad = Math.atan2(this._yVelocity, this._xVelocity);\n directionInDeg = (directionInRad * 180.0) / Math.PI;\n const xVelocityWasPositive = this._xVelocity >= 0;\n const yVelocityWasPositive = this._yVelocity >= 0;\n // This makes the trigo resilient to rounding errors on directionInRad.\n cos = Math.cos(directionInRad);\n sin = Math.sin(directionInRad);\n if (cos === -1 || cos === 1) {\n sin = 0;\n }\n if (sin === -1 || sin === 1) {\n cos = 0;\n }\n this._xVelocity -= this._deceleration * timeDelta * cos;\n this._yVelocity -= this._deceleration * timeDelta * sin;\n if (this._xVelocity > 0 !== xVelocityWasPositive) {\n this._xVelocity = 0;\n }\n if (this._yVelocity > 0 !== yVelocityWasPositive) {\n this._yVelocity = 0;\n }\n }\n const squaredSpeed =\n this._xVelocity * this._xVelocity + this._yVelocity * this._yVelocity;\n if (squaredSpeed > this._maxSpeed * this._maxSpeed) {\n this._xVelocity = this._maxSpeed * cos;\n this._yVelocity = this._maxSpeed * sin;\n }\n\n // No acceleration for angular speed for now.\n this._angularSpeed = this._angularMaxSpeed;\n\n for (const topDownMovementHook of this._topDownMovementHooks) {\n topDownMovementHook.beforePositionUpdate(hookContext);\n }\n\n // Position object.\n // This is a Verlet integration considering the acceleration as constant.\n // If you expand deltaX or deltaY, it gives, thanks to the usage of both\n // the old and the new velocity:\n // \"velocity * timeDelta + acceleration * timeDelta^2 / 2\".\n //\n // The acceleration is not actually always constant, particularly with a gamepad,\n // but the error is multiplied by timDelta^3. So, it shouldn't matter much.\n const deltaX = ((previousVelocityX + this._xVelocity) / 2) * timeDelta;\n const deltaY = ((previousVelocityY + this._yVelocity) / 2) * timeDelta;\n if (this._basisTransformation === null) {\n // Top-down viewpoint\n object.setX(object.getX() + deltaX);\n object.setY(object.getY() + deltaY);\n } else {\n // Isometry viewpoint\n const point = this._temporaryPointForTransformations;\n point[0] = deltaX;\n point[1] = deltaY;\n this._basisTransformation.toScreen(point, point);\n object.setX(object.getX() + point[0]);\n object.setY(object.getY() + point[1]);\n }\n\n // Also update angle if needed.\n if (this._xVelocity !== 0 || this._yVelocity !== 0) {\n this._angle = directionInDeg;\n if (this._rotateObject) {\n object.rotateTowardAngle(\n directionInDeg + this._angleOffset,\n this._angularSpeed\n );\n }\n }\n\n this._wasLeftKeyPressed = this._leftKey;\n this._wasRightKeyPressed = this._rightKey;\n this._wasUpKeyPressed = this._upKey;\n this._wasDownKeyPressed = this._downKey;\n if (!this._dontClearInputsBetweenFrames) {\n this._leftKey = false;\n this._rightKey = false;\n this._upKey = false;\n this._downKey = false;\n }\n }\n\n simulateControl(input: string) {\n if (input === 'Left') {\n this._leftKey = true;\n } else if (input === 'Right') {\n this._rightKey = true;\n } else if (input === 'Up') {\n this._upKey = true;\n } else if (input === 'Down') {\n this._downKey = true;\n }\n }\n\n ignoreDefaultControls(ignore: boolean) {\n this._ignoreDefaultControls = ignore;\n }\n\n shouldIgnoreDefaultControls() {\n return (\n this._ignoreDefaultControls ||\n this._ignoreDefaultControlsAsSyncedByNetwork\n );\n }\n\n simulateLeftKey() {\n this._leftKey = true;\n }\n\n simulateRightKey() {\n this._rightKey = true;\n }\n\n simulateUpKey() {\n this._upKey = true;\n }\n\n simulateDownKey() {\n this._downKey = true;\n }\n\n simulateStick(stickAngle: float, stickForce: float) {\n this._stickAngle = stickAngle % 360;\n this._stickForce = Math.max(0, Math.min(1, stickForce));\n }\n\n /**.\n * @param input The control to be tested [Left,Right,Up,Down,Stick].\n * @returns true if the key was used since the last `doStepPreEvents` call.\n */\n isUsingControl(input: string): boolean {\n if (input === 'Left') {\n return this._leftKeyPressedDuration > 0;\n }\n if (input === 'Right') {\n return this._rightKeyPressedDuration > 0;\n }\n if (input === 'Up') {\n return this._upKeyPressedDuration > 0;\n }\n if (input === 'Down') {\n return this._downKeyPressedDuration > 0;\n }\n if (input === 'Stick') {\n return this._wasStickUsed;\n }\n return false;\n }\n\n getLastStickInputAngle() {\n return this._stickAngle;\n }\n\n /**\n * A hook must typically be registered by a behavior that requires this one\n * in its onCreate function.\n * The hook must stay forever to avoid side effects like a hooks order\n * change. To handle deactivated behavior, the hook can check that its\n * behavior is activated before doing anything.\n */\n registerHook(\n hook: gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook\n ) {\n this._topDownMovementHooks.push(hook);\n }\n }\n\n export namespace TopDownMovementRuntimeBehavior {\n export class TopDownMovementHookContext {\n private direction: integer = -1;\n\n /**\n * @returns The movement direction from 0 for left to 7 for up-left and\n * -1 for no direction.\n */\n getDirection(): integer {\n return this.direction;\n }\n\n /**\n * This method won't change the direction used by the top-down movement\n * behavior.\n */\n _setDirection(direction: integer): void {\n this.direction = direction;\n }\n }\n\n // This should be a static attribute but it's not possible because of\n // declaration order.\n export const _topDownMovementHookContext =\n new gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHookContext();\n\n /**\n * Allow extensions relying on the top-down movement to customize its\n * behavior a bit.\n */\n export interface TopDownMovementHook {\n /**\n * Return the direction to use instead of the direction given in\n * parameter.\n */\n overrideDirection(hookContext: TopDownMovementHookContext): integer;\n /**\n * Called before the acceleration and new direction is applied to the\n * velocity.\n */\n beforeSpeedUpdate(hookContext: TopDownMovementHookContext): void;\n /**\n * Called before the velocity is applied to the object position and\n * angle.\n */\n beforePositionUpdate(hookContext: TopDownMovementHookContext): void;\n }\n\n export interface BasisTransformation {\n toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void;\n }\n\n export class IsometryTransformation\n implements gdjs.TopDownMovementRuntimeBehavior.BasisTransformation\n {\n private _screen: float[][];\n\n /**\n * @param angle between the x axis and the projected isometric x axis.\n * @throws if the angle is not in ]0; pi/4[. Note that 0 is a front viewpoint and pi/4 a top-down viewpoint.\n */\n constructor(angle: float) {\n if (angle <= 0 || angle >= Math.PI / 4)\n throw new RangeError(\n 'An isometry angle must be in ]0; pi/4] but was: ' + angle\n );\n\n const alpha = Math.asin(Math.tan(angle));\n const sinA = Math.sin(alpha);\n const cosB = Math.cos(Math.PI / 4);\n const sinB = cosB;\n // https://en.wikipedia.org/wiki/Isometric_projection\n //\n // / 1 0 0 \\ / cosB 0 -sinB \\ / 1 0 0 \\\n // | 0 cosA sinA | | 0 1 0 | | 0 0 -1 |\n // \\ 0 -sinA cosA / \\ sinB 0 cosB / \\ 0 1 0 /\n this._screen = [\n [cosB, -sinB],\n [sinA * sinB, sinA * cosB],\n ];\n }\n\n toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void {\n const x =\n this._screen[0][0] * worldPoint[0] +\n this._screen[0][1] * worldPoint[1];\n const y =\n this._screen[1][0] * worldPoint[0] +\n this._screen[1][1] * worldPoint[1];\n screenPoint[0] = x;\n screenPoint[1] = y;\n }\n }\n }\n\n gdjs.registerBehavior(\n 'TopDownMovementBehavior::TopDownMovementBehavior',\n gdjs.TopDownMovementRuntimeBehavior\n );\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAuBS,eAA6C,GAAK,eAAgB,CAyDvE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GAjDjC,YAAgB,EAGhB,gBAAoB,EACpB,gBAAoB,EACpB,mBAAuB,EAGvB,cAAoB,GACpB,eAAqB,GACrB,YAAkB,GAClB,cAAoB,GACpB,6BA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,GAAG,GAAK,EAAW,GAClC,EAAY,GAAK,EACjB,EAAY,GAAK,GAtCd,EAAM,0BApDE,2EA+FjB,EAAK,iBACH,mDACA,EAAK,kCAnwBC",
4
+ "sourcesContent": ["/*\nGDevelop - Top-down movement Behavior Extension\nCopyright (c) 2010-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n interface TopDownMovementNetworkSyncDataType {\n a: float;\n xv: float;\n yv: float;\n as: float;\n lk: boolean;\n rk: boolean;\n uk: boolean;\n dk: boolean;\n wsu: boolean;\n sa: float;\n sf: float;\n }\n\n export interface TopDownMovementNetworkSyncData\n extends BehaviorNetworkSyncData {\n props: TopDownMovementNetworkSyncDataType;\n }\n /**\n * Allows an object to move in 4 or 8 directions, with customizable speed, accelerations\n * and rotation.\n */\n export class TopDownMovementRuntimeBehavior extends gdjs.RuntimeBehavior {\n //Behavior configuration:\n private _allowDiagonals: boolean;\n private _acceleration: float;\n private _deceleration: float;\n private _maxSpeed: float;\n private _angularMaxSpeed: float;\n private _rotateObject: boolean;\n private _angleOffset: float;\n private _ignoreDefaultControls: boolean;\n private _movementAngleOffset: float;\n private _useLegacyTurnBack: boolean;\n\n /** The latest angle of movement, in degrees. */\n private _angle: float = 0;\n\n //Attributes used when moving\n private _xVelocity: float = 0;\n private _yVelocity: float = 0;\n private _angularSpeed: float = 0;\n\n // Inputs\n private _leftKey: boolean = false;\n private _rightKey: boolean = false;\n private _upKey: boolean = false;\n private _downKey: boolean = false;\n private _leftKeyPressedDuration: float = 0;\n private _rightKeyPressedDuration: float = 0;\n private _upKeyPressedDuration: float = 0;\n private _downKeyPressedDuration: float = 0;\n private _wasStickUsed: boolean = false;\n private _stickAngle: float = 0;\n private _stickForce: float = 0;\n\n // This is useful when the object is synchronized by an external source\n // like in a multiplayer game, and we want to be able to predict the\n // movement of the object, even if the inputs are not updated every frame.\n _dontClearInputsBetweenFrames: boolean = false;\n // This is useful when the object is synchronized over the network,\n // object is controlled by the network and we want to ensure the current player\n // cannot control it.\n _ignoreDefaultControlsAsSyncedByNetwork: boolean = false;\n\n // This is useful for extensions that need to know\n // which keys were pressed and doesn't know the mapping\n // done by the scene events.\n private _wasLeftKeyPressed: boolean = false;\n private _wasRightKeyPressed: boolean = false;\n private _wasUpKeyPressed: boolean = false;\n private _wasDownKeyPressed: boolean = false;\n\n // @ts-ignore The setter \"setViewpoint\" is not detected as an affectation.\n private _basisTransformation: gdjs.TopDownMovementRuntimeBehavior.BasisTransformation | null;\n private _temporaryPointForTransformations: FloatPoint = [0, 0];\n\n private _topDownMovementHooks: Array<gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook> =\n [];\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._allowDiagonals = behaviorData.allowDiagonals;\n this._acceleration = behaviorData.acceleration;\n this._deceleration = behaviorData.deceleration;\n this._maxSpeed = behaviorData.maxSpeed;\n this._angularMaxSpeed = behaviorData.angularMaxSpeed;\n this._rotateObject = behaviorData.rotateObject;\n this._angleOffset = behaviorData.angleOffset;\n this._ignoreDefaultControls = behaviorData.ignoreDefaultControls;\n this.setViewpoint(\n behaviorData.viewpoint,\n behaviorData.customIsometryAngle\n );\n this._movementAngleOffset = behaviorData.movementAngleOffset || 0;\n this._useLegacyTurnBack =\n behaviorData.useLegacyTurnBack === undefined\n ? true\n : behaviorData.useLegacyTurnBack;\n }\n\n getNetworkSyncData(): TopDownMovementNetworkSyncData {\n // This method is called, so we are synchronizing this object.\n // Let's clear the inputs between frames as we control it.\n this._dontClearInputsBetweenFrames = false;\n this._ignoreDefaultControlsAsSyncedByNetwork = false;\n\n return {\n ...super.getNetworkSyncData(),\n props: {\n a: this._angle,\n xv: this._xVelocity,\n yv: this._yVelocity,\n as: this._angularSpeed,\n lk: this._wasLeftKeyPressed,\n rk: this._wasRightKeyPressed,\n uk: this._wasUpKeyPressed,\n dk: this._wasDownKeyPressed,\n wsu: this._wasStickUsed,\n sa: this._stickAngle,\n sf: this._stickForce,\n },\n };\n }\n\n updateFromNetworkSyncData(\n networkSyncData: TopDownMovementNetworkSyncData\n ): void {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n if (behaviorSpecificProps.a !== undefined) {\n this._angle = behaviorSpecificProps.a;\n }\n if (behaviorSpecificProps.xv !== undefined) {\n this._xVelocity = behaviorSpecificProps.xv;\n }\n if (behaviorSpecificProps.yv !== undefined) {\n this._yVelocity = behaviorSpecificProps.yv;\n }\n if (behaviorSpecificProps.as !== undefined) {\n this._angularSpeed = behaviorSpecificProps.as;\n }\n if (behaviorSpecificProps.lk !== undefined) {\n this._leftKey = behaviorSpecificProps.lk;\n }\n if (behaviorSpecificProps.rk !== undefined) {\n this._rightKey = behaviorSpecificProps.rk;\n }\n if (behaviorSpecificProps.uk !== undefined) {\n this._upKey = behaviorSpecificProps.uk;\n }\n if (behaviorSpecificProps.dk !== undefined) {\n this._downKey = behaviorSpecificProps.dk;\n }\n if (behaviorSpecificProps.wsu !== undefined) {\n this._wasStickUsed = behaviorSpecificProps.wsu;\n }\n if (behaviorSpecificProps.sa !== undefined) {\n this._stickAngle = behaviorSpecificProps.sa;\n }\n if (behaviorSpecificProps.sf !== undefined) {\n this._stickForce = behaviorSpecificProps.sf;\n }\n\n // When the object is synchronized from the network, the inputs must not be cleared.\n this._dontClearInputsBetweenFrames = true;\n // And we are not using the default controls.\n this._ignoreDefaultControlsAsSyncedByNetwork = true;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.allowDiagonals !== newBehaviorData.allowDiagonals) {\n this._allowDiagonals = newBehaviorData.allowDiagonals;\n }\n if (oldBehaviorData.acceleration !== newBehaviorData.acceleration) {\n this._acceleration = newBehaviorData.acceleration;\n }\n if (oldBehaviorData.deceleration !== newBehaviorData.deceleration) {\n this._deceleration = newBehaviorData.deceleration;\n }\n if (oldBehaviorData.maxSpeed !== newBehaviorData.maxSpeed) {\n this._maxSpeed = newBehaviorData.maxSpeed;\n }\n if (oldBehaviorData.angularMaxSpeed !== newBehaviorData.angularMaxSpeed) {\n this._angularMaxSpeed = newBehaviorData.angularMaxSpeed;\n }\n if (oldBehaviorData.rotateObject !== newBehaviorData.rotateObject) {\n this._rotateObject = newBehaviorData.rotateObject;\n }\n if (oldBehaviorData.angleOffset !== newBehaviorData.angleOffset) {\n this._angleOffset = newBehaviorData.angleOffset;\n }\n if (\n oldBehaviorData.ignoreDefaultControls !==\n newBehaviorData.ignoreDefaultControls\n ) {\n this._ignoreDefaultControls = newBehaviorData.ignoreDefaultControls;\n }\n if (\n oldBehaviorData.platformType !== newBehaviorData.platformType ||\n oldBehaviorData.customIsometryAngle !==\n newBehaviorData.customIsometryAngle\n ) {\n this.setViewpoint(\n newBehaviorData.platformType,\n newBehaviorData.customIsometryAngle\n );\n }\n if (\n oldBehaviorData.movementAngleOffset !==\n newBehaviorData.movementAngleOffset\n ) {\n this._movementAngleOffset = newBehaviorData.movementAngleOffset;\n }\n return true;\n }\n\n setViewpoint(viewpoint: string, customIsometryAngle: float): void {\n if (viewpoint === 'PixelIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n Math.atan(0.5)\n );\n } else if (viewpoint === 'TrueIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n Math.PI / 6\n );\n } else if (viewpoint === 'CustomIsometry') {\n this._basisTransformation =\n new gdjs.TopDownMovementRuntimeBehavior.IsometryTransformation(\n (customIsometryAngle * Math.PI) / 180\n );\n } else {\n this._basisTransformation = null;\n }\n }\n\n setAcceleration(acceleration: float): void {\n this._acceleration = acceleration;\n }\n\n getAcceleration() {\n return this._acceleration;\n }\n\n setDeceleration(deceleration: float): void {\n this._deceleration = deceleration;\n }\n\n getDeceleration() {\n return this._deceleration;\n }\n\n setMaxSpeed(maxSpeed: float): void {\n this._maxSpeed = maxSpeed;\n }\n\n getMaxSpeed() {\n return this._maxSpeed;\n }\n\n setAngularMaxSpeed(angularMaxSpeed: float): void {\n this._angularMaxSpeed = angularMaxSpeed;\n }\n\n getAngularMaxSpeed() {\n return this._angularMaxSpeed;\n }\n\n setAngleOffset(angleOffset: float): void {\n this._angleOffset = angleOffset;\n }\n\n getAngleOffset() {\n return this._angleOffset;\n }\n\n allowDiagonals(allow: boolean) {\n this._allowDiagonals = allow;\n }\n\n diagonalsAllowed() {\n return this._allowDiagonals;\n }\n\n setRotateObject(allow: boolean): void {\n this._rotateObject = allow;\n }\n\n isObjectRotated(): boolean {\n return this._rotateObject;\n }\n\n isMoving(): boolean {\n return this._xVelocity !== 0 || this._yVelocity !== 0;\n }\n\n getSpeed(): float {\n return Math.hypot(this._xVelocity, this._yVelocity);\n }\n\n getXVelocity(): float {\n return this._xVelocity;\n }\n\n setXVelocity(velocityX: float): void {\n this._xVelocity = velocityX;\n }\n\n getYVelocity(): float {\n return this._yVelocity;\n }\n\n setYVelocity(velocityY: float): void {\n this._yVelocity = velocityY;\n }\n\n getAngle(): float {\n return this._angle;\n }\n\n isMovementAngleAround(degreeAngle: float, tolerance: float) {\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(this._angle, degreeAngle)\n ) <= tolerance\n );\n }\n\n setMovementAngleOffset(movementAngleOffset: float): void {\n this._movementAngleOffset = movementAngleOffset;\n }\n\n getMovementAngleOffset() {\n return this._movementAngleOffset;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n const LEFTKEY = 37;\n const UPKEY = 38;\n const RIGHTKEY = 39;\n const DOWNKEY = 40;\n\n //Get the player input:\n this._leftKey ||\n (this._leftKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(LEFTKEY));\n this._rightKey ||\n (this._rightKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(RIGHTKEY));\n this._downKey ||\n (this._downKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(DOWNKEY));\n this._upKey ||\n (this._upKey =\n !this.shouldIgnoreDefaultControls() &&\n instanceContainer.getGame().getInputManager().isKeyPressed(UPKEY));\n\n const elapsedTime = this.owner.getElapsedTime();\n\n if (!this._leftKey) {\n this._leftKeyPressedDuration = 0;\n } else {\n this._leftKeyPressedDuration += elapsedTime;\n }\n if (!this._rightKey) {\n this._rightKeyPressedDuration = 0;\n } else {\n this._rightKeyPressedDuration += elapsedTime;\n }\n if (!this._downKey) {\n this._downKeyPressedDuration = 0;\n } else {\n this._downKeyPressedDuration += elapsedTime;\n }\n if (!this._upKey) {\n this._upKeyPressedDuration = 0;\n } else {\n this._upKeyPressedDuration += elapsedTime;\n }\n\n let direction = -1;\n if (!this._allowDiagonals) {\n if (this._upKey && !this._downKey) {\n direction = 6;\n } else if (!this._upKey && this._downKey) {\n direction = 2;\n }\n // when 2 keys are pressed for diagonals the most recently pressed win\n if (\n this._leftKey &&\n !this._rightKey &&\n (this._upKey === this._downKey ||\n (this._upKey &&\n this._leftKeyPressedDuration < this._upKeyPressedDuration) ||\n (this._downKey &&\n this._leftKeyPressedDuration < this._downKeyPressedDuration))\n ) {\n direction = 4;\n } else if (\n this._rightKey &&\n !this._leftKey &&\n (this._upKey === this._downKey ||\n (this._upKey &&\n this._rightKeyPressedDuration < this._upKeyPressedDuration) ||\n (this._downKey &&\n this._rightKeyPressedDuration < this._downKeyPressedDuration))\n ) {\n direction = 0;\n }\n } else {\n if (this._upKey && !this._downKey) {\n if (this._leftKey && !this._rightKey) {\n direction = 5;\n } else if (!this._leftKey && this._rightKey) {\n direction = 7;\n } else {\n direction = 6;\n }\n } else if (!this._upKey && this._downKey) {\n if (this._leftKey && !this._rightKey) {\n direction = 3;\n } else if (!this._leftKey && this._rightKey) {\n direction = 1;\n } else {\n direction = 2;\n }\n } else {\n if (this._leftKey && !this._rightKey) {\n direction = 4;\n } else if (!this._leftKey && this._rightKey) {\n direction = 0;\n }\n }\n }\n\n const hookContext =\n gdjs.TopDownMovementRuntimeBehavior._topDownMovementHookContext;\n for (const topDownMovementHook of this._topDownMovementHooks) {\n hookContext._setDirection(direction);\n direction = topDownMovementHook.overrideDirection(hookContext);\n }\n hookContext._setDirection(direction);\n for (const topDownMovementHook of this._topDownMovementHooks) {\n topDownMovementHook.beforeSpeedUpdate(hookContext);\n }\n\n const object = this.owner;\n const timeDelta = this.owner.getElapsedTime() / 1000;\n const previousVelocityX = this._xVelocity;\n const previousVelocityY = this._yVelocity;\n this._wasStickUsed = false;\n\n // These 4 values are not actually used.\n // JavaScript doesn't allow to declare\n // variables without assigning them a value.\n let directionInRad = 0;\n let directionInDeg = 0;\n\n let isMoving = false;\n let targetedSpeed = 0;\n // Update the speed of the object:\n if (direction !== -1) {\n isMoving = true;\n directionInRad =\n ((direction + this._movementAngleOffset / 45) * Math.PI) / 4.0;\n directionInDeg = direction * 45 + this._movementAngleOffset;\n targetedSpeed = this._maxSpeed;\n } else if (this._stickForce !== 0) {\n isMoving = true;\n if (!this._allowDiagonals) {\n this._stickAngle = 90 * Math.floor((this._stickAngle + 45) / 90);\n }\n directionInDeg = this._stickAngle + this._movementAngleOffset;\n directionInRad = (directionInDeg * Math.PI) / 180;\n targetedSpeed = this._maxSpeed * this._stickForce;\n\n this._wasStickUsed = true;\n } else if (this._yVelocity !== 0 || this._xVelocity !== 0) {\n isMoving = true;\n directionInRad = Math.atan2(this._yVelocity, this._xVelocity);\n directionInDeg = (directionInRad * 180.0) / Math.PI;\n }\n if (isMoving) {\n // This makes the trigo resilient to rounding errors on directionInRad.\n let cos = Math.cos(directionInRad);\n let sin = Math.sin(directionInRad);\n if (cos === -1 || cos === 1) {\n sin = 0;\n }\n if (sin === -1 || sin === 1) {\n cos = 0;\n }\n\n const getAcceleratedSpeed = this._useLegacyTurnBack\n ? TopDownMovementRuntimeBehavior.getLegacyAcceleratedSpeed\n : TopDownMovementRuntimeBehavior.getAcceleratedSpeed;\n\n let currentSpeed = Math.hypot(this._xVelocity, this._yVelocity);\n const dotProduct = this._xVelocity * cos + this._yVelocity * sin;\n if (dotProduct < 0) {\n // The object is turning back.\n // Keep the negative velocity projected on the new direction.\n currentSpeed = dotProduct;\n }\n const speed = getAcceleratedSpeed(\n currentSpeed,\n targetedSpeed,\n this._maxSpeed,\n this._acceleration,\n this._deceleration,\n timeDelta\n );\n this._xVelocity = speed * cos;\n this._yVelocity = speed * sin;\n }\n\n const squaredSpeed =\n this._xVelocity * this._xVelocity + this._yVelocity * this._yVelocity;\n if (squaredSpeed > this._maxSpeed * this._maxSpeed) {\n const ratio = this._maxSpeed / Math.sqrt(squaredSpeed);\n this._xVelocity *= ratio;\n this._yVelocity *= ratio;\n }\n\n // No acceleration for angular speed for now.\n this._angularSpeed = this._angularMaxSpeed;\n\n for (const topDownMovementHook of this._topDownMovementHooks) {\n topDownMovementHook.beforePositionUpdate(hookContext);\n }\n\n // Position object.\n // This is a Verlet integration considering the acceleration as constant.\n // If you expand deltaX or deltaY, it gives, thanks to the usage of both\n // the old and the new velocity:\n // \"velocity * timeDelta + acceleration * timeDelta^2 / 2\".\n //\n // The acceleration is not actually always constant, particularly with a gamepad,\n // but the error is multiplied by timDelta^3. So, it shouldn't matter much.\n const deltaX = ((previousVelocityX + this._xVelocity) / 2) * timeDelta;\n const deltaY = ((previousVelocityY + this._yVelocity) / 2) * timeDelta;\n if (this._basisTransformation === null) {\n // Top-down viewpoint\n object.setX(object.getX() + deltaX);\n object.setY(object.getY() + deltaY);\n } else {\n // Isometry viewpoint\n const point = this._temporaryPointForTransformations;\n point[0] = deltaX;\n point[1] = deltaY;\n this._basisTransformation.toScreen(point, point);\n object.setX(object.getX() + point[0]);\n object.setY(object.getY() + point[1]);\n }\n\n // Also update angle if needed.\n if (this._xVelocity !== 0 || this._yVelocity !== 0) {\n this._angle = directionInDeg;\n if (this._rotateObject) {\n object.rotateTowardAngle(\n directionInDeg + this._angleOffset,\n this._angularSpeed\n );\n }\n }\n\n this._wasLeftKeyPressed = this._leftKey;\n this._wasRightKeyPressed = this._rightKey;\n this._wasUpKeyPressed = this._upKey;\n this._wasDownKeyPressed = this._downKey;\n if (!this._dontClearInputsBetweenFrames) {\n this._leftKey = false;\n this._rightKey = false;\n this._upKey = false;\n this._downKey = false;\n this._stickForce = 0;\n }\n }\n\n private static getAcceleratedSpeed(\n currentSpeed: float,\n targetedSpeed: float,\n speedMax: float,\n acceleration: float,\n deceleration: float,\n timeDelta: float\n ): float {\n let newSpeed = currentSpeed;\n const turningBackAcceleration = Math.max(acceleration, deceleration);\n if (targetedSpeed < 0) {\n if (currentSpeed <= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + turningBackAcceleration * timeDelta\n );\n } else if (currentSpeed <= 0) {\n // Accelerate\n newSpeed -= Math.max(-speedMax, acceleration * timeDelta);\n } else {\n // Turn back at least as fast as it would stop.\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - turningBackAcceleration * timeDelta\n );\n }\n } else if (targetedSpeed > 0) {\n if (currentSpeed >= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - turningBackAcceleration * timeDelta\n );\n } else if (currentSpeed >= 0) {\n // Accelerate\n newSpeed = Math.min(\n speedMax,\n currentSpeed + acceleration * timeDelta\n );\n } else {\n // Turn back at least as fast as it would stop.\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + turningBackAcceleration * timeDelta\n );\n }\n } else {\n // Decelerate and stop.\n if (currentSpeed < 0) {\n newSpeed = Math.min(currentSpeed + deceleration * timeDelta, 0);\n }\n if (currentSpeed > 0) {\n newSpeed = Math.max(currentSpeed - deceleration * timeDelta, 0);\n }\n }\n return newSpeed;\n }\n\n private static getLegacyAcceleratedSpeed(\n currentSpeed: float,\n targetedSpeed: float,\n speedMax: float,\n acceleration: float,\n deceleration: float,\n timeDelta: float\n ): float {\n let newSpeed = currentSpeed;\n if (targetedSpeed < 0) {\n if (currentSpeed <= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + deceleration * timeDelta\n );\n } else if (currentSpeed <= 0) {\n // Accelerate\n newSpeed -= Math.max(-speedMax, acceleration * timeDelta);\n } else {\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - deceleration * timeDelta\n );\n }\n } else if (targetedSpeed > 0) {\n if (currentSpeed >= targetedSpeed) {\n // Reduce the speed to match the stick force.\n newSpeed = Math.max(\n targetedSpeed,\n currentSpeed - deceleration * timeDelta\n );\n } else if (currentSpeed >= 0) {\n // Accelerate\n newSpeed = Math.min(\n speedMax,\n currentSpeed + acceleration * timeDelta\n );\n } else {\n newSpeed = Math.min(\n targetedSpeed,\n currentSpeed + deceleration * timeDelta\n );\n }\n } else {\n // Decelerate and stop.\n if (currentSpeed < 0) {\n newSpeed = Math.min(currentSpeed + deceleration * timeDelta, 0);\n }\n if (currentSpeed > 0) {\n newSpeed = Math.max(currentSpeed - deceleration * timeDelta, 0);\n }\n }\n return newSpeed;\n }\n\n simulateControl(input: string) {\n if (input === 'Left') {\n this._leftKey = true;\n } else if (input === 'Right') {\n this._rightKey = true;\n } else if (input === 'Up') {\n this._upKey = true;\n } else if (input === 'Down') {\n this._downKey = true;\n }\n }\n\n ignoreDefaultControls(ignore: boolean) {\n this._ignoreDefaultControls = ignore;\n }\n\n shouldIgnoreDefaultControls() {\n return (\n this._ignoreDefaultControls ||\n this._ignoreDefaultControlsAsSyncedByNetwork\n );\n }\n\n simulateLeftKey() {\n this._leftKey = true;\n }\n\n simulateRightKey() {\n this._rightKey = true;\n }\n\n simulateUpKey() {\n this._upKey = true;\n }\n\n simulateDownKey() {\n this._downKey = true;\n }\n\n simulateStick(stickAngle: float, stickForce: float) {\n this._stickAngle = stickAngle % 360;\n this._stickForce = Math.max(0, Math.min(1, stickForce));\n }\n\n /**.\n * @param input The control to be tested [Left,Right,Up,Down,Stick].\n * @returns true if the key was used since the last `doStepPreEvents` call.\n */\n isUsingControl(input: string): boolean {\n if (input === 'Left') {\n return this._leftKeyPressedDuration > 0;\n }\n if (input === 'Right') {\n return this._rightKeyPressedDuration > 0;\n }\n if (input === 'Up') {\n return this._upKeyPressedDuration > 0;\n }\n if (input === 'Down') {\n return this._downKeyPressedDuration > 0;\n }\n if (input === 'Stick') {\n return this._wasStickUsed;\n }\n return false;\n }\n\n getLastStickInputAngle() {\n return this._stickAngle;\n }\n\n /**\n * A hook must typically be registered by a behavior that requires this one\n * in its onCreate function.\n * The hook must stay forever to avoid side effects like a hooks order\n * change. To handle deactivated behavior, the hook can check that its\n * behavior is activated before doing anything.\n */\n registerHook(\n hook: gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHook\n ) {\n this._topDownMovementHooks.push(hook);\n }\n }\n\n export namespace TopDownMovementRuntimeBehavior {\n export class TopDownMovementHookContext {\n private direction: integer = -1;\n\n /**\n * @returns The movement direction from 0 for left to 7 for up-left and\n * -1 for no direction.\n */\n getDirection(): integer {\n return this.direction;\n }\n\n /**\n * This method won't change the direction used by the top-down movement\n * behavior.\n */\n _setDirection(direction: integer): void {\n this.direction = direction;\n }\n }\n\n // This should be a static attribute but it's not possible because of\n // declaration order.\n export const _topDownMovementHookContext =\n new gdjs.TopDownMovementRuntimeBehavior.TopDownMovementHookContext();\n\n /**\n * Allow extensions relying on the top-down movement to customize its\n * behavior a bit.\n */\n export interface TopDownMovementHook {\n /**\n * Return the direction to use instead of the direction given in\n * parameter.\n */\n overrideDirection(hookContext: TopDownMovementHookContext): integer;\n /**\n * Called before the acceleration and new direction is applied to the\n * velocity.\n */\n beforeSpeedUpdate(hookContext: TopDownMovementHookContext): void;\n /**\n * Called before the velocity is applied to the object position and\n * angle.\n */\n beforePositionUpdate(hookContext: TopDownMovementHookContext): void;\n }\n\n export interface BasisTransformation {\n toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void;\n }\n\n export class IsometryTransformation\n implements gdjs.TopDownMovementRuntimeBehavior.BasisTransformation\n {\n private _screen: float[][];\n\n /**\n * @param angle between the x axis and the projected isometric x axis.\n * @throws if the angle is not in ]0; pi/4[. Note that 0 is a front viewpoint and pi/4 a top-down viewpoint.\n */\n constructor(angle: float) {\n if (angle <= 0 || angle >= Math.PI / 4)\n throw new RangeError(\n 'An isometry angle must be in ]0; pi/4] but was: ' + angle\n );\n\n const alpha = Math.asin(Math.tan(angle));\n const sinA = Math.sin(alpha);\n const cosB = Math.cos(Math.PI / 4);\n const sinB = cosB;\n // https://en.wikipedia.org/wiki/Isometric_projection\n //\n // / 1 0 0 \\ / cosB 0 -sinB \\ / 1 0 0 \\\n // | 0 cosA sinA | | 0 1 0 | | 0 0 -1 |\n // \\ 0 -sinA cosA / \\ sinB 0 cosB / \\ 0 1 0 /\n this._screen = [\n [cosB, -sinB],\n [sinA * sinB, sinA * cosB],\n ];\n }\n\n toScreen(worldPoint: FloatPoint, screenPoint: FloatPoint): void {\n const x =\n this._screen[0][0] * worldPoint[0] +\n this._screen[0][1] * worldPoint[1];\n const y =\n this._screen[1][0] * worldPoint[0] +\n this._screen[1][1] * worldPoint[1];\n screenPoint[0] = x;\n screenPoint[1] = y;\n }\n }\n }\n\n gdjs.registerBehavior(\n 'TopDownMovementBehavior::TopDownMovementBehavior',\n gdjs.TopDownMovementRuntimeBehavior\n );\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAuBS,eAA6C,GAAK,eAAgB,CA0DvE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GAjDjC,YAAgB,EAGhB,gBAAoB,EACpB,gBAAoB,EACpB,mBAAuB,EAGvB,cAAoB,GACpB,eAAqB,GACrB,YAAkB,GAClB,cAAoB,GACpB,6BAAiC,EACjC,8BAAkC,EAClC,2BAA+B,EAC/B,6BAAiC,EACjC,mBAAyB,GACzB,iBAAqB,EACrB,iBAAqB,EAK7B,mCAAyC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AU,QACL,KAAK,yBAA2B,EAErC,IAAU,KACL,KAAK,sBAAwB,EAElC,IAAU,OACL,KAAK,wBAA0B,EAEpC,IAAU,QACL,KAAK,cAEP,GAGT,wBAAyB,CACvB,MAAO,MAAK,YAUd,aACE,EACA,CACA,KAAK,sBAAsB,KAAK,IA3vB7B,EAAM,iCA+vBN,SAAU,EAAV,CACE,OAAiC,CAAjC,aA5xBX,CA6xBc,eAAqB,GAM7B,cAAwB,CACtB,MAAO,MAAK,UAOd,cAAc,EAA0B,CACtC,KAAK,UAAY,GAhBd,EAAM,6BAsBA,8BACX,GAAI,GAAK,+BAA+B,2BA4BnC,OAEP,CAOE,YAAY,EAAc,CACxB,GAAI,GAAS,GAAK,GAAS,KAAK,GAAK,EACnC,KAAM,IAAI,YACR,mDAAqD,GAGzD,KAAM,GAAQ,KAAK,KAAK,KAAK,IAAI,IAC3B,EAAO,KAAK,IAAI,GAChB,EAAO,KAAK,IAAI,KAAK,GAAK,GAC1B,EAAO,EAMb,KAAK,QAAU,CACb,CAAC,EAAM,CAAC,GACR,CAAC,EAAO,EAAM,EAAO,IAIzB,SAAS,EAAwB,EAA+B,CAC9D,KAAM,GACJ,KAAK,QAAQ,GAAG,GAAK,EAAW,GAChC,KAAK,QAAQ,GAAG,GAAK,EAAW,GAC5B,EACJ,KAAK,QAAQ,GAAG,GAAK,EAAW,GAChC,KAAK,QAAQ,GAAG,GAAK,EAAW,GAClC,EAAY,GAAK,EACjB,EAAY,GAAK,GAtCd,EAAM,0BApDE,2EA+FjB,EAAK,iBACH,mDACA,EAAK,kCAv3BC",
6
6
  "names": []
7
7
  }
@@ -60,7 +60,7 @@ module.exports = {
60
60
  'Tween',
61
61
  _('Tweening'),
62
62
  _(
63
- 'Animate object properties over time. This allows smooth transitions, animations or movement of objects to specified positions.'
63
+ 'Smoothly animate object properties over time — such as position, rotation scale, opacity, and more — as well as variables. Ideal for creating fluid transitions and UI animations. While you can use tweens to move objects, other behaviors (like platform, physics, ellipse movement...) or forces are often better suited for dynamic movement. Tween is best used for animating UI elements, static objects that need to move from one point to another, or other values like variables.'
64
64
  ),
65
65
  'Matthias Meike, Florian Rival',
66
66
  'Open source (MIT License)'
@@ -1,2 +1,2 @@
1
- var gdjs;(function(w){const p=new w.Logger("Tween");function O(h){return h.setScaleX&&h.setScaleY&&h.getScaleX&&h.getScaleY}function R(h){return h.setOpacity&&h.getOpacity}function S(h){return h.getZ&&h.setZ}function C(h){return h.setColor&&h.getColor}function F(h){return h.setCharacterSize&&h.getCharacterSize}const g=w.evtTools.common.lerp,m=w.evtTools.common.exponentialInterpolation;class X extends w.RuntimeBehavior{constructor(e,t,n){super(e,t,n);this._tweens=new w.evtTools.tween.TweenManager;this._isActive=!0}updateFromBehaviorData(e,t){return!0}doStepPreEvents(e){this._tweens.step()}_deleteFromScene(){this.owner.deleteFromScene(this.owner.getInstanceContainer())}addVariableTween(e,t,n,o,i,s,r){this._tweens.addSimpleTween(e,this.owner.getRuntimeScene(),s/1e3,i,g,n,o,a=>t.setNumber(a),r?()=>this._deleteFromScene():null)}addVariableTween2(e,t,n,o,i,s){this._addVariableTween(e,t,n,o,i/1e3,s,this.owner.getRuntimeScene())}addVariableTween3(e,t,n,o,i,s){this._addVariableTween(e,t,n,o,i,s,this.owner)}_addVariableTween(e,t,n,o,i,s,r){t.getType()==="number"&&this._tweens.addSimpleTween(e,r,i,o,g,t.getValue(),n,a=>t.setNumber(a),s?()=>this._deleteFromScene():null)}addValueTween(e,t,n,o,i,s,r){this._tweens.addSimpleTween(e,this.owner,i,o,s?m:g,t,n,a=>{},r?()=>this._deleteFromScene():null)}addObjectPositionTween(e,t,n,o,i,s){this._addObjectPositionTween(e,t,n,o,i/1e3,s,this.owner.getRuntimeScene())}addObjectPositionTween2(e,t,n,o,i,s){this._addObjectPositionTween(e,t,n,o,i,s,this.owner)}_addObjectPositionTween(e,t,n,o,i,s,r){this._tweens.addMultiTween(e,r,i,o,g,[this.owner.getX(),this.owner.getY()],[t,n],([a,l])=>this.owner.setPosition(a,l),s?()=>this._deleteFromScene():null)}addObjectPositionXTween(e,t,n,o,i){this._addObjectPositionXTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectPositionXTween2(e,t,n,o,i){this._addObjectPositionXTween(e,t,n,o,i,this.owner)}_addObjectPositionXTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getX(),t,r=>this.owner.setX(r),i?()=>this._deleteFromScene():null)}addObjectPositionYTween(e,t,n,o,i){this._addObjectPositionYTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectPositionYTween2(e,t,n,o,i){this._addObjectPositionYTween(e,t,n,o,i,this.owner)}_addObjectPositionYTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getY(),t,r=>this.owner.setY(r),i?()=>this._deleteFromScene():null)}addObjectPositionZTween(e,t,n,o,i){this._addObjectPositionZTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectPositionZTween2(e,t,n,o,i,s){this._addObjectPositionZTween(t,n,o,i,s,this.owner)}_addObjectPositionZTween(e,t,n,o,i,s){const{owner:r}=this;!S(r)||this._tweens.addSimpleTween(e,s,o,n,g,r.getZ(),t,a=>r.setZ(a),i?()=>this._deleteFromScene():null)}addObjectAngleTween(e,t,n,o,i){this._addObjectAngleTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectAngleTween2(e,t,n,o,i){this._addObjectAngleTween(e,t,n,o,i,this.owner)}_addObjectAngleTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getAngle(),t,r=>this.owner.setAngle(r),i?()=>this._deleteFromScene():null)}addObjectRotationXTween(e,t,n,o,i,s){const{owner:r}=this;!S(r)||this._tweens.addSimpleTween(t,this.owner,i,o,g,r.getRotationX(),n,a=>r.setRotationX(a),s?()=>this._deleteFromScene():null)}addObjectRotationYTween(e,t,n,o,i,s){const{owner:r}=this;!S(r)||this._tweens.addSimpleTween(t,this.owner,i,o,g,r.getRotationY(),n,a=>r.setRotationY(a),s?()=>this._deleteFromScene():null)}addObjectScaleTween(e,t,n,o,i,s,r){this._addObjectScaleTween(e,t,n,o,i/1e3,s,r,this.owner.getRuntimeScene(),g)}addObjectScaleTween2(e,t,n,o,i,s,r){this._addObjectScaleTween(e,t,n,o,i,s,r,this.owner,m)}_addObjectScaleTween(e,t,n,o,i,s,r,a,l){const d=this.owner;if(!O(d))return;t<0&&(t=0),n<0&&(n=0);const c=r?([b,T])=>{const f=d.getCenterXInScene(),u=d.getCenterYInScene();d.setScaleX(b),d.setScaleY(T),d.setCenterPositionInScene(f,u)}:([b,T])=>{d.setScaleX(b),d.setScaleY(T)};this._tweens.addMultiTween(e,a,i,o,l,[d.getScaleX(),d.getScaleY()],[t,n],c,s?()=>this._deleteFromScene():null)}addObjectScaleTween3(e,t,n,o,i,s){this._addObjectScaleXTween(e,t,n,o,i,s,this.owner,m);const r=this.owner;if(!O(r))return;const a=S(r)?r:null,l=s?d=>{const c=r.getCenterXInScene(),b=r.getCenterYInScene(),T=a?a.getCenterZInScene():0;r.setScale(d),r.setCenterXInScene(c),r.setCenterYInScene(b),a&&a.setCenterZInScene(T)}:d=>r.setScale(d);this._tweens.addSimpleTween(e,this.owner,o,n,m,r.getScale(),t,l,i?()=>this._deleteFromScene():null)}addObjectScaleXTween(e,t,n,o,i,s){this._addObjectScaleXTween(e,t,n,o/1e3,i,s,this.owner.getRuntimeScene(),g)}addObjectScaleXTween2(e,t,n,o,i,s){this._addObjectScaleXTween(e,t,n,o,i,s,this.owner,m)}_addObjectScaleXTween(e,t,n,o,i,s,r,a){const l=this.owner;if(!O(l))return;const d=s?c=>{const b=l.getCenterXInScene();l.setScaleX(c),l.setCenterXInScene(b)}:c=>l.setScaleX(c);this._tweens.addSimpleTween(e,r,o,n,a,l.getScaleX(),t,d,i?()=>this._deleteFromScene():null)}addObjectScaleYTween(e,t,n,o,i,s){this._addObjectScaleYTween(e,t,n,o/1e3,i,s,this.owner.getRuntimeScene(),g)}addObjectScaleYTween2(e,t,n,o,i,s){this._addObjectScaleYTween(e,t,n,o,i,s,this.owner,m)}_addObjectScaleYTween(e,t,n,o,i,s,r,a){const l=this.owner;if(!O(l))return;const d=s?c=>{const b=l.getCenterYInScene();l.setScaleY(c),l.setCenterYInScene(b)}:c=>l.setScaleY(c);this._tweens.addSimpleTween(e,r,o,n,a,l.getScaleY(),t,d,i?()=>this._deleteFromScene():null)}addObjectOpacityTween(e,t,n,o,i){this._addObjectOpacityTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectOpacityTween2(e,t,n,o,i){this._addObjectOpacityTween(e,t,n,o,i,this.owner)}_addObjectOpacityTween(e,t,n,o,i,s){const r=this.owner;!R(r)||this._tweens.addSimpleTween(e,s,o,n,g,r.getOpacity(),t,a=>r.setOpacity(a),i?()=>this._deleteFromScene():null)}addNumberEffectPropertyTween(e,t,n,o,i,s,r,a){const l=this.owner.getRendererEffects()[o];l||p.error(`The object "${this.owner.name}" doesn't have any effect called "${o}"`),this._tweens.addSimpleTween(t,this.owner,r,s,g,l?l.getDoubleParameter(i):0,n,d=>{l&&l.updateDoubleParameter(i,d)},a?()=>this._deleteFromScene():null)}addColorEffectPropertyTween(e,t,n,o,i,s,r,a){const l=this.owner.getRendererEffects()[o];l||p.error(`The object "${this.owner.name}" doesn't have any effect called "${o}"`);const d=w.hexNumberToRGB(l?l.getColorParameter(i):0),c=w.rgbOrHexToRGBColor(n);this._tweens.addMultiTween(t,this.owner,r,s,g,w.evtTools.tween.rgbToHsl(d.r,d.g,d.b),w.evtTools.tween.rgbToHsl(c[0],c[1],c[2]),([b,T,f])=>{if(l){const u=w.evtTools.tween.hslToRgb(b,T,f);l.updateColorParameter(i,w.rgbToHexNumber(u[0],u[1],u[2]))}},a?()=>this._deleteFromScene():null)}addObjectColorTween(e,t,n,o,i,s){this._addObjectColorTween(e,t,n,o/1e3,i,s,this.owner.getRuntimeScene())}addObjectColorTween2(e,t,n,o,i,s=!0){this._addObjectColorTween(e,t,n,o,i,s,this.owner)}_addObjectColorTween(e,t,n,o,i,s,r){const a=this.owner;if(!C(a))return;const l=w.rgbOrHexToRGBColor(a.getColor()),d=w.rgbOrHexToRGBColor(t);let c,b,T;s?(c=w.evtTools.tween.rgbToHsl(l[0],l[1],l[2]),b=w.evtTools.tween.rgbToHsl(d[0],d[1],d[2]),T=([f,u,j])=>{const _=w.evtTools.tween.hslToRgb(f,u,j);a.setColor(Math.floor(_[0])+";"+Math.floor(_[1])+";"+Math.floor(_[2]))}):(c=l,b=d,T=([f,u,j])=>{a.setColor(Math.floor(f)+";"+Math.floor(u)+";"+Math.floor(j))}),this._tweens.addMultiTween(e,r,o,n,g,c,b,T,i?()=>this._deleteFromScene():null)}addObjectColorHSLTween(e,t,n,o,i,s,r,a){this._addObjectColorHSLTween(e,t,n,o,i,s,r/1e3,a,this.owner.getRuntimeScene())}addObjectColorHSLTween2(e,t,n,o,i,s,r,a){this._addObjectColorHSLTween(e,t,n,o,i,s,r,a,this.owner)}_addObjectColorHSLTween(e,t,n,o,i,s,r,a,l){if(!C(this.owner))return;const d=this.owner,c=d.getColor().split(";");if(c.length<3)return;const b=w.evtTools.tween.rgbToHsl(parseFloat(c[0]),parseFloat(c[1]),parseFloat(c[2])),T=n?t:b[0],f=o===-1?b[1]:Math.min(Math.max(o,0),100),u=i===-1?b[2]:Math.min(Math.max(i,0),100);this._tweens.addMultiTween(e,l,r,s,g,b,[T,f,u],([j,_,P])=>{const v=w.evtTools.tween.hslToRgb(j,_,P);d.setColor(Math.floor(v[0])+";"+Math.floor(v[1])+";"+Math.floor(v[2]))},a?()=>this._deleteFromScene():null)}addTextObjectCharacterSizeTween(e,t,n,o,i){this._addTextObjectCharacterSizeTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene(),g)}addTextObjectCharacterSizeTween2(e,t,n,o,i){this._addTextObjectCharacterSizeTween(e,t,n,o,i,this.owner,m)}_addTextObjectCharacterSizeTween(e,t,n,o,i,s,r){const a=this.owner;!F(a)||this._tweens.addSimpleTween(e,s,o,n,r,a.getCharacterSize(),t,l=>a.setCharacterSize(l),i?()=>this._deleteFromScene():null)}addObjectWidthTween(e,t,n,o,i){this._addObjectWidthTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectWidthTween2(e,t,n,o,i){this._addObjectWidthTween(e,t,n,o,i,this.owner)}_addObjectWidthTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getWidth(),t,r=>this.owner.setWidth(r),i?()=>this._deleteFromScene():null)}addObjectHeightTween(e,t,n,o,i){this._addObjectHeightTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectHeightTween2(e,t,n,o,i){this._addObjectHeightTween(e,t,n,o,i,this.owner)}_addObjectHeightTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getHeight(),t,r=>this.owner.setHeight(r),i?()=>this._deleteFromScene():null)}addObjectDepthTween(e,t,n,o,i){this._addObjectDepthTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectDepthTween2(e,t,n,o,i,s){this._addObjectDepthTween(t,n,o,i,s,this.owner)}_addObjectDepthTween(e,t,n,o,i,s){const{owner:r}=this;!S(r)||this._tweens.addSimpleTween(e,s,o,n,g,r.getDepth(),t,a=>r.setDepth(a),i?()=>this._deleteFromScene():null)}isPlaying(e){return this._tweens.isPlaying(e)}exists(e){return this._tweens.exists(e)}hasFinished(e){return this._tweens.hasFinished(e)}pauseTween(e){this._isActive&&this._tweens.pauseTween(e)}stopTween(e,t){this._isActive&&this._tweens.stopTween(e,t)}resumeTween(e){this._isActive&&this._tweens.resumeTween(e)}removeTween(e){this._tweens.removeTween(e)}getProgress(e){return this._tweens.getProgress(e)}getValue(e){return this._tweens.getValue(e)}onDeActivate(){this._isActive=!1}onActivate(){this._isActive=!0}}w.TweenRuntimeBehavior=X,w.registerBehavior("Tween::TweenBehavior",w.TweenRuntimeBehavior)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(w){const p=new w.Logger("Tween");function O(h){return h.setScaleX&&h.setScaleY&&h.getScaleX&&h.getScaleY}function R(h){return h.setOpacity&&h.getOpacity}function S(h){return h.getZ&&h.setZ}function C(h){return h.setColor&&h.getColor}function F(h){return h.setCharacterSize&&h.getCharacterSize}const g=w.evtTools.common.lerp,m=w.evtTools.common.exponentialInterpolation;class X extends w.RuntimeBehavior{constructor(e,t,n){super(e,t,n);this._tweens=new w.evtTools.tween.TweenManager;this._isActive=!0}updateFromBehaviorData(e,t){return!0}doStepPreEvents(e){this._tweens.step()}_deleteFromScene(){this.owner.deleteFromScene()}addVariableTween(e,t,n,o,i,s,r){this._tweens.addSimpleTween(e,this.owner.getRuntimeScene(),s/1e3,i,g,n,o,a=>t.setNumber(a),r?()=>this._deleteFromScene():null)}addVariableTween2(e,t,n,o,i,s){this._addVariableTween(e,t,n,o,i/1e3,s,this.owner.getRuntimeScene())}addVariableTween3(e,t,n,o,i,s){this._addVariableTween(e,t,n,o,i,s,this.owner)}_addVariableTween(e,t,n,o,i,s,r){t.getType()==="number"&&this._tweens.addSimpleTween(e,r,i,o,g,t.getValue(),n,a=>t.setNumber(a),s?()=>this._deleteFromScene():null)}addValueTween(e,t,n,o,i,s,r){this._tweens.addSimpleTween(e,this.owner,i,o,s?m:g,t,n,a=>{},r?()=>this._deleteFromScene():null)}addObjectPositionTween(e,t,n,o,i,s){this._addObjectPositionTween(e,t,n,o,i/1e3,s,this.owner.getRuntimeScene())}addObjectPositionTween2(e,t,n,o,i,s){this._addObjectPositionTween(e,t,n,o,i,s,this.owner)}_addObjectPositionTween(e,t,n,o,i,s,r){this._tweens.addMultiTween(e,r,i,o,g,[this.owner.getX(),this.owner.getY()],[t,n],([a,l])=>this.owner.setPosition(a,l),s?()=>this._deleteFromScene():null)}addObjectPositionXTween(e,t,n,o,i){this._addObjectPositionXTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectPositionXTween2(e,t,n,o,i){this._addObjectPositionXTween(e,t,n,o,i,this.owner)}_addObjectPositionXTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getX(),t,r=>this.owner.setX(r),i?()=>this._deleteFromScene():null)}addObjectPositionYTween(e,t,n,o,i){this._addObjectPositionYTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectPositionYTween2(e,t,n,o,i){this._addObjectPositionYTween(e,t,n,o,i,this.owner)}_addObjectPositionYTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getY(),t,r=>this.owner.setY(r),i?()=>this._deleteFromScene():null)}addObjectPositionZTween(e,t,n,o,i){this._addObjectPositionZTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectPositionZTween2(e,t,n,o,i,s){this._addObjectPositionZTween(t,n,o,i,s,this.owner)}_addObjectPositionZTween(e,t,n,o,i,s){const{owner:r}=this;!S(r)||this._tweens.addSimpleTween(e,s,o,n,g,r.getZ(),t,a=>r.setZ(a),i?()=>this._deleteFromScene():null)}addObjectAngleTween(e,t,n,o,i){this._addObjectAngleTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectAngleTween2(e,t,n,o,i){this._addObjectAngleTween(e,t,n,o,i,this.owner)}_addObjectAngleTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getAngle(),t,r=>this.owner.setAngle(r),i?()=>this._deleteFromScene():null)}addObjectRotationXTween(e,t,n,o,i,s){const{owner:r}=this;!S(r)||this._tweens.addSimpleTween(t,this.owner,i,o,g,r.getRotationX(),n,a=>r.setRotationX(a),s?()=>this._deleteFromScene():null)}addObjectRotationYTween(e,t,n,o,i,s){const{owner:r}=this;!S(r)||this._tweens.addSimpleTween(t,this.owner,i,o,g,r.getRotationY(),n,a=>r.setRotationY(a),s?()=>this._deleteFromScene():null)}addObjectScaleTween(e,t,n,o,i,s,r){this._addObjectScaleTween(e,t,n,o,i/1e3,s,r,this.owner.getRuntimeScene(),g)}addObjectScaleTween2(e,t,n,o,i,s,r){this._addObjectScaleTween(e,t,n,o,i,s,r,this.owner,m)}_addObjectScaleTween(e,t,n,o,i,s,r,a,l){const d=this.owner;if(!O(d))return;t<0&&(t=0),n<0&&(n=0);const c=r?([b,T])=>{const f=d.getCenterXInScene(),u=d.getCenterYInScene();d.setScaleX(b),d.setScaleY(T),d.setCenterPositionInScene(f,u)}:([b,T])=>{d.setScaleX(b),d.setScaleY(T)};this._tweens.addMultiTween(e,a,i,o,l,[d.getScaleX(),d.getScaleY()],[t,n],c,s?()=>this._deleteFromScene():null)}addObjectScaleTween3(e,t,n,o,i,s){this._addObjectScaleXTween(e,t,n,o,i,s,this.owner,m);const r=this.owner;if(!O(r))return;const a=S(r)?r:null,l=s?d=>{const c=r.getCenterXInScene(),b=r.getCenterYInScene(),T=a?a.getCenterZInScene():0;r.setScale(d),r.setCenterXInScene(c),r.setCenterYInScene(b),a&&a.setCenterZInScene(T)}:d=>r.setScale(d);this._tweens.addSimpleTween(e,this.owner,o,n,m,r.getScale(),t,l,i?()=>this._deleteFromScene():null)}addObjectScaleXTween(e,t,n,o,i,s){this._addObjectScaleXTween(e,t,n,o/1e3,i,s,this.owner.getRuntimeScene(),g)}addObjectScaleXTween2(e,t,n,o,i,s){this._addObjectScaleXTween(e,t,n,o,i,s,this.owner,m)}_addObjectScaleXTween(e,t,n,o,i,s,r,a){const l=this.owner;if(!O(l))return;const d=s?c=>{const b=l.getCenterXInScene();l.setScaleX(c),l.setCenterXInScene(b)}:c=>l.setScaleX(c);this._tweens.addSimpleTween(e,r,o,n,a,l.getScaleX(),t,d,i?()=>this._deleteFromScene():null)}addObjectScaleYTween(e,t,n,o,i,s){this._addObjectScaleYTween(e,t,n,o/1e3,i,s,this.owner.getRuntimeScene(),g)}addObjectScaleYTween2(e,t,n,o,i,s){this._addObjectScaleYTween(e,t,n,o,i,s,this.owner,m)}_addObjectScaleYTween(e,t,n,o,i,s,r,a){const l=this.owner;if(!O(l))return;const d=s?c=>{const b=l.getCenterYInScene();l.setScaleY(c),l.setCenterYInScene(b)}:c=>l.setScaleY(c);this._tweens.addSimpleTween(e,r,o,n,a,l.getScaleY(),t,d,i?()=>this._deleteFromScene():null)}addObjectOpacityTween(e,t,n,o,i){this._addObjectOpacityTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectOpacityTween2(e,t,n,o,i){this._addObjectOpacityTween(e,t,n,o,i,this.owner)}_addObjectOpacityTween(e,t,n,o,i,s){const r=this.owner;!R(r)||this._tweens.addSimpleTween(e,s,o,n,g,r.getOpacity(),t,a=>r.setOpacity(a),i?()=>this._deleteFromScene():null)}addNumberEffectPropertyTween(e,t,n,o,i,s,r,a){const l=this.owner.getRendererEffects()[o];l||p.error(`The object "${this.owner.name}" doesn't have any effect called "${o}"`),this._tweens.addSimpleTween(t,this.owner,r,s,g,l?l.getDoubleParameter(i):0,n,d=>{l&&l.updateDoubleParameter(i,d)},a?()=>this._deleteFromScene():null)}addColorEffectPropertyTween(e,t,n,o,i,s,r,a){const l=this.owner.getRendererEffects()[o];l||p.error(`The object "${this.owner.name}" doesn't have any effect called "${o}"`);const d=w.hexNumberToRGB(l?l.getColorParameter(i):0),c=w.rgbOrHexToRGBColor(n);this._tweens.addMultiTween(t,this.owner,r,s,g,w.evtTools.tween.rgbToHsl(d.r,d.g,d.b),w.evtTools.tween.rgbToHsl(c[0],c[1],c[2]),([b,T,f])=>{if(l){const u=w.evtTools.tween.hslToRgb(b,T,f);l.updateColorParameter(i,w.rgbToHexNumber(u[0],u[1],u[2]))}},a?()=>this._deleteFromScene():null)}addObjectColorTween(e,t,n,o,i,s){this._addObjectColorTween(e,t,n,o/1e3,i,s,this.owner.getRuntimeScene())}addObjectColorTween2(e,t,n,o,i,s=!0){this._addObjectColorTween(e,t,n,o,i,s,this.owner)}_addObjectColorTween(e,t,n,o,i,s,r){const a=this.owner;if(!C(a))return;const l=w.rgbOrHexToRGBColor(a.getColor()),d=w.rgbOrHexToRGBColor(t);let c,b,T;s?(c=w.evtTools.tween.rgbToHsl(l[0],l[1],l[2]),b=w.evtTools.tween.rgbToHsl(d[0],d[1],d[2]),T=([f,u,j])=>{const _=w.evtTools.tween.hslToRgb(f,u,j);a.setColor(Math.floor(_[0])+";"+Math.floor(_[1])+";"+Math.floor(_[2]))}):(c=l,b=d,T=([f,u,j])=>{a.setColor(Math.floor(f)+";"+Math.floor(u)+";"+Math.floor(j))}),this._tweens.addMultiTween(e,r,o,n,g,c,b,T,i?()=>this._deleteFromScene():null)}addObjectColorHSLTween(e,t,n,o,i,s,r,a){this._addObjectColorHSLTween(e,t,n,o,i,s,r/1e3,a,this.owner.getRuntimeScene())}addObjectColorHSLTween2(e,t,n,o,i,s,r,a){this._addObjectColorHSLTween(e,t,n,o,i,s,r,a,this.owner)}_addObjectColorHSLTween(e,t,n,o,i,s,r,a,l){if(!C(this.owner))return;const d=this.owner,c=d.getColor().split(";");if(c.length<3)return;const b=w.evtTools.tween.rgbToHsl(parseFloat(c[0]),parseFloat(c[1]),parseFloat(c[2])),T=n?t:b[0],f=o===-1?b[1]:Math.min(Math.max(o,0),100),u=i===-1?b[2]:Math.min(Math.max(i,0),100);this._tweens.addMultiTween(e,l,r,s,g,b,[T,f,u],([j,_,P])=>{const v=w.evtTools.tween.hslToRgb(j,_,P);d.setColor(Math.floor(v[0])+";"+Math.floor(v[1])+";"+Math.floor(v[2]))},a?()=>this._deleteFromScene():null)}addTextObjectCharacterSizeTween(e,t,n,o,i){this._addTextObjectCharacterSizeTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene(),g)}addTextObjectCharacterSizeTween2(e,t,n,o,i){this._addTextObjectCharacterSizeTween(e,t,n,o,i,this.owner,m)}_addTextObjectCharacterSizeTween(e,t,n,o,i,s,r){const a=this.owner;!F(a)||this._tweens.addSimpleTween(e,s,o,n,r,a.getCharacterSize(),t,l=>a.setCharacterSize(l),i?()=>this._deleteFromScene():null)}addObjectWidthTween(e,t,n,o,i){this._addObjectWidthTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectWidthTween2(e,t,n,o,i){this._addObjectWidthTween(e,t,n,o,i,this.owner)}_addObjectWidthTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getWidth(),t,r=>this.owner.setWidth(r),i?()=>this._deleteFromScene():null)}addObjectHeightTween(e,t,n,o,i){this._addObjectHeightTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectHeightTween2(e,t,n,o,i){this._addObjectHeightTween(e,t,n,o,i,this.owner)}_addObjectHeightTween(e,t,n,o,i,s){this._tweens.addSimpleTween(e,s,o,n,g,this.owner.getHeight(),t,r=>this.owner.setHeight(r),i?()=>this._deleteFromScene():null)}addObjectDepthTween(e,t,n,o,i){this._addObjectDepthTween(e,t,n,o/1e3,i,this.owner.getRuntimeScene())}addObjectDepthTween2(e,t,n,o,i,s){this._addObjectDepthTween(t,n,o,i,s,this.owner)}_addObjectDepthTween(e,t,n,o,i,s){const{owner:r}=this;!S(r)||this._tweens.addSimpleTween(e,s,o,n,g,r.getDepth(),t,a=>r.setDepth(a),i?()=>this._deleteFromScene():null)}isPlaying(e){return this._tweens.isPlaying(e)}exists(e){return this._tweens.exists(e)}hasFinished(e){return this._tweens.hasFinished(e)}pauseTween(e){this._isActive&&this._tweens.pauseTween(e)}stopTween(e,t){this._isActive&&this._tweens.stopTween(e,t)}resumeTween(e){this._isActive&&this._tweens.resumeTween(e)}removeTween(e){this._tweens.removeTween(e)}getProgress(e){return this._tweens.getProgress(e)}getValue(e){return this._tweens.getValue(e)}onDeActivate(){this._isActive=!1}onActivate(){this._isActive=!0}}w.TweenRuntimeBehavior=X,w.registerBehavior("Tween::TweenBehavior",w.TweenRuntimeBehavior)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=tweenruntimebehavior.js.map