gdcore-tools 2.0.0-gd-v5.5.232-autobuild → 2.0.0-gd-v5.5.234-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/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  2. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  3. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js +1 -1
  4. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
  6. package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/JsExtension.js +60 -9
  8. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  9. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  10. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  11. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  12. package/dist/Runtime/Extensions/BBText/JsExtension.js +6 -6
  13. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +6 -6
  14. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +10 -10
  15. package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +20 -7
  16. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  17. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  18. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
  19. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
  20. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  21. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  22. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
  23. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
  24. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
  25. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
  26. package/dist/Runtime/Extensions/TextInput/JsExtension.js +11 -11
  27. package/dist/Runtime/Extensions/TileMap/JsExtension.js +3 -3
  28. package/dist/Runtime/Model3DManager.js +1 -1
  29. package/dist/Runtime/Model3DManager.js.map +2 -2
  30. package/dist/Runtime/ResourceLoader.js +1 -1
  31. package/dist/Runtime/ResourceLoader.js.map +2 -2
  32. package/dist/Runtime/RuntimeLayer.js +1 -1
  33. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  34. package/dist/Runtime/events-tools/objecttools.js +1 -1
  35. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  36. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js +1 -1
  37. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
  38. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  39. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  40. package/dist/Runtime/jsonmanager.js +1 -1
  41. package/dist/Runtime/jsonmanager.js.map +2 -2
  42. package/dist/Runtime/logger.js +1 -1
  43. package/dist/Runtime/logger.js.map +2 -2
  44. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js +1 -1
  45. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
  46. package/dist/Runtime/pixi-renderers/pixi-effects-manager.js.map +2 -2
  47. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  48. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  49. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  50. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  51. package/dist/Runtime/runtimegame.js +1 -1
  52. package/dist/Runtime/runtimegame.js.map +2 -2
  53. package/dist/Runtime/runtimescene.js +1 -1
  54. package/dist/Runtime/runtimescene.js.map +2 -2
  55. package/dist/Runtime/scenestack.js +1 -1
  56. package/dist/Runtime/scenestack.js.map +2 -2
  57. package/dist/Runtime/types/project-data.d.ts +6 -1
  58. package/dist/lib/libGD.cjs +1 -1
  59. package/dist/lib/libGD.wasm +0 -0
  60. package/gd.d.ts +21 -0
  61. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.ts"],
4
- "sourcesContent": ["/// <reference path=\"./jolt-physics.d.ts\" />\n\nnamespace gdjs {\n interface PhysicsCar3DNetworkSyncDataType {\n lek: boolean;\n rik: boolean;\n upk: boolean;\n dok: boolean;\n hbk: boolean;\n asf: float;\n ssf: float;\n etm: float;\n esm: float;\n ei: float;\n }\n\n export interface PhysicsCar3DNetworkSyncData extends BehaviorNetworkSyncData {\n props: PhysicsCar3DNetworkSyncDataType;\n }\n\n type Physics3D = {\n behavior: gdjs.Physics3DRuntimeBehavior;\n };\n\n export class PhysicsCar3DRuntimeBehavior\n extends gdjs.RuntimeBehavior\n implements gdjs.Physics3DRuntimeBehavior.Physics3DHook\n {\n owner3D: gdjs.RuntimeObject3D;\n private _physics3DBehaviorName: string;\n private _physics3D: Physics3D | null = null;\n _vehicleController: Jolt.WheeledVehicleController | null = null;\n _stepListener: Jolt.VehicleConstraintStepListener | null = null;\n _vehicleCollisionTester: Jolt.VehicleCollisionTesterCastCylinder | null =\n null;\n /**\n * sharedData is a reference to the shared data of the scene, that registers\n * every physics behavior that is created so that collisions can be cleared\n * before stepping the world.\n */\n _sharedData: gdjs.Physics3DSharedData;\n private _destroyedDuringFrameLogic: boolean = false;\n\n // Readonly configuration\n\n _steerAngleMax;\n private _beginningSteerSpeed: float;\n private _endSteerSpeed: float;\n _gearRatios: Array<float>;\n _reverseGearRatios: Array<float>;\n private _backWheelOffsetX: float;\n private _frontWheelOffsetX: float;\n private _wheelOffsetY: float;\n private _wheelOffsetZ: float;\n private _wheelRadius: float;\n private _wheelWidth: float;\n private _brakeTorqueMax: float;\n private _handBrakeTorqueMax: float;\n _hasBackWheelDrive: boolean;\n _hasFrontWheelDrive: boolean;\n _pitchRollAngleMax: float;\n\n // Mutable configuration\n\n _engineTorqueMax: float;\n /** in RPM (rotation per minute) */\n _engineSpeedMax: float;\n _engineInertia: float;\n\n // State\n\n private _currentSteerRatio: float = 0;\n /** Used to make sure the car is stopped before going backward. */\n _previousForward = 1;\n\n private _hasPressedForwardKey: boolean = false;\n private _hasPressedBackwardKey: boolean = false;\n private _hasPressedRightKey: boolean = false;\n private _hasPressedLeftKey: boolean = false;\n private _hasPressedHandBrakeKey: boolean = false;\n private _acceleratorStickForce: float = 0;\n private _steeringStickForce: float = 0;\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 _wasForwardKeyPressed: boolean = false;\n private _wasBackwardKeyPressed: boolean = false;\n private _wasHandBrakeKeyPressed: boolean = false;\n private _previousAcceleratorStickForce: float = 0;\n private _previousSteeringStickForce: 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 private _dontClearInputsBetweenFrames: boolean = false;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject3D\n ) {\n super(instanceContainer, behaviorData, owner);\n this.owner3D = owner;\n this._physics3DBehaviorName = behaviorData.physics3D;\n this._sharedData = gdjs.Physics3DSharedData.getSharedData(\n instanceContainer.getScene(),\n behaviorData.Physics3D\n );\n this._steerAngleMax = behaviorData.steerAngleMax;\n this._beginningSteerSpeed = behaviorData.beginningSteerSpeed;\n this._endSteerSpeed = behaviorData.endSteerSpeed;\n this._engineTorqueMax = behaviorData.engineTorqueMax;\n this._engineSpeedMax = behaviorData.engineSpeedMax;\n this._engineInertia = behaviorData.engineInertia;\n this._reverseGearRatios = [behaviorData.reverseGearRatio1];\n this._gearRatios = [\n behaviorData.gearRatio1,\n behaviorData.gearRatio2,\n behaviorData.gearRatio3,\n behaviorData.gearRatio4,\n behaviorData.gearRatio5,\n behaviorData.gearRatio6,\n ];\n this._backWheelOffsetX = behaviorData.backWheelOffsetX;\n this._frontWheelOffsetX = behaviorData.frontWheelOffsetX;\n this._wheelOffsetY = behaviorData.wheelOffsetY;\n this._wheelOffsetZ = behaviorData.wheelOffsetZ;\n this._wheelRadius = behaviorData.wheelRadius;\n this._wheelWidth = behaviorData.wheelWidth;\n this._brakeTorqueMax = behaviorData.brakeTorqueMax;\n this._handBrakeTorqueMax = behaviorData.handBrakeTorqueMax;\n this._hasBackWheelDrive = behaviorData.hasBackWheelDrive;\n this._hasFrontWheelDrive = behaviorData.hasFrontWheelDrive;\n this._pitchRollAngleMax = behaviorData.pitchRollAngleMax;\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n getPhysics3D(): Physics3D | null {\n if (this._destroyedDuringFrameLogic) {\n return null;\n }\n if (this._physics3D) {\n return this._physics3D;\n }\n const behavior = this.owner.getBehavior(\n this._physics3DBehaviorName\n ) as gdjs.Physics3DRuntimeBehavior;\n\n const sharedData = behavior._sharedData;\n\n this._physics3D = {\n behavior,\n };\n sharedData.registerHook(this);\n\n behavior.bodyUpdater =\n new gdjs.PhysicsCar3DRuntimeBehavior.VehicleBodyUpdater(\n this,\n behavior.bodyUpdater\n );\n behavior.recreateBody();\n\n return this._physics3D;\n }\n\n override updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.steerAngleMax !== newBehaviorData.steerAngleMax) {\n this.setSteerAngleMax(newBehaviorData.steerAngleMax);\n }\n if (\n oldBehaviorData.beginningSteerSpeed !==\n newBehaviorData.beginningSteerSpeed\n ) {\n this.setBeginningSteerSpeed(newBehaviorData.beginningSteerSpeed);\n }\n if (oldBehaviorData.endSteerSpeed !== newBehaviorData.endSteerSpeed) {\n this.setEndSteerSpeed(newBehaviorData.endSteerSpeed);\n }\n if (oldBehaviorData.engineTorqueMax !== newBehaviorData.engineTorqueMax) {\n this.setEngineTorqueMax(newBehaviorData.engineTorqueMax);\n }\n if (oldBehaviorData.engineSpeedMax !== newBehaviorData.engineSpeedMax) {\n this.setEngineSpeedMax(newBehaviorData.engineSpeedMax);\n }\n if (oldBehaviorData.engineInertia !== newBehaviorData.engineInertia) {\n this.setEngineInertia(newBehaviorData.engineInertia);\n }\n if (\n oldBehaviorData.reverseGearRatio1 !== newBehaviorData.reverseGearRatio1\n ) {\n this.setGearRatio(-1, newBehaviorData.reverseGearRatio1);\n }\n if (oldBehaviorData.gearRatio1 !== newBehaviorData.gearRatio1) {\n this.setGearRatio(1, newBehaviorData.gearRatio1);\n }\n if (oldBehaviorData.gearRatio2 !== newBehaviorData.gearRatio2) {\n this.setGearRatio(2, newBehaviorData.gearRatio2);\n }\n if (oldBehaviorData.gearRatio3 !== newBehaviorData.gearRatio3) {\n this.setGearRatio(3, newBehaviorData.gearRatio3);\n }\n if (oldBehaviorData.gearRatio4 !== newBehaviorData.gearRatio4) {\n this.setGearRatio(4, newBehaviorData.gearRatio4);\n }\n if (oldBehaviorData.gearRatio5 !== newBehaviorData.gearRatio5) {\n this.setGearRatio(5, newBehaviorData.gearRatio5);\n }\n if (oldBehaviorData.gearRatio6 !== newBehaviorData.gearRatio6) {\n this.setGearRatio(6, newBehaviorData.gearRatio6);\n }\n if (\n oldBehaviorData.backWheelOffsetX !== newBehaviorData.backWheelOffsetX\n ) {\n this.setBackWheelOffsetX(newBehaviorData.backWheelOffsetX);\n }\n if (\n oldBehaviorData.frontWheelOffsetX !== newBehaviorData.frontWheelOffsetX\n ) {\n this.setFrontWheelOffsetX(newBehaviorData.frontWheelOffsetX);\n }\n if (oldBehaviorData.wheelOffsetY !== newBehaviorData.wheelOffsetY) {\n this.setWheelOffsetY(newBehaviorData.wheelOffsetY);\n }\n if (oldBehaviorData.wheelOffsetZ !== newBehaviorData.wheelOffsetZ) {\n this.setWheelOffsetZ(newBehaviorData.wheelOffsetZ);\n }\n if (oldBehaviorData.wheelRadius !== newBehaviorData.wheelRadius) {\n this.setWheelRadius(newBehaviorData.wheelRadius);\n }\n if (oldBehaviorData.wheelWidth !== newBehaviorData.wheelWidth) {\n this.setWheelWidth(newBehaviorData.wheelWidth);\n }\n if (oldBehaviorData.brakeTorqueMax !== newBehaviorData.brakeTorqueMax) {\n this.setBrakeTorqueMax(newBehaviorData.brakeTorqueMax);\n }\n if (\n oldBehaviorData.handBrakeTorqueMax !==\n newBehaviorData.handBrakeTorqueMax\n ) {\n this.setHandBrakeTorqueMax(newBehaviorData.handBrakeTorqueMax);\n }\n if (\n oldBehaviorData.hasBackWheelDrive !== newBehaviorData.hasBackWheelDrive\n ) {\n this.setBackWheelDrive(newBehaviorData.hasBackWheelDrive);\n }\n if (\n oldBehaviorData.hasFrontWheelDrive !==\n newBehaviorData.hasFrontWheelDrive\n ) {\n this.setFrontWheelDrive(newBehaviorData.hasFrontWheelDrive);\n }\n if (\n oldBehaviorData.pitchRollAngleMax !== newBehaviorData.pitchRollAngleMax\n ) {\n this.setPitchRollAngleMax(newBehaviorData.pitchRollAngleMax);\n }\n return true;\n }\n\n override getNetworkSyncData(): PhysicsCar3DNetworkSyncData {\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\n return {\n ...super.getNetworkSyncData(),\n props: {\n lek: this._wasLeftKeyPressed,\n rik: this._wasRightKeyPressed,\n upk: this._wasForwardKeyPressed,\n dok: this._wasBackwardKeyPressed,\n hbk: this._wasHandBrakeKeyPressed,\n asf: this._previousAcceleratorStickForce,\n ssf: this._previousSteeringStickForce,\n etm: this._engineTorqueMax,\n esm: this._engineSpeedMax,\n ei: this._engineInertia,\n },\n };\n }\n\n override updateFromNetworkSyncData(\n networkSyncData: PhysicsCar3DNetworkSyncData\n ) {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n this._hasPressedForwardKey = behaviorSpecificProps.upk;\n this._hasPressedBackwardKey = behaviorSpecificProps.dok;\n this._hasPressedLeftKey = behaviorSpecificProps.lek;\n this._hasPressedRightKey = behaviorSpecificProps.rik;\n this._hasPressedHandBrakeKey = behaviorSpecificProps.hbk;\n this._acceleratorStickForce = behaviorSpecificProps.asf;\n this._steeringStickForce = behaviorSpecificProps.ssf;\n this._engineTorqueMax = behaviorSpecificProps.etm;\n this._engineSpeedMax = behaviorSpecificProps.esm;\n this._engineInertia = behaviorSpecificProps.ei;\n\n // When the object is synchronized from the network, the inputs must not be cleared.\n this._dontClearInputsBetweenFrames = true;\n }\n\n _getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n result.Set(0, 0, 0);\n return result;\n }\n const { behavior } = physics3D;\n // Same as for characters, the origin is at its feet:\n // - the center is used for X and Y because Box3D origin is at the top-left corner\n // - the origin is used for Z because, when the character is made smaller,\n // it must stay on the ground and not fell from its old size.\n result.Set(\n this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,\n this.owner3D.getZ() * this._sharedData.worldInvScale +\n behavior._shapeHalfDepth\n );\n return result;\n }\n\n override onDeActivate() {\n if (this._stepListener) {\n this._sharedData.physicsSystem.RemoveStepListener(this._stepListener);\n }\n }\n\n override onActivate() {\n if (this._stepListener) {\n this._sharedData.physicsSystem.AddStepListener(this._stepListener);\n }\n }\n\n override onDestroy() {\n if (!this._vehicleController) {\n return;\n }\n this._destroyedDuringFrameLogic = true;\n this.onDeActivate();\n if (this._stepListener) {\n // stepListener is removed by onDeActivate\n Jolt.destroy(this._stepListener);\n this._stepListener = null;\n }\n const constraint = this._vehicleController.GetConstraint();\n this._sharedData.physicsSystem.RemoveConstraint(constraint);\n // The controller is destroyed with the constraint.\n this._vehicleController = null;\n // VehicleConstraint.mVehicleCollisionTester is a RefConst (smart pointer).\n // It is destroyed with the constraint.\n this._vehicleCollisionTester = null;\n if (this._physics3D) {\n this._physics3D = null;\n }\n }\n\n override doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Trigger createAndAddBody()\n this.getPhysics3D();\n }\n\n override doStepPostEvents(\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n // Trigger createAndAddBody()\n this.getPhysics3D();\n }\n\n doBeforePhysicsStep(timeDelta: float): void {\n if (!this.activated()) {\n return;\n }\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n if (!this._vehicleController) {\n return;\n }\n const carBody = behavior._body;\n if (!carBody) {\n return;\n }\n\n const steeringControl =\n this._steeringStickForce ||\n (this._hasPressedLeftKey ? -1 : 0) + (this._hasPressedRightKey ? 1 : 0);\n if (steeringControl === 0) {\n this._currentSteerRatio = 0;\n } else {\n const steerSpeed = gdjs.evtTools.common.lerp(\n this._beginningSteerSpeed,\n this._endSteerSpeed,\n Math.abs(this._currentSteerRatio)\n );\n if (steeringControl < 0) {\n // Avoid to much latency when changing of direction\n this._currentSteerRatio = Math.min(0, this._currentSteerRatio);\n this._currentSteerRatio +=\n (steeringControl * steerSpeed * timeDelta) / this._steerAngleMax;\n this._currentSteerRatio = Math.max(-1, this._currentSteerRatio);\n }\n if (steeringControl > 0) {\n // Avoid to much latency when changing of direction\n this._currentSteerRatio = Math.max(0, this._currentSteerRatio);\n this._currentSteerRatio +=\n (steeringControl * steerSpeed * timeDelta) / this._steerAngleMax;\n this._currentSteerRatio = Math.min(1, this._currentSteerRatio);\n }\n }\n\n let brake = 0;\n const acceleratorControl =\n this._acceleratorStickForce ||\n (this._hasPressedBackwardKey ? -1 : 0) +\n (this._hasPressedForwardKey ? 1 : 0);\n let forward = acceleratorControl;\n if (this._previousForward * forward < 0.0) {\n const velocity = carBody\n .GetRotation()\n .InverseRotate(carBody.GetLinearVelocity())\n .GetX();\n if (\n (forward > 0.0 && velocity < -0.1) ||\n (forward < 0.0 && velocity > 0.1)\n ) {\n // Brake while we've not stopped yet\n forward = 0.0;\n brake = 1.0;\n } else {\n // When we've come to a stop, accept the new direction\n this._previousForward = forward;\n }\n }\n\n let handBrake = 0;\n if (this._hasPressedHandBrakeKey) {\n forward = 0.0;\n handBrake = 1.0;\n }\n\n this._vehicleController.SetDriverInput(\n forward,\n -this._currentSteerRatio,\n brake,\n handBrake\n );\n if (\n forward !== 0.0 ||\n this._currentSteerRatio !== 0.0 ||\n brake !== 0.0 ||\n handBrake !== 0.0\n ) {\n this._sharedData.bodyInterface.ActivateBody(carBody.GetID());\n }\n\n this._wasForwardKeyPressed = this._hasPressedForwardKey;\n this._wasBackwardKeyPressed = this._hasPressedBackwardKey;\n this._wasRightKeyPressed = this._hasPressedRightKey;\n this._wasLeftKeyPressed = this._hasPressedLeftKey;\n this._wasHandBrakeKeyPressed = this._hasPressedHandBrakeKey;\n this._previousAcceleratorStickForce = this._acceleratorStickForce;\n this._previousSteeringStickForce = this._steeringStickForce;\n\n if (!this._dontClearInputsBetweenFrames) {\n this._hasPressedForwardKey = false;\n this._hasPressedBackwardKey = false;\n this._hasPressedRightKey = false;\n this._hasPressedLeftKey = false;\n this._hasPressedHandBrakeKey = false;\n this._acceleratorStickForce = 0;\n this._steeringStickForce = 0;\n }\n }\n\n override onObjectHotReloaded() {}\n\n simulateForwardKey(): void {\n this._hasPressedForwardKey = true;\n }\n\n wasForwardKeyPressed(): boolean {\n return this._wasForwardKeyPressed;\n }\n\n simulateBackwardKey(): void {\n this._hasPressedBackwardKey = true;\n }\n\n wasBackwardKeyPressed(): boolean {\n return this._wasBackwardKeyPressed;\n }\n\n simulateRightKey(): void {\n this._hasPressedRightKey = true;\n }\n\n wasRightKeyPressed(): boolean {\n return this._wasRightKeyPressed;\n }\n\n simulateLeftKey(): void {\n this._hasPressedLeftKey = true;\n }\n\n wasLeftKeyPressed(): boolean {\n return this._wasLeftKeyPressed;\n }\n\n simulateHandBrakeKey(): void {\n this._hasPressedHandBrakeKey = true;\n }\n\n wasHandBrakeKeyPressed(): boolean {\n return this._wasHandBrakeKeyPressed;\n }\n\n simulateAcceleratorStick(stickForce: float): void {\n this._acceleratorStickForce = gdjs.evtTools.common.clamp(\n -1,\n 1,\n stickForce\n );\n }\n\n simulateSteeringStick(stickForce: float): void {\n this._steeringStickForce = gdjs.evtTools.common.clamp(-1, 1, stickForce);\n }\n\n getAcceleratorStickForce(): float {\n return this._acceleratorStickForce;\n }\n\n getSteeringStickForce(): float {\n return this._steeringStickForce;\n }\n\n getPreviousAcceleratorStickForce(): float {\n return this._previousAcceleratorStickForce;\n }\n\n getPreviousSteeringStickForce(): float {\n return this._previousSteeringStickForce;\n }\n\n getSteerAngle(): float {\n return this._currentSteerRatio * this._steerAngleMax;\n }\n\n /**\n * @returns The engine current speed in RPM (rotation per minute)\n */\n getEngineSpeed(): float {\n return this._vehicleController\n ? this._vehicleController.GetEngine().GetCurrentRPM()\n : 0;\n }\n\n getCurrentGear(): float {\n return this._vehicleController\n ? this._vehicleController.GetTransmission().GetCurrentGear()\n : 0;\n }\n\n getSteerAngleMax(): float {\n return this._steerAngleMax;\n }\n\n setSteerAngleMax(steerAngleMax: float) {\n this._steerAngleMax = steerAngleMax;\n }\n\n getBeginningSteerSpeed(): float {\n return this._beginningSteerSpeed;\n }\n\n setBeginningSteerSpeed(beginningSteerSpeed: float): void {\n this._beginningSteerSpeed = beginningSteerSpeed;\n }\n\n getEndSteerSpeed(): float {\n return this._endSteerSpeed;\n }\n\n setEndSteerSpeed(endSteerSpeed: float): void {\n this._endSteerSpeed = endSteerSpeed;\n }\n\n invalidateShape(): void {\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n behavior._needToRecreateShape = true;\n }\n\n getEngineTorqueMax(): float {\n return this._engineTorqueMax;\n }\n\n setEngineTorqueMax(engineTorqueMax: float): void {\n this._engineTorqueMax = engineTorqueMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mMaxTorque = engineTorqueMax;\n }\n\n /**\n * @returns The engine maximum speed in RPM (rotation per minute)\n */\n getEngineSpeedMax(): float {\n return this._engineSpeedMax;\n }\n\n setEngineSpeedMax(engineSpeedMax: float): void {\n this._engineSpeedMax = engineSpeedMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mMaxRPM = engineSpeedMax;\n }\n\n getEngineInertia(): float {\n return this._engineInertia;\n }\n\n setEngineInertia(engineInertia: float): void {\n this._engineInertia = engineInertia;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mInertia = engineInertia;\n }\n\n getGearRatio(gearNumber: integer): float {\n if (gearNumber === 0) {\n return 0;\n }\n if (gearNumber < 0) {\n return this._reverseGearRatios[-gearNumber - 1] || 0;\n }\n return this._gearRatios[gearNumber - 1] || 0;\n }\n\n setGearRatio(gearNumber: integer, ratio: float) {\n if (gearNumber > 0) {\n this._gearRatios[gearNumber - 1] = ratio;\n if (!this._vehicleController) {\n return;\n }\n this._updateGearRatios();\n } else if (gearNumber < 0) {\n this._reverseGearRatios[-gearNumber - 1] = ratio;\n this._updateReverseGearRatios();\n }\n }\n\n _updateGearRatios() {\n if (!this._vehicleController) {\n return;\n }\n const gearRatios = this._vehicleController.GetTransmission().mGearRatios;\n gearRatios.clear();\n let previousGearRatio = Number.POSITIVE_INFINITY;\n for (let index = 0; index < this._gearRatios.length; index++) {\n const gearRatio = this._gearRatios[index];\n if (0 < gearRatio && gearRatio < previousGearRatio) {\n gearRatios.push_back(gearRatio);\n previousGearRatio = gearRatio;\n }\n }\n }\n\n _updateReverseGearRatios() {\n if (!this._vehicleController) {\n return;\n }\n const reverseGearRatios =\n this._vehicleController.GetTransmission().mReverseGearRatios;\n reverseGearRatios.clear();\n let previousGearRatio = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < this._reverseGearRatios.length; index++) {\n const gearRatio = this._reverseGearRatios[index];\n if (previousGearRatio < gearRatio && gearRatio < 0) {\n reverseGearRatios.push_back(gearRatio);\n previousGearRatio = gearRatio;\n }\n }\n }\n\n getBackWheelOffsetX(): float {\n return this._backWheelOffsetX;\n }\n\n setBackWheelOffsetX(backWheelOffsetX: float): void {\n this._backWheelOffsetX = backWheelOffsetX;\n this._updateWheels();\n }\n\n getFrontWheelOffsetX(): float {\n return this._frontWheelOffsetX;\n }\n\n setFrontWheelOffsetX(frontWheelOffsetX: float): void {\n this._frontWheelOffsetX = frontWheelOffsetX;\n this._updateWheels();\n }\n\n getWheelOffsetY(): float {\n return this._wheelOffsetY;\n }\n\n setWheelOffsetY(wheelOffsetY: float): void {\n this._wheelOffsetY = wheelOffsetY;\n this._updateWheels();\n }\n\n getWheelOffsetZ(): float {\n return this._wheelOffsetZ;\n }\n\n setWheelOffsetZ(wheelOffsetZ: float): void {\n this._wheelOffsetY = wheelOffsetZ;\n this._updateWheels();\n }\n\n getWheelRadius(): float {\n return this._wheelRadius;\n }\n\n setWheelRadius(wheelRadius: float): void {\n this._wheelRadius = wheelRadius;\n this._updateWheels();\n }\n\n getWheelWidth(): float {\n return this._wheelWidth;\n }\n\n setWheelWidth(wheelWidth: float): void {\n this._wheelWidth = wheelWidth;\n this._updateWheels();\n }\n\n getBrakeTorqueMax(): float {\n return this._brakeTorqueMax;\n }\n\n setBrakeTorqueMax(brakeTorqueMax: float): void {\n this._brakeTorqueMax = brakeTorqueMax;\n this._updateWheels();\n }\n\n getHandBrakeTorqueMax(): float {\n return this._handBrakeTorqueMax;\n }\n\n setHandBrakeTorqueMax(handBrakeTorqueMax: float): void {\n this._handBrakeTorqueMax = handBrakeTorqueMax;\n this._updateWheels();\n }\n\n hasBackWheelDrive(): boolean {\n return this._hasBackWheelDrive;\n }\n\n setBackWheelDrive(hasBackWheelDrive: boolean): void {\n this._hasBackWheelDrive = hasBackWheelDrive;\n this.invalidateShape();\n }\n\n hasFrontWheelDrive(): boolean {\n return this._hasBackWheelDrive;\n }\n\n setFrontWheelDrive(hasFrontWheelDrive: boolean): void {\n this._hasBackWheelDrive = hasFrontWheelDrive;\n this.invalidateShape();\n }\n\n getPitchRollAngleMax(): float {\n return this._pitchRollAngleMax;\n }\n\n setPitchRollAngleMax(pitchRollAngleMax: float): void {\n this._pitchRollAngleMax = pitchRollAngleMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController\n .GetConstraint()\n .SetMaxPitchRollAngle(pitchRollAngleMax);\n }\n\n isOnFloor() {\n if (!this._vehicleController) {\n return;\n }\n for (let index = 0; index < 4; index++) {\n const wheel = Jolt.castObject(\n this._vehicleController.GetConstraint().GetWheel(index),\n Jolt.WheelWV\n );\n if (wheel.HasContact()) {\n return true;\n }\n }\n return false;\n }\n\n _updateWheels() {\n if (!this._vehicleController) {\n return;\n }\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n\n // Retrieved the dimensions set by `createShape`.\n const halfVehicleWidth = behavior._shapeHalfWidth;\n const halfVehicleHeight = behavior._shapeHalfHeight;\n const halfVehicleDepth = behavior._shapeHalfDepth;\n\n const shapeScale =\n behavior.shapeScale * behavior._sharedData.worldInvScale;\n\n const wheelRadius = this._wheelRadius * shapeScale;\n const wheelWidth = this._wheelWidth * shapeScale;\n const backWheelOffsetX =\n halfVehicleWidth - wheelRadius + this._backWheelOffsetX * shapeScale;\n const frontWheelOffsetX =\n halfVehicleWidth - wheelRadius + this._frontWheelOffsetX * shapeScale;\n const wheelOffsetY =\n halfVehicleHeight - wheelWidth / 2 + this._wheelOffsetY * shapeScale;\n // Put the wheels center at the bottom of the car physics shape.\n const wheelOffsetZ =\n halfVehicleDepth +\n (-behavior.shapeOffsetZ + this._wheelOffsetZ) * shapeScale;\n const suspensionMinLength = wheelRadius;\n const suspensionMaxLength = 1.5 * suspensionMinLength;\n\n const constraint = this._vehicleController.GetConstraint();\n const fl = constraint.GetWheel(0).GetSettings();\n fl.mPosition = this.getVec3(\n frontWheelOffsetX,\n -wheelOffsetY,\n -wheelOffsetZ\n );\n const fr = constraint.GetWheel(1).GetSettings();\n fr.mPosition = this.getVec3(\n frontWheelOffsetX,\n wheelOffsetY,\n -wheelOffsetZ\n );\n const bl = constraint.GetWheel(2).GetSettings();\n bl.mPosition = this.getVec3(\n -backWheelOffsetX,\n -wheelOffsetY,\n -wheelOffsetZ\n );\n const br = constraint.GetWheel(3).GetSettings();\n br.mPosition = this.getVec3(\n -backWheelOffsetX,\n wheelOffsetY,\n -wheelOffsetZ\n );\n for (let index = 0; index < 4; index++) {\n const wheel = Jolt.castObject(\n constraint.GetWheel(index),\n Jolt.WheelWV\n ).GetSettings();\n wheel.mRadius = wheelRadius;\n wheel.mWidth = wheelWidth;\n wheel.mSuspensionMinLength = suspensionMinLength;\n wheel.mSuspensionMaxLength = suspensionMaxLength;\n wheel.mMaxBrakeTorque = this._brakeTorqueMax;\n if (index >= 2) {\n wheel.mMaxHandBrakeTorque = this._handBrakeTorqueMax;\n }\n }\n }\n }\n\n gdjs.registerBehavior(\n 'Physics3D::PhysicsCar3D',\n gdjs.PhysicsCar3DRuntimeBehavior\n );\n\n export namespace PhysicsCar3DRuntimeBehavior {\n export class VehicleBodyUpdater\n implements gdjs.Physics3DRuntimeBehavior.BodyUpdater\n {\n carBehavior: gdjs.PhysicsCar3DRuntimeBehavior;\n physicsBodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;\n\n constructor(\n carBehavior: gdjs.PhysicsCar3DRuntimeBehavior,\n physicsBodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater\n ) {\n this.carBehavior = carBehavior;\n this.physicsBodyUpdater = physicsBodyUpdater;\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this.carBehavior._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n createAndAddBody(): Jolt.Body | null {\n const physics3D = this.carBehavior.getPhysics3D();\n if (!physics3D) {\n return null;\n }\n const { behavior } = physics3D;\n const { _sharedData } = this.carBehavior;\n\n const carShape = behavior.createShape();\n\n // Create car body\n const carBodySettings = new Jolt.BodyCreationSettings(\n carShape,\n this.carBehavior._getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n behavior._getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n Jolt.EMotionType_Dynamic,\n behavior.getBodyLayer()\n );\n carBodySettings.mFriction = behavior.friction;\n carBodySettings.mRestitution = behavior.restitution;\n carBodySettings.mLinearDamping = behavior.linearDamping;\n carBodySettings.mAngularDamping = behavior.angularDamping;\n carBodySettings.mGravityFactor = behavior.gravityScale;\n if (behavior.massOverride > 0) {\n carBodySettings.mOverrideMassProperties =\n Jolt.EOverrideMassProperties_CalculateInertia;\n carBodySettings.mMassPropertiesOverride.mMass = behavior.massOverride;\n }\n const carBody = _sharedData.bodyInterface.CreateBody(carBodySettings);\n Jolt.destroy(carBodySettings);\n _sharedData.bodyInterface.AddBody(\n carBody.GetID(),\n Jolt.EActivation_Activate\n );\n\n // Create vehicle constraint\n const vehicle = new Jolt.VehicleConstraintSettings();\n vehicle.mUp = this.getVec3(0, 0, 1);\n vehicle.mForward = this.getVec3(1, 0, 0);\n vehicle.mMaxPitchRollAngle = gdjs.toRad(\n this.carBehavior._pitchRollAngleMax\n );\n\n const FL_WHEEL = 0;\n const FR_WHEEL = 1;\n const BL_WHEEL = 2;\n const BR_WHEEL = 3;\n {\n const setupWheel = (wheelS: Jolt.WheelSettingsWV) => {\n wheelS.mWheelUp = this.getVec3(0, 0, 1);\n wheelS.mWheelForward = this.getVec3(1, 0, 0);\n wheelS.mSuspensionDirection = this.getVec3(0, 0, -1);\n wheelS.mSteeringAxis = this.getVec3(0, 0, 1);\n };\n\n // vehicle.mWheels is a Array of Ref (smart pointer).\n // They are destroyed automatically.\n vehicle.mWheels.clear();\n\n const fl = new Jolt.WheelSettingsWV();\n fl.mMaxSteerAngle = gdjs.toRad(this.carBehavior._steerAngleMax);\n // Front wheel doesn't have hand brake\n fl.mMaxHandBrakeTorque = 0.0;\n setupWheel(fl);\n vehicle.mWheels.push_back(fl);\n\n const fr = new Jolt.WheelSettingsWV();\n fr.mMaxSteerAngle = gdjs.toRad(this.carBehavior._steerAngleMax);\n fr.mMaxHandBrakeTorque = 0.0;\n setupWheel(fr);\n vehicle.mWheels.push_back(fr);\n\n const bl = new Jolt.WheelSettingsWV();\n bl.mMaxSteerAngle = 0.0;\n setupWheel(bl);\n vehicle.mWheels.push_back(bl);\n\n const br = new Jolt.WheelSettingsWV();\n br.mMaxSteerAngle = 0.0;\n setupWheel(br);\n vehicle.mWheels.push_back(br);\n }\n\n const controllerSettings = new Jolt.WheeledVehicleControllerSettings();\n controllerSettings.mEngine.mMaxTorque =\n this.carBehavior._engineTorqueMax;\n controllerSettings.mEngine.mMaxRPM = this.carBehavior._engineSpeedMax;\n controllerSettings.mEngine.mInertia = this.carBehavior._engineInertia;\n // vehicle.mController is a Ref (smart pointer).\n // It is destroyed with the vehicle.\n vehicle.mController = controllerSettings;\n\n const fourWheelDrive =\n this.carBehavior._hasBackWheelDrive &&\n this.carBehavior._hasFrontWheelDrive;\n controllerSettings.mDifferentials.clear();\n\n // Front differential\n if (this.carBehavior._hasFrontWheelDrive) {\n const frontWheelDrive = new Jolt.VehicleDifferentialSettings();\n frontWheelDrive.mLeftWheel = FL_WHEEL;\n frontWheelDrive.mRightWheel = FR_WHEEL;\n if (fourWheelDrive) {\n // Split engine torque when 4 wheels drive\n frontWheelDrive.mEngineTorqueRatio = 0.5;\n }\n controllerSettings.mDifferentials.push_back(frontWheelDrive);\n }\n\n // Rear differential\n if (this.carBehavior._hasBackWheelDrive) {\n const rearWheelDrive = new Jolt.VehicleDifferentialSettings();\n rearWheelDrive.mLeftWheel = BL_WHEEL;\n rearWheelDrive.mRightWheel = BR_WHEEL;\n if (fourWheelDrive) {\n // Split engine torque when 4 wheels drive\n rearWheelDrive.mEngineTorqueRatio = 0.5;\n }\n controllerSettings.mDifferentials.push_back(rearWheelDrive);\n }\n\n // Anti-roll bars\n vehicle.mAntiRollBars.clear();\n const frontRollBar = new Jolt.VehicleAntiRollBar();\n frontRollBar.mLeftWheel = FL_WHEEL;\n frontRollBar.mRightWheel = FR_WHEEL;\n const rearRollBar = new Jolt.VehicleAntiRollBar();\n rearRollBar.mLeftWheel = BL_WHEEL;\n rearRollBar.mRightWheel = BR_WHEEL;\n vehicle.mAntiRollBars.push_back(frontRollBar);\n vehicle.mAntiRollBars.push_back(rearRollBar);\n\n const constraint = new Jolt.VehicleConstraint(carBody, vehicle);\n Jolt.destroy(vehicle);\n\n // VehicleConstraint.mVehicleCollisionTester is a RefConst (smart pointer)\n // previously created ones are destroyed automatically.\n const vehicleCollisionTester =\n new Jolt.VehicleCollisionTesterCastCylinder(\n behavior.getBodyLayer(),\n 0.05\n );\n constraint.SetVehicleCollisionTester(vehicleCollisionTester);\n this.carBehavior._vehicleCollisionTester = vehicleCollisionTester;\n\n if (this.carBehavior._vehicleController) {\n const constraint =\n this.carBehavior._vehicleController.GetConstraint();\n this.carBehavior._sharedData.physicsSystem.RemoveConstraint(\n constraint\n );\n }\n _sharedData.physicsSystem.AddConstraint(constraint);\n this.carBehavior._vehicleController = Jolt.castObject(\n constraint.GetController(),\n Jolt.WheeledVehicleController\n );\n if (this.carBehavior._stepListener) {\n _sharedData.physicsSystem.RemoveStepListener(\n this.carBehavior._stepListener\n );\n }\n this.carBehavior._stepListener = new Jolt.VehicleConstraintStepListener(\n constraint\n );\n _sharedData.physicsSystem.AddStepListener(\n this.carBehavior._stepListener\n );\n this.carBehavior._updateWheels();\n this.carBehavior._updateGearRatios();\n this.carBehavior._updateReverseGearRatios();\n return carBody;\n }\n\n updateObjectFromBody() {\n this.physicsBodyUpdater.updateObjectFromBody();\n }\n\n updateBodyFromObject() {\n this.physicsBodyUpdater.updateBodyFromObject();\n }\n\n recreateShape() {\n this.physicsBodyUpdater.recreateShape();\n this.carBehavior._updateWheels();\n }\n\n destroyBody() {\n this.carBehavior.onDestroy();\n this.physicsBodyUpdater.destroyBody();\n }\n }\n }\n}\n"],
5
- "mappings": "AAEA,GAAU,MAAV,UAAU,EAAV,CAsBS,eACG,GAAK,eAEf,CAwEE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GA1EjC,gBAA+B,KACvC,wBAA2D,KAC3D,mBAA2D,KAC3D,6BACE,KAOM,gCAAsC,GA8BtC,wBAA4B,EAEpC,sBAAmB,EAEX,2BAAiC,GACjC,4BAAkC,GAClC,yBAA+B,GAC/B,wBAA8B,GAC9B,6BAAmC,GACnC,4BAAgC,EAChC,yBAA6B,EAK7B,wBAA8B,GAC9B,yBAA+B,GAC/B,2BAAiC,GACjC,4BAAkC,GAClC,6BAAmC,GACnC,oCAAwC,EACxC,iCAAqC,EAKrC,mCAAyC,GAQ/C,KAAK,QAAU,EACf,KAAK,uBAAyB,EAAa,UAC3C,KAAK,YAAc,EAAK,oBAAoB,cAC1C,EAAkB,WAClB,EAAa,WAEf,KAAK,eAAiB,EAAa,cACnC,KAAK,qBAAuB,EAAa,oBACzC,KAAK,eAAiB,EAAa,cACnC,KAAK,iBAAmB,EAAa,gBACrC,KAAK,gBAAkB,EAAa,eACpC,KAAK,eAAiB,EAAa,cACnC,KAAK,mBAAqB,CAAC,EAAa,mBACxC,KAAK,YAAc,CACjB,EAAa,WACb,EAAa,WACb,EAAa,WACb,EAAa,WACb,EAAa,WACb,EAAa,YAEf,KAAK,kBAAoB,EAAa,iBACtC,KAAK,mBAAqB,EAAa,kBACvC,KAAK,cAAgB,EAAa,aA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,GAAI,MAAK,mCACP,EAAS,eACT,KAKJ,GAHA,EAAW,0BAA0B,GACrC,KAAK,YAAY,wBAA0B,EAEvC,KAAK,YAAY,mBAAoB,CACvC,KAAM,GACJ,KAAK,YAAY,mBAAmB,gBACtC,KAAK,YAAY,YAAY,cAAc,iBACzC,GAGJ,SAAY,cAAc,cAAc,GACxC,KAAK,YAAY,mBAAqB,KAAK,WACzC,EAAW,gBACX,KAAK,0BAEH,KAAK,YAAY,eACnB,EAAY,cAAc,mBACxB,KAAK,YAAY,eAGrB,KAAK,YAAY,cAAgB,GAAI,MAAK,8BACxC,GAEF,EAAY,cAAc,gBACxB,KAAK,YAAY,eAEnB,KAAK,YAAY,gBACjB,KAAK,YAAY,oBACjB,KAAK,YAAY,2BACV,EAGT,sBAAuB,CACrB,KAAK,mBAAmB,uBAG1B,sBAAuB,CACrB,KAAK,mBAAmB,uBAG1B,eAAgB,CACd,KAAK,mBAAmB,gBACxB,KAAK,YAAY,gBAGnB,aAAc,CACZ,KAAK,YAAY,YACjB,KAAK,mBAAmB,eAjNrB,EAAM,sBADE,uEAr4BT",
4
+ "sourcesContent": ["/// <reference path=\"./jolt-physics.d.ts\" />\n\nnamespace gdjs {\n interface PhysicsCar3DNetworkSyncDataType {\n lek: boolean;\n rik: boolean;\n upk: boolean;\n dok: boolean;\n hbk: boolean;\n asf: float;\n ssf: float;\n etm: float;\n esm: float;\n ei: float;\n }\n\n export interface PhysicsCar3DNetworkSyncData extends BehaviorNetworkSyncData {\n props: PhysicsCar3DNetworkSyncDataType;\n }\n\n type Physics3D = {\n behavior: gdjs.Physics3DRuntimeBehavior;\n };\n\n export class PhysicsCar3DRuntimeBehavior\n extends gdjs.RuntimeBehavior\n implements gdjs.Physics3DRuntimeBehavior.Physics3DHook\n {\n owner3D: gdjs.RuntimeObject3D;\n private _physics3DBehaviorName: string;\n private _physics3D: Physics3D | null = null;\n _vehicleController: Jolt.WheeledVehicleController | null = null;\n _stepListener: Jolt.VehicleConstraintStepListener | null = null;\n _vehicleCollisionTester: Jolt.VehicleCollisionTesterCastCylinder | null =\n null;\n /**\n * sharedData is a reference to the shared data of the scene, that registers\n * every physics behavior that is created so that collisions can be cleared\n * before stepping the world.\n */\n _sharedData: gdjs.Physics3DSharedData;\n private _destroyedDuringFrameLogic: boolean = false;\n\n // Readonly configuration\n\n _steerAngleMax;\n private _beginningSteerSpeed: float;\n private _endSteerSpeed: float;\n _gearRatios: Array<float>;\n _reverseGearRatios: Array<float>;\n private _backWheelOffsetX: float;\n private _frontWheelOffsetX: float;\n private _wheelOffsetY: float;\n private _wheelOffsetZ: float;\n private _wheelRadius: float;\n private _wheelWidth: float;\n private _brakeTorqueMax: float;\n private _handBrakeTorqueMax: float;\n _hasBackWheelDrive: boolean;\n _hasFrontWheelDrive: boolean;\n _pitchRollAngleMax: float;\n\n // Mutable configuration\n\n _engineTorqueMax: float;\n /** in RPM (rotation per minute) */\n _engineSpeedMax: float;\n _engineInertia: float;\n\n // State\n\n private _currentSteerRatio: float = 0;\n /** Used to make sure the car is stopped before going backward. */\n _previousForward = 1;\n\n private _hasPressedForwardKey: boolean = false;\n private _hasPressedBackwardKey: boolean = false;\n private _hasPressedRightKey: boolean = false;\n private _hasPressedLeftKey: boolean = false;\n private _hasPressedHandBrakeKey: boolean = false;\n private _acceleratorStickForce: float = 0;\n private _steeringStickForce: float = 0;\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 _wasForwardKeyPressed: boolean = false;\n private _wasBackwardKeyPressed: boolean = false;\n private _wasHandBrakeKeyPressed: boolean = false;\n private _previousAcceleratorStickForce: float = 0;\n private _previousSteeringStickForce: 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 private _dontClearInputsBetweenFrames: boolean = false;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject3D\n ) {\n super(instanceContainer, behaviorData, owner);\n this.owner3D = owner;\n this._physics3DBehaviorName = behaviorData.physics3D;\n this._sharedData = gdjs.Physics3DSharedData.getSharedData(\n instanceContainer.getScene(),\n behaviorData.Physics3D\n );\n this._steerAngleMax = behaviorData.steerAngleMax;\n this._beginningSteerSpeed = behaviorData.beginningSteerSpeed;\n this._endSteerSpeed = behaviorData.endSteerSpeed;\n this._engineTorqueMax = behaviorData.engineTorqueMax;\n this._engineSpeedMax = behaviorData.engineSpeedMax;\n this._engineInertia = behaviorData.engineInertia;\n this._reverseGearRatios = [behaviorData.reverseGearRatio1];\n this._gearRatios = [\n behaviorData.gearRatio1,\n behaviorData.gearRatio2,\n behaviorData.gearRatio3,\n behaviorData.gearRatio4,\n behaviorData.gearRatio5,\n behaviorData.gearRatio6,\n ];\n this._backWheelOffsetX = behaviorData.backWheelOffsetX;\n this._frontWheelOffsetX = behaviorData.frontWheelOffsetX;\n this._wheelOffsetY = behaviorData.wheelOffsetY;\n this._wheelOffsetZ = behaviorData.wheelOffsetZ;\n this._wheelRadius = behaviorData.wheelRadius;\n this._wheelWidth = behaviorData.wheelWidth;\n this._brakeTorqueMax = behaviorData.brakeTorqueMax;\n this._handBrakeTorqueMax = behaviorData.handBrakeTorqueMax;\n this._hasBackWheelDrive = behaviorData.hasBackWheelDrive;\n this._hasFrontWheelDrive = behaviorData.hasFrontWheelDrive;\n this._pitchRollAngleMax = behaviorData.pitchRollAngleMax;\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n getPhysics3D(): Physics3D | null {\n if (this._destroyedDuringFrameLogic) {\n return null;\n }\n if (this._physics3D) {\n return this._physics3D;\n }\n const behavior = this.owner.getBehavior(\n this._physics3DBehaviorName\n ) as gdjs.Physics3DRuntimeBehavior;\n\n const sharedData = behavior._sharedData;\n\n this._physics3D = {\n behavior,\n };\n sharedData.registerHook(this);\n\n behavior.bodyUpdater =\n new gdjs.PhysicsCar3DRuntimeBehavior.VehicleBodyUpdater(\n this,\n behavior.bodyUpdater\n );\n behavior.recreateBody();\n\n return this._physics3D;\n }\n\n override updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.steerAngleMax !== newBehaviorData.steerAngleMax) {\n this.setSteerAngleMax(newBehaviorData.steerAngleMax);\n }\n if (\n oldBehaviorData.beginningSteerSpeed !==\n newBehaviorData.beginningSteerSpeed\n ) {\n this.setBeginningSteerSpeed(newBehaviorData.beginningSteerSpeed);\n }\n if (oldBehaviorData.endSteerSpeed !== newBehaviorData.endSteerSpeed) {\n this.setEndSteerSpeed(newBehaviorData.endSteerSpeed);\n }\n if (oldBehaviorData.engineTorqueMax !== newBehaviorData.engineTorqueMax) {\n this.setEngineTorqueMax(newBehaviorData.engineTorqueMax);\n }\n if (oldBehaviorData.engineSpeedMax !== newBehaviorData.engineSpeedMax) {\n this.setEngineSpeedMax(newBehaviorData.engineSpeedMax);\n }\n if (oldBehaviorData.engineInertia !== newBehaviorData.engineInertia) {\n this.setEngineInertia(newBehaviorData.engineInertia);\n }\n if (\n oldBehaviorData.reverseGearRatio1 !== newBehaviorData.reverseGearRatio1\n ) {\n this.setGearRatio(-1, newBehaviorData.reverseGearRatio1);\n }\n if (oldBehaviorData.gearRatio1 !== newBehaviorData.gearRatio1) {\n this.setGearRatio(1, newBehaviorData.gearRatio1);\n }\n if (oldBehaviorData.gearRatio2 !== newBehaviorData.gearRatio2) {\n this.setGearRatio(2, newBehaviorData.gearRatio2);\n }\n if (oldBehaviorData.gearRatio3 !== newBehaviorData.gearRatio3) {\n this.setGearRatio(3, newBehaviorData.gearRatio3);\n }\n if (oldBehaviorData.gearRatio4 !== newBehaviorData.gearRatio4) {\n this.setGearRatio(4, newBehaviorData.gearRatio4);\n }\n if (oldBehaviorData.gearRatio5 !== newBehaviorData.gearRatio5) {\n this.setGearRatio(5, newBehaviorData.gearRatio5);\n }\n if (oldBehaviorData.gearRatio6 !== newBehaviorData.gearRatio6) {\n this.setGearRatio(6, newBehaviorData.gearRatio6);\n }\n if (\n oldBehaviorData.backWheelOffsetX !== newBehaviorData.backWheelOffsetX\n ) {\n this.setBackWheelOffsetX(newBehaviorData.backWheelOffsetX);\n }\n if (\n oldBehaviorData.frontWheelOffsetX !== newBehaviorData.frontWheelOffsetX\n ) {\n this.setFrontWheelOffsetX(newBehaviorData.frontWheelOffsetX);\n }\n if (oldBehaviorData.wheelOffsetY !== newBehaviorData.wheelOffsetY) {\n this.setWheelOffsetY(newBehaviorData.wheelOffsetY);\n }\n if (oldBehaviorData.wheelOffsetZ !== newBehaviorData.wheelOffsetZ) {\n this.setWheelOffsetZ(newBehaviorData.wheelOffsetZ);\n }\n if (oldBehaviorData.wheelRadius !== newBehaviorData.wheelRadius) {\n this.setWheelRadius(newBehaviorData.wheelRadius);\n }\n if (oldBehaviorData.wheelWidth !== newBehaviorData.wheelWidth) {\n this.setWheelWidth(newBehaviorData.wheelWidth);\n }\n if (oldBehaviorData.brakeTorqueMax !== newBehaviorData.brakeTorqueMax) {\n this.setBrakeTorqueMax(newBehaviorData.brakeTorqueMax);\n }\n if (\n oldBehaviorData.handBrakeTorqueMax !==\n newBehaviorData.handBrakeTorqueMax\n ) {\n this.setHandBrakeTorqueMax(newBehaviorData.handBrakeTorqueMax);\n }\n if (\n oldBehaviorData.hasBackWheelDrive !== newBehaviorData.hasBackWheelDrive\n ) {\n this.setBackWheelDrive(newBehaviorData.hasBackWheelDrive);\n }\n if (\n oldBehaviorData.hasFrontWheelDrive !==\n newBehaviorData.hasFrontWheelDrive\n ) {\n this.setFrontWheelDrive(newBehaviorData.hasFrontWheelDrive);\n }\n if (\n oldBehaviorData.pitchRollAngleMax !== newBehaviorData.pitchRollAngleMax\n ) {\n this.setPitchRollAngleMax(newBehaviorData.pitchRollAngleMax);\n }\n return true;\n }\n\n override getNetworkSyncData(): PhysicsCar3DNetworkSyncData {\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\n return {\n ...super.getNetworkSyncData(),\n props: {\n lek: this._wasLeftKeyPressed,\n rik: this._wasRightKeyPressed,\n upk: this._wasForwardKeyPressed,\n dok: this._wasBackwardKeyPressed,\n hbk: this._wasHandBrakeKeyPressed,\n asf: this._previousAcceleratorStickForce,\n ssf: this._previousSteeringStickForce,\n etm: this._engineTorqueMax,\n esm: this._engineSpeedMax,\n ei: this._engineInertia,\n },\n };\n }\n\n override updateFromNetworkSyncData(\n networkSyncData: PhysicsCar3DNetworkSyncData\n ) {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n this._hasPressedForwardKey = behaviorSpecificProps.upk;\n this._hasPressedBackwardKey = behaviorSpecificProps.dok;\n this._hasPressedLeftKey = behaviorSpecificProps.lek;\n this._hasPressedRightKey = behaviorSpecificProps.rik;\n this._hasPressedHandBrakeKey = behaviorSpecificProps.hbk;\n this._acceleratorStickForce = behaviorSpecificProps.asf;\n this._steeringStickForce = behaviorSpecificProps.ssf;\n this._engineTorqueMax = behaviorSpecificProps.etm;\n this._engineSpeedMax = behaviorSpecificProps.esm;\n this._engineInertia = behaviorSpecificProps.ei;\n\n // When the object is synchronized from the network, the inputs must not be cleared.\n this._dontClearInputsBetweenFrames = true;\n }\n\n _getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n result.Set(0, 0, 0);\n return result;\n }\n const { behavior } = physics3D;\n // Same as for characters, the origin is at its feet:\n // - the center is used for X and Y because Box3D origin is at the top-left corner\n // - the origin is used for Z because, when the character is made smaller,\n // it must stay on the ground and not fell from its old size.\n result.Set(\n this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,\n this.owner3D.getZ() * this._sharedData.worldInvScale +\n behavior._shapeHalfDepth\n );\n return result;\n }\n\n override onDeActivate() {\n if (this._stepListener) {\n this._sharedData.physicsSystem.RemoveStepListener(this._stepListener);\n }\n }\n\n override onActivate() {\n if (this._stepListener) {\n this._sharedData.physicsSystem.AddStepListener(this._stepListener);\n }\n }\n\n override onDestroy() {\n if (!this._vehicleController) {\n return;\n }\n this._destroyedDuringFrameLogic = true;\n this.onDeActivate();\n if (this._stepListener) {\n // stepListener is removed by onDeActivate\n Jolt.destroy(this._stepListener);\n this._stepListener = null;\n }\n const constraint = this._vehicleController.GetConstraint();\n this._sharedData.physicsSystem.RemoveConstraint(constraint);\n // The controller is destroyed with the constraint.\n this._vehicleController = null;\n // VehicleConstraint.mVehicleCollisionTester is a RefConst (smart pointer).\n // It is destroyed with the constraint.\n this._vehicleCollisionTester = null;\n if (this._physics3D) {\n this._physics3D = null;\n }\n }\n\n override doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Trigger createAndAddBody()\n this.getPhysics3D();\n }\n\n override doStepPostEvents(\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n // Trigger createAndAddBody()\n this.getPhysics3D();\n }\n\n doBeforePhysicsStep(timeDelta: float): void {\n if (!this.activated()) {\n return;\n }\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n if (!this._vehicleController) {\n return;\n }\n const carBody = behavior._body;\n if (!carBody) {\n return;\n }\n\n const steeringControl =\n this._steeringStickForce ||\n (this._hasPressedLeftKey ? -1 : 0) + (this._hasPressedRightKey ? 1 : 0);\n if (steeringControl === 0) {\n this._currentSteerRatio = 0;\n } else {\n const steerSpeed = gdjs.evtTools.common.lerp(\n this._beginningSteerSpeed,\n this._endSteerSpeed,\n Math.abs(this._currentSteerRatio)\n );\n if (steeringControl < 0) {\n // Avoid to much latency when changing of direction\n this._currentSteerRatio = Math.min(0, this._currentSteerRatio);\n this._currentSteerRatio +=\n (steeringControl * steerSpeed * timeDelta) / this._steerAngleMax;\n this._currentSteerRatio = Math.max(-1, this._currentSteerRatio);\n }\n if (steeringControl > 0) {\n // Avoid to much latency when changing of direction\n this._currentSteerRatio = Math.max(0, this._currentSteerRatio);\n this._currentSteerRatio +=\n (steeringControl * steerSpeed * timeDelta) / this._steerAngleMax;\n this._currentSteerRatio = Math.min(1, this._currentSteerRatio);\n }\n }\n\n let brake = 0;\n const acceleratorControl =\n this._acceleratorStickForce ||\n (this._hasPressedBackwardKey ? -1 : 0) +\n (this._hasPressedForwardKey ? 1 : 0);\n let forward = acceleratorControl;\n if (this._previousForward * forward < 0.0) {\n const velocity = carBody\n .GetRotation()\n .InverseRotate(carBody.GetLinearVelocity())\n .GetX();\n if (\n (forward > 0.0 && velocity < -0.1) ||\n (forward < 0.0 && velocity > 0.1)\n ) {\n // Brake while we've not stopped yet\n forward = 0.0;\n brake = 1.0;\n } else {\n // When we've come to a stop, accept the new direction\n this._previousForward = forward;\n }\n }\n\n let handBrake = 0;\n if (this._hasPressedHandBrakeKey) {\n forward = 0.0;\n handBrake = 1.0;\n }\n\n this._vehicleController.SetDriverInput(\n forward,\n -this._currentSteerRatio,\n brake,\n handBrake\n );\n if (\n forward !== 0.0 ||\n this._currentSteerRatio !== 0.0 ||\n brake !== 0.0 ||\n handBrake !== 0.0\n ) {\n this._sharedData.bodyInterface.ActivateBody(carBody.GetID());\n }\n\n this._wasForwardKeyPressed = this._hasPressedForwardKey;\n this._wasBackwardKeyPressed = this._hasPressedBackwardKey;\n this._wasRightKeyPressed = this._hasPressedRightKey;\n this._wasLeftKeyPressed = this._hasPressedLeftKey;\n this._wasHandBrakeKeyPressed = this._hasPressedHandBrakeKey;\n this._previousAcceleratorStickForce = this._acceleratorStickForce;\n this._previousSteeringStickForce = this._steeringStickForce;\n\n if (!this._dontClearInputsBetweenFrames) {\n this._hasPressedForwardKey = false;\n this._hasPressedBackwardKey = false;\n this._hasPressedRightKey = false;\n this._hasPressedLeftKey = false;\n this._hasPressedHandBrakeKey = false;\n this._acceleratorStickForce = 0;\n this._steeringStickForce = 0;\n }\n }\n\n override onObjectHotReloaded() {}\n\n simulateForwardKey(): void {\n this._hasPressedForwardKey = true;\n }\n\n wasForwardKeyPressed(): boolean {\n return this._wasForwardKeyPressed;\n }\n\n simulateBackwardKey(): void {\n this._hasPressedBackwardKey = true;\n }\n\n wasBackwardKeyPressed(): boolean {\n return this._wasBackwardKeyPressed;\n }\n\n simulateRightKey(): void {\n this._hasPressedRightKey = true;\n }\n\n wasRightKeyPressed(): boolean {\n return this._wasRightKeyPressed;\n }\n\n simulateLeftKey(): void {\n this._hasPressedLeftKey = true;\n }\n\n wasLeftKeyPressed(): boolean {\n return this._wasLeftKeyPressed;\n }\n\n simulateHandBrakeKey(): void {\n this._hasPressedHandBrakeKey = true;\n }\n\n wasHandBrakeKeyPressed(): boolean {\n return this._wasHandBrakeKeyPressed;\n }\n\n simulateAcceleratorStick(stickForce: float): void {\n this._acceleratorStickForce = gdjs.evtTools.common.clamp(\n -1,\n 1,\n stickForce\n );\n }\n\n simulateSteeringStick(stickForce: float): void {\n this._steeringStickForce = gdjs.evtTools.common.clamp(-1, 1, stickForce);\n }\n\n getAcceleratorStickForce(): float {\n return this._acceleratorStickForce;\n }\n\n getSteeringStickForce(): float {\n return this._steeringStickForce;\n }\n\n getPreviousAcceleratorStickForce(): float {\n return this._previousAcceleratorStickForce;\n }\n\n getPreviousSteeringStickForce(): float {\n return this._previousSteeringStickForce;\n }\n\n getSteerAngle(): float {\n return this._currentSteerRatio * this._steerAngleMax;\n }\n\n /**\n * @returns The engine current speed in RPM (rotation per minute)\n */\n getEngineSpeed(): float {\n return this._vehicleController\n ? this._vehicleController.GetEngine().GetCurrentRPM()\n : 0;\n }\n\n getCurrentGear(): float {\n return this._vehicleController\n ? this._vehicleController.GetTransmission().GetCurrentGear()\n : 0;\n }\n\n getSteerAngleMax(): float {\n return this._steerAngleMax;\n }\n\n setSteerAngleMax(steerAngleMax: float) {\n this._steerAngleMax = steerAngleMax;\n }\n\n getBeginningSteerSpeed(): float {\n return this._beginningSteerSpeed;\n }\n\n setBeginningSteerSpeed(beginningSteerSpeed: float): void {\n this._beginningSteerSpeed = beginningSteerSpeed;\n }\n\n getEndSteerSpeed(): float {\n return this._endSteerSpeed;\n }\n\n setEndSteerSpeed(endSteerSpeed: float): void {\n this._endSteerSpeed = endSteerSpeed;\n }\n\n invalidateShape(): void {\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n behavior._needToRecreateShape = true;\n }\n\n getEngineTorqueMax(): float {\n return this._engineTorqueMax;\n }\n\n setEngineTorqueMax(engineTorqueMax: float): void {\n this._engineTorqueMax = engineTorqueMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mMaxTorque = engineTorqueMax;\n }\n\n /**\n * @returns The engine maximum speed in RPM (rotation per minute)\n */\n getEngineSpeedMax(): float {\n return this._engineSpeedMax;\n }\n\n setEngineSpeedMax(engineSpeedMax: float): void {\n this._engineSpeedMax = engineSpeedMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mMaxRPM = engineSpeedMax;\n }\n\n getEngineInertia(): float {\n return this._engineInertia;\n }\n\n setEngineInertia(engineInertia: float): void {\n this._engineInertia = engineInertia;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mInertia = engineInertia;\n }\n\n getGearRatio(gearNumber: integer): float {\n if (gearNumber === 0) {\n return 0;\n }\n if (gearNumber < 0) {\n return this._reverseGearRatios[-gearNumber - 1] || 0;\n }\n return this._gearRatios[gearNumber - 1] || 0;\n }\n\n setGearRatio(gearNumber: integer, ratio: float) {\n if (gearNumber > 0) {\n this._gearRatios[gearNumber - 1] = ratio;\n if (!this._vehicleController) {\n return;\n }\n this._updateGearRatios();\n } else if (gearNumber < 0) {\n this._reverseGearRatios[-gearNumber - 1] = ratio;\n this._updateReverseGearRatios();\n }\n }\n\n _updateGearRatios() {\n if (!this._vehicleController) {\n return;\n }\n const gearRatios = this._vehicleController.GetTransmission().mGearRatios;\n gearRatios.clear();\n let previousGearRatio = Number.POSITIVE_INFINITY;\n for (let index = 0; index < this._gearRatios.length; index++) {\n const gearRatio = this._gearRatios[index];\n if (0 < gearRatio && gearRatio < previousGearRatio) {\n gearRatios.push_back(gearRatio);\n previousGearRatio = gearRatio;\n }\n }\n }\n\n _updateReverseGearRatios() {\n if (!this._vehicleController) {\n return;\n }\n const reverseGearRatios =\n this._vehicleController.GetTransmission().mReverseGearRatios;\n reverseGearRatios.clear();\n let previousGearRatio = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < this._reverseGearRatios.length; index++) {\n const gearRatio = this._reverseGearRatios[index];\n if (previousGearRatio < gearRatio && gearRatio < 0) {\n reverseGearRatios.push_back(gearRatio);\n previousGearRatio = gearRatio;\n }\n }\n }\n\n getBackWheelOffsetX(): float {\n return this._backWheelOffsetX;\n }\n\n setBackWheelOffsetX(backWheelOffsetX: float): void {\n this._backWheelOffsetX = backWheelOffsetX;\n this._updateWheels();\n }\n\n getFrontWheelOffsetX(): float {\n return this._frontWheelOffsetX;\n }\n\n setFrontWheelOffsetX(frontWheelOffsetX: float): void {\n this._frontWheelOffsetX = frontWheelOffsetX;\n this._updateWheels();\n }\n\n getWheelOffsetY(): float {\n return this._wheelOffsetY;\n }\n\n setWheelOffsetY(wheelOffsetY: float): void {\n this._wheelOffsetY = wheelOffsetY;\n this._updateWheels();\n }\n\n getWheelOffsetZ(): float {\n return this._wheelOffsetZ;\n }\n\n setWheelOffsetZ(wheelOffsetZ: float): void {\n this._wheelOffsetZ = wheelOffsetZ;\n this._updateWheels();\n }\n\n getWheelRadius(): float {\n return this._wheelRadius;\n }\n\n setWheelRadius(wheelRadius: float): void {\n this._wheelRadius = wheelRadius;\n this._updateWheels();\n }\n\n getWheelWidth(): float {\n return this._wheelWidth;\n }\n\n setWheelWidth(wheelWidth: float): void {\n this._wheelWidth = wheelWidth;\n this._updateWheels();\n }\n\n getBrakeTorqueMax(): float {\n return this._brakeTorqueMax;\n }\n\n setBrakeTorqueMax(brakeTorqueMax: float): void {\n this._brakeTorqueMax = brakeTorqueMax;\n this._updateWheels();\n }\n\n getHandBrakeTorqueMax(): float {\n return this._handBrakeTorqueMax;\n }\n\n setHandBrakeTorqueMax(handBrakeTorqueMax: float): void {\n this._handBrakeTorqueMax = handBrakeTorqueMax;\n this._updateWheels();\n }\n\n hasBackWheelDrive(): boolean {\n return this._hasBackWheelDrive;\n }\n\n setBackWheelDrive(hasBackWheelDrive: boolean): void {\n this._hasBackWheelDrive = hasBackWheelDrive;\n this.invalidateShape();\n }\n\n hasFrontWheelDrive(): boolean {\n return this._hasFrontWheelDrive;\n }\n\n setFrontWheelDrive(hasFrontWheelDrive: boolean): void {\n this._hasFrontWheelDrive = hasFrontWheelDrive;\n this.invalidateShape();\n }\n\n getPitchRollAngleMax(): float {\n return this._pitchRollAngleMax;\n }\n\n setPitchRollAngleMax(pitchRollAngleMax: float): void {\n this._pitchRollAngleMax = pitchRollAngleMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController\n .GetConstraint()\n .SetMaxPitchRollAngle(pitchRollAngleMax);\n }\n\n isOnFloor() {\n if (!this._vehicleController) {\n return;\n }\n for (let index = 0; index < 4; index++) {\n const wheel = Jolt.castObject(\n this._vehicleController.GetConstraint().GetWheel(index),\n Jolt.WheelWV\n );\n if (wheel.HasContact()) {\n return true;\n }\n }\n return false;\n }\n\n _updateWheels() {\n if (!this._vehicleController) {\n return;\n }\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n\n // Retrieved the dimensions set by `createShape`.\n const halfVehicleWidth = behavior._shapeHalfWidth;\n const halfVehicleHeight = behavior._shapeHalfHeight;\n const halfVehicleDepth = behavior._shapeHalfDepth;\n\n const shapeScale =\n behavior.shapeScale * behavior._sharedData.worldInvScale;\n\n const wheelRadius = this._wheelRadius * shapeScale;\n const wheelWidth = this._wheelWidth * shapeScale;\n const backWheelOffsetX =\n halfVehicleWidth - wheelRadius + this._backWheelOffsetX * shapeScale;\n const frontWheelOffsetX =\n halfVehicleWidth - wheelRadius + this._frontWheelOffsetX * shapeScale;\n const wheelOffsetY =\n halfVehicleHeight - wheelWidth / 2 + this._wheelOffsetY * shapeScale;\n // Put the wheels center at the bottom of the car physics shape.\n const wheelOffsetZ =\n halfVehicleDepth +\n (-behavior.shapeOffsetZ + this._wheelOffsetZ) * shapeScale;\n const suspensionMinLength = wheelRadius;\n const suspensionMaxLength = 1.5 * suspensionMinLength;\n\n const constraint = this._vehicleController.GetConstraint();\n const fl = constraint.GetWheel(0).GetSettings();\n fl.mPosition = this.getVec3(\n frontWheelOffsetX,\n -wheelOffsetY,\n -wheelOffsetZ\n );\n const fr = constraint.GetWheel(1).GetSettings();\n fr.mPosition = this.getVec3(\n frontWheelOffsetX,\n wheelOffsetY,\n -wheelOffsetZ\n );\n const bl = constraint.GetWheel(2).GetSettings();\n bl.mPosition = this.getVec3(\n -backWheelOffsetX,\n -wheelOffsetY,\n -wheelOffsetZ\n );\n const br = constraint.GetWheel(3).GetSettings();\n br.mPosition = this.getVec3(\n -backWheelOffsetX,\n wheelOffsetY,\n -wheelOffsetZ\n );\n for (let index = 0; index < 4; index++) {\n const wheel = Jolt.castObject(\n constraint.GetWheel(index),\n Jolt.WheelWV\n ).GetSettings();\n wheel.mRadius = wheelRadius;\n wheel.mWidth = wheelWidth;\n wheel.mSuspensionMinLength = suspensionMinLength;\n wheel.mSuspensionMaxLength = suspensionMaxLength;\n wheel.mMaxBrakeTorque = this._brakeTorqueMax;\n if (index >= 2) {\n wheel.mMaxHandBrakeTorque = this._handBrakeTorqueMax;\n }\n }\n }\n }\n\n gdjs.registerBehavior(\n 'Physics3D::PhysicsCar3D',\n gdjs.PhysicsCar3DRuntimeBehavior\n );\n\n export namespace PhysicsCar3DRuntimeBehavior {\n export class VehicleBodyUpdater\n implements gdjs.Physics3DRuntimeBehavior.BodyUpdater\n {\n carBehavior: gdjs.PhysicsCar3DRuntimeBehavior;\n physicsBodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;\n\n constructor(\n carBehavior: gdjs.PhysicsCar3DRuntimeBehavior,\n physicsBodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater\n ) {\n this.carBehavior = carBehavior;\n this.physicsBodyUpdater = physicsBodyUpdater;\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this.carBehavior._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n createAndAddBody(): Jolt.Body | null {\n const physics3D = this.carBehavior.getPhysics3D();\n if (!physics3D) {\n return null;\n }\n const { behavior } = physics3D;\n const { _sharedData } = this.carBehavior;\n\n const carShape = behavior.createShape();\n\n // Create car body\n const carBodySettings = new Jolt.BodyCreationSettings(\n carShape,\n this.carBehavior._getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n behavior._getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n Jolt.EMotionType_Dynamic,\n behavior.getBodyLayer()\n );\n carBodySettings.mFriction = behavior.friction;\n carBodySettings.mRestitution = behavior.restitution;\n carBodySettings.mLinearDamping = behavior.linearDamping;\n carBodySettings.mAngularDamping = behavior.angularDamping;\n carBodySettings.mGravityFactor = behavior.gravityScale;\n if (behavior.massOverride > 0) {\n carBodySettings.mOverrideMassProperties =\n Jolt.EOverrideMassProperties_CalculateInertia;\n carBodySettings.mMassPropertiesOverride.mMass = behavior.massOverride;\n }\n const carBody = _sharedData.bodyInterface.CreateBody(carBodySettings);\n Jolt.destroy(carBodySettings);\n _sharedData.bodyInterface.AddBody(\n carBody.GetID(),\n Jolt.EActivation_Activate\n );\n\n // Create vehicle constraint\n const vehicle = new Jolt.VehicleConstraintSettings();\n vehicle.mUp = this.getVec3(0, 0, 1);\n vehicle.mForward = this.getVec3(1, 0, 0);\n vehicle.mMaxPitchRollAngle = gdjs.toRad(\n this.carBehavior._pitchRollAngleMax\n );\n\n const FL_WHEEL = 0;\n const FR_WHEEL = 1;\n const BL_WHEEL = 2;\n const BR_WHEEL = 3;\n {\n const setupWheel = (wheelS: Jolt.WheelSettingsWV) => {\n wheelS.mWheelUp = this.getVec3(0, 0, 1);\n wheelS.mWheelForward = this.getVec3(1, 0, 0);\n wheelS.mSuspensionDirection = this.getVec3(0, 0, -1);\n wheelS.mSteeringAxis = this.getVec3(0, 0, 1);\n };\n\n // vehicle.mWheels is a Array of Ref (smart pointer).\n // They are destroyed automatically.\n vehicle.mWheels.clear();\n\n const fl = new Jolt.WheelSettingsWV();\n fl.mMaxSteerAngle = gdjs.toRad(this.carBehavior._steerAngleMax);\n // Front wheel doesn't have hand brake\n fl.mMaxHandBrakeTorque = 0.0;\n setupWheel(fl);\n vehicle.mWheels.push_back(fl);\n\n const fr = new Jolt.WheelSettingsWV();\n fr.mMaxSteerAngle = gdjs.toRad(this.carBehavior._steerAngleMax);\n fr.mMaxHandBrakeTorque = 0.0;\n setupWheel(fr);\n vehicle.mWheels.push_back(fr);\n\n const bl = new Jolt.WheelSettingsWV();\n bl.mMaxSteerAngle = 0.0;\n setupWheel(bl);\n vehicle.mWheels.push_back(bl);\n\n const br = new Jolt.WheelSettingsWV();\n br.mMaxSteerAngle = 0.0;\n setupWheel(br);\n vehicle.mWheels.push_back(br);\n }\n\n const controllerSettings = new Jolt.WheeledVehicleControllerSettings();\n controllerSettings.mEngine.mMaxTorque =\n this.carBehavior._engineTorqueMax;\n controllerSettings.mEngine.mMaxRPM = this.carBehavior._engineSpeedMax;\n controllerSettings.mEngine.mInertia = this.carBehavior._engineInertia;\n // vehicle.mController is a Ref (smart pointer).\n // It is destroyed with the vehicle.\n vehicle.mController = controllerSettings;\n\n const fourWheelDrive =\n this.carBehavior._hasBackWheelDrive &&\n this.carBehavior._hasFrontWheelDrive;\n controllerSettings.mDifferentials.clear();\n\n // Front differential\n if (this.carBehavior._hasFrontWheelDrive) {\n const frontWheelDrive = new Jolt.VehicleDifferentialSettings();\n frontWheelDrive.mLeftWheel = FL_WHEEL;\n frontWheelDrive.mRightWheel = FR_WHEEL;\n if (fourWheelDrive) {\n // Split engine torque when 4 wheels drive\n frontWheelDrive.mEngineTorqueRatio = 0.5;\n }\n controllerSettings.mDifferentials.push_back(frontWheelDrive);\n }\n\n // Rear differential\n if (this.carBehavior._hasBackWheelDrive) {\n const rearWheelDrive = new Jolt.VehicleDifferentialSettings();\n rearWheelDrive.mLeftWheel = BL_WHEEL;\n rearWheelDrive.mRightWheel = BR_WHEEL;\n if (fourWheelDrive) {\n // Split engine torque when 4 wheels drive\n rearWheelDrive.mEngineTorqueRatio = 0.5;\n }\n controllerSettings.mDifferentials.push_back(rearWheelDrive);\n }\n\n // Anti-roll bars\n vehicle.mAntiRollBars.clear();\n const frontRollBar = new Jolt.VehicleAntiRollBar();\n frontRollBar.mLeftWheel = FL_WHEEL;\n frontRollBar.mRightWheel = FR_WHEEL;\n const rearRollBar = new Jolt.VehicleAntiRollBar();\n rearRollBar.mLeftWheel = BL_WHEEL;\n rearRollBar.mRightWheel = BR_WHEEL;\n vehicle.mAntiRollBars.push_back(frontRollBar);\n vehicle.mAntiRollBars.push_back(rearRollBar);\n\n const constraint = new Jolt.VehicleConstraint(carBody, vehicle);\n Jolt.destroy(vehicle);\n\n // VehicleConstraint.mVehicleCollisionTester is a RefConst (smart pointer)\n // previously created ones are destroyed automatically.\n const vehicleCollisionTester =\n new Jolt.VehicleCollisionTesterCastCylinder(\n behavior.getBodyLayer(),\n 0.05\n );\n constraint.SetVehicleCollisionTester(vehicleCollisionTester);\n this.carBehavior._vehicleCollisionTester = vehicleCollisionTester;\n\n if (this.carBehavior._vehicleController) {\n const constraint =\n this.carBehavior._vehicleController.GetConstraint();\n this.carBehavior._sharedData.physicsSystem.RemoveConstraint(\n constraint\n );\n }\n _sharedData.physicsSystem.AddConstraint(constraint);\n this.carBehavior._vehicleController = Jolt.castObject(\n constraint.GetController(),\n Jolt.WheeledVehicleController\n );\n if (this.carBehavior._stepListener) {\n _sharedData.physicsSystem.RemoveStepListener(\n this.carBehavior._stepListener\n );\n }\n this.carBehavior._stepListener = new Jolt.VehicleConstraintStepListener(\n constraint\n );\n _sharedData.physicsSystem.AddStepListener(\n this.carBehavior._stepListener\n );\n this.carBehavior._updateWheels();\n this.carBehavior._updateGearRatios();\n this.carBehavior._updateReverseGearRatios();\n return carBody;\n }\n\n updateObjectFromBody() {\n this.physicsBodyUpdater.updateObjectFromBody();\n }\n\n updateBodyFromObject() {\n this.physicsBodyUpdater.updateBodyFromObject();\n }\n\n recreateShape() {\n this.physicsBodyUpdater.recreateShape();\n this.carBehavior._updateWheels();\n }\n\n destroyBody() {\n this.carBehavior.onDestroy();\n this.physicsBodyUpdater.destroyBody();\n }\n }\n }\n}\n"],
5
+ "mappings": "AAEA,GAAU,MAAV,UAAU,EAAV,CAsBS,eACG,GAAK,eAEf,CAwEE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GA1EjC,gBAA+B,KACvC,wBAA2D,KAC3D,mBAA2D,KAC3D,6BACE,KAOM,gCAAsC,GA8BtC,wBAA4B,EAEpC,sBAAmB,EAEX,2BAAiC,GACjC,4BAAkC,GAClC,yBAA+B,GAC/B,wBAA8B,GAC9B,6BAAmC,GACnC,4BAAgC,EAChC,yBAA6B,EAK7B,wBAA8B,GAC9B,yBAA+B,GAC/B,2BAAiC,GACjC,4BAAkC,GAClC,6BAAmC,GACnC,oCAAwC,EACxC,iCAAqC,EAKrC,mCAAyC,GAQ/C,KAAK,QAAU,EACf,KAAK,uBAAyB,EAAa,UAC3C,KAAK,YAAc,EAAK,oBAAoB,cAC1C,EAAkB,WAClB,EAAa,WAEf,KAAK,eAAiB,EAAa,cACnC,KAAK,qBAAuB,EAAa,oBACzC,KAAK,eAAiB,EAAa,cACnC,KAAK,iBAAmB,EAAa,gBACrC,KAAK,gBAAkB,EAAa,eACpC,KAAK,eAAiB,EAAa,cACnC,KAAK,mBAAqB,CAAC,EAAa,m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7B,EAAY,WAAa,EACzB,EAAY,YAAc,EAC1B,EAAQ,cAAc,UAAU,GAChC,EAAQ,cAAc,UAAU,GAEhC,KAAM,GAAa,GAAI,MAAK,kBAAkB,EAAS,GACvD,KAAK,QAAQ,GAIb,KAAM,GACJ,GAAI,MAAK,mCACP,EAAS,eACT,KAKJ,GAHA,EAAW,0BAA0B,GACrC,KAAK,YAAY,wBAA0B,EAEvC,KAAK,YAAY,mBAAoB,CACvC,KAAM,GACJ,KAAK,YAAY,mBAAmB,gBACtC,KAAK,YAAY,YAAY,cAAc,iBACzC,GAGJ,SAAY,cAAc,cAAc,GACxC,KAAK,YAAY,mBAAqB,KAAK,WACzC,EAAW,gBACX,KAAK,0BAEH,KAAK,YAAY,eACnB,EAAY,cAAc,mBACxB,KAAK,YAAY,eAGrB,KAAK,YAAY,cAAgB,GAAI,MAAK,8BACxC,GAEF,EAAY,cAAc,gBACxB,KAAK,YAAY,eAEnB,KAAK,YAAY,gBACjB,KAAK,YAAY,oBACjB,KAAK,YAAY,2BACV,EAGT,sBAAuB,CACrB,KAAK,mBAAmB,uBAG1B,sBAAuB,CACrB,KAAK,mBAAmB,uBAG1B,eAAgB,CACd,KAAK,mBAAmB,gBACxB,KAAK,YAAY,gBAGnB,aAAc,CACZ,KAAK,YAAY,YACjB,KAAK,mBAAmB,eAjNrB,EAAM,sBADE,uEAr4BT",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(n){const u=class extends n.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this._ignoreTouchingEdges=!0;this._slopeClimbingFactor=1;this._canGoDownFromJumpthru=!1;this._currentSpeed=0;this._requestedDeltaX=0;this._requestedDeltaY=0;this._lastDeltaY=0;this._currentFallSpeed=0;this._canJump=!1;this._lastDirectionIsLeft=!1;this._leftKey=!1;this._rightKey=!1;this._ladderKey=!1;this._upKey=!1;this._downKey=!1;this._jumpKey=!1;this._jumpKeyHeldSinceJumpStart=!1;this._releasePlatformKey=!1;this._releaseLadderKey=!1;this._dontClearInputsBetweenFrames=!1;this._ignoreDefaultControlsAsSyncedByNetwork=!1;this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasLadderKeyPressed=!1;this._wasUpKeyPressed=!1;this._wasDownKeyPressed=!1;this._wasJumpKeyPressed=!1;this._wasReleasePlatformKeyPressed=!1;this._wasReleaseLadderKeyPressed=!1;this._hasReallyMoved=!1;this._hasMovedAtLeastOnePixel=!1;this._gravity=t.gravity,this._maxFallingSpeed=t.maxFallingSpeed,this._ladderClimbingSpeed=t.ladderClimbingSpeed||150,this._acceleration=t.acceleration,this._deceleration=t.deceleration,this._maxSpeed=t.maxSpeed,this._jumpSpeed=t.jumpSpeed,this._canGrabPlatforms=t.canGrabPlatforms||!1,this._canGrabWithoutMoving=t.canGrabWithoutMoving,this._yGrabOffset=t.yGrabOffset||0,this._xGrabTolerance=t.xGrabTolerance||10,this._jumpSustainTime=t.jumpSustainTime||0,this._ignoreDefaultControls=t.ignoreDefaultControls,this._useLegacyTrajectory=t.useLegacyTrajectory===void 0?!0:t.useLegacyTrajectory,this._useRepeatedJump=t.useRepeatedJump===void 0?!0:t.useRepeatedJump,this._canGoDownFromJumpthru=t.canGoDownFromJumpthru,this._slopeMaxAngle=0,this.setSlopeMaxAngle(t.slopeMaxAngle),this._potentialCollidingObjects=[],this._overlappedJumpThru=[],this._manager=n.PlatformObjectsManager.getManager(e),this._falling=new w(this),this._onFloor=new v(this),this._jumping=new j(this),this._grabbingPlatform=new F(this),this._onLadder=new M(this),this._state=this._falling}getNetworkSyncData(){return this._dontClearInputsBetweenFrames=!1,this._ignoreDefaultControlsAsSyncedByNetwork=!1,{...super.getNetworkSyncData(),props:{cs:this._currentSpeed,rdx:this._requestedDeltaX,rdy:this._requestedDeltaY,ldy:this._lastDeltaY,cfs:this._currentFallSpeed,cj:this._canJump,ldl:this._lastDirectionIsLeft,lek:this._wasLeftKeyPressed,rik:this._wasRightKeyPressed,lak:this._wasLadderKeyPressed,upk:this._wasUpKeyPressed,dok:this._wasDownKeyPressed,juk:this._wasJumpKeyPressed,rpk:this._wasReleasePlatformKeyPressed,rlk:this._wasReleaseLadderKeyPressed,jkhsjs:this._jumpKeyHeldSinceJumpStart,sn:this._state.toString(),ssd:this._state.getNetworkSyncData()}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;if(t.cs!==this._currentSpeed&&(this._currentSpeed=t.cs),t.rdx!==this._requestedDeltaX&&(this._requestedDeltaX=t.rdx),t.rdy!==this._requestedDeltaY&&(this._requestedDeltaY=t.rdy),t.ldy!==this._lastDeltaY&&(this._lastDeltaY=t.ldy),t.cfs!==this._currentFallSpeed&&(this._currentFallSpeed=t.cfs),t.cj!==this._canJump&&(this._canJump=t.cj),t.ldl!==this._lastDirectionIsLeft&&(this._lastDirectionIsLeft=t.ldl),t.lek!==this._leftKey&&(this._leftKey=t.lek),t.rik!==this._rightKey&&(this._rightKey=t.rik),t.lak!==this._ladderKey&&(this._ladderKey=t.lak),t.upk!==this._upKey&&(this._upKey=t.upk),t.dok!==this._downKey&&(this._downKey=t.dok),t.juk!==this._jumpKey&&(this._jumpKey=t.juk),t.rpk!==this._releasePlatformKey&&(this._releasePlatformKey=t.rpk),t.rlk!==this._releaseLadderKey&&(this._releaseLadderKey=t.rlk),t.jkhsjs!==this._jumpKeyHeldSinceJumpStart&&(this._jumpKeyHeldSinceJumpStart=t.jkhsjs),t.sn!==this._state.toString())switch(t.sn){case"Falling":this._setFalling();break;case"OnFloor":break;case"Jumping":this._setJumping();break;case"GrabbingPlatform":break;case"OnLadder":this._setOnLadder();break;default:console.error("Unknown state name: "+t.sn+".");break}t.sn===this._state.toString()&&this._state.updateFromNetworkSyncData(t.ssd),this._dontClearInputsBetweenFrames=!0,this._ignoreDefaultControlsAsSyncedByNetwork=!0}updateFromBehaviorData(e,t){return e.gravity!==t.gravity&&this.setGravity(t.gravity),e.maxFallingSpeed!==t.maxFallingSpeed&&this.setMaxFallingSpeed(t.maxFallingSpeed),e.acceleration!==t.acceleration&&this.setAcceleration(t.acceleration),e.deceleration!==t.deceleration&&this.setDeceleration(t.deceleration),e.maxSpeed!==t.maxSpeed&&this.setMaxSpeed(t.maxSpeed),e.jumpSpeed!==t.jumpSpeed&&this.setJumpSpeed(t.jumpSpeed),e.canGrabPlatforms!==t.canGrabPlatforms&&this.setCanGrabPlatforms(t.canGrabPlatforms),e.canGrabWithoutMoving!==t.canGrabWithoutMoving&&(this._canGrabWithoutMoving=t.canGrabWithoutMoving),e.yGrabOffset!==t.yGrabOffset&&(this._yGrabOffset=t.yGrabOffset),e.xGrabTolerance!==t.xGrabTolerance&&(this._xGrabTolerance=t.xGrabTolerance),e.jumpSustainTime!==t.jumpSustainTime&&this.setJumpSustainTime(t.jumpSustainTime),e.useLegacyTrajectory!==t.useLegacyTrajectory&&(this._useLegacyTrajectory=t.useLegacyTrajectory),e.canGoDownFromJumpthru!==t.canGoDownFromJumpthru&&(this._canGoDownFromJumpthru=t.canGoDownFromJumpthru),!0}doStepPreEvents(e){const t=37,i=38,r=39,s=40,a=1016,o=2016,f=32,l=this.owner,h=this.owner.getElapsedTime()/1e3;this._requestedDeltaX=0,this._requestedDeltaY=0;const _=e.getGame().getInputManager();this._leftKey||(this._leftKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(t)),this._rightKey||(this._rightKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(r)),this._jumpKey||(this._jumpKey=!this.shouldIgnoreDefaultControls()&&(_.isKeyPressed(a)||_.isKeyPressed(o)||_.isKeyPressed(f))),this._jumpKey||(this._jumpKeyHeldSinceJumpStart=!1),this._ladderKey||(this._ladderKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(i)),this._upKey||(this._upKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(i)),this._downKey||(this._downKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(s)),this._releasePlatformKey||(this._releasePlatformKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(s)),this._requestedDeltaX+=this._updateSpeed(h),this._leftKey!==this._rightKey&&(this._lastDirectionIsLeft=this._leftKey),this._state.beforeUpdatingObstacles(h),this._onFloor._oldHeight=l.getHeight(),this._updatePotentialCollidingObjects(Math.max(this._requestedDeltaX,this._maxFallingSpeed*h)),this._updateOverlappedJumpThru();const g=this._state;this._state.checkTransitionBeforeX(),this._state.beforeMovingX(),this._separateFromPlatforms(this._potentialCollidingObjects,!0)&&(this._canJump=!0);const d=l.getX();this._moveX();const m=l.getX()!==d+this._requestedDeltaX,p=this._state;this._state.checkTransitionBeforeY(h),this._state.beforeMovingY(h,d);const P=l.getY();this._moveY();const Y=this._state;this._state!==this._onLadder&&this._checkTransitionOnFloorOrFalling(),m&&this._state===g&&this._state===p&&this._state===Y&&this._state!==this._onFloor&&(this._currentSpeed=0),this._wasLeftKeyPressed=this._leftKey,this._wasRightKeyPressed=this._rightKey,this._wasLadderKeyPressed=this._ladderKey,this._wasUpKeyPressed=this._upKey,this._wasDownKeyPressed=this._downKey,this._wasJumpKeyPressed=this._jumpKey,this._wasReleasePlatformKeyPressed=this._releasePlatformKey,this._wasReleaseLadderKeyPressed=this._releaseLadderKey,this._dontClearInputsBetweenFrames||(this._leftKey=!1,this._rightKey=!1,this._ladderKey=!1,this._upKey=!1,this._downKey=!1,this._jumpKey=!1,this._releasePlatformKey=!1,this._releaseLadderKey=!1),this._hasReallyMoved=Math.abs(l.getX()-d)>u.epsilon||Math.abs(l.getY()-P)>u.epsilon,this._hasMovedAtLeastOnePixel=Math.abs(l.getX()-d)>=1||Math.abs(l.getY()-P)>=1,this._lastDeltaY=l.getY()-P}doStepPostEvents(e){}_updateSpeed(e){const t=this._currentSpeed;if(this._leftKey!==this._rightKey&&(this._leftKey?this._currentSpeed<=0?this._currentSpeed-=this._acceleration*e:this._currentSpeed-=Math.max(this._acceleration,this._deceleration)*e:this._rightKey&&(this._currentSpeed>=0?this._currentSpeed+=this._acceleration*e:this._currentSpeed+=Math.max(this._acceleration,this._deceleration)*e)),this._leftKey===this._rightKey){const i=this._currentSpeed>0;this._currentSpeed-=this._deceleration*e*(i?1:-1),i&&this._currentSpeed<0&&(this._currentSpeed=0),!i&&this._currentSpeed>0&&(this._currentSpeed=0)}return this._currentSpeed>this._maxSpeed&&(this._currentSpeed=this._maxSpeed),this._currentSpeed<-this._maxSpeed&&(this._currentSpeed=-this._maxSpeed),(this._currentSpeed+t)*e/2}_moveX(){const e=this.owner,t=e.getX();if(this._requestedDeltaX!==0){let i=this._onFloor.getFloorPlatform()!==null?this._onFloor.getFloorPlatform().owner.id:null;e.setX(e.getX()+this._requestedDeltaX);let r=!0;for(;this._isCollidingWithOneOf(this._potentialCollidingObjects,i,!0,this._onFloor.getFloorPolygon());){if(this._requestedDeltaX>0&&e.getX()<=t||this._requestedDeltaX<0&&e.getX()>=t){e.setX(t);break}r?(e.setX(Math.round(e.getX())),r=!1):e.setX(Math.round(e.getX())+(this._requestedDeltaX>0?-1:1))}}}_moveY(){const e=this.owner;if(this._requestedDeltaY!==0)if(this._requestedDeltaY>0){const{highestGroundPlatform:t}=this._findHighestFloorAndMoveOnTop(this._potentialCollidingObjects,0,this._requestedDeltaY);t||e.setY(e.getY()+this._requestedDeltaY)}else{let t=e.getY();for(e.setY(e.getY()+this._requestedDeltaY);this._requestedDeltaY<0&&this._isCollidingWithOneOf(this._potentialCollidingObjects,null,!0)||this._requestedDeltaY>0&&this._isCollidingWithOneOfExcluding(this._potentialCollidingObjects,this._overlappedJumpThru);){if(this._state===this._jumping&&this._setFalling(),this._requestedDeltaY>0&&e.getY()<=t||this._requestedDeltaY<0&&e.getY()>=t){e.setY(t);break}e.setY(Math.floor(e.getY())+(this._requestedDeltaY>0?-1:1))}}}_setFalling(){this._state.leave();const e=this._state;this._state=this._falling,this._falling.enter(e)}_setOnFloor(e,t){this._state.leave(),this._state=this._onFloor,this._onFloor.enter(e,t)}_setJumping(){this._state.leave();const e=this._state;this._state=this._jumping,this._jumping.enter(e)}_setGrabbingPlatform(e){this._state.leave(),this._state=this._grabbingPlatform,this._grabbingPlatform.enter(e)}_setOnLadder(){this._state.leave(),this._state=this._onLadder,this._onLadder.enter()}_checkTransitionOnLadder(){this._ladderKey&&this._isOverlappingLadder()&&this._setOnLadder()}_checkTransitionJumping(){this._canJump&&this._jumpKey&&(!this._jumpKeyHeldSinceJumpStart||this._useRepeatedJump)&&this._setJumping()}_checkGrabPlatform(){const e=this.owner;let t=e.getX();e.setX(e.getX()+(this._requestedDeltaX<0||this._requestedDeltaX===0&&this._lastDirectionIsLeft?-this._xGrabTolerance:this._xGrabTolerance));const i=n.staticArray(u.prototype._checkGrabPlatform);i.length=0;for(const s of this._potentialCollidingObjects)this._isCollidingWith(s)&&this._canGrab(s)&&i.push(s);e.setX(t);let r=e.getY();for(const s of i){if(e.setY(s.owner.getY()+s.getYGrabOffset()-this._yGrabOffset),!this._isCollidingWithOneOf(this._potentialCollidingObjects,null,!0)){this._setGrabbingPlatform(s),this._requestedDeltaY=0,i.length=0;return}e.setY(r)}i.length=0}_checkTransitionOnFloorOrFalling(){const e=this.owner,t=e.getY(),i=this._requestedDeltaY>=0,{highestGroundPlatform:r,highestGroundPolygon:s}=this._findHighestFloorAndMoveOnTop(this._potentialCollidingObjects,-1,1);this._state===this._onFloor?!r||!s?this._setFalling():r===this._onFloor.getFloorPlatform()&&s===this._onFloor.getFloorPolygon()?this._onFloor.updateFloorPosition():this._setOnFloor(r,s):r&&s&&i?this._setOnFloor(r,s):e.setY(t)}_fall(e){const t=this._currentFallSpeed;this._currentFallSpeed+=this._gravity*e,this._currentFallSpeed>this._maxFallingSpeed&&(this._currentFallSpeed=this._maxFallingSpeed),this._useLegacyTrajectory?this._requestedDeltaY+=this._currentFallSpeed*e:this._requestedDeltaY+=(this._currentFallSpeed+t)/2*e}_canGrab(e){const t=this.owner.getY()+this._yGrabOffset-this._lastDeltaY,i=this.owner.getY()+this._yGrabOffset,r=e.owner.getY()+e.getYGrabOffset();return e.canBeGrabbed()&&(t<r&&r<=i||i<=r&&r<t)}_releaseGrabbedPlatform(){this._state===this._grabbingPlatform&&this._setFalling()}_releaseLadder(){this._state===this._onLadder&&this._setFalling()}_separateFromPlatforms(e,t){t=!!t;const i=n.staticArray(u.prototype._separateFromPlatforms);i.length=0;for(let r=0;r<e.length;++r){const s=e[r];s.getPlatformType()!==n.PlatformRuntimeBehavior.LADDER&&(t&&s.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU||i.push(s.owner))}return this.owner.separateFromObjects(i,this._ignoreTouchingEdges)}_isCollidingWithOneOf(e,t,i,r){i=!!i;for(let s=0;s<e.length;++s){const a=e[s],o=a.owner.id===t;if(!(o&&!r)&&a.getPlatformType()!==n.PlatformRuntimeBehavior.LADDER&&!(i&&a.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU)&&n.RuntimeObject.collisionTest(a.owner,this.owner,this._ignoreTouchingEdges,o?r:null))return!0}return!1}_findHighestFloorAndMoveOnTop(e,t,i){const r=y.instance;r.initializeBeforeSearch(this,t,i);let s=Number.MAX_VALUE,a=null,o=null,f=!1;for(const h of e){if(h.getPlatformType()===n.PlatformRuntimeBehavior.LADDER||h.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU&&(this._state===this._onFloor&&h!==this._onFloor.getFloorPlatform()&&i<0||this._state!==this._onFloor&&this._isIn(this._overlappedJumpThru,h.owner.id)))continue;const _=r.allowedMinDeltaY,g=r.allowedMaxDeltaY;this._findPlatformHighestRelativeYUnderObject(h,r);let d=r.getFloorDeltaY();if(h.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU&&(this._state===this._onFloor&&h!==this._onFloor.getFloorPlatform()&&d<0||r.allowedMinDeltaY!==_)){r.revertTo(_,g);continue}if(r.isCollidingAnyPlatform()&&(f=!0),r.floorIsTooHigh()){a=null,o=null;break}r.isCollidingAnyPlatform()&&d<s&&(s=d,a=h,o=r.highestFloorPolygon)}if(a){const h=this.owner;h.setY(h.getY()+s)}const l=n.PlatformerObjectRuntimeBehavior._platformSearchResult;return l.highestGroundPlatform=a,l.highestGroundPolygon=o,l.isCollidingAnyPlatform=f,l}_findPlatformHighestRelativeYUnderObject(e,t){const i=e.owner,r=i.getAABB();if(r.max[0]<=t.ownerMinX||r.min[0]>=t.ownerMaxX||r.max[1]<=t.headMinY||r.min[1]>t.floorMaxY)return t;for(const s of i.getHitBoxesAround(t.ownerMinX,t.headMinY,t.ownerMaxX,t.floorMaxY)){if(s.vertices.length<3)continue;t.initializeBeforeHitboxCheck();let a=s.vertices[s.vertices.length-2],o=s.vertices[s.vertices.length-1];for(const f of s.vertices){(t.ownerMinX<o[0]&&o[0]<t.ownerMaxX||o[0]===t.ownerMinX&&(a[0]>o[0]||f[0]>o[0])||o[0]===t.ownerMaxX&&(a[0]<o[0]||f[0]<o[0]))&&t.addPointConstraint(o[1],s);const l=o[0]-a[0];if(l!==0){if(o[0]<t.ownerMinX&&t.ownerMinX<a[0]||a[0]<t.ownerMinX&&t.ownerMinX<o[0]){const h=o[1]-a[1],_=a[1]+(t.ownerMinX-a[0])*h/l;t.addPointConstraint(_,s)}if(o[0]<t.ownerMaxX&&t.ownerMaxX<a[0]||a[0]<t.ownerMaxX&&t.ownerMaxX<o[0]){const h=o[1]-a[1],_=a[1]+(t.ownerMaxX-a[0])*h/l;t.addPointConstraint(_,s)}}if(t.floorIsTooHigh())return t;a=o,o=f}}return t}_isCollidingWithOneOfExcluding(e,t){for(let i=0;i<e.length;++i){const r=e[i];if(!(t&&this._isIn(t,r.owner.id))&&r.getPlatformType()!==n.PlatformRuntimeBehavior.LADDER&&n.RuntimeObject.collisionTest(this.owner,r.owner,this._ignoreTouchingEdges))return!0}return!1}_isCollidingWith(e){return e.getPlatformType()!==n.PlatformRuntimeBehavior.LADDER&&!this._isIn(this._overlappedJumpThru,e.owner.id)&&n.RuntimeObject.collisionTest(this.owner,e.owner,this._ignoreTouchingEdges)}_updateOverlappedJumpThru(){this._overlappedJumpThru.length=0;for(let e=0;e<this._potentialCollidingObjects.length;++e){const t=this._potentialCollidingObjects[e];t.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU&&n.RuntimeObject.collisionTest(this.owner,t.owner,this._ignoreTouchingEdges)&&this._overlappedJumpThru.push(t)}}_isOverlappingLadder(){for(let e=0;e<this._potentialCollidingObjects.length;++e){const t=this._potentialCollidingObjects[e];if(t.getPlatformType()===n.PlatformRuntimeBehavior.LADDER&&n.RuntimeObject.collisionTest(this.owner,t.owner,this._ignoreTouchingEdges))return!0}return!1}_isIn(e,t){for(let i=0;i<e.length;++i)if(e[i].owner.id===t)return!0;return!1}_updatePotentialCollidingObjects(e){const t=this.owner;this._manager.getAllPlatformsAround(t,e,this._potentialCollidingObjects);for(let i=0;i<this._potentialCollidingObjects.length;)this._potentialCollidingObjects[i].owner===t?this._potentialCollidingObjects.splice(i,1):i++}simulateControl(e){e==="Left"?this._leftKey=!0:e==="Right"?this._rightKey=!0:e==="Up"?this._upKey=!0:e==="Down"?this._downKey=!0:e==="Ladder"?this._ladderKey=!0:e==="Jump"?this._jumpKey=!0:e==="Release"?this._releasePlatformKey=!0:e==="Release Ladder"&&(this._releaseLadderKey=!0)}isUsingControl(e){return e==="Left"?this._wasLeftKeyPressed:e==="Right"?this._wasRightKeyPressed:e==="Up"?this._wasUpKeyPressed:e==="Down"?this._wasDownKeyPressed:e==="Ladder"?this._wasLadderKeyPressed:e==="Jump"?this._wasJumpKeyPressed:e==="Release"?this._wasReleasePlatformKeyPressed:e==="Release Ladder"?this._wasReleaseLadderKeyPressed:!1}getGravity(){return this._gravity}getSlopeMaxAngle(){return this._slopeMaxAngle}getMaxFallingSpeed(){return this._maxFallingSpeed}getLadderClimbingSpeed(){return this._ladderClimbingSpeed}getAcceleration(){return this._acceleration}getDeceleration(){return this._deceleration}getMaxSpeed(){return this._maxSpeed}getJumpSpeed(){return this._jumpSpeed}getJumpSustainTime(){return this._jumpSustainTime}getCurrentFallSpeed(){return this._currentFallSpeed}getCurrentSpeed(){return this._currentSpeed}setCurrentSpeed(e){this._currentSpeed=n.evtTools.common.clamp(e,-this._maxSpeed,this._maxSpeed)}getCurrentJumpSpeed(){return this._jumping.getCurrentJumpSpeed()}canGrabPlatforms(){return this._canGrabPlatforms}canJump(){return this._canJump}setGravity(e){this._gravity=e}setMaxFallingSpeed(e,t=!1){if(t&&this._state===this._jumping){const i=this._currentFallSpeed-e;i>0&&(this._currentFallSpeed-=i,this._jumping.setCurrentJumpSpeed(Math.max(0,this._jumping.getCurrentJumpSpeed()-i)))}this._maxFallingSpeed=e}setLadderClimbingSpeed(e){this._ladderClimbingSpeed=e}setAcceleration(e){this._acceleration=e}setDeceleration(e){this._deceleration=e}setMaxSpeed(e){this._maxSpeed=e}setJumpSpeed(e){this._jumpSpeed=e}setJumpSustainTime(e){this._jumpSustainTime=e}setSlopeMaxAngle(e){e<0||e>=90||(this._slopeMaxAngle=e,e===45?this._slopeClimbingFactor=1:this._slopeClimbingFactor=Math.tan(e*3.1415926/180),this._slopeClimbingFactor<1/1024&&(this._slopeClimbingFactor=1/1024))}setCanJump(){this._canJump=!0}setCanNotAirJump(){(this._state===this._jumping||this._state===this._falling)&&(this._canJump=!1)}abortJump(){this._state===this._jumping&&(this._currentFallSpeed=0,this._setFalling())}setCurrentFallSpeed(e){this._state===this._falling&&(this._currentFallSpeed=n.evtTools.common.clamp(e,0,this._maxFallingSpeed))}setCanGrabPlatforms(e){this._canGrabPlatforms=e,this._canGrabPlatforms||this._releaseGrabbedPlatform()}ignoreDefaultControls(e){this._ignoreDefaultControls=e}shouldIgnoreDefaultControls(){return this._ignoreDefaultControls||this._ignoreDefaultControlsAsSyncedByNetwork}simulateLeftKey(){this._leftKey=!0}simulateRightKey(){this._rightKey=!0}simulateLadderKey(){this._ladderKey=!0}simulateReleaseLadderKey(){this._releaseLadderKey=!0}simulateUpKey(){this._upKey=!0}simulateDownKey(){this._downKey=!0}simulateJumpKey(){this._jumpKey=!0}simulateReleasePlatformKey(){this._releasePlatformKey=!0}isOnFloor(){return this._state===this._onFloor}isOnFloorObject(e){if(this.isOnFloor()){const t=this._onFloor.getFloorPlatform();return!!t&&t.owner.id===e.id}return!1}isOnLadder(){return this._state===this._onLadder}isJumping(){return this._state===this._jumping}isGrabbingPlatform(){return this._state===this._grabbingPlatform}isFallingWithoutJumping(){return this._state===this._falling}isFalling(){return this._state===this._falling||this._state===this._jumping&&this._currentFallSpeed>this._jumping.getCurrentJumpSpeed()}isMoving(){return this._hasMovedAtLeastOnePixel&&(this._currentSpeed!==0||this._state===this._onLadder)||this._jumping.getCurrentJumpSpeed()!==0||this._currentFallSpeed!==0}isMovingEvenALittle(){return this._hasReallyMoved&&(this._currentSpeed!==0||this._state===this._onLadder)||this._jumping.getCurrentJumpSpeed()!==0||this._currentFallSpeed!==0}};let b=u;b._platformSearchResult={highestGroundPlatform:null,highestGroundPolygon:null,isCollidingAnyPlatform:!1},b.epsilon=2**-20,n.PlatformerObjectRuntimeBehavior=b;class v{constructor(e){this._floorPlatform=null;this._floorPolygon=null;this._floorLastX=0;this._floorLastY=0;this._oldHeight=0;this._behavior=e}getFloorPlatform(){return this._floorPlatform}getFloorPolygon(){return this._floorPolygon}enter(e,t){this._floorPlatform=e,this._floorPolygon=t,this.updateFloorPosition(),this._behavior._canJump=!0,this._behavior._currentFallSpeed=0}leave(){this._floorPlatform=null,this._floorPolygon=null}updateFloorPosition(){this._floorLastX=this._floorPlatform.owner.getX(),this._floorLastY=this._floorPlatform.owner.getY()}beforeUpdatingObstacles(e){const t=this._behavior.owner;if(this._oldHeight!==t.getHeight()){const r=(this._oldHeight-t.getHeight())*(t.getHeight()+t.getDrawableY()-t.getY())/t.getHeight();t.setY(t.getY()+r)}const i=this._floorPlatform.owner.getY()-this._floorLastY;i!==0&&Math.abs(i)<=Math.abs(this._behavior._maxFallingSpeed*e)&&t.setY(t.getY()+i)}checkTransitionBeforeX(){const e=this._behavior;e._isIn(e._potentialCollidingObjects,this._floorPlatform.owner.id)?this._behavior._downKey&&this._floorPlatform._platformType===n.PlatformRuntimeBehavior.JUMPTHRU&&e._canGoDownFromJumpthru&&(e._overlappedJumpThru.push(this._floorPlatform),e._setFalling()):e._setFalling(),e._checkTransitionJumping()}beforeMovingX(){const e=this._behavior;e._requestedDeltaX+=this._floorPlatform.owner.getX()-this._floorLastX}checkTransitionBeforeY(e){this._behavior._checkTransitionOnLadder()}beforeMovingY(e,t){const i=this._behavior,r=i.owner;if(r.getX()===t+i._requestedDeltaX){const s=Math.abs(i._requestedDeltaX*i._slopeClimbingFactor),{highestGroundPlatform:a,highestGroundPolygon:o,isCollidingAnyPlatform:f}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,-s,s);a&&o&&(a!==this._floorPlatform||o!==this._floorPolygon)&&i._setOnFloor(a,o),a===null&&f&&i.owner.setX(t)}else{const{highestGroundPlatform:s,isCollidingAnyPlatform:a}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,Math.min(0,-Math.abs(r.getX()-t)*i._slopeClimbingFactor),0);if(s===null&&a)i.owner.setX(t);else{const o=i._requestedDeltaX,f=o-(r.getX()-t),l=r.getY(),h=r.getX();r.setX(r.getX()+Math.sign(o));const{highestGroundPlatform:_}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,Math.min(-1,-1*i._slopeClimbingFactor),0);if(_){const g=Math.sign(o)*Math.max(1,Math.abs(f)-1);r.setX(r.getX()+g);const{highestGroundPlatform:d,highestGroundPolygon:m}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,-Math.abs(g)*i._slopeClimbingFactor,0);if(d&&m)if(Math.abs(f)>=2)i._setOnFloor(d,m);else{r.setPosition(t+o,l);const{highestGroundPlatform:p}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,Math.min(-1,-Math.abs(f)*i._slopeClimbingFactor),0);p&&m&&i._setOnFloor(p,m)}else Math.sign(h-t)===Math.sign(o)?r.setPosition(h,l):r.setPosition(t,l),i._currentSpeed=0}else Math.sign(h-t)===Math.sign(o)?r.setPosition(h,l):r.setPosition(t,l),i._currentSpeed=0}}}getNetworkSyncData(){return{flx:this._floorLastX,fly:this._floorLastY,oh:this._oldHeight}}updateFromNetworkSyncData(e){this._floorLastX=e.flx,this._floorLastY=e.fly,this._oldHeight=e.oh}toString(){return"OnFloor"}}class w{constructor(e){this._behavior=e}enter(e){e!==this._behavior._jumping&&e!==this&&(this._behavior._canJump=!1)}leave(){}beforeUpdatingObstacles(e){}checkTransitionBeforeX(){}beforeMovingX(){}checkTransitionBeforeY(e){const t=this._behavior;t._checkTransitionOnLadder(),t._checkTransitionJumping(),t._canGrabPlatforms&&(t._requestedDeltaX!==0||t._canGrabWithoutMoving)&&t._checkGrabPlatform()}beforeMovingY(e,t){this._behavior._fall(e)}getNetworkSyncData(){return{}}updateFromNetworkSyncData(e){}toString(){return"Falling"}}class j{constructor(e){this._currentJumpSpeed=0;this._timeSinceCurrentJumpStart=0;this._jumpingFirstDelta=!1;this._behavior=e}getCurrentJumpSpeed(){return this._currentJumpSpeed}setCurrentJumpSpeed(e){this._currentJumpSpeed=e}enter(e){const t=this._behavior;this._timeSinceCurrentJumpStart=0,t._jumpKeyHeldSinceJumpStart=!0,e!==t._jumping&&e!==t._falling&&(this._jumpingFirstDelta=!0),t._canJump=!1,this._currentJumpSpeed=t._jumpSpeed,t._currentFallSpeed=0}leave(){this._currentJumpSpeed=0}beforeUpdatingObstacles(e){}checkTransitionBeforeX(){}beforeMovingX(){}checkTransitionBeforeY(e){const t=this._behavior;t._checkTransitionOnLadder(),t._checkTransitionJumping(),t._canGrabPlatforms&&(t._requestedDeltaX!==0||t._canGrabWithoutMoving)&&t._lastDeltaY>=0&&t._checkGrabPlatform()}beforeMovingY(e,t){const i=this._behavior;this._timeSinceCurrentJumpStart+=e;const r=this._currentJumpSpeed;i._jumpKeyHeldSinceJumpStart&&this._timeSinceCurrentJumpStart<i._jumpSustainTime||(this._currentJumpSpeed-=i._gravity*e),this._behavior._useLegacyTrajectory?(i._requestedDeltaY-=r*e,this._jumpingFirstDelta||i._fall(e)):(i._requestedDeltaY+=(-r-this._currentJumpSpeed)/2*e,i._fall(e)),this._jumpingFirstDelta=!1,this._currentJumpSpeed<0&&i._setFalling()}getNetworkSyncData(){return{cjs:this._currentJumpSpeed,tscjs:this._timeSinceCurrentJumpStart,jfd:this._jumpingFirstDelta}}updateFromNetworkSyncData(e){this._currentJumpSpeed=e.cjs,this._timeSinceCurrentJumpStart=e.tscjs,this._jumpingFirstDelta=e.jfd}toString(){return"Jumping"}}class F{constructor(e){this._grabbedPlatform=null;this._behavior=e}enter(e){this._grabbedPlatform=e,this._behavior._canJump=!0,this._behavior._currentFallSpeed=0}leave(){this._grabbedPlatform=null}beforeUpdatingObstacles(e){}checkTransitionBeforeX(){const e=this._behavior;e._isIn(e._potentialCollidingObjects,this._grabbedPlatform.owner.id)||e._releaseGrabbedPlatform()}beforeMovingX(){const e=this._behavior;e._requestedDeltaX=this._grabbedPlatform.owner.getX()-this._grabbedPlatformLastX,e._requestedDeltaY=this._grabbedPlatform.owner.getY()-this._grabbedPlatformLastY}checkTransitionBeforeY(e){const t=this._behavior;t._checkTransitionOnLadder(),t._releasePlatformKey&&t._releaseGrabbedPlatform(),t._checkTransitionJumping()}beforeMovingY(e,t){this._grabbedPlatformLastX=this._grabbedPlatform.owner.getX(),this._grabbedPlatformLastY=this._grabbedPlatform.owner.getY()}getNetworkSyncData(){return{gplx:this._grabbedPlatformLastX,gply:this._grabbedPlatformLastY}}updateFromNetworkSyncData(e){this._grabbedPlatformLastX=e.gplx,this._grabbedPlatformLastY=e.gply}toString(){return"GrabbingPlatform"}}class M{constructor(e){this._behavior=e}enter(){this._behavior._canJump=!0,this._behavior._currentFallSpeed=0}leave(){}beforeUpdatingObstacles(e){}checkTransitionBeforeX(){}beforeMovingX(){}checkTransitionBeforeY(e){const t=this._behavior;t._isOverlappingLadder()||t._setFalling(),t._checkTransitionJumping(),t._releaseLadderKey&&t._releaseLadder()}beforeMovingY(e,t){const i=this._behavior;i._upKey&&(i._requestedDeltaY-=i._ladderClimbingSpeed*e),i._downKey&&(i._requestedDeltaY+=i._ladderClimbingSpeed*e)}getNetworkSyncData(){return{}}updateFromNetworkSyncData(e){}toString(){return"OnLadder"}}const S=class{constructor(){this.ownerMinX=0;this.ownerMaxX=0;this.headMinY=0;this.ownerMinY=0;this.headMaxY=0;this.floorMinY=0;this.ownerMaxY=0;this.floorMaxY=0;this.allowedMinDeltaY=0;this.allowedMaxDeltaY=0;this.foundOverHead=!1;this.foundUnderBottom=!1;this.highestFloorPolygon=null}initializeBeforeSearch(e,t,i){let r=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=Number.MAX_VALUE,o=-Number.MAX_VALUE;for(const f of e.owner.getHitBoxes())for(const l of f.vertices)r=Math.min(r,l[0]),s=Math.max(s,l[0]),a=Math.min(a,l[1]),o=Math.max(o,l[1]);this.ownerMinX=r,this.ownerMaxX=s,this.headMinY=a+t,this.ownerMinY=a,this.headMaxY=a+i,this.floorMinY=o+t,this.ownerMaxY=o,this.floorMaxY=o+i,this.allowedMinDeltaY=t,this.allowedMaxDeltaY=Number.MAX_VALUE}initializeBeforeHitboxCheck(){this.foundOverHead=!1,this.foundUnderBottom=!1}revertTo(e,t){this.allowedMinDeltaY=e,this.allowedMaxDeltaY=t}setFloorIsTooHigh(){this.allowedMinDeltaY=Number.MAX_VALUE,this.allowedMaxDeltaY=-Number.MAX_VALUE}floorIsTooHigh(){return this.allowedMinDeltaY>this.allowedMaxDeltaY}isCollidingAnyPlatform(){return this.ownerMaxY+this.allowedMaxDeltaY<=this.floorMaxY}getFloorDeltaY(){return this.allowedMaxDeltaY}addPointConstraint(e,t){if(e<this.floorMinY){if(e>this.headMaxY){this.setFloorIsTooHigh();return}if(this.foundOverHead=!0,this.foundUnderBottom){this.setFloorIsTooHigh();return}this.allowedMinDeltaY=Math.max(this.allowedMinDeltaY,e-this.ownerMinY)}else{if(this.foundUnderBottom=!0,this.foundOverHead){this.setFloorIsTooHigh();return}this.allowedMaxDeltaY=Math.min(this.allowedMaxDeltaY,e-this.ownerMaxY),this.highestFloorPolygon=t}}};let y=S;y.instance=new S,n.registerBehavior("PlatformBehavior::PlatformerObjectBehavior",n.PlatformerObjectRuntimeBehavior)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(n){const g=class extends n.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this._ignoreTouchingEdges=!0;this._slopeClimbingFactor=1;this._canGoDownFromJumpthru=!1;this._currentSpeed=0;this._requestedDeltaX=0;this._requestedDeltaY=0;this._lastDeltaY=0;this._currentFallSpeed=0;this._canJump=!1;this._lastDirectionIsLeft=!1;this._leftKey=!1;this._rightKey=!1;this._ladderKey=!1;this._upKey=!1;this._downKey=!1;this._jumpKey=!1;this._jumpKeyHeldSinceJumpStart=!1;this._releasePlatformKey=!1;this._releaseLadderKey=!1;this._dontClearInputsBetweenFrames=!1;this._ignoreDefaultControlsAsSyncedByNetwork=!1;this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasLadderKeyPressed=!1;this._wasUpKeyPressed=!1;this._wasDownKeyPressed=!1;this._wasJumpKeyPressed=!1;this._wasReleasePlatformKeyPressed=!1;this._wasReleaseLadderKeyPressed=!1;this._hasReallyMoved=!1;this._hasMovedAtLeastOnePixel=!1;this._gravity=t.gravity,this._maxFallingSpeed=t.maxFallingSpeed,this._ladderClimbingSpeed=t.ladderClimbingSpeed||150,this._acceleration=t.acceleration,this._deceleration=t.deceleration,this._maxSpeed=t.maxSpeed,this._jumpSpeed=t.jumpSpeed,this._canGrabPlatforms=t.canGrabPlatforms||!1,this._canGrabWithoutMoving=t.canGrabWithoutMoving,this._yGrabOffset=t.yGrabOffset||0,this._xGrabTolerance=t.xGrabTolerance||10,this._jumpSustainTime=t.jumpSustainTime||0,this._ignoreDefaultControls=t.ignoreDefaultControls,this._useLegacyTrajectory=t.useLegacyTrajectory===void 0?!0:t.useLegacyTrajectory,this._useRepeatedJump=t.useRepeatedJump===void 0?!0:t.useRepeatedJump,this._canGoDownFromJumpthru=t.canGoDownFromJumpthru,this._slopeMaxAngle=0,this.setSlopeMaxAngle(t.slopeMaxAngle),this._potentialCollidingObjects=[],this._overlappedJumpThru=[],this._manager=n.PlatformObjectsManager.getManager(e),this._falling=new w(this),this._onFloor=new v(this),this._jumping=new j(this),this._grabbingPlatform=new F(this),this._onLadder=new M(this),this._state=this._falling}getNetworkSyncData(){return this._dontClearInputsBetweenFrames=!1,this._ignoreDefaultControlsAsSyncedByNetwork=!1,{...super.getNetworkSyncData(),props:{cs:this._currentSpeed,rdx:this._requestedDeltaX,rdy:this._requestedDeltaY,ldy:this._lastDeltaY,cfs:this._currentFallSpeed,cj:this._canJump,ldl:this._lastDirectionIsLeft,lek:this._wasLeftKeyPressed,rik:this._wasRightKeyPressed,lak:this._wasLadderKeyPressed,upk:this._wasUpKeyPressed,dok:this._wasDownKeyPressed,juk:this._wasJumpKeyPressed,rpk:this._wasReleasePlatformKeyPressed,rlk:this._wasReleaseLadderKeyPressed,jkhsjs:this._jumpKeyHeldSinceJumpStart,sn:this._state.toString(),ssd:this._state.getNetworkSyncData()}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;if(t.cs!==this._currentSpeed&&(this._currentSpeed=t.cs),t.rdx!==this._requestedDeltaX&&(this._requestedDeltaX=t.rdx),t.rdy!==this._requestedDeltaY&&(this._requestedDeltaY=t.rdy),t.ldy!==this._lastDeltaY&&(this._lastDeltaY=t.ldy),t.cfs!==this._currentFallSpeed&&(this._currentFallSpeed=t.cfs),t.cj!==this._canJump&&(this._canJump=t.cj),t.ldl!==this._lastDirectionIsLeft&&(this._lastDirectionIsLeft=t.ldl),t.lek!==this._leftKey&&(this._leftKey=t.lek),t.rik!==this._rightKey&&(this._rightKey=t.rik),t.lak!==this._ladderKey&&(this._ladderKey=t.lak),t.upk!==this._upKey&&(this._upKey=t.upk),t.dok!==this._downKey&&(this._downKey=t.dok),t.juk!==this._jumpKey&&(this._jumpKey=t.juk),t.rpk!==this._releasePlatformKey&&(this._releasePlatformKey=t.rpk),t.rlk!==this._releaseLadderKey&&(this._releaseLadderKey=t.rlk),t.jkhsjs!==this._jumpKeyHeldSinceJumpStart&&(this._jumpKeyHeldSinceJumpStart=t.jkhsjs),t.sn!==this._state.toString())switch(t.sn){case"Falling":this._setFalling();break;case"OnFloor":break;case"Jumping":this._setJumping();break;case"GrabbingPlatform":break;case"OnLadder":this._setOnLadder();break;default:console.error("Unknown state name: "+t.sn+".");break}t.sn===this._state.toString()&&this._state.updateFromNetworkSyncData(t.ssd),this._dontClearInputsBetweenFrames=!0,this._ignoreDefaultControlsAsSyncedByNetwork=!0}updateFromBehaviorData(e,t){return e.gravity!==t.gravity&&this.setGravity(t.gravity),e.maxFallingSpeed!==t.maxFallingSpeed&&this.setMaxFallingSpeed(t.maxFallingSpeed),e.acceleration!==t.acceleration&&this.setAcceleration(t.acceleration),e.deceleration!==t.deceleration&&this.setDeceleration(t.deceleration),e.maxSpeed!==t.maxSpeed&&this.setMaxSpeed(t.maxSpeed),e.jumpSpeed!==t.jumpSpeed&&this.setJumpSpeed(t.jumpSpeed),e.canGrabPlatforms!==t.canGrabPlatforms&&this.setCanGrabPlatforms(t.canGrabPlatforms),e.canGrabWithoutMoving!==t.canGrabWithoutMoving&&(this._canGrabWithoutMoving=t.canGrabWithoutMoving),e.yGrabOffset!==t.yGrabOffset&&(this._yGrabOffset=t.yGrabOffset),e.xGrabTolerance!==t.xGrabTolerance&&(this._xGrabTolerance=t.xGrabTolerance),e.jumpSustainTime!==t.jumpSustainTime&&this.setJumpSustainTime(t.jumpSustainTime),e.useLegacyTrajectory!==t.useLegacyTrajectory&&(this._useLegacyTrajectory=t.useLegacyTrajectory),e.canGoDownFromJumpthru!==t.canGoDownFromJumpthru&&(this._canGoDownFromJumpthru=t.canGoDownFromJumpthru),!0}doStepPreEvents(e){const t=37,i=38,r=39,s=40,a=1016,o=2016,f=32,l=this.owner,h=this.owner.getElapsedTime()/1e3;this._requestedDeltaX=0,this._requestedDeltaY=0;const _=e.getGame().getInputManager();this._leftKey||(this._leftKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(t)),this._rightKey||(this._rightKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(r)),this._jumpKey||(this._jumpKey=!this.shouldIgnoreDefaultControls()&&(_.isKeyPressed(a)||_.isKeyPressed(o)||_.isKeyPressed(f))),this._jumpKey||(this._jumpKeyHeldSinceJumpStart=!1),this._ladderKey||(this._ladderKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(i)),this._upKey||(this._upKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(i)),this._downKey||(this._downKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(s)),this._releasePlatformKey||(this._releasePlatformKey=!this.shouldIgnoreDefaultControls()&&_.isKeyPressed(s)),this._requestedDeltaX+=this._updateSpeed(h),this._leftKey!==this._rightKey&&(this._lastDirectionIsLeft=this._leftKey),this._state.beforeUpdatingObstacles(h),this._onFloor._oldHeight=l.getHeight(),this._updatePotentialCollidingObjects(Math.max(this._requestedDeltaX,this._maxFallingSpeed*h)),this._updateOverlappedJumpThru();const m=this._state;this._state.checkTransitionBeforeX(),this._state.beforeMovingX(),this._separateFromPlatforms(this._potentialCollidingObjects,!0)&&!this._jumpKey&&(this._canJump=!0);const d=l.getX();this._moveX();const p=l.getX()!==d+this._requestedDeltaX,Y=this._state;this._state.checkTransitionBeforeY(h),this._state.beforeMovingY(h,d);const P=l.getY();this._moveY();const O=this._state;this._state!==this._onLadder&&this._checkTransitionOnFloorOrFalling(),p&&this._state===m&&this._state===Y&&this._state===O&&this._state!==this._onFloor&&(this._currentSpeed=0),this._wasLeftKeyPressed=this._leftKey,this._wasRightKeyPressed=this._rightKey,this._wasLadderKeyPressed=this._ladderKey,this._wasUpKeyPressed=this._upKey,this._wasDownKeyPressed=this._downKey,this._wasJumpKeyPressed=this._jumpKey,this._wasReleasePlatformKeyPressed=this._releasePlatformKey,this._wasReleaseLadderKeyPressed=this._releaseLadderKey,this._dontClearInputsBetweenFrames||(this._leftKey=!1,this._rightKey=!1,this._ladderKey=!1,this._upKey=!1,this._downKey=!1,this._jumpKey=!1,this._releasePlatformKey=!1,this._releaseLadderKey=!1),this._hasReallyMoved=Math.abs(l.getX()-d)>g.epsilon||Math.abs(l.getY()-P)>g.epsilon,this._hasMovedAtLeastOnePixel=Math.abs(l.getX()-d)>=1||Math.abs(l.getY()-P)>=1,this._lastDeltaY=l.getY()-P}doStepPostEvents(e){}_updateSpeed(e){const t=this._currentSpeed;if(this._leftKey!==this._rightKey&&(this._leftKey?this._currentSpeed<=0?this._currentSpeed-=this._acceleration*e:this._currentSpeed-=Math.max(this._acceleration,this._deceleration)*e:this._rightKey&&(this._currentSpeed>=0?this._currentSpeed+=this._acceleration*e:this._currentSpeed+=Math.max(this._acceleration,this._deceleration)*e)),this._leftKey===this._rightKey){const i=this._currentSpeed>0;this._currentSpeed-=this._deceleration*e*(i?1:-1),i&&this._currentSpeed<0&&(this._currentSpeed=0),!i&&this._currentSpeed>0&&(this._currentSpeed=0)}return this._currentSpeed>this._maxSpeed&&(this._currentSpeed=this._maxSpeed),this._currentSpeed<-this._maxSpeed&&(this._currentSpeed=-this._maxSpeed),(this._currentSpeed+t)*e/2}_moveX(){const e=this.owner,t=e.getX();if(this._requestedDeltaX!==0){let i=this._onFloor.getFloorPlatform()!==null?this._onFloor.getFloorPlatform().owner.id:null;e.setX(e.getX()+this._requestedDeltaX);let r=!0;for(;this._isCollidingWithOneOf(this._potentialCollidingObjects,i,!0,this._onFloor.getFloorPolygon());){if(this._requestedDeltaX>0&&e.getX()<=t||this._requestedDeltaX<0&&e.getX()>=t){e.setX(t);break}r?(e.setX(Math.round(e.getX())),r=!1):e.setX(Math.round(e.getX())+(this._requestedDeltaX>0?-1:1))}}}_moveY(){const e=this.owner;if(this._requestedDeltaY!==0)if(this._requestedDeltaY>0){const{highestGroundPlatform:t}=this._findHighestFloorAndMoveOnTop(this._potentialCollidingObjects,0,this._requestedDeltaY);t||e.setY(e.getY()+this._requestedDeltaY)}else{let t=e.getY();for(e.setY(e.getY()+this._requestedDeltaY);this._requestedDeltaY<0&&this._isCollidingWithOneOf(this._potentialCollidingObjects,null,!0)||this._requestedDeltaY>0&&this._isCollidingWithOneOfExcluding(this._potentialCollidingObjects,this._overlappedJumpThru);){if(this._state===this._jumping&&this._setFalling(),this._requestedDeltaY>0&&e.getY()<=t||this._requestedDeltaY<0&&e.getY()>=t){e.setY(t);break}e.setY(Math.floor(e.getY())+(this._requestedDeltaY>0?-1:1))}}}_setFalling(){this._state.leave();const e=this._state;this._state=this._falling,this._falling.enter(e)}_setOnFloor(e,t){this._state.leave(),this._state=this._onFloor,this._onFloor.enter(e,t)}_setJumping(){this._state.leave();const e=this._state;this._state=this._jumping,this._jumping.enter(e)}_setGrabbingPlatform(e){this._state.leave(),this._state=this._grabbingPlatform,this._grabbingPlatform.enter(e)}_setOnLadder(){this._state.leave(),this._state=this._onLadder,this._onLadder.enter()}_checkTransitionOnLadder(){this._ladderKey&&this._isOverlappingLadder()&&this._setOnLadder()}_checkTransitionJumping(){this._canJump&&this._jumpKey&&(!this._jumpKeyHeldSinceJumpStart||this._useRepeatedJump)&&this._setJumping()}_checkGrabPlatform(){const e=this.owner;let t=e.getX();e.setX(e.getX()+(this._requestedDeltaX<0||this._requestedDeltaX===0&&this._lastDirectionIsLeft?-this._xGrabTolerance:this._xGrabTolerance));const i=n.staticArray(g.prototype._checkGrabPlatform);i.length=0;for(const s of this._potentialCollidingObjects)this._isCollidingWith(s)&&this._canGrab(s)&&i.push(s);e.setX(t);let r=e.getY();for(const s of i){if(e.setY(s.owner.getY()+s.getYGrabOffset()-this._yGrabOffset),!this._isCollidingWithOneOf(this._potentialCollidingObjects,null,!0)){this._setGrabbingPlatform(s),this._requestedDeltaY=0,i.length=0;return}e.setY(r)}i.length=0}_checkTransitionOnFloorOrFalling(){const e=this.owner,t=e.getY(),i=this._requestedDeltaY>=0,{highestGroundPlatform:r,highestGroundPolygon:s}=this._findHighestFloorAndMoveOnTop(this._potentialCollidingObjects,-1,1);this._state===this._onFloor?!r||!s?this._setFalling():r===this._onFloor.getFloorPlatform()&&s===this._onFloor.getFloorPolygon()?this._onFloor.updateFloorPosition():this._setOnFloor(r,s):r&&s&&i?this._setOnFloor(r,s):e.setY(t)}_fall(e){const t=this._currentFallSpeed;this._currentFallSpeed+=this._gravity*e,this._currentFallSpeed>this._maxFallingSpeed&&(this._currentFallSpeed=this._maxFallingSpeed),this._useLegacyTrajectory?this._requestedDeltaY+=this._currentFallSpeed*e:this._requestedDeltaY+=(this._currentFallSpeed+t)/2*e}_canGrab(e){const t=this.owner.getY()+this._yGrabOffset-this._lastDeltaY,i=this.owner.getY()+this._yGrabOffset,r=e.owner.getY()+e.getYGrabOffset();return e.canBeGrabbed()&&(t<r&&r<=i||i<=r&&r<t)}_releaseGrabbedPlatform(){this._state===this._grabbingPlatform&&this._setFalling()}_releaseLadder(){this._state===this._onLadder&&this._setFalling()}_separateFromPlatforms(e,t){t=!!t;const i=n.staticArray(g.prototype._separateFromPlatforms);i.length=0;for(let r=0;r<e.length;++r){const s=e[r];s.getPlatformType()!==n.PlatformRuntimeBehavior.LADDER&&(t&&s.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU||i.push(s.owner))}return this.owner.separateFromObjects(i,this._ignoreTouchingEdges)}_isCollidingWithOneOf(e,t,i,r){i=!!i;for(let s=0;s<e.length;++s){const a=e[s],o=a.owner.id===t;if(!(o&&!r)&&a.getPlatformType()!==n.PlatformRuntimeBehavior.LADDER&&!(i&&a.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU)&&n.RuntimeObject.collisionTest(a.owner,this.owner,this._ignoreTouchingEdges,o?r:null))return!0}return!1}_findHighestFloorAndMoveOnTop(e,t,i){const r=y.instance;r.initializeBeforeSearch(this,t,i);let s=Number.MAX_VALUE,a=null,o=null,f=!1;for(const h of e){if(h.getPlatformType()===n.PlatformRuntimeBehavior.LADDER||h.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU&&(this._state===this._onFloor&&h!==this._onFloor.getFloorPlatform()&&i<0||this._state!==this._onFloor&&this._isIn(this._overlappedJumpThru,h.owner.id)))continue;const _=r.allowedMinDeltaY,m=r.allowedMaxDeltaY;this._findPlatformHighestRelativeYUnderObject(h,r);let u=r.getFloorDeltaY();if(h.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU&&(this._state===this._onFloor&&h!==this._onFloor.getFloorPlatform()&&u<0||r.allowedMinDeltaY!==_)){r.revertTo(_,m);continue}if(r.isCollidingAnyPlatform()&&(f=!0),r.floorIsTooHigh()){a=null,o=null;break}r.isCollidingAnyPlatform()&&u<s&&(s=u,a=h,o=r.highestFloorPolygon)}if(a){const h=this.owner;h.setY(h.getY()+s)}const l=n.PlatformerObjectRuntimeBehavior._platformSearchResult;return l.highestGroundPlatform=a,l.highestGroundPolygon=o,l.isCollidingAnyPlatform=f,l}_findPlatformHighestRelativeYUnderObject(e,t){const i=e.owner,r=i.getAABB();if(r.max[0]<=t.ownerMinX||r.min[0]>=t.ownerMaxX||r.max[1]<=t.headMinY||r.min[1]>t.floorMaxY)return t;for(const s of i.getHitBoxesAround(t.ownerMinX,t.headMinY,t.ownerMaxX,t.floorMaxY)){if(s.vertices.length<3)continue;t.initializeBeforeHitboxCheck();let a=s.vertices[s.vertices.length-2],o=s.vertices[s.vertices.length-1];for(const f of s.vertices){(t.ownerMinX<o[0]&&o[0]<t.ownerMaxX||o[0]===t.ownerMinX&&(a[0]>o[0]||f[0]>o[0])||o[0]===t.ownerMaxX&&(a[0]<o[0]||f[0]<o[0]))&&t.addPointConstraint(o[1],s);const l=o[0]-a[0];if(l!==0){if(o[0]<t.ownerMinX&&t.ownerMinX<a[0]||a[0]<t.ownerMinX&&t.ownerMinX<o[0]){const h=o[1]-a[1],_=a[1]+(t.ownerMinX-a[0])*h/l;t.addPointConstraint(_,s)}if(o[0]<t.ownerMaxX&&t.ownerMaxX<a[0]||a[0]<t.ownerMaxX&&t.ownerMaxX<o[0]){const h=o[1]-a[1],_=a[1]+(t.ownerMaxX-a[0])*h/l;t.addPointConstraint(_,s)}}if(t.floorIsTooHigh())return t;a=o,o=f}}return t}_isCollidingWithOneOfExcluding(e,t){for(let i=0;i<e.length;++i){const r=e[i];if(!(t&&this._isIn(t,r.owner.id))&&r.getPlatformType()!==n.PlatformRuntimeBehavior.LADDER&&n.RuntimeObject.collisionTest(this.owner,r.owner,this._ignoreTouchingEdges))return!0}return!1}_isCollidingWith(e){return e.getPlatformType()!==n.PlatformRuntimeBehavior.LADDER&&!this._isIn(this._overlappedJumpThru,e.owner.id)&&n.RuntimeObject.collisionTest(this.owner,e.owner,this._ignoreTouchingEdges)}_updateOverlappedJumpThru(){this._overlappedJumpThru.length=0;for(let e=0;e<this._potentialCollidingObjects.length;++e){const t=this._potentialCollidingObjects[e];t.getPlatformType()===n.PlatformRuntimeBehavior.JUMPTHRU&&n.RuntimeObject.collisionTest(this.owner,t.owner,this._ignoreTouchingEdges)&&this._overlappedJumpThru.push(t)}}_isOverlappingLadder(){for(let e=0;e<this._potentialCollidingObjects.length;++e){const t=this._potentialCollidingObjects[e];if(t.getPlatformType()===n.PlatformRuntimeBehavior.LADDER&&n.RuntimeObject.collisionTest(this.owner,t.owner,this._ignoreTouchingEdges))return!0}return!1}_isIn(e,t){for(let i=0;i<e.length;++i)if(e[i].owner.id===t)return!0;return!1}_updatePotentialCollidingObjects(e){const t=this.owner;this._manager.getAllPlatformsAround(t,e,this._potentialCollidingObjects);for(let i=0;i<this._potentialCollidingObjects.length;)this._potentialCollidingObjects[i].owner===t?this._potentialCollidingObjects.splice(i,1):i++}simulateControl(e){e==="Left"?this._leftKey=!0:e==="Right"?this._rightKey=!0:e==="Up"?this._upKey=!0:e==="Down"?this._downKey=!0:e==="Ladder"?this._ladderKey=!0:e==="Jump"?this._jumpKey=!0:e==="Release"?this._releasePlatformKey=!0:e==="Release Ladder"&&(this._releaseLadderKey=!0)}isUsingControl(e){return e==="Left"?this._wasLeftKeyPressed:e==="Right"?this._wasRightKeyPressed:e==="Up"?this._wasUpKeyPressed:e==="Down"?this._wasDownKeyPressed:e==="Ladder"?this._wasLadderKeyPressed:e==="Jump"?this._wasJumpKeyPressed:e==="Release"?this._wasReleasePlatformKeyPressed:e==="Release Ladder"?this._wasReleaseLadderKeyPressed:!1}getGravity(){return this._gravity}getSlopeMaxAngle(){return this._slopeMaxAngle}getMaxFallingSpeed(){return this._maxFallingSpeed}getLadderClimbingSpeed(){return this._ladderClimbingSpeed}getAcceleration(){return this._acceleration}getDeceleration(){return this._deceleration}getMaxSpeed(){return this._maxSpeed}getJumpSpeed(){return this._jumpSpeed}getJumpSustainTime(){return this._jumpSustainTime}getCurrentFallSpeed(){return this._currentFallSpeed}getCurrentSpeed(){return this._currentSpeed}setCurrentSpeed(e){this._currentSpeed=n.evtTools.common.clamp(e,-this._maxSpeed,this._maxSpeed)}getCurrentJumpSpeed(){return this._jumping.getCurrentJumpSpeed()}canGrabPlatforms(){return this._canGrabPlatforms}canJump(){return this._canJump}setGravity(e){this._gravity=e}setMaxFallingSpeed(e,t=!1){if(t&&this._state===this._jumping){const i=this._currentFallSpeed-e;i>0&&(this._currentFallSpeed-=i,this._jumping.setCurrentJumpSpeed(Math.max(0,this._jumping.getCurrentJumpSpeed()-i)))}this._maxFallingSpeed=e}setLadderClimbingSpeed(e){this._ladderClimbingSpeed=e}setAcceleration(e){this._acceleration=e}setDeceleration(e){this._deceleration=e}setMaxSpeed(e){this._maxSpeed=e}setJumpSpeed(e){this._jumpSpeed=e}setJumpSustainTime(e){this._jumpSustainTime=e}setSlopeMaxAngle(e){e<0||e>=90||(this._slopeMaxAngle=e,e===45?this._slopeClimbingFactor=1:this._slopeClimbingFactor=Math.tan(e*3.1415926/180),this._slopeClimbingFactor<1/1024&&(this._slopeClimbingFactor=1/1024))}setCanJump(){this._canJump=!0}setCanNotAirJump(){(this._state===this._jumping||this._state===this._falling)&&(this._canJump=!1)}abortJump(){this._state===this._jumping&&(this._currentFallSpeed=0,this._setFalling())}setCurrentFallSpeed(e){this._state===this._falling&&(this._currentFallSpeed=n.evtTools.common.clamp(e,0,this._maxFallingSpeed))}setCanGrabPlatforms(e){this._canGrabPlatforms=e,this._canGrabPlatforms||this._releaseGrabbedPlatform()}ignoreDefaultControls(e){this._ignoreDefaultControls=e}shouldIgnoreDefaultControls(){return this._ignoreDefaultControls||this._ignoreDefaultControlsAsSyncedByNetwork}simulateLeftKey(){this._leftKey=!0}simulateRightKey(){this._rightKey=!0}simulateLadderKey(){this._ladderKey=!0}simulateReleaseLadderKey(){this._releaseLadderKey=!0}simulateUpKey(){this._upKey=!0}simulateDownKey(){this._downKey=!0}simulateJumpKey(){this._jumpKey=!0}simulateReleasePlatformKey(){this._releasePlatformKey=!0}isOnFloor(){return this._state===this._onFloor}isOnFloorObject(e){if(this.isOnFloor()){const t=this._onFloor.getFloorPlatform();return!!t&&t.owner.id===e.id}return!1}isOnLadder(){return this._state===this._onLadder}isJumping(){return this._state===this._jumping}isGrabbingPlatform(){return this._state===this._grabbingPlatform}isFallingWithoutJumping(){return this._state===this._falling}isFalling(){return this._state===this._falling||this._state===this._jumping&&this._currentFallSpeed>this._jumping.getCurrentJumpSpeed()}isMoving(){return this._hasMovedAtLeastOnePixel&&(this._currentSpeed!==0||this._state===this._onLadder)||this._jumping.getCurrentJumpSpeed()!==0||this._currentFallSpeed!==0}isMovingEvenALittle(){return this._hasReallyMoved&&(this._currentSpeed!==0||this._state===this._onLadder)||this._jumping.getCurrentJumpSpeed()!==0||this._currentFallSpeed!==0}};let b=g;b._platformSearchResult={highestGroundPlatform:null,highestGroundPolygon:null,isCollidingAnyPlatform:!1},b.epsilon=2**-20,n.PlatformerObjectRuntimeBehavior=b;class v{constructor(e){this._floorPlatform=null;this._floorPolygon=null;this._floorLastX=0;this._floorLastY=0;this._oldHeight=0;this._behavior=e}getFloorPlatform(){return this._floorPlatform}getFloorPolygon(){return this._floorPolygon}enter(e,t){this._floorPlatform=e,this._floorPolygon=t,this.updateFloorPosition(),this._behavior._canJump=!0,this._behavior._currentFallSpeed=0}leave(){this._floorPlatform=null,this._floorPolygon=null}updateFloorPosition(){this._floorLastX=this._floorPlatform.owner.getX(),this._floorLastY=this._floorPlatform.owner.getY()}beforeUpdatingObstacles(e){const t=this._behavior.owner;if(this._oldHeight!==t.getHeight()){const r=(this._oldHeight-t.getHeight())*(t.getHeight()+t.getDrawableY()-t.getY())/t.getHeight();t.setY(t.getY()+r)}const i=this._floorPlatform.owner.getY()-this._floorLastY;i!==0&&Math.abs(i)<=Math.abs(this._behavior._maxFallingSpeed*e)&&t.setY(t.getY()+i)}checkTransitionBeforeX(){const e=this._behavior;e._isIn(e._potentialCollidingObjects,this._floorPlatform.owner.id)?this._behavior._downKey&&this._floorPlatform._platformType===n.PlatformRuntimeBehavior.JUMPTHRU&&e._canGoDownFromJumpthru&&(e._overlappedJumpThru.push(this._floorPlatform),e._setFalling()):e._setFalling(),e._checkTransitionJumping()}beforeMovingX(){const e=this._behavior;e._requestedDeltaX+=this._floorPlatform.owner.getX()-this._floorLastX}checkTransitionBeforeY(e){this._behavior._checkTransitionOnLadder()}beforeMovingY(e,t){const i=this._behavior,r=i.owner;if(r.getX()===t+i._requestedDeltaX){const s=Math.abs(i._requestedDeltaX*i._slopeClimbingFactor),{highestGroundPlatform:a,highestGroundPolygon:o,isCollidingAnyPlatform:f}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,-s,s);a&&o&&(a!==this._floorPlatform||o!==this._floorPolygon)&&i._setOnFloor(a,o),a===null&&f&&i.owner.setX(t)}else{const{highestGroundPlatform:s,isCollidingAnyPlatform:a}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,Math.min(0,-Math.abs(r.getX()-t)*i._slopeClimbingFactor),0);if(s===null&&a)i.owner.setX(t);else{const o=i._requestedDeltaX,f=o-(r.getX()-t),l=r.getY(),h=r.getX();r.setX(r.getX()+Math.sign(o));const{highestGroundPlatform:_}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,Math.min(-1,-1*i._slopeClimbingFactor),0);if(_){const m=Math.sign(o)*Math.max(1,Math.abs(f)-1);r.setX(r.getX()+m);const{highestGroundPlatform:u,highestGroundPolygon:d}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,-Math.abs(m)*i._slopeClimbingFactor,0);if(u&&d)if(Math.abs(f)>=2)i._setOnFloor(u,d);else{r.setPosition(t+o,l);const{highestGroundPlatform:p}=i._findHighestFloorAndMoveOnTop(i._potentialCollidingObjects,Math.min(-1,-Math.abs(f)*i._slopeClimbingFactor),0);p&&d&&i._setOnFloor(p,d)}else Math.sign(h-t)===Math.sign(o)?r.setPosition(h,l):r.setPosition(t,l),i._currentSpeed=0}else Math.sign(h-t)===Math.sign(o)?r.setPosition(h,l):r.setPosition(t,l),i._currentSpeed=0}}}getNetworkSyncData(){return{flx:this._floorLastX,fly:this._floorLastY,oh:this._oldHeight}}updateFromNetworkSyncData(e){this._floorLastX=e.flx,this._floorLastY=e.fly,this._oldHeight=e.oh}toString(){return"OnFloor"}}class w{constructor(e){this._behavior=e}enter(e){e!==this._behavior._jumping&&e!==this&&(this._behavior._canJump=!1)}leave(){}beforeUpdatingObstacles(e){}checkTransitionBeforeX(){}beforeMovingX(){}checkTransitionBeforeY(e){const t=this._behavior;t._checkTransitionOnLadder(),t._checkTransitionJumping(),t._canGrabPlatforms&&(t._requestedDeltaX!==0||t._canGrabWithoutMoving)&&t._checkGrabPlatform()}beforeMovingY(e,t){this._behavior._fall(e)}getNetworkSyncData(){return{}}updateFromNetworkSyncData(e){}toString(){return"Falling"}}class j{constructor(e){this._currentJumpSpeed=0;this._timeSinceCurrentJumpStart=0;this._jumpingFirstDelta=!1;this._behavior=e}getCurrentJumpSpeed(){return this._currentJumpSpeed}setCurrentJumpSpeed(e){this._currentJumpSpeed=e}enter(e){const t=this._behavior;this._timeSinceCurrentJumpStart=0,t._jumpKeyHeldSinceJumpStart=!0,e!==t._jumping&&e!==t._falling&&(this._jumpingFirstDelta=!0),t._canJump=!1,this._currentJumpSpeed=t._jumpSpeed,t._currentFallSpeed=0}leave(){this._currentJumpSpeed=0}beforeUpdatingObstacles(e){}checkTransitionBeforeX(){}beforeMovingX(){}checkTransitionBeforeY(e){const t=this._behavior;t._checkTransitionOnLadder(),t._checkTransitionJumping(),t._canGrabPlatforms&&(t._requestedDeltaX!==0||t._canGrabWithoutMoving)&&t._lastDeltaY>=0&&t._checkGrabPlatform()}beforeMovingY(e,t){const i=this._behavior;this._timeSinceCurrentJumpStart+=e;const r=this._currentJumpSpeed;i._jumpKeyHeldSinceJumpStart&&this._timeSinceCurrentJumpStart<i._jumpSustainTime||(this._currentJumpSpeed-=i._gravity*e),this._behavior._useLegacyTrajectory?(i._requestedDeltaY-=r*e,this._jumpingFirstDelta||i._fall(e)):(i._requestedDeltaY+=(-r-this._currentJumpSpeed)/2*e,i._fall(e)),this._jumpingFirstDelta=!1,this._currentJumpSpeed<0&&i._setFalling()}getNetworkSyncData(){return{cjs:this._currentJumpSpeed,tscjs:this._timeSinceCurrentJumpStart,jfd:this._jumpingFirstDelta}}updateFromNetworkSyncData(e){this._currentJumpSpeed=e.cjs,this._timeSinceCurrentJumpStart=e.tscjs,this._jumpingFirstDelta=e.jfd}toString(){return"Jumping"}}class F{constructor(e){this._grabbedPlatform=null;this._behavior=e}enter(e){this._grabbedPlatform=e,this._behavior._canJump=!0,this._behavior._currentFallSpeed=0}leave(){this._grabbedPlatform=null}beforeUpdatingObstacles(e){}checkTransitionBeforeX(){const e=this._behavior;e._isIn(e._potentialCollidingObjects,this._grabbedPlatform.owner.id)||e._releaseGrabbedPlatform()}beforeMovingX(){const e=this._behavior;e._requestedDeltaX=this._grabbedPlatform.owner.getX()-this._grabbedPlatformLastX,e._requestedDeltaY=this._grabbedPlatform.owner.getY()-this._grabbedPlatformLastY}checkTransitionBeforeY(e){const t=this._behavior;t._checkTransitionOnLadder(),t._releasePlatformKey&&t._releaseGrabbedPlatform(),t._checkTransitionJumping()}beforeMovingY(e,t){this._grabbedPlatformLastX=this._grabbedPlatform.owner.getX(),this._grabbedPlatformLastY=this._grabbedPlatform.owner.getY()}getNetworkSyncData(){return{gplx:this._grabbedPlatformLastX,gply:this._grabbedPlatformLastY}}updateFromNetworkSyncData(e){this._grabbedPlatformLastX=e.gplx,this._grabbedPlatformLastY=e.gply}toString(){return"GrabbingPlatform"}}class M{constructor(e){this._behavior=e}enter(){this._behavior._canJump=!0,this._behavior._currentFallSpeed=0}leave(){}beforeUpdatingObstacles(e){}checkTransitionBeforeX(){}beforeMovingX(){}checkTransitionBeforeY(e){const t=this._behavior;t._isOverlappingLadder()||t._setFalling(),t._checkTransitionJumping(),t._releaseLadderKey&&t._releaseLadder()}beforeMovingY(e,t){const i=this._behavior;i._upKey&&(i._requestedDeltaY-=i._ladderClimbingSpeed*e),i._downKey&&(i._requestedDeltaY+=i._ladderClimbingSpeed*e)}getNetworkSyncData(){return{}}updateFromNetworkSyncData(e){}toString(){return"OnLadder"}}const S=class{constructor(){this.ownerMinX=0;this.ownerMaxX=0;this.headMinY=0;this.ownerMinY=0;this.headMaxY=0;this.floorMinY=0;this.ownerMaxY=0;this.floorMaxY=0;this.allowedMinDeltaY=0;this.allowedMaxDeltaY=0;this.foundOverHead=!1;this.foundUnderBottom=!1;this.highestFloorPolygon=null}initializeBeforeSearch(e,t,i){let r=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=Number.MAX_VALUE,o=-Number.MAX_VALUE;for(const f of e.owner.getHitBoxes())for(const l of f.vertices)r=Math.min(r,l[0]),s=Math.max(s,l[0]),a=Math.min(a,l[1]),o=Math.max(o,l[1]);this.ownerMinX=r,this.ownerMaxX=s,this.headMinY=a+t,this.ownerMinY=a,this.headMaxY=a+i,this.floorMinY=o+t,this.ownerMaxY=o,this.floorMaxY=o+i,this.allowedMinDeltaY=t,this.allowedMaxDeltaY=Number.MAX_VALUE}initializeBeforeHitboxCheck(){this.foundOverHead=!1,this.foundUnderBottom=!1}revertTo(e,t){this.allowedMinDeltaY=e,this.allowedMaxDeltaY=t}setFloorIsTooHigh(){this.allowedMinDeltaY=Number.MAX_VALUE,this.allowedMaxDeltaY=-Number.MAX_VALUE}floorIsTooHigh(){return this.allowedMinDeltaY>this.allowedMaxDeltaY}isCollidingAnyPlatform(){return this.ownerMaxY+this.allowedMaxDeltaY<=this.floorMaxY}getFloorDeltaY(){return this.allowedMaxDeltaY}addPointConstraint(e,t){if(e<this.floorMinY){if(e>this.headMaxY){this.setFloorIsTooHigh();return}if(this.foundOverHead=!0,this.foundUnderBottom){this.setFloorIsTooHigh();return}this.allowedMinDeltaY=Math.max(this.allowedMinDeltaY,e-this.ownerMinY)}else{if(this.foundUnderBottom=!0,this.foundOverHead){this.setFloorIsTooHigh();return}this.allowedMaxDeltaY=Math.min(this.allowedMaxDeltaY,e-this.ownerMaxY),this.highestFloorPolygon=t}}};let y=S;y.instance=new S,n.registerBehavior("PlatformBehavior::PlatformerObjectBehavior",n.PlatformerObjectRuntimeBehavior)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=platformerobjectruntimebehavior.js.map