Files

3 lines
10 KiB
JavaScript
Raw Permalink Normal View History

2026-07-28 10:47:32 -04:00
var gdjs;(function(f){class d extends f.RuntimeBehavior{constructor(e,t,s){super(e,t,s);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._clearInputsBetweenFrames=!0;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(e){return this._clearInputsBetweenFrames=!0,this._ignoreDefaultControlsAsSyncedByNetwork=!1,{...super.getNetworkSyncData(e),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,t){super.updateFromNetworkSyncData(e,t);const s=e.props;s.a!==void 0&&(this._angle=s.a),s.xv!==void 0&&(this._xVelocity=s.xv),s.yv!==void 0&&(this._yVelocity=s.yv),s.as!==void 0&&(this._angularSpeed=s.as),s.lk!==void 0&&(this._leftKey=s.lk),s.rk!==void 0&&(this._rightKey=s.rk),s.uk!==void 0&&(this._upKey=s.uk),s.dk!==void 0&&(this._downKey=s.dk),s.wsu!==void 0&&(this._wasStickUsed=s.wsu),s.sa!==void 0&&(this._stickAngle=s.sa),s.sf!==void 0&&(this._stickForce=s.sf),this._clearInputsBetweenFrames=!!t.clearInputs,this._ignoreDefaultControlsAsSyncedByNetwork=!t.keepControl}applyBehaviorOverriding(e){return e.allowDiagonals!==void 0&&(this._allowDiagonals=e.allowDiagonals),e.acceleration!==void 0&&(this._acceleration=e.acceleration),e.deceleration!==void 0&&(this._deceleration=e.deceleration),e.maxSpeed!==void 0&&(this._maxSpeed=e.maxSpeed),e.angularMaxSpeed!==void 0&&(this._angularMaxSpeed=e.angularMaxSpeed),e.rotateObject!==void 0&&(this._rotateObject=e.rotateObject),e.angleOffset!==void 0&&(this._angleOffset=e.angleOffset),e.ignoreDefaultControls!==void 0&&(this._ignoreDefaultControls=e.ignoreDefaultControls),(e.platformType!==void 0||e.customIsometryAngle!==void 0)&&this.setViewpoint(e.platformType,e.customIsometryAngle),e.movementAngleOffset!==void 0&&(this._movementAngleOffset=e.movementAngleOffset),!0}setViewpoint(e,t){e==="PixelIsometry"?this._basisTransformation=new f.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.atan(.5)):e==="TrueIsometry"?this._basisTransformation=new f.TopDownMovementRuntimeBehavior.IsometryTransformation(Math.PI/6):e==="CustomIsometry"?this._basisTransformation=new f.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(){ret
//# sourceMappingURL=topdownmovementruntimebehavior.js.map