gdcore-tools 2.0.0-gd-v5.5.230-autobuild → 2.0.0-gd-v5.5.231-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 (43) hide show
  1. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  2. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/JsExtension.js +6 -2
  6. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
  7. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
  8. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  9. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  10. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  11. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  12. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  13. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  14. package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +1047 -3
  15. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  16. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  17. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +2 -0
  18. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +7 -0
  19. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  20. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  21. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.d.ts +94 -9
  22. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js +1 -1
  23. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js.map +2 -2
  24. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.wasm +0 -0
  25. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
  26. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
  27. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  28. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  29. package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
  30. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  31. package/dist/Runtime/events-tools/cameratools.js +1 -1
  32. package/dist/Runtime/events-tools/cameratools.js.map +2 -2
  33. package/dist/Runtime/runtimeobject.js +1 -1
  34. package/dist/Runtime/runtimeobject.js.map +2 -2
  35. package/dist/Runtime/runtimescene.js +1 -1
  36. package/dist/Runtime/runtimescene.js.map +2 -2
  37. package/dist/Runtime/spriteruntimeobject.js +1 -1
  38. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  39. package/dist/lib/libGD.cjs +1 -1
  40. package/dist/lib/libGD.wasm +0 -0
  41. package/dist/loaders.cjs +3 -3
  42. package/gd.d.ts +1 -0
  43. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- var gdjs;(function(s){const o=new s.Logger("CustomRuntimeObject");class h extends s.RuntimeObject{constructor(t,e){super(t,e);this._isUntransformedHitBoxesDirty=!0;this._untransformedHitBoxes=[];this._unrotatedAABB={min:[0,0],max:[0,0]};this._innerArea=null;this._isInnerAreaFollowingParentSize=!1;this._scaleX=1;this._scaleY=1;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._customCenter=null;this._localTransformation=new s.AffineTransformation;this._localInverseTransformation=new s.AffineTransformation;this._isLocalTransformationDirty=!0;this._type=e.type,this._instanceContainer=new s.CustomRuntimeObjectInstanceContainer(t,this),this._renderer=this._createRender(),this._initializeFromObjectData(e)}_initializeFromObjectData(t){const e=this._runtimeScene.getGame().getEventsBasedObjectData(t.type);if(!e){o.error(`A CustomRuntimeObject was initialized (or re-initialized) from object data referring to an non existing events based object data with type "${t.type}".`);return}e.defaultVariant||(e.defaultVariant={...e,name:""});let i=e.defaultVariant;if(t.variant)for(let n=0;n<e.variants.length;n++){const r=e.variants[n];if(r.name===t.variant){i=r;break}}this._isInnerAreaFollowingParentSize=e.isInnerAreaFollowingParentSize,i.instances.length>0&&(this._innerArea||(this._innerArea={min:[0,0,0],max:[0,0,0]}),this._innerArea.min[0]=i.areaMinX,this._innerArea.min[1]=i.areaMinY,this._innerArea.min[2]=i.areaMinZ,this._innerArea.max[0]=i.areaMaxX,this._innerArea.max[1]=i.areaMaxY,this._innerArea.max[2]=i.areaMaxZ),this._instanceContainer.loadFrom(t,i)}reinitialize(t){super.reinitialize(t),this._initializeFromObjectData(t),this._reinitializeRenderer(),this.onCreated()}updateFromObjectData(t,e){const i=this.getAnimator();return i&&i.updateFromObjectData(t.animatable||[],e.animatable||[]),!0}extraInitializationFromInitialInstance(t){const e=this.getAnimator();if(t.numberProperties)for(let i=0,n=t.numberProperties.length;i<n;++i){const r=t.numberProperties[i];e&&r.name==="animation"&&e.setAnimationIndex(r.value)}t.customSize&&(this.setWidth(t.width),this.setHeight(t.height)),t.opacity!==void 0&&this.setOpacity(t.opacity),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY)}onDeletedFromScene(t){this.onDestroy(t),super.onDeletedFromScene(t),this._instanceContainer.onDestroyFromScene(t)}update(t){this._instanceContainer._updateObjectsPreEvents(),this.doStepPreEvents(this._instanceContainer);const e=this.getRuntimeScene().getProfiler();e&&e.begin(this.type),this.doStepPostEvents(this._instanceContainer),e&&e.end(this.type),this._instanceContainer._updateObjectsPostEvents()}onHotReloading(t){}doStepPreEvents(t){}doStepPostEvents(t){}onDestroy(t){}updatePreRender(t){this._instanceContainer._updateObjectsPreRender(),this.getRenderer().ensureUpToDate()}getRenderer(){return this._renderer}getChildrenContainer(){return this._instanceContainer}onChildrenLocationChanged(){this._isUntransformedHitBoxesDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()}updateHitBoxes(){this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes();const t=this.getLocalTransformation();for(let e=0;e<this._untransformedHitBoxes.length;++e){e>=this.hitBoxes.length&&this.hitBoxes.push(new s.Polygon);for(let i=0;i<this._untransformedHitBoxes[e].vertices.length;++i)i>=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),t.transform(this._untransformedHitBoxes[e].vertices[i],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=this._untransformedHitBoxes[e].vertices.length}}_updateUntransformedHitBoxes(){this._isUntransformedHitBoxesDirty=!1,this._untransformedHitBoxes.length=0;let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=-Number.MAX_VALUE,n=-Number.MAX_VALUE;for(const r of this._instanceContainer.getAdhocListOfAllInstances()){if(!r.isIncludedInParentCollisionMask())continue;Array.prototype.push.apply(this._untransformedHitBoxes,r.getHitBoxes());const a=r.getAABB();t=Math.min(t,a.min[0]),e=Math.min(e,a.min[1]),i=Math.max(i,a.max[0]),n=Math.max(n,a.max[1])}for(t===Number.MAX_VALUE&&(t=0,e=0,i=1,n=1),this._unrotatedAABB.min[0]=t,this._unrotatedAABB.min[1]=e,this._unrotatedAABB.max[0]=i,this._unrotatedAABB.max[1]=n;this.hitBoxes.length<this._untransformedHitBoxes.length;)this.hitBoxes.push(new s.Polygon);this.hitBoxes.length=this._untransformedHitBoxes.length}applyObjectTransformation(t,e,i){const n=i;n[0]=t,n[1]=e,this.getLocalTransformation().transform(n,i)}getLocalTransformation(){return this._isLocalTransformationDirty&&this._updateLocalTransformation(),this._localTransformation}getLocalInverseTransformation(){return this._isLocalTransformationDirty&&this._updateLocalTransformation(),this._localInverseTransformation}_updateLocalTransformation(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY),i=this.getUnscaledCenterX()*t,n=this.getUnscaledCenterY()*e,r=this.angle*Math.PI/180;this._localTransformation.setToTranslation(this.x,this.y),this._localTransformation.rotateAround(r,i,n),this._flippedX&&this._localTransformation.flipX(i),this._flippedY&&this._localTransformation.flipY(n),this._localTransformation.scale(t,e),this._localInverseTransformation.copyFrom(this._localTransformation),this._localInverseTransformation.invert(),this._isLocalTransformationDirty=!1}applyObjectInverseTransformation(t,e,i){const n=i;n[0]=t,n[1]=e,this.getLocalInverseTransformation().transform(n,i)}getDrawableX(){let t=0;this._innerArea?t=this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._unrotatedAABB.min[0]);const e=this.getScaleX();return this._flippedX?this.x+(-t-this.getUnscaledWidth()+2*this.getUnscaledCenterX())*e:this.x+t*e}getDrawableY(){let t=0;this._innerArea?t=this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._unrotatedAABB.min[1]);const e=this.getScaleY();return this._flippedY?this.y+(-t-this.getUnscaledHeight()+2*this.getUnscaledCenterY())*e:this.y+t*e}getInnerAreaMinX(){return this._innerArea?this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.min[0])}getInnerAreaMinY(){return this._innerArea?this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.min[1])}getInnerAreaMaxX(){return this._innerArea?this._innerArea.max[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[0])}getInnerAreaMaxY(){return this._innerArea?this._innerArea.max[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[1])}getUnscaledWidth(){return this._innerArea?this._innerArea.max[0]-this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[0]-this._unrotatedAABB.min[0])}getUnscaledHeight(){return this._innerArea?this._innerArea.max[1]-this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[1]-this._unrotatedAABB.min[1])}getUnscaledCenterX(){return this._customCenter?this._customCenter[0]:this._innerArea?(this._innerArea.min[0]+this._innerArea.max[0])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._unrotatedAABB.min[0]+this._unrotatedAABB.max[0])/2)}getUnscaledCenterY(){return this._customCenter?this._customCenter[1]:this._innerArea?(this._innerArea.min[1]+this._innerArea.max[1])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._unrotatedAABB.min[1]+this._unrotatedAABB.max[1])/2)}setRotationCenter(t,e){this._customCenter||(this._customCenter=[0,0]),this._customCenter[0]=t,this._customCenter[1]=e,this._isLocalTransformationDirty=!0,this.invalidateHitboxes()}hasCustomRotationCenter(){return!!this._customCenter}getCenterX(){return(this.getUnscaledCenterX()-this._unrotatedAABB.min[0])*this.getScaleX()}getCenterY(){return(this.getUnscaledCenterY()-this._unrotatedAABB.min[1])*this.getScaleY()}getWidth(){return this.getUnscaledWidth()*this.getScaleX()}getHeight(){return this.getUnscaledHeight()*this.getScaleY()}setWidth(t){const e=this.getUnscaledWidth();if(e===0)return;const i=t/e;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[0]*=i,this._innerArea.max[0]*=i):this.setScaleX(i)}setHeight(t){const e=this.getUnscaledHeight();if(e===0)return;const i=t/e;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[1]*=i,this._innerArea.max[1]*=i):this.setScaleY(i)}setSize(t,e){this.setWidth(t),this.setHeight(e)}setX(t){t!==this.x&&(this.x=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateX())}setY(t){t!==this.y&&(this.y=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateY())}setAngle(t){this.angle!==t&&(this.angle=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateAngle())}setScale(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()))}setScaleX(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()))}setScaleY(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this.invalidateHitboxes(),this.getRenderer().update()))}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this.getRenderer().updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this.getRenderer().updateVisibility()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this.getRenderer().update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this.getRenderer().update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getAnimator(){return null}}s.CustomRuntimeObject=h,h.supportsReinitialization=!1})(gdjs||(gdjs={}));
1
+ var gdjs;(function(s){const o=new s.Logger("CustomRuntimeObject");class h extends s.RuntimeObject{constructor(t,e){super(t,e);this._isUntransformedHitBoxesDirty=!0;this._untransformedHitBoxes=[];this._unrotatedAABB={min:[0,0],max:[0,0]};this._innerArea=null;this._isInnerAreaFollowingParentSize=!1;this._scaleX=1;this._scaleY=1;this._flippedX=!1;this._flippedY=!1;this.opacity=255;this._customCenter=null;this._localTransformation=new s.AffineTransformation;this._localInverseTransformation=new s.AffineTransformation;this._isLocalTransformationDirty=!0;this._type=e.type,this._instanceContainer=new s.CustomRuntimeObjectInstanceContainer(t,this),this._renderer=this._createRender(),this._initializeFromObjectData(e)}_initializeFromObjectData(t){const e=this._runtimeScene.getGame().getEventsBasedObjectData(t.type);if(!e){o.error(`A CustomRuntimeObject was initialized (or re-initialized) from object data referring to an non existing events based object data with type "${t.type}".`);return}e.defaultVariant||(e.defaultVariant={...e,name:""});let i=e.defaultVariant;if(t.variant)for(let n=0;n<e.variants.length;n++){const r=e.variants[n];if(r.name===t.variant){i=r;break}}this._isInnerAreaFollowingParentSize=e.isInnerAreaFollowingParentSize,i.instances.length>0&&(this._innerArea||(this._innerArea={min:[0,0,0],max:[0,0,0]}),this._innerArea.min[0]=i.areaMinX,this._innerArea.min[1]=i.areaMinY,this._innerArea.min[2]=i.areaMinZ,this._innerArea.max[0]=i.areaMaxX,this._innerArea.max[1]=i.areaMaxY,this._innerArea.max[2]=i.areaMaxZ),this._instanceContainer.loadFrom(t,i)}reinitialize(t){super.reinitialize(t),this._initializeFromObjectData(t),this._reinitializeRenderer(),this.onCreated()}updateFromObjectData(t,e){const i=this.getAnimator();return i&&i.updateFromObjectData(t.animatable||[],e.animatable||[]),!0}extraInitializationFromInitialInstance(t){const e=this.getAnimator();if(t.numberProperties)for(let i=0,n=t.numberProperties.length;i<n;++i){const r=t.numberProperties[i];e&&r.name==="animation"&&e.setAnimationIndex(r.value)}t.customSize&&(this.setWidth(t.width),this.setHeight(t.height)),t.opacity!==void 0&&this.setOpacity(t.opacity),t.flippedX&&this.flipX(t.flippedX),t.flippedY&&this.flipY(t.flippedY)}onDeletedFromScene(){this.onDestroy(this._runtimeScene),super.onDeletedFromScene(),this._instanceContainer.onDestroyFromScene(this._runtimeScene)}update(t){this._instanceContainer._updateObjectsPreEvents(),this.doStepPreEvents(this._instanceContainer);const e=this.getRuntimeScene().getProfiler();e&&e.begin(this.type),this.doStepPostEvents(this._instanceContainer),e&&e.end(this.type),this._instanceContainer._updateObjectsPostEvents()}onHotReloading(t){}doStepPreEvents(t){}doStepPostEvents(t){}onDestroy(t){}updatePreRender(t){this._instanceContainer._updateObjectsPreRender(),this.getRenderer().ensureUpToDate()}getRenderer(){return this._renderer}getChildrenContainer(){return this._instanceContainer}onChildrenLocationChanged(){this._isUntransformedHitBoxesDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()}updateHitBoxes(){this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes();const t=this.getLocalTransformation();for(let e=0;e<this._untransformedHitBoxes.length;++e){e>=this.hitBoxes.length&&this.hitBoxes.push(new s.Polygon);for(let i=0;i<this._untransformedHitBoxes[e].vertices.length;++i)i>=this.hitBoxes[e].vertices.length&&this.hitBoxes[e].vertices.push([0,0]),t.transform(this._untransformedHitBoxes[e].vertices[i],this.hitBoxes[e].vertices[i]);this.hitBoxes[e].vertices.length=this._untransformedHitBoxes[e].vertices.length}}_updateUntransformedHitBoxes(){this._isUntransformedHitBoxesDirty=!1,this._untransformedHitBoxes.length=0;let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=-Number.MAX_VALUE,n=-Number.MAX_VALUE;for(const r of this._instanceContainer.getAdhocListOfAllInstances()){if(!r.isIncludedInParentCollisionMask())continue;Array.prototype.push.apply(this._untransformedHitBoxes,r.getHitBoxes());const a=r.getAABB();t=Math.min(t,a.min[0]),e=Math.min(e,a.min[1]),i=Math.max(i,a.max[0]),n=Math.max(n,a.max[1])}for(t===Number.MAX_VALUE&&(t=0,e=0,i=1,n=1),this._unrotatedAABB.min[0]=t,this._unrotatedAABB.min[1]=e,this._unrotatedAABB.max[0]=i,this._unrotatedAABB.max[1]=n;this.hitBoxes.length<this._untransformedHitBoxes.length;)this.hitBoxes.push(new s.Polygon);this.hitBoxes.length=this._untransformedHitBoxes.length}applyObjectTransformation(t,e,i){const n=i;n[0]=t,n[1]=e,this.getLocalTransformation().transform(n,i)}getLocalTransformation(){return this._isLocalTransformationDirty&&this._updateLocalTransformation(),this._localTransformation}getLocalInverseTransformation(){return this._isLocalTransformationDirty&&this._updateLocalTransformation(),this._localInverseTransformation}_updateLocalTransformation(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY),i=this.getUnscaledCenterX()*t,n=this.getUnscaledCenterY()*e,r=this.angle*Math.PI/180;this._localTransformation.setToTranslation(this.x,this.y),this._localTransformation.rotateAround(r,i,n),this._flippedX&&this._localTransformation.flipX(i),this._flippedY&&this._localTransformation.flipY(n),this._localTransformation.scale(t,e),this._localInverseTransformation.copyFrom(this._localTransformation),this._localInverseTransformation.invert(),this._isLocalTransformationDirty=!1}applyObjectInverseTransformation(t,e,i){const n=i;n[0]=t,n[1]=e,this.getLocalInverseTransformation().transform(n,i)}getDrawableX(){let t=0;this._innerArea?t=this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._unrotatedAABB.min[0]);const e=this.getScaleX();return this._flippedX?this.x+(-t-this.getUnscaledWidth()+2*this.getUnscaledCenterX())*e:this.x+t*e}getDrawableY(){let t=0;this._innerArea?t=this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),t=this._unrotatedAABB.min[1]);const e=this.getScaleY();return this._flippedY?this.y+(-t-this.getUnscaledHeight()+2*this.getUnscaledCenterY())*e:this.y+t*e}getInnerAreaMinX(){return this._innerArea?this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.min[0])}getInnerAreaMinY(){return this._innerArea?this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.min[1])}getInnerAreaMaxX(){return this._innerArea?this._innerArea.max[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[0])}getInnerAreaMaxY(){return this._innerArea?this._innerArea.max[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[1])}getUnscaledWidth(){return this._innerArea?this._innerArea.max[0]-this._innerArea.min[0]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[0]-this._unrotatedAABB.min[0])}getUnscaledHeight(){return this._innerArea?this._innerArea.max[1]-this._innerArea.min[1]:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),this._unrotatedAABB.max[1]-this._unrotatedAABB.min[1])}getUnscaledCenterX(){return this._customCenter?this._customCenter[0]:this._innerArea?(this._innerArea.min[0]+this._innerArea.max[0])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._unrotatedAABB.min[0]+this._unrotatedAABB.max[0])/2)}getUnscaledCenterY(){return this._customCenter?this._customCenter[1]:this._innerArea?(this._innerArea.min[1]+this._innerArea.max[1])/2:(this._isUntransformedHitBoxesDirty&&this._updateUntransformedHitBoxes(),(this._unrotatedAABB.min[1]+this._unrotatedAABB.max[1])/2)}setRotationCenter(t,e){this._customCenter||(this._customCenter=[0,0]),this._customCenter[0]=t,this._customCenter[1]=e,this._isLocalTransformationDirty=!0,this.invalidateHitboxes()}hasCustomRotationCenter(){return!!this._customCenter}getCenterX(){return(this.getUnscaledCenterX()-this._unrotatedAABB.min[0])*this.getScaleX()}getCenterY(){return(this.getUnscaledCenterY()-this._unrotatedAABB.min[1])*this.getScaleY()}getWidth(){return this.getUnscaledWidth()*this.getScaleX()}getHeight(){return this.getUnscaledHeight()*this.getScaleY()}setWidth(t){const e=this.getUnscaledWidth();if(e===0)return;const i=t/e;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[0]*=i,this._innerArea.max[0]*=i):this.setScaleX(i)}setHeight(t){const e=this.getUnscaledHeight();if(e===0)return;const i=t/e;this._innerArea&&this._isInnerAreaFollowingParentSize?(this._innerArea.min[1]*=i,this._innerArea.max[1]*=i):this.setScaleY(i)}setSize(t,e){this.setWidth(t),this.setHeight(e)}setX(t){t!==this.x&&(this.x=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateX())}setY(t){t!==this.y&&(this.y=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateY())}setAngle(t){this.angle!==t&&(this.angle=t,this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().updateAngle())}setScale(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),!(t===Math.abs(this._scaleX)&&t===Math.abs(this._scaleY))&&(this._scaleX=t*(this._flippedX?-1:1),this._scaleY=t*(this._flippedY?-1:1),this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()))}setScaleX(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleX)&&(this._scaleX=t*(this._flippedX?-1:1),this._isLocalTransformationDirty=!0,this.invalidateHitboxes(),this.getRenderer().update()))}setScaleY(t){this._innerArea&&this._isInnerAreaFollowingParentSize||(t<0&&(t=0),t!==Math.abs(this._scaleY)&&(this._scaleY=t*(this._flippedY?-1:1),this.invalidateHitboxes(),this.getRenderer().update()))}getScaleMean(){return(Math.abs(this._scaleX)+Math.abs(this._scaleY))/2}getScale(){const t=Math.abs(this._scaleX),e=Math.abs(this._scaleY);return t===e?t:Math.sqrt(t*e)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}setOpacity(t){t<0&&(t=0),t>255&&(t=255),this.opacity=t,this.getRenderer().updateOpacity()}getOpacity(){return this.opacity}hide(t){t===void 0&&(t=!0),this.hidden=t,this.getRenderer().updateVisibility()}flipX(t){t!==this._flippedX&&(this._scaleX*=-1,this._flippedX=t,this.invalidateHitboxes(),this.getRenderer().update())}flipY(t){t!==this._flippedY&&(this._scaleY*=-1,this._flippedY=t,this.invalidateHitboxes(),this.getRenderer().update())}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}getAnimator(){return null}}s.CustomRuntimeObject=h,h.supportsReinitialization=!1})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=CustomRuntimeObject.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/CustomRuntimeObject.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2022 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('CustomRuntimeObject');\n\n export type ObjectConfiguration = {\n content: any;\n };\n\n export type CustomObjectConfiguration = ObjectConfiguration & {\n animatable?: SpriteAnimationData[];\n variant: string;\n childrenContent: { [objectName: string]: ObjectConfiguration & any };\n };\n\n /**\n * An object that contains other object.\n *\n * This is the base class for objects generated from EventsBasedObject.\n *\n * @see gdjs.CustomRuntimeObjectInstanceContainer\n */\n export abstract class CustomRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.OpacityHandler\n {\n _renderer:\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer;\n /** It contains the children of this object. */\n _instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer;\n _isUntransformedHitBoxesDirty: boolean = true;\n /** It contains shallow copies of the children hitboxes */\n private _untransformedHitBoxes: gdjs.Polygon[] = [];\n /** The dimension of this object is calculated from its children AABBs. */\n private _unrotatedAABB: AABB = { min: [0, 0], max: [0, 0] };\n /**\n * The bounds of the object content before any transformation.\n * @see gdjs.CustomRuntimeObjectInstanceContainer._initialInnerArea\n **/\n protected _innerArea: {\n min: [float, float, float];\n max: [float, float, float];\n } | null = null;\n /**\n * When the parent dimensions change:\n * - if `false`, the object is stretch proportionally while children local\n * positions stay the same ({@link gdjs.CustomRuntimeObject._innerArea} don't change).\n * - if `true`, the children local positions need to be adapted by events\n * to follow their parent size.\n */\n protected _isInnerAreaFollowingParentSize = false;\n private _scaleX: float = 1;\n private _scaleY: float = 1;\n private _flippedX: boolean = false;\n private _flippedY: boolean = false;\n private opacity: float = 255;\n private _customCenter: FloatPoint | null = null;\n private _localTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n private _localInverseTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n private _isLocalTransformationDirty: boolean = true;\n _type: string;\n\n /**\n * @param parent The container the object belongs to\n * @param objectData The object data used to initialize the object\n */\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: ObjectData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._type = objectData.type;\n this._instanceContainer = new gdjs.CustomRuntimeObjectInstanceContainer(\n parent,\n this\n );\n this._renderer = this._createRender();\n\n this._initializeFromObjectData(objectData);\n\n // The generated code calls onCreated at the constructor end\n // and onCreated calls its super implementation at its end.\n }\n\n private _initializeFromObjectData(\n customObjectData: ObjectData & CustomObjectConfiguration\n ) {\n const eventsBasedObjectData = this._runtimeScene\n .getGame()\n .getEventsBasedObjectData(customObjectData.type);\n if (!eventsBasedObjectData) {\n logger.error(\n `A CustomRuntimeObject was initialized (or re-initialized) from object data referring to an non existing events based object data with type \"${customObjectData.type}\".`\n );\n return;\n }\n\n if (!eventsBasedObjectData.defaultVariant) {\n eventsBasedObjectData.defaultVariant = {\n ...eventsBasedObjectData,\n name: '',\n };\n }\n let usedVariantData: EventsBasedObjectVariantData =\n eventsBasedObjectData.defaultVariant;\n if (customObjectData.variant) {\n for (\n let variantIndex = 0;\n variantIndex < eventsBasedObjectData.variants.length;\n variantIndex++\n ) {\n const variantData = eventsBasedObjectData.variants[variantIndex];\n if (variantData.name === customObjectData.variant) {\n usedVariantData = variantData;\n break;\n }\n }\n }\n\n this._isInnerAreaFollowingParentSize =\n eventsBasedObjectData.isInnerAreaFollowingParentSize;\n if (usedVariantData.instances.length > 0) {\n if (!this._innerArea) {\n this._innerArea = {\n min: [0, 0, 0],\n max: [0, 0, 0],\n };\n }\n this._innerArea.min[0] = usedVariantData.areaMinX;\n this._innerArea.min[1] = usedVariantData.areaMinY;\n this._innerArea.min[2] = usedVariantData.areaMinZ;\n this._innerArea.max[0] = usedVariantData.areaMaxX;\n this._innerArea.max[1] = usedVariantData.areaMaxY;\n this._innerArea.max[2] = usedVariantData.areaMaxZ;\n }\n this._instanceContainer.loadFrom(customObjectData, usedVariantData);\n }\n\n protected abstract _createRender():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer;\n protected abstract _reinitializeRenderer(): void;\n\n override reinitialize(objectData: ObjectData & CustomObjectConfiguration) {\n super.reinitialize(objectData);\n\n this._initializeFromObjectData(objectData);\n this._reinitializeRenderer();\n\n // The generated code calls the onCreated super implementation at the end.\n this.onCreated();\n }\n\n override updateFromObjectData(\n oldObjectData: ObjectData & CustomObjectConfiguration,\n newObjectData: ObjectData & CustomObjectConfiguration\n ): boolean {\n const animator = this.getAnimator();\n if (animator) {\n animator.updateFromObjectData(\n oldObjectData.animatable || [],\n newObjectData.animatable || []\n );\n }\n return true;\n }\n\n override extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ) {\n const animator = this.getAnimator();\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (animator && extraData.name === 'animation') {\n animator.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n }\n\n override onDeletedFromScene(parent: gdjs.RuntimeInstanceContainer): void {\n // Let subclasses do something before the object is destroyed.\n this.onDestroy(parent);\n // Let behaviors do something before the object is destroyed.\n super.onDeletedFromScene(parent);\n // Destroy the children.\n this._instanceContainer.onDestroyFromScene(parent);\n }\n\n override update(parent: gdjs.RuntimeInstanceContainer): void {\n this._instanceContainer._updateObjectsPreEvents();\n\n this.doStepPreEvents(this._instanceContainer);\n\n const profiler = this.getRuntimeScene().getProfiler();\n if (profiler) {\n profiler.begin(this.type);\n }\n // This is a bit like the \"scene\" events for custom objects.\n this.doStepPostEvents(this._instanceContainer);\n if (profiler) {\n profiler.end(this.type);\n }\n\n this._instanceContainer._updateObjectsPostEvents();\n }\n\n /**\n * This method is called when the preview is being hot-reloaded.\n */\n onHotReloading(parent: gdjs.RuntimeInstanceContainer) {}\n\n // This is only to handle trigger once.\n doStepPreEvents(parent: gdjs.RuntimeInstanceContainer) {}\n\n /**\n * This method is called each tick after events are done.\n * @param parent The instanceContainer owning the object\n */\n doStepPostEvents(parent: gdjs.RuntimeInstanceContainer) {}\n\n /**\n * This method is called when the object is being removed from its parent\n * container and is about to be destroyed/reused later.\n */\n onDestroy(parent: gdjs.RuntimeInstanceContainer) {}\n\n override updatePreRender(parent: gdjs.RuntimeInstanceContainer): void {\n this._instanceContainer._updateObjectsPreRender();\n this.getRenderer().ensureUpToDate();\n }\n\n getRenderer():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer {\n return this._renderer;\n }\n\n getChildrenContainer(): gdjs.RuntimeInstanceContainer {\n return this._instanceContainer;\n }\n\n onChildrenLocationChanged() {\n this._isUntransformedHitBoxesDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n override updateHitBoxes(): void {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n\n // Update the current hitboxes with the frame custom hit boxes\n // and apply transformations.\n const localTransformation = this.getLocalTransformation();\n for (let i = 0; i < this._untransformedHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < this._untransformedHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n localTransformation.transform(\n this._untransformedHitBoxes[i].vertices[j],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length =\n this._untransformedHitBoxes[i].vertices.length;\n }\n }\n\n /**\n * Merge the hitboxes of the children.\n */\n _updateUntransformedHitBoxes() {\n this._isUntransformedHitBoxesDirty = false;\n\n this._untransformedHitBoxes.length = 0;\n let minX = Number.MAX_VALUE;\n let minY = Number.MAX_VALUE;\n let maxX = -Number.MAX_VALUE;\n let maxY = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n Array.prototype.push.apply(\n this._untransformedHitBoxes,\n childInstance.getHitBoxes()\n );\n const childAABB = childInstance.getAABB();\n minX = Math.min(minX, childAABB.min[0]);\n minY = Math.min(minY, childAABB.min[1]);\n maxX = Math.max(maxX, childAABB.max[0]);\n maxY = Math.max(maxY, childAABB.max[1]);\n }\n if (minX === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minX = 0;\n minY = 0;\n maxX = 1;\n maxY = 1;\n }\n this._unrotatedAABB.min[0] = minX;\n this._unrotatedAABB.min[1] = minY;\n this._unrotatedAABB.max[0] = maxX;\n this._unrotatedAABB.max[1] = maxY;\n\n while (this.hitBoxes.length < this._untransformedHitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n this.hitBoxes.length = this._untransformedHitBoxes.length;\n }\n\n // Position:\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in parent coordinate coordinates (as opposed to the object local coordinates).\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param destination Array that will be updated with the result\n * (x and y position of the point in parent coordinates).\n */\n applyObjectTransformation(x: float, y: float, destination: FloatPoint) {\n const source = destination;\n source[0] = x;\n source[1] = y;\n this.getLocalTransformation().transform(source, destination);\n }\n\n /**\n * Return the affine transformation that represents\n * flipping, scale, rotation and translation of the object.\n * @returns the affine transformation.\n */\n getLocalTransformation(): gdjs.AffineTransformation {\n if (this._isLocalTransformationDirty) {\n this._updateLocalTransformation();\n }\n return this._localTransformation;\n }\n\n getLocalInverseTransformation(): gdjs.AffineTransformation {\n if (this._isLocalTransformationDirty) {\n this._updateLocalTransformation();\n }\n return this._localInverseTransformation;\n }\n\n _updateLocalTransformation() {\n const absScaleX = Math.abs(this._scaleX);\n const absScaleY = Math.abs(this._scaleY);\n const centerX = this.getUnscaledCenterX() * absScaleX;\n const centerY = this.getUnscaledCenterY() * absScaleY;\n const angleInRadians = (this.angle * Math.PI) / 180;\n\n this._localTransformation.setToTranslation(this.x, this.y);\n this._localTransformation.rotateAround(angleInRadians, centerX, centerY);\n if (this._flippedX) {\n this._localTransformation.flipX(centerX);\n }\n if (this._flippedY) {\n this._localTransformation.flipY(centerY);\n }\n this._localTransformation.scale(absScaleX, absScaleY);\n\n this._localInverseTransformation.copyFrom(this._localTransformation);\n this._localInverseTransformation.invert();\n this._isLocalTransformationDirty = false;\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in object local coordinates (as opposed to the parent coordinate coordinates).\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in parent coordinates.\n * @param y The Y position of the point, in parent coordinates.\n * @param destination Array that will be updated with the result\n * (x and y position of the point in object coordinates).\n */\n applyObjectInverseTransformation(\n x: float,\n y: float,\n destination: FloatPoint\n ) {\n const source = destination;\n source[0] = x;\n source[1] = y;\n this.getLocalInverseTransformation().transform(source, destination);\n }\n\n override getDrawableX(): float {\n let minX = 0;\n if (this._innerArea) {\n minX = this._innerArea.min[0];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minX = this._unrotatedAABB.min[0];\n }\n const absScaleX = this.getScaleX();\n if (!this._flippedX) {\n return this.x + minX * absScaleX;\n } else {\n return (\n this.x +\n (-minX - this.getUnscaledWidth() + 2 * this.getUnscaledCenterX()) *\n absScaleX\n );\n }\n }\n\n override getDrawableY(): float {\n let minY = 0;\n if (this._innerArea) {\n minY = this._innerArea.min[1];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minY = this._unrotatedAABB.min[1];\n }\n const absScaleY = this.getScaleY();\n if (!this._flippedY) {\n return this.y + minY * absScaleY;\n } else {\n return (\n this.y +\n (-minY - this.getUnscaledHeight() + 2 * this.getUnscaledCenterY()) *\n absScaleY\n );\n }\n }\n\n /**\n * @return the internal left bound of the object according to its children.\n */\n getInnerAreaMinX(): number {\n if (this._innerArea) {\n return this._innerArea.min[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.min[0];\n }\n\n /**\n * @return the internal top bound of the object according to its children.\n */\n getInnerAreaMinY(): number {\n if (this._innerArea) {\n return this._innerArea.min[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.min[1];\n }\n\n /**\n * @return the internal right bound of the object according to its children.\n */\n getInnerAreaMaxX(): number {\n if (this._innerArea) {\n return this._innerArea.max[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[0];\n }\n\n /**\n * @return the internal bottom bound of the object according to its children.\n */\n getInnerAreaMaxY(): number {\n if (this._innerArea) {\n return this._innerArea.max[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[1];\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledWidth(): float {\n if (this._innerArea) {\n return this._innerArea.max[0] - this._innerArea.min[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[0] - this._unrotatedAABB.min[0];\n }\n\n /**\n * @return the internal height of the object according to its children.\n */\n getUnscaledHeight(): float {\n if (this._innerArea) {\n return this._innerArea.max[1] - this._innerArea.min[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[1] - this._unrotatedAABB.min[1];\n }\n\n /**\n * @returns the center X from the local origin (0;0).\n */\n getUnscaledCenterX(): float {\n if (this._customCenter) {\n return this._customCenter[0];\n }\n if (this._innerArea) {\n return (this._innerArea.min[0] + this._innerArea.max[0]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._unrotatedAABB.min[0] + this._unrotatedAABB.max[0]) / 2;\n }\n\n /**\n * @returns the center Y from the local origin (0;0).\n */\n getUnscaledCenterY(): float {\n if (this._customCenter) {\n return this._customCenter[1];\n }\n if (this._innerArea) {\n return (this._innerArea.min[1] + this._innerArea.max[1]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._unrotatedAABB.min[1] + this._unrotatedAABB.max[1]) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter(x: float, y: float) {\n if (!this._customCenter) {\n this._customCenter = [0, 0];\n }\n this._customCenter[0] = x;\n this._customCenter[1] = y;\n\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n }\n\n hasCustomRotationCenter(): boolean {\n return !!this._customCenter;\n }\n\n override getCenterX(): float {\n return (\n (this.getUnscaledCenterX() - this._unrotatedAABB.min[0]) *\n this.getScaleX()\n );\n }\n\n override getCenterY(): float {\n return (\n (this.getUnscaledCenterY() - this._unrotatedAABB.min[1]) *\n this.getScaleY()\n );\n }\n\n override getWidth(): float {\n return this.getUnscaledWidth() * this.getScaleX();\n }\n\n override getHeight(): float {\n return this.getUnscaledHeight() * this.getScaleY();\n }\n\n override setWidth(newWidth: float): void {\n const unscaledWidth = this.getUnscaledWidth();\n if (unscaledWidth === 0) {\n return;\n }\n const scaleX = newWidth / unscaledWidth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[0] *= scaleX;\n this._innerArea.max[0] *= scaleX;\n } else {\n this.setScaleX(scaleX);\n }\n }\n\n override setHeight(newHeight: float): void {\n const unscaledHeight = this.getUnscaledHeight();\n if (unscaledHeight === 0) {\n return;\n }\n const scaleY = newHeight / unscaledHeight;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[1] *= scaleY;\n this._innerArea.max[1] *= scaleY;\n } else {\n this.setScaleY(scaleY);\n }\n }\n\n /**\n * Change the size of the object.\n *\n * @param newWidth The new width of the object, in pixels.\n * @param newHeight The new height of the object, in pixels.\n */\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n override setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateX();\n }\n\n override setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateY();\n }\n\n override setAngle(angle: float): void {\n if (this.angle === angle) {\n return;\n }\n this.angle = angle;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateAngle();\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n // Visibility and display :\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this.getRenderer().updateOpacity();\n }\n\n getOpacity(): number {\n return this.opacity;\n }\n\n override hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this.getRenderer().updateVisibility();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n /**\n * Return the sprite animator.\n *\n * It returns `null` when custom objects don't have the Animatable capability.\n */\n getAnimator(): gdjs.SpriteAnimator<any> | null {\n return null;\n }\n }\n\n // Others initialization and internal state management :\n // TODO EBO Activate and test instance recycling.\n CustomRuntimeObject.supportsReinitialization = false;\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,uBAmBxB,eACG,GAAK,aAMf,CA4CE,YACE,EACA,EACA,CACA,MAAM,EAAQ,GA1ChB,mCAAyC,GAEjC,4BAA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qBACL,KAAK,cAAc,UAIvB,MAAM,EAAiB,CACrB,AAAI,IAAW,KAAK,WAClB,MAAK,SAAW,GAChB,KAAK,UAAY,EACjB,KAAK,qBACL,KAAK,cAAc,UAIvB,YAAsB,CACpB,MAAO,MAAK,UAGd,YAAsB,CACpB,MAAO,MAAK,UAQd,aAA+C,CAC7C,MAAO,OA30BJ,EAAe,sBAi1BtB,EAAoB,yBAA2B,KAr2BvC",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2022 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('CustomRuntimeObject');\n\n export type ObjectConfiguration = {\n content: any;\n };\n\n export type CustomObjectConfiguration = ObjectConfiguration & {\n animatable?: SpriteAnimationData[];\n variant: string;\n childrenContent: { [objectName: string]: ObjectConfiguration & any };\n };\n\n /**\n * An object that contains other object.\n *\n * This is the base class for objects generated from EventsBasedObject.\n *\n * @see gdjs.CustomRuntimeObjectInstanceContainer\n */\n export abstract class CustomRuntimeObject\n extends gdjs.RuntimeObject\n implements\n gdjs.Resizable,\n gdjs.Scalable,\n gdjs.Flippable,\n gdjs.OpacityHandler\n {\n _renderer:\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer;\n /** It contains the children of this object. */\n _instanceContainer: gdjs.CustomRuntimeObjectInstanceContainer;\n _isUntransformedHitBoxesDirty: boolean = true;\n /** It contains shallow copies of the children hitboxes */\n private _untransformedHitBoxes: gdjs.Polygon[] = [];\n /** The dimension of this object is calculated from its children AABBs. */\n private _unrotatedAABB: AABB = { min: [0, 0], max: [0, 0] };\n /**\n * The bounds of the object content before any transformation.\n * @see gdjs.CustomRuntimeObjectInstanceContainer._initialInnerArea\n **/\n protected _innerArea: {\n min: [float, float, float];\n max: [float, float, float];\n } | null = null;\n /**\n * When the parent dimensions change:\n * - if `false`, the object is stretch proportionally while children local\n * positions stay the same ({@link gdjs.CustomRuntimeObject._innerArea} don't change).\n * - if `true`, the children local positions need to be adapted by events\n * to follow their parent size.\n */\n protected _isInnerAreaFollowingParentSize = false;\n private _scaleX: float = 1;\n private _scaleY: float = 1;\n private _flippedX: boolean = false;\n private _flippedY: boolean = false;\n private opacity: float = 255;\n private _customCenter: FloatPoint | null = null;\n private _localTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n private _localInverseTransformation: gdjs.AffineTransformation =\n new gdjs.AffineTransformation();\n private _isLocalTransformationDirty: boolean = true;\n _type: string;\n\n /**\n * @param parent The container the object belongs to\n * @param objectData The object data used to initialize the object\n */\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n objectData: ObjectData & CustomObjectConfiguration\n ) {\n super(parent, objectData);\n this._type = objectData.type;\n this._instanceContainer = new gdjs.CustomRuntimeObjectInstanceContainer(\n parent,\n this\n );\n this._renderer = this._createRender();\n\n this._initializeFromObjectData(objectData);\n\n // The generated code calls onCreated at the constructor end\n // and onCreated calls its super implementation at its end.\n }\n\n private _initializeFromObjectData(\n customObjectData: ObjectData & CustomObjectConfiguration\n ) {\n const eventsBasedObjectData = this._runtimeScene\n .getGame()\n .getEventsBasedObjectData(customObjectData.type);\n if (!eventsBasedObjectData) {\n logger.error(\n `A CustomRuntimeObject was initialized (or re-initialized) from object data referring to an non existing events based object data with type \"${customObjectData.type}\".`\n );\n return;\n }\n\n if (!eventsBasedObjectData.defaultVariant) {\n eventsBasedObjectData.defaultVariant = {\n ...eventsBasedObjectData,\n name: '',\n };\n }\n let usedVariantData: EventsBasedObjectVariantData =\n eventsBasedObjectData.defaultVariant;\n if (customObjectData.variant) {\n for (\n let variantIndex = 0;\n variantIndex < eventsBasedObjectData.variants.length;\n variantIndex++\n ) {\n const variantData = eventsBasedObjectData.variants[variantIndex];\n if (variantData.name === customObjectData.variant) {\n usedVariantData = variantData;\n break;\n }\n }\n }\n\n this._isInnerAreaFollowingParentSize =\n eventsBasedObjectData.isInnerAreaFollowingParentSize;\n if (usedVariantData.instances.length > 0) {\n if (!this._innerArea) {\n this._innerArea = {\n min: [0, 0, 0],\n max: [0, 0, 0],\n };\n }\n this._innerArea.min[0] = usedVariantData.areaMinX;\n this._innerArea.min[1] = usedVariantData.areaMinY;\n this._innerArea.min[2] = usedVariantData.areaMinZ;\n this._innerArea.max[0] = usedVariantData.areaMaxX;\n this._innerArea.max[1] = usedVariantData.areaMaxY;\n this._innerArea.max[2] = usedVariantData.areaMaxZ;\n }\n this._instanceContainer.loadFrom(customObjectData, usedVariantData);\n }\n\n protected abstract _createRender():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer;\n protected abstract _reinitializeRenderer(): void;\n\n override reinitialize(objectData: ObjectData & CustomObjectConfiguration) {\n super.reinitialize(objectData);\n\n this._initializeFromObjectData(objectData);\n this._reinitializeRenderer();\n\n // The generated code calls the onCreated super implementation at the end.\n this.onCreated();\n }\n\n override updateFromObjectData(\n oldObjectData: ObjectData & CustomObjectConfiguration,\n newObjectData: ObjectData & CustomObjectConfiguration\n ): boolean {\n const animator = this.getAnimator();\n if (animator) {\n animator.updateFromObjectData(\n oldObjectData.animatable || [],\n newObjectData.animatable || []\n );\n }\n return true;\n }\n\n override extraInitializationFromInitialInstance(\n initialInstanceData: InstanceData\n ) {\n const animator = this.getAnimator();\n if (initialInstanceData.numberProperties) {\n for (\n let i = 0, len = initialInstanceData.numberProperties.length;\n i < len;\n ++i\n ) {\n const extraData = initialInstanceData.numberProperties[i];\n if (animator && extraData.name === 'animation') {\n animator.setAnimationIndex(extraData.value);\n }\n }\n }\n if (initialInstanceData.customSize) {\n this.setWidth(initialInstanceData.width);\n this.setHeight(initialInstanceData.height);\n }\n if (initialInstanceData.opacity !== undefined) {\n this.setOpacity(initialInstanceData.opacity);\n }\n if (initialInstanceData.flippedX) {\n this.flipX(initialInstanceData.flippedX);\n }\n if (initialInstanceData.flippedY) {\n this.flipY(initialInstanceData.flippedY);\n }\n }\n\n override onDeletedFromScene(): void {\n // Let subclasses do something before the object is destroyed.\n this.onDestroy(this._runtimeScene);\n // Let behaviors do something before the object is destroyed.\n super.onDeletedFromScene();\n // Destroy the children.\n this._instanceContainer.onDestroyFromScene(this._runtimeScene);\n }\n\n override update(parent: gdjs.RuntimeInstanceContainer): void {\n this._instanceContainer._updateObjectsPreEvents();\n\n this.doStepPreEvents(this._instanceContainer);\n\n const profiler = this.getRuntimeScene().getProfiler();\n if (profiler) {\n profiler.begin(this.type);\n }\n // This is a bit like the \"scene\" events for custom objects.\n this.doStepPostEvents(this._instanceContainer);\n if (profiler) {\n profiler.end(this.type);\n }\n\n this._instanceContainer._updateObjectsPostEvents();\n }\n\n /**\n * This method is called when the preview is being hot-reloaded.\n */\n onHotReloading(parent: gdjs.RuntimeInstanceContainer) {}\n\n // This is only to handle trigger once.\n doStepPreEvents(parent: gdjs.RuntimeInstanceContainer) {}\n\n /**\n * This method is called each tick after events are done.\n * @param parent The instanceContainer owning the object\n */\n doStepPostEvents(parent: gdjs.RuntimeInstanceContainer) {}\n\n /**\n * This method is called when the object is being removed from its parent\n * container and is about to be destroyed/reused later.\n */\n onDestroy(parent: gdjs.RuntimeInstanceContainer) {}\n\n override updatePreRender(parent: gdjs.RuntimeInstanceContainer): void {\n this._instanceContainer._updateObjectsPreRender();\n this.getRenderer().ensureUpToDate();\n }\n\n getRenderer():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer {\n return this._renderer;\n }\n\n getChildrenContainer(): gdjs.RuntimeInstanceContainer {\n return this._instanceContainer;\n }\n\n onChildrenLocationChanged() {\n this._isUntransformedHitBoxesDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n override updateHitBoxes(): void {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n\n // Update the current hitboxes with the frame custom hit boxes\n // and apply transformations.\n const localTransformation = this.getLocalTransformation();\n for (let i = 0; i < this._untransformedHitBoxes.length; ++i) {\n if (i >= this.hitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n for (\n let j = 0;\n j < this._untransformedHitBoxes[i].vertices.length;\n ++j\n ) {\n if (j >= this.hitBoxes[i].vertices.length) {\n this.hitBoxes[i].vertices.push([0, 0]);\n }\n localTransformation.transform(\n this._untransformedHitBoxes[i].vertices[j],\n this.hitBoxes[i].vertices[j]\n );\n }\n this.hitBoxes[i].vertices.length =\n this._untransformedHitBoxes[i].vertices.length;\n }\n }\n\n /**\n * Merge the hitboxes of the children.\n */\n _updateUntransformedHitBoxes() {\n this._isUntransformedHitBoxesDirty = false;\n\n this._untransformedHitBoxes.length = 0;\n let minX = Number.MAX_VALUE;\n let minY = Number.MAX_VALUE;\n let maxX = -Number.MAX_VALUE;\n let maxY = -Number.MAX_VALUE;\n for (const childInstance of this._instanceContainer.getAdhocListOfAllInstances()) {\n if (!childInstance.isIncludedInParentCollisionMask()) {\n continue;\n }\n Array.prototype.push.apply(\n this._untransformedHitBoxes,\n childInstance.getHitBoxes()\n );\n const childAABB = childInstance.getAABB();\n minX = Math.min(minX, childAABB.min[0]);\n minY = Math.min(minY, childAABB.min[1]);\n maxX = Math.max(maxX, childAABB.max[0]);\n maxY = Math.max(maxY, childAABB.max[1]);\n }\n if (minX === Number.MAX_VALUE) {\n // The unscaled size can't be 0 because setWidth and setHeight wouldn't\n // have any effect.\n minX = 0;\n minY = 0;\n maxX = 1;\n maxY = 1;\n }\n this._unrotatedAABB.min[0] = minX;\n this._unrotatedAABB.min[1] = minY;\n this._unrotatedAABB.max[0] = maxX;\n this._unrotatedAABB.max[1] = maxY;\n\n while (this.hitBoxes.length < this._untransformedHitBoxes.length) {\n this.hitBoxes.push(new gdjs.Polygon());\n }\n this.hitBoxes.length = this._untransformedHitBoxes.length;\n }\n\n // Position:\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in parent coordinate coordinates (as opposed to the object local coordinates).\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in object coordinates.\n * @param y The Y position of the point, in object coordinates.\n * @param destination Array that will be updated with the result\n * (x and y position of the point in parent coordinates).\n */\n applyObjectTransformation(x: float, y: float, destination: FloatPoint) {\n const source = destination;\n source[0] = x;\n source[1] = y;\n this.getLocalTransformation().transform(source, destination);\n }\n\n /**\n * Return the affine transformation that represents\n * flipping, scale, rotation and translation of the object.\n * @returns the affine transformation.\n */\n getLocalTransformation(): gdjs.AffineTransformation {\n if (this._isLocalTransformationDirty) {\n this._updateLocalTransformation();\n }\n return this._localTransformation;\n }\n\n getLocalInverseTransformation(): gdjs.AffineTransformation {\n if (this._isLocalTransformationDirty) {\n this._updateLocalTransformation();\n }\n return this._localInverseTransformation;\n }\n\n _updateLocalTransformation() {\n const absScaleX = Math.abs(this._scaleX);\n const absScaleY = Math.abs(this._scaleY);\n const centerX = this.getUnscaledCenterX() * absScaleX;\n const centerY = this.getUnscaledCenterY() * absScaleY;\n const angleInRadians = (this.angle * Math.PI) / 180;\n\n this._localTransformation.setToTranslation(this.x, this.y);\n this._localTransformation.rotateAround(angleInRadians, centerX, centerY);\n if (this._flippedX) {\n this._localTransformation.flipX(centerX);\n }\n if (this._flippedY) {\n this._localTransformation.flipY(centerY);\n }\n this._localTransformation.scale(absScaleX, absScaleY);\n\n this._localInverseTransformation.copyFrom(this._localTransformation);\n this._localInverseTransformation.invert();\n this._isLocalTransformationDirty = false;\n }\n\n /**\n * Return an array containing the coordinates of the point passed as parameter\n * in object local coordinates (as opposed to the parent coordinate coordinates).\n *\n * All transformations (flipping, scale, rotation) are supported.\n *\n * @param x The X position of the point, in parent coordinates.\n * @param y The Y position of the point, in parent coordinates.\n * @param destination Array that will be updated with the result\n * (x and y position of the point in object coordinates).\n */\n applyObjectInverseTransformation(\n x: float,\n y: float,\n destination: FloatPoint\n ) {\n const source = destination;\n source[0] = x;\n source[1] = y;\n this.getLocalInverseTransformation().transform(source, destination);\n }\n\n override getDrawableX(): float {\n let minX = 0;\n if (this._innerArea) {\n minX = this._innerArea.min[0];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minX = this._unrotatedAABB.min[0];\n }\n const absScaleX = this.getScaleX();\n if (!this._flippedX) {\n return this.x + minX * absScaleX;\n } else {\n return (\n this.x +\n (-minX - this.getUnscaledWidth() + 2 * this.getUnscaledCenterX()) *\n absScaleX\n );\n }\n }\n\n override getDrawableY(): float {\n let minY = 0;\n if (this._innerArea) {\n minY = this._innerArea.min[1];\n } else {\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n minY = this._unrotatedAABB.min[1];\n }\n const absScaleY = this.getScaleY();\n if (!this._flippedY) {\n return this.y + minY * absScaleY;\n } else {\n return (\n this.y +\n (-minY - this.getUnscaledHeight() + 2 * this.getUnscaledCenterY()) *\n absScaleY\n );\n }\n }\n\n /**\n * @return the internal left bound of the object according to its children.\n */\n getInnerAreaMinX(): number {\n if (this._innerArea) {\n return this._innerArea.min[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.min[0];\n }\n\n /**\n * @return the internal top bound of the object according to its children.\n */\n getInnerAreaMinY(): number {\n if (this._innerArea) {\n return this._innerArea.min[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.min[1];\n }\n\n /**\n * @return the internal right bound of the object according to its children.\n */\n getInnerAreaMaxX(): number {\n if (this._innerArea) {\n return this._innerArea.max[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[0];\n }\n\n /**\n * @return the internal bottom bound of the object according to its children.\n */\n getInnerAreaMaxY(): number {\n if (this._innerArea) {\n return this._innerArea.max[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[1];\n }\n\n /**\n * @return the internal width of the object according to its children.\n */\n getUnscaledWidth(): float {\n if (this._innerArea) {\n return this._innerArea.max[0] - this._innerArea.min[0];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[0] - this._unrotatedAABB.min[0];\n }\n\n /**\n * @return the internal height of the object according to its children.\n */\n getUnscaledHeight(): float {\n if (this._innerArea) {\n return this._innerArea.max[1] - this._innerArea.min[1];\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return this._unrotatedAABB.max[1] - this._unrotatedAABB.min[1];\n }\n\n /**\n * @returns the center X from the local origin (0;0).\n */\n getUnscaledCenterX(): float {\n if (this._customCenter) {\n return this._customCenter[0];\n }\n if (this._innerArea) {\n return (this._innerArea.min[0] + this._innerArea.max[0]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._unrotatedAABB.min[0] + this._unrotatedAABB.max[0]) / 2;\n }\n\n /**\n * @returns the center Y from the local origin (0;0).\n */\n getUnscaledCenterY(): float {\n if (this._customCenter) {\n return this._customCenter[1];\n }\n if (this._innerArea) {\n return (this._innerArea.min[1] + this._innerArea.max[1]) / 2;\n }\n if (this._isUntransformedHitBoxesDirty) {\n this._updateUntransformedHitBoxes();\n }\n return (this._unrotatedAABB.min[1] + this._unrotatedAABB.max[1]) / 2;\n }\n\n /**\n * The center of rotation is defined relatively to the origin (the object\n * position).\n * This avoids the center to move when children push the bounds.\n *\n * When no custom center is defined, it will move\n * to stay at the center of the children bounds.\n *\n * @param x coordinate of the custom center\n * @param y coordinate of the custom center\n */\n setRotationCenter(x: float, y: float) {\n if (!this._customCenter) {\n this._customCenter = [0, 0];\n }\n this._customCenter[0] = x;\n this._customCenter[1] = y;\n\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n }\n\n hasCustomRotationCenter(): boolean {\n return !!this._customCenter;\n }\n\n override getCenterX(): float {\n return (\n (this.getUnscaledCenterX() - this._unrotatedAABB.min[0]) *\n this.getScaleX()\n );\n }\n\n override getCenterY(): float {\n return (\n (this.getUnscaledCenterY() - this._unrotatedAABB.min[1]) *\n this.getScaleY()\n );\n }\n\n override getWidth(): float {\n return this.getUnscaledWidth() * this.getScaleX();\n }\n\n override getHeight(): float {\n return this.getUnscaledHeight() * this.getScaleY();\n }\n\n override setWidth(newWidth: float): void {\n const unscaledWidth = this.getUnscaledWidth();\n if (unscaledWidth === 0) {\n return;\n }\n const scaleX = newWidth / unscaledWidth;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[0] *= scaleX;\n this._innerArea.max[0] *= scaleX;\n } else {\n this.setScaleX(scaleX);\n }\n }\n\n override setHeight(newHeight: float): void {\n const unscaledHeight = this.getUnscaledHeight();\n if (unscaledHeight === 0) {\n return;\n }\n const scaleY = newHeight / unscaledHeight;\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n this._innerArea.min[1] *= scaleY;\n this._innerArea.max[1] *= scaleY;\n } else {\n this.setScaleY(scaleY);\n }\n }\n\n /**\n * Change the size of the object.\n *\n * @param newWidth The new width of the object, in pixels.\n * @param newHeight The new height of the object, in pixels.\n */\n setSize(newWidth: float, newHeight: float): void {\n this.setWidth(newWidth);\n this.setHeight(newHeight);\n }\n\n override setX(x: float): void {\n if (x === this.x) {\n return;\n }\n this.x = x;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateX();\n }\n\n override setY(y: float): void {\n if (y === this.y) {\n return;\n }\n this.y = y;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateY();\n }\n\n override setAngle(angle: float): void {\n if (this.angle === angle) {\n return;\n }\n this.angle = angle;\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().updateAngle();\n }\n\n /**\n * Change the scale on X and Y axis of the object.\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScale(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (\n newScale === Math.abs(this._scaleX) &&\n newScale === Math.abs(this._scaleY)\n ) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Change the scale on X axis of the object (changing its width).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleX(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleX)) {\n return;\n }\n this._scaleX = newScale * (this._flippedX ? -1 : 1);\n this._isLocalTransformationDirty = true;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Change the scale on Y axis of the object (changing its height).\n *\n * @param newScale The new scale (must be greater than 0).\n */\n setScaleY(newScale: float): void {\n if (this._innerArea && this._isInnerAreaFollowingParentSize) {\n // The scale is always 1;\n return;\n }\n if (newScale < 0) {\n newScale = 0;\n }\n if (newScale === Math.abs(this._scaleY)) {\n return;\n }\n this._scaleY = newScale * (this._flippedY ? -1 : 1);\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n\n /**\n * Get the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the arithmetic mean of the X and Y scale in case they are different).\n * @deprecated Use `getScale` instead.\n */\n getScaleMean(): float {\n return (Math.abs(this._scaleX) + Math.abs(this._scaleY)) / 2.0;\n }\n\n /**\n * Get the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n *\n * @return the scale of the object (or the geometric mean of the X and Y scale in case they are different).\n */\n getScale(): float {\n const scaleX = Math.abs(this._scaleX);\n const scaleY = Math.abs(this._scaleY);\n return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);\n }\n\n /**\n * Get the scale of the object on Y axis.\n *\n * @return the scale of the object on Y axis\n */\n getScaleY(): float {\n return Math.abs(this._scaleY);\n }\n\n /**\n * Get the scale of the object on X axis.\n *\n * @return the scale of the object on X axis\n */\n getScaleX(): float {\n return Math.abs(this._scaleX);\n }\n\n // Visibility and display :\n\n setOpacity(opacity: float): void {\n if (opacity < 0) {\n opacity = 0;\n }\n if (opacity > 255) {\n opacity = 255;\n }\n this.opacity = opacity;\n this.getRenderer().updateOpacity();\n }\n\n getOpacity(): number {\n return this.opacity;\n }\n\n override hide(enable: boolean): void {\n if (enable === undefined) {\n enable = true;\n }\n this.hidden = enable;\n this.getRenderer().updateVisibility();\n }\n\n flipX(enable: boolean) {\n if (enable !== this._flippedX) {\n this._scaleX *= -1;\n this._flippedX = enable;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n }\n\n flipY(enable: boolean) {\n if (enable !== this._flippedY) {\n this._scaleY *= -1;\n this._flippedY = enable;\n this.invalidateHitboxes();\n this.getRenderer().update();\n }\n }\n\n isFlippedX(): boolean {\n return this._flippedX;\n }\n\n isFlippedY(): boolean {\n return this._flippedY;\n }\n\n /**\n * Return the sprite animator.\n *\n * It returns `null` when custom objects don't have the Animatable capability.\n */\n getAnimator(): gdjs.SpriteAnimator<any> | null {\n return null;\n }\n }\n\n // Others initialization and internal state management :\n // TODO EBO Activate and test instance recycling.\n CustomRuntimeObject.supportsReinitialization = false;\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,uBAmBxB,eACG,GAAK,aAMf,CA4CE,YACE,EACA,EACA,CACA,MAAM,EAAQ,GA1ChB,mCAAyC,GAEjC,4BAAyC,GAEzC,oBAAuB,CAAE,IAAK,CAAC,EAAG,GAAI,IAAK,CAAC,EAAG,IAK7C,gBAGC,KAQD,qCAAkC,GACpC,aAAiB,EACjB,aAAiB,EACjB,eAAqB,GACrB,eAAqB,GACrB,aAAiB,IACjB,mBAAmC,KACn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O,MAAK,UAQd,aAA+C,CAC7C,MAAO,OA30BJ,EAAe,sBAi1BtB,EAAoB,yBAA2B,KAr2BvC",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(s){class l extends s.RuntimeInstanceContainer{constructor(t,n){super();this._isLoaded=!1;this._initialInnerArea=null;this._parent=t,this._customObject=n,this._runtimeScene=t.getScene(),this._debuggerRenderer=new s.DebuggerRenderer(this)}addLayer(t){const n=new s.RuntimeCustomObjectLayer(t,this);this._layers.put(t.name,n),this._orderedLayers.push(n)}createObject(t){const n=super.createObject(t);return this._customObject.onChildrenLocationChanged(),n}loadFrom(t,n){this._isLoaded&&this.onDestroyFromScene(this._parent),this._setOriginalInnerArea(n);for(let r=0,e=n.objects.length;r<e;++r){const i=n.objects[r];t.childrenContent&&!n.name?this.registerObject({...i,...t.childrenContent[i.name]}):this.registerObject(i)}if(n.layers.length>0)for(let r=0,e=n.layers.length;r<e;++r)this.addLayer(n.layers[r]);else this.addLayer({name:"",visibility:!0,cameras:[{defaultSize:!0,defaultViewport:!0,height:0,viewportBottom:0,viewportLeft:0,viewportRight:0,viewportTop:0,width:0}],effects:[],ambientLightColorR:0,ambientLightColorG:0,ambientLightColorB:0,isLightingLayer:!1,followBaseLayerCamera:!1});this.createObjectsFrom(n.instances,0,0,0,!0),this._setLayerDefaultZOrders(),this._isLoaded=!0}_setOriginalInnerArea(t){t.instances.length>0&&(t._initialInnerArea||(t._initialInnerArea={min:[t.areaMinX,t.areaMinY,t.areaMinZ],max:[t.areaMaxX,t.areaMaxY,t.areaMaxZ]}),this._initialInnerArea=t._initialInnerArea)}onDestroyFromScene(t){if(!this._isLoaded)return;const n=this.getAdhocListOfAllInstances();for(let r=0,e=n.length;r<e;++r){const i=n[r];i.onDeletedFromScene(this),i.onDestroyed()}this._destroy(),this._isLoaded=!1}_destroy(){super._destroy(),this._onceTriggers=null}_updateObjectsPreRender(){const t=this.getAdhocListOfAllInstances();for(let n=0,r=t.length;n<r;++n){const e=t[n],i=e.getRendererObject();i&&(i.visible=!e.isHidden(),i.visible&&this.getGame().getEffectsManager().updatePreRender(e.getRendererEffects(),e)),this._debugDrawEnabled&&this._debuggerRenderer.renderDebugDraw(t,this._debugDrawShowHiddenInstances,this._debugDrawShowPointsNames,this._debugDrawShowCustomPoints),e.updatePreRender(this)}}_updateObjectsPreEvents(){const t=this.getAdhocListOfAllInstances();for(let n=0,r=t.length;n<r;++n){const e=t[n],i=e.getElapsedTime();if(e.hasNoForces())e.update(this);else{const a=e.getAverageForce(),o=i/1e3;e.setX(e.getX()+a.getX()*o),e.setY(e.getY()+a.getY()*o),e.update(this),e.updateForces(o)}e.updateTimers(i),e.stepBehaviorsPreEvents(this)}this._cacheOrClearRemovedInstances()}getRenderer(){return this._customObject.getRenderer()}getDebuggerRenderer(){return this._debuggerRenderer}getGame(){return this._runtimeScene.getGame()}getScene(){return this._runtimeScene}getOwner(){return this._customObject}getAsyncTasksManager(){return this._runtimeScene.getAsyncTasksManager()}getUnrotatedViewportMinX(){return this._customObject.getInnerAreaMinX()}getUnrotatedViewportMinY(){return this._customObject.getInnerAreaMinY()}getUnrotatedViewportMaxX(){return this._customObject.getInnerAreaMaxX()}getUnrotatedViewportMaxY(){return this._customObject.getInnerAreaMaxY()}getInitialUnrotatedViewportMinX(){return this._initialInnerArea?this._initialInnerArea.min[0]:0}getInitialUnrotatedViewportMinY(){return this._initialInnerArea?this._initialInnerArea.min[1]:0}getInitialUnrotatedViewportMaxX(){return this._initialInnerArea?this._initialInnerArea.max[0]:0}getInitialUnrotatedViewportMaxY(){return this._initialInnerArea?this._initialInnerArea.max[1]:0}getViewportWidth(){return this._customObject.getUnscaledWidth()}getViewportHeight(){return this._customObject.getUnscaledHeight()}getViewportOriginX(){return this._customObject.getUnscaledCenterX()}getViewportOriginY(){return this._customObject.getUnscaledCenterY()}onChildrenLocationChanged(){this._customObject.onChildrenLocationChanged()}convertCoords(t,n,r){let e=r||[0,0];return e=this._parent.getLayer(this._customObject.getLayer()).convertCoords(t,n,0,e),this._customObject.applyObjectInverseTransformation(e[0],e[1],e),e}convertInverseCoords(t,n,r){const e=r||[0,0];return this._customObject.applyObjectTransformation(t,n,e),this._parent.convertInverseCoords(e[0],e[1],e)}getElapsedTime(){return this._parent.getElapsedTime()}}s.CustomRuntimeObjectInstanceContainer=l})(gdjs||(gdjs={}));
1
+ var gdjs;(function(s){class l extends s.RuntimeInstanceContainer{constructor(t,n){super();this._isLoaded=!1;this._initialInnerArea=null;this._parent=t,this._customObject=n,this._runtimeScene=t.getScene(),this._debuggerRenderer=new s.DebuggerRenderer(this)}addLayer(t){const n=new s.RuntimeCustomObjectLayer(t,this);this._layers.put(t.name,n),this._orderedLayers.push(n)}createObject(t){const n=super.createObject(t);return this._customObject.onChildrenLocationChanged(),n}loadFrom(t,n){this._isLoaded&&this.onDestroyFromScene(this._parent),this._setOriginalInnerArea(n);for(let r=0,e=n.objects.length;r<e;++r){const i=n.objects[r];t.childrenContent&&!n.name?this.registerObject({...i,...t.childrenContent[i.name]}):this.registerObject(i)}if(n.layers.length>0)for(let r=0,e=n.layers.length;r<e;++r)this.addLayer(n.layers[r]);else this.addLayer({name:"",visibility:!0,cameras:[{defaultSize:!0,defaultViewport:!0,height:0,viewportBottom:0,viewportLeft:0,viewportRight:0,viewportTop:0,width:0}],effects:[],ambientLightColorR:0,ambientLightColorG:0,ambientLightColorB:0,isLightingLayer:!1,followBaseLayerCamera:!1});this.createObjectsFrom(n.instances,0,0,0,!0),this._setLayerDefaultZOrders(),this._isLoaded=!0}_setOriginalInnerArea(t){t.instances.length>0&&(t._initialInnerArea||(t._initialInnerArea={min:[t.areaMinX,t.areaMinY,t.areaMinZ],max:[t.areaMaxX,t.areaMaxY,t.areaMaxZ]}),this._initialInnerArea=t._initialInnerArea)}onDestroyFromScene(t){if(!this._isLoaded)return;const n=this.getAdhocListOfAllInstances();for(let r=0,e=n.length;r<e;++r){const i=n[r];i.onDeletedFromScene(),i.onDestroyed()}this._destroy(),this._isLoaded=!1}_destroy(){super._destroy(),this._onceTriggers=null}_updateObjectsPreRender(){const t=this.getAdhocListOfAllInstances();for(let n=0,r=t.length;n<r;++n){const e=t[n],i=e.getRendererObject();i&&(i.visible=!e.isHidden(),i.visible&&this.getGame().getEffectsManager().updatePreRender(e.getRendererEffects(),e)),this._debugDrawEnabled&&this._debuggerRenderer.renderDebugDraw(t,this._debugDrawShowHiddenInstances,this._debugDrawShowPointsNames,this._debugDrawShowCustomPoints),e.updatePreRender(this)}}_updateObjectsPreEvents(){const t=this.getAdhocListOfAllInstances();for(let n=0,r=t.length;n<r;++n){const e=t[n],i=e.getElapsedTime();if(e.hasNoForces())e.update(this);else{const a=e.getAverageForce(),o=i/1e3;e.setX(e.getX()+a.getX()*o),e.setY(e.getY()+a.getY()*o),e.update(this),e.updateForces(o)}e.updateTimers(i),e.stepBehaviorsPreEvents(this)}this._cacheOrClearRemovedInstances()}getRenderer(){return this._customObject.getRenderer()}getDebuggerRenderer(){return this._debuggerRenderer}getGame(){return this._runtimeScene.getGame()}getScene(){return this._runtimeScene}getOwner(){return this._customObject}getAsyncTasksManager(){return this._runtimeScene.getAsyncTasksManager()}getUnrotatedViewportMinX(){return this._customObject.getInnerAreaMinX()}getUnrotatedViewportMinY(){return this._customObject.getInnerAreaMinY()}getUnrotatedViewportMaxX(){return this._customObject.getInnerAreaMaxX()}getUnrotatedViewportMaxY(){return this._customObject.getInnerAreaMaxY()}getInitialUnrotatedViewportMinX(){return this._initialInnerArea?this._initialInnerArea.min[0]:0}getInitialUnrotatedViewportMinY(){return this._initialInnerArea?this._initialInnerArea.min[1]:0}getInitialUnrotatedViewportMaxX(){return this._initialInnerArea?this._initialInnerArea.max[0]:0}getInitialUnrotatedViewportMaxY(){return this._initialInnerArea?this._initialInnerArea.max[1]:0}getViewportWidth(){return this._customObject.getUnscaledWidth()}getViewportHeight(){return this._customObject.getUnscaledHeight()}getViewportOriginX(){return this._customObject.getUnscaledCenterX()}getViewportOriginY(){return this._customObject.getUnscaledCenterY()}onChildrenLocationChanged(){this._customObject.onChildrenLocationChanged()}convertCoords(t,n,r){let e=r||[0,0];return e=this._parent.getLayer(this._customObject.getLayer()).convertCoords(t,n,0,e),this._customObject.applyObjectInverseTransformation(e[0],e[1],e),e}convertInverseCoords(t,n,r){const e=r||[0,0];return this._customObject.applyObjectTransformation(t,n,e),this._parent.convertInverseCoords(e[0],e[1],e)}getElapsedTime(){return this._parent.getElapsedTime()}}s.CustomRuntimeObjectInstanceContainer=l})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=CustomRuntimeObjectInstanceContainer.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/CustomRuntimeObjectInstanceContainer.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2022 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * The instance container of a custom object, containing instances of objects rendered on screen.\n *\n * @see gdjs.CustomRuntimeObject\n */\n export class CustomRuntimeObjectInstanceContainer extends gdjs.RuntimeInstanceContainer {\n _debuggerRenderer: gdjs.DebuggerRenderer;\n _runtimeScene: gdjs.RuntimeScene;\n /** The parent container that contains the object associated with this container. */\n _parent: gdjs.RuntimeInstanceContainer;\n /** The object that is built with the instances of this container. */\n _customObject: gdjs.CustomRuntimeObject;\n _isLoaded: boolean = false;\n /**\n * The default size defined by users in the custom object initial instances editor.\n *\n * Don't modify it as it would affect every instance.\n *\n * @see gdjs.CustomRuntimeObject._innerArea\n **/\n private _initialInnerArea: {\n min: [float, float, float];\n max: [float, float, float];\n } | null = null;\n\n /**\n * @param parent the parent container that contains the object associated\n * with this container.\n * @param customObject the object that is built with the instances of this\n * container.\n */\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n customObject: gdjs.CustomRuntimeObject\n ) {\n super();\n this._parent = parent;\n this._customObject = customObject;\n this._runtimeScene = parent.getScene();\n this._debuggerRenderer = new gdjs.DebuggerRenderer(this);\n }\n\n addLayer(layerData: LayerData) {\n const layer = new gdjs.RuntimeCustomObjectLayer(layerData, this);\n this._layers.put(layerData.name, layer);\n this._orderedLayers.push(layer);\n }\n\n createObject(objectName: string): gdjs.RuntimeObject | null {\n const result = super.createObject(objectName);\n this._customObject.onChildrenLocationChanged();\n return result;\n }\n\n /**\n * Load the container from the given initial configuration.\n * @param customObjectData An object containing the container data.\n * @see gdjs.RuntimeGame#getSceneAndExtensionsData\n */\n loadFrom(\n customObjectData: ObjectData & CustomObjectConfiguration,\n eventsBasedObjectVariantData: EventsBasedObjectVariantData\n ) {\n if (this._isLoaded) {\n this.onDestroyFromScene(this._parent);\n }\n\n this._setOriginalInnerArea(eventsBasedObjectVariantData);\n\n // Registering objects\n for (\n let i = 0, len = eventsBasedObjectVariantData.objects.length;\n i < len;\n ++i\n ) {\n const childObjectData = eventsBasedObjectVariantData.objects[i];\n // The children configuration override only applies to the default variant.\n if (\n customObjectData.childrenContent &&\n !eventsBasedObjectVariantData.name\n ) {\n this.registerObject({\n ...childObjectData,\n // The custom object overrides its events-based object configuration.\n ...customObjectData.childrenContent[childObjectData.name],\n });\n } else {\n // The custom object follows its events-based object configuration.\n this.registerObject(childObjectData);\n }\n }\n\n if (eventsBasedObjectVariantData.layers.length > 0) {\n // Load layers\n for (\n let i = 0, len = eventsBasedObjectVariantData.layers.length;\n i < len;\n ++i\n ) {\n this.addLayer(eventsBasedObjectVariantData.layers[i]);\n }\n } else {\n // Add a default layer\n this.addLayer({\n name: '',\n visibility: true,\n cameras: [\n {\n defaultSize: true,\n defaultViewport: true,\n height: 0,\n viewportBottom: 0,\n viewportLeft: 0,\n viewportRight: 0,\n viewportTop: 0,\n width: 0,\n },\n ],\n effects: [],\n ambientLightColorR: 0,\n ambientLightColorG: 0,\n ambientLightColorB: 0,\n isLightingLayer: false,\n followBaseLayerCamera: false,\n });\n }\n\n this.createObjectsFrom(\n eventsBasedObjectVariantData.instances,\n 0,\n 0,\n 0,\n // TODO EBO: handle hot-reloading for custom objects (including nested custom objects)\n true\n );\n\n // Set up the default z order (for objects created from events)\n this._setLayerDefaultZOrders();\n\n this._isLoaded = true;\n }\n\n /**\n * Initialize `_initialInnerArea` if it doesn't exist.\n * `_initialInnerArea` is shared by every instance to save memory.\n */\n private _setOriginalInnerArea(\n eventsBasedObjectData: EventsBasedObjectVariantData\n ) {\n if (eventsBasedObjectData.instances.length > 0) {\n if (!eventsBasedObjectData._initialInnerArea) {\n eventsBasedObjectData._initialInnerArea = {\n min: [\n eventsBasedObjectData.areaMinX,\n eventsBasedObjectData.areaMinY,\n eventsBasedObjectData.areaMinZ,\n ],\n max: [\n eventsBasedObjectData.areaMaxX,\n eventsBasedObjectData.areaMaxY,\n eventsBasedObjectData.areaMaxZ,\n ],\n };\n }\n this._initialInnerArea = eventsBasedObjectData._initialInnerArea;\n }\n }\n\n /**\n * Called when the associated object is destroyed (because it is removed\n * from its parent container or the scene is being unloaded).\n *\n * @param instanceContainer The container owning the object.\n */\n onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (!this._isLoaded) {\n return;\n }\n\n // Notify the objects they are being destroyed\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onDeletedFromScene(this);\n // The object can free all its resource directly...\n object.onDestroyed();\n }\n // ...as its container cache `_instancesRemoved` is also destroy.\n this._destroy();\n\n this._isLoaded = false;\n }\n\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the container is released immediately.\n super._destroy();\n // @ts-ignore We are deleting the object\n this._onceTriggers = null;\n }\n\n /**\n * Called to update visibility of the renderers of objects\n * rendered on the scene (\"culling\"), update effects (of visible objects)\n * and give a last chance for objects to update before rendering.\n *\n * Visibility is set to false if object is hidden, or if\n * object is too far from the camera of its layer (\"culling\").\n */\n _updateObjectsPreRender() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n // TODO (3D) culling - add support for 3D object culling?\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n const rendererObject = object.getRendererObject();\n if (rendererObject) {\n rendererObject.visible = !object.isHidden();\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this.getGame()\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n }\n }\n\n // Set to true to enable debug rendering (look for the implementation in the renderer\n // to see what is rendered).\n if (this._debugDrawEnabled) {\n this._debuggerRenderer.renderDebugDraw(\n allInstancesList,\n this._debugDrawShowHiddenInstances,\n this._debugDrawShowPointsNames,\n this._debugDrawShowCustomPoints\n );\n }\n\n // Perform pre-render update.\n object.updatePreRender(this);\n }\n return;\n }\n\n /**\n * Update the objects before launching the events.\n */\n _updateObjectsPreEvents() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const obj = allInstancesList[i];\n const elapsedTime = obj.getElapsedTime();\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = elapsedTime / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.update(this);\n obj.updateForces(elapsedTimeInSeconds);\n } else {\n obj.update(this);\n }\n obj.updateTimers(elapsedTime);\n obj.stepBehaviorsPreEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Get the renderer associated to the RuntimeScene.\n */\n getRenderer():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer {\n return this._customObject.getRenderer();\n }\n\n getDebuggerRenderer() {\n return this._debuggerRenderer;\n }\n\n getGame() {\n return this._runtimeScene.getGame();\n }\n\n getScene() {\n return this._runtimeScene;\n }\n\n getOwner(): gdjs.CustomRuntimeObject {\n return this._customObject;\n }\n\n getAsyncTasksManager(): AsyncTasksManager {\n return this._runtimeScene.getAsyncTasksManager();\n }\n\n getUnrotatedViewportMinX(): float {\n return this._customObject.getInnerAreaMinX();\n }\n\n getUnrotatedViewportMinY(): float {\n return this._customObject.getInnerAreaMinY();\n }\n\n getUnrotatedViewportMaxX(): float {\n return this._customObject.getInnerAreaMaxX();\n }\n\n getUnrotatedViewportMaxY(): float {\n return this._customObject.getInnerAreaMaxY();\n }\n\n getInitialUnrotatedViewportMinX(): float {\n return this._initialInnerArea ? this._initialInnerArea.min[0] : 0;\n }\n\n getInitialUnrotatedViewportMinY(): float {\n return this._initialInnerArea ? this._initialInnerArea.min[1] : 0;\n }\n\n getInitialUnrotatedViewportMaxX(): float {\n return this._initialInnerArea ? this._initialInnerArea.max[0] : 0;\n }\n\n getInitialUnrotatedViewportMaxY(): float {\n return this._initialInnerArea ? this._initialInnerArea.max[1] : 0;\n }\n\n getViewportWidth(): float {\n return this._customObject.getUnscaledWidth();\n }\n\n getViewportHeight(): float {\n return this._customObject.getUnscaledHeight();\n }\n\n getViewportOriginX(): float {\n return this._customObject.getUnscaledCenterX();\n }\n\n getViewportOriginY(): float {\n return this._customObject.getUnscaledCenterY();\n }\n\n onChildrenLocationChanged(): void {\n this._customObject.onChildrenLocationChanged();\n }\n\n convertCoords(x: float, y: float, result: FloatPoint): FloatPoint {\n // The result parameter used to be optional.\n let position = result || [0, 0];\n position = this._parent\n .getLayer(this._customObject.getLayer())\n .convertCoords(x, y, 0, position);\n this._customObject.applyObjectInverseTransformation(\n position[0],\n position[1],\n position\n );\n return position;\n }\n\n convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint {\n const position = result || [0, 0];\n this._customObject.applyObjectTransformation(sceneX, sceneY, position);\n return this._parent.convertInverseCoords(\n position[0],\n position[1],\n position\n );\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n getElapsedTime(): float {\n return this._parent.getElapsedTime();\n }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MAAK,QAAQ,kBA1XjB,EAAM,yCANL",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2022 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n /**\n * The instance container of a custom object, containing instances of objects rendered on screen.\n *\n * @see gdjs.CustomRuntimeObject\n */\n export class CustomRuntimeObjectInstanceContainer extends gdjs.RuntimeInstanceContainer {\n _debuggerRenderer: gdjs.DebuggerRenderer;\n _runtimeScene: gdjs.RuntimeScene;\n /** The parent container that contains the object associated with this container. */\n _parent: gdjs.RuntimeInstanceContainer;\n /** The object that is built with the instances of this container. */\n _customObject: gdjs.CustomRuntimeObject;\n _isLoaded: boolean = false;\n /**\n * The default size defined by users in the custom object initial instances editor.\n *\n * Don't modify it as it would affect every instance.\n *\n * @see gdjs.CustomRuntimeObject._innerArea\n **/\n private _initialInnerArea: {\n min: [float, float, float];\n max: [float, float, float];\n } | null = null;\n\n /**\n * @param parent the parent container that contains the object associated\n * with this container.\n * @param customObject the object that is built with the instances of this\n * container.\n */\n constructor(\n parent: gdjs.RuntimeInstanceContainer,\n customObject: gdjs.CustomRuntimeObject\n ) {\n super();\n this._parent = parent;\n this._customObject = customObject;\n this._runtimeScene = parent.getScene();\n this._debuggerRenderer = new gdjs.DebuggerRenderer(this);\n }\n\n addLayer(layerData: LayerData) {\n const layer = new gdjs.RuntimeCustomObjectLayer(layerData, this);\n this._layers.put(layerData.name, layer);\n this._orderedLayers.push(layer);\n }\n\n createObject(objectName: string): gdjs.RuntimeObject | null {\n const result = super.createObject(objectName);\n this._customObject.onChildrenLocationChanged();\n return result;\n }\n\n /**\n * Load the container from the given initial configuration.\n * @param customObjectData An object containing the container data.\n * @see gdjs.RuntimeGame#getSceneAndExtensionsData\n */\n loadFrom(\n customObjectData: ObjectData & CustomObjectConfiguration,\n eventsBasedObjectVariantData: EventsBasedObjectVariantData\n ) {\n if (this._isLoaded) {\n this.onDestroyFromScene(this._parent);\n }\n\n this._setOriginalInnerArea(eventsBasedObjectVariantData);\n\n // Registering objects\n for (\n let i = 0, len = eventsBasedObjectVariantData.objects.length;\n i < len;\n ++i\n ) {\n const childObjectData = eventsBasedObjectVariantData.objects[i];\n // The children configuration override only applies to the default variant.\n if (\n customObjectData.childrenContent &&\n !eventsBasedObjectVariantData.name\n ) {\n this.registerObject({\n ...childObjectData,\n // The custom object overrides its events-based object configuration.\n ...customObjectData.childrenContent[childObjectData.name],\n });\n } else {\n // The custom object follows its events-based object configuration.\n this.registerObject(childObjectData);\n }\n }\n\n if (eventsBasedObjectVariantData.layers.length > 0) {\n // Load layers\n for (\n let i = 0, len = eventsBasedObjectVariantData.layers.length;\n i < len;\n ++i\n ) {\n this.addLayer(eventsBasedObjectVariantData.layers[i]);\n }\n } else {\n // Add a default layer\n this.addLayer({\n name: '',\n visibility: true,\n cameras: [\n {\n defaultSize: true,\n defaultViewport: true,\n height: 0,\n viewportBottom: 0,\n viewportLeft: 0,\n viewportRight: 0,\n viewportTop: 0,\n width: 0,\n },\n ],\n effects: [],\n ambientLightColorR: 0,\n ambientLightColorG: 0,\n ambientLightColorB: 0,\n isLightingLayer: false,\n followBaseLayerCamera: false,\n });\n }\n\n this.createObjectsFrom(\n eventsBasedObjectVariantData.instances,\n 0,\n 0,\n 0,\n // TODO EBO: handle hot-reloading for custom objects (including nested custom objects)\n true\n );\n\n // Set up the default z order (for objects created from events)\n this._setLayerDefaultZOrders();\n\n this._isLoaded = true;\n }\n\n /**\n * Initialize `_initialInnerArea` if it doesn't exist.\n * `_initialInnerArea` is shared by every instance to save memory.\n */\n private _setOriginalInnerArea(\n eventsBasedObjectData: EventsBasedObjectVariantData\n ) {\n if (eventsBasedObjectData.instances.length > 0) {\n if (!eventsBasedObjectData._initialInnerArea) {\n eventsBasedObjectData._initialInnerArea = {\n min: [\n eventsBasedObjectData.areaMinX,\n eventsBasedObjectData.areaMinY,\n eventsBasedObjectData.areaMinZ,\n ],\n max: [\n eventsBasedObjectData.areaMaxX,\n eventsBasedObjectData.areaMaxY,\n eventsBasedObjectData.areaMaxZ,\n ],\n };\n }\n this._initialInnerArea = eventsBasedObjectData._initialInnerArea;\n }\n }\n\n /**\n * Called when the associated object is destroyed (because it is removed\n * from its parent container or the scene is being unloaded).\n *\n * @param instanceContainer The container owning the object.\n */\n onDestroyFromScene(instanceContainer: gdjs.RuntimeInstanceContainer): void {\n if (!this._isLoaded) {\n return;\n }\n\n // Notify the objects they are being destroyed\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n object.onDeletedFromScene();\n // The object can free all its resource directly...\n object.onDestroyed();\n }\n // ...as its container cache `_instancesRemoved` is also destroy.\n this._destroy();\n\n this._isLoaded = false;\n }\n\n _destroy() {\n // It should not be necessary to reset these variables, but this help\n // ensuring that all memory related to the container is released immediately.\n super._destroy();\n // @ts-ignore We are deleting the object\n this._onceTriggers = null;\n }\n\n /**\n * Called to update visibility of the renderers of objects\n * rendered on the scene (\"culling\"), update effects (of visible objects)\n * and give a last chance for objects to update before rendering.\n *\n * Visibility is set to false if object is hidden, or if\n * object is too far from the camera of its layer (\"culling\").\n */\n _updateObjectsPreRender() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n // TODO (3D) culling - add support for 3D object culling?\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const object = allInstancesList[i];\n const rendererObject = object.getRendererObject();\n if (rendererObject) {\n rendererObject.visible = !object.isHidden();\n\n // Update effects, only for visible objects.\n if (rendererObject.visible) {\n this.getGame()\n .getEffectsManager()\n .updatePreRender(object.getRendererEffects(), object);\n }\n }\n\n // Set to true to enable debug rendering (look for the implementation in the renderer\n // to see what is rendered).\n if (this._debugDrawEnabled) {\n this._debuggerRenderer.renderDebugDraw(\n allInstancesList,\n this._debugDrawShowHiddenInstances,\n this._debugDrawShowPointsNames,\n this._debugDrawShowCustomPoints\n );\n }\n\n // Perform pre-render update.\n object.updatePreRender(this);\n }\n return;\n }\n\n /**\n * Update the objects before launching the events.\n */\n _updateObjectsPreEvents() {\n const allInstancesList = this.getAdhocListOfAllInstances();\n for (let i = 0, len = allInstancesList.length; i < len; ++i) {\n const obj = allInstancesList[i];\n const elapsedTime = obj.getElapsedTime();\n if (!obj.hasNoForces()) {\n const averageForce = obj.getAverageForce();\n const elapsedTimeInSeconds = elapsedTime / 1000;\n obj.setX(obj.getX() + averageForce.getX() * elapsedTimeInSeconds);\n obj.setY(obj.getY() + averageForce.getY() * elapsedTimeInSeconds);\n obj.update(this);\n obj.updateForces(elapsedTimeInSeconds);\n } else {\n obj.update(this);\n }\n obj.updateTimers(elapsedTime);\n obj.stepBehaviorsPreEvents(this);\n }\n\n // Some behaviors may have request objects to be deleted.\n this._cacheOrClearRemovedInstances();\n }\n\n /**\n * Get the renderer associated to the RuntimeScene.\n */\n getRenderer():\n | gdjs.CustomRuntimeObject2DRenderer\n | gdjs.CustomRuntimeObject3DRenderer {\n return this._customObject.getRenderer();\n }\n\n getDebuggerRenderer() {\n return this._debuggerRenderer;\n }\n\n getGame() {\n return this._runtimeScene.getGame();\n }\n\n getScene() {\n return this._runtimeScene;\n }\n\n getOwner(): gdjs.CustomRuntimeObject {\n return this._customObject;\n }\n\n getAsyncTasksManager(): AsyncTasksManager {\n return this._runtimeScene.getAsyncTasksManager();\n }\n\n getUnrotatedViewportMinX(): float {\n return this._customObject.getInnerAreaMinX();\n }\n\n getUnrotatedViewportMinY(): float {\n return this._customObject.getInnerAreaMinY();\n }\n\n getUnrotatedViewportMaxX(): float {\n return this._customObject.getInnerAreaMaxX();\n }\n\n getUnrotatedViewportMaxY(): float {\n return this._customObject.getInnerAreaMaxY();\n }\n\n getInitialUnrotatedViewportMinX(): float {\n return this._initialInnerArea ? this._initialInnerArea.min[0] : 0;\n }\n\n getInitialUnrotatedViewportMinY(): float {\n return this._initialInnerArea ? this._initialInnerArea.min[1] : 0;\n }\n\n getInitialUnrotatedViewportMaxX(): float {\n return this._initialInnerArea ? this._initialInnerArea.max[0] : 0;\n }\n\n getInitialUnrotatedViewportMaxY(): float {\n return this._initialInnerArea ? this._initialInnerArea.max[1] : 0;\n }\n\n getViewportWidth(): float {\n return this._customObject.getUnscaledWidth();\n }\n\n getViewportHeight(): float {\n return this._customObject.getUnscaledHeight();\n }\n\n getViewportOriginX(): float {\n return this._customObject.getUnscaledCenterX();\n }\n\n getViewportOriginY(): float {\n return this._customObject.getUnscaledCenterY();\n }\n\n onChildrenLocationChanged(): void {\n this._customObject.onChildrenLocationChanged();\n }\n\n convertCoords(x: float, y: float, result: FloatPoint): FloatPoint {\n // The result parameter used to be optional.\n let position = result || [0, 0];\n position = this._parent\n .getLayer(this._customObject.getLayer())\n .convertCoords(x, y, 0, position);\n this._customObject.applyObjectInverseTransformation(\n position[0],\n position[1],\n position\n );\n return position;\n }\n\n convertInverseCoords(\n sceneX: float,\n sceneY: float,\n result: FloatPoint\n ): FloatPoint {\n const position = result || [0, 0];\n this._customObject.applyObjectTransformation(sceneX, sceneY, position);\n return this._parent.convertInverseCoords(\n position[0],\n position[1],\n position\n );\n }\n\n /**\n * Return the time elapsed since the last frame,\n * in milliseconds, for objects on the layer.\n */\n getElapsedTime(): float {\n return this._parent.getElapsedTime();\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAMS,eAAmD,GAAK,wBAAyB,CA0BtF,YACE,EACA,EACA,CACA,QAvBF,eAAqB,GAQb,uBAGG,KAaT,KAAK,QAAU,EACf,KAAK,cAAgB,EACrB,KAAK,cAAgB,EAAO,WAC5B,KAAK,kBAAoB,GAAI,GAAK,iBAAiB,MAGrD,SAAS,EAAsB,CAC7B,KAAM,GAAQ,GAAI,GAAK,yBAAyB,EAAW,MAC3D,KAAK,QAAQ,IAAI,EAAU,KAAM,GACjC,KAAK,eAAe,KAAK,GAG3B,aAAa,EAA+C,CAC1D,KAAM,GAAS,MAAM,aAAa,GAClC,YAAK,cAAc,4BACZ,EAQ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yC,CACvC,MAAO,MAAK,kBAAoB,KAAK,kBAAkB,IAAI,GAAK,EAGlE,iCAAyC,CACvC,MAAO,MAAK,kBAAoB,KAAK,kBAAkB,IAAI,GAAK,EAGlE,iCAAyC,CACvC,MAAO,MAAK,kBAAoB,KAAK,kBAAkB,IAAI,GAAK,EAGlE,kBAA0B,CACxB,MAAO,MAAK,cAAc,mBAG5B,mBAA2B,CACzB,MAAO,MAAK,cAAc,oBAG5B,oBAA4B,CAC1B,MAAO,MAAK,cAAc,qBAG5B,oBAA4B,CAC1B,MAAO,MAAK,cAAc,qBAG5B,2BAAkC,CAChC,KAAK,cAAc,4BAGrB,cAAc,EAAU,EAAU,EAAgC,CAEhE,GAAI,GAAW,GAAU,CAAC,EAAG,GAC7B,SAAW,KAAK,QACb,SAAS,KAAK,cAAc,YAC5B,cAAc,EAAG,EAAG,EAAG,GAC1B,KAAK,cAAc,iCACjB,EAAS,GACT,EAAS,GACT,GAEK,EAGT,qBACE,EACA,EACA,EACY,CACZ,KAAM,GAAW,GAAU,CAAC,EAAG,GAC/B,YAAK,cAAc,0BAA0B,EAAQ,EAAQ,GACtD,KAAK,QAAQ,qBAClB,EAAS,GACT,EAAS,GACT,GAQJ,gBAAwB,CACtB,MAAO,MAAK,QAAQ,kBA1XjB,EAAM,yCANL",
6
6
  "names": []
7
7
  }
@@ -21,7 +21,9 @@ module.exports = {
21
21
  .setExtensionInformation(
22
22
  'Scene3D',
23
23
  _('3D'),
24
- _('Support for 3D in GDevelop.'),
24
+ _(
25
+ 'Support for 3D in GDevelop: this provides 3D objects and the common features for all 3D objects.'
26
+ ),
25
27
  'Florian Rival',
26
28
  'MIT'
27
29
  )
@@ -36,7 +38,9 @@ module.exports = {
36
38
  'Base3DBehavior',
37
39
  _('3D capability'),
38
40
  'Object3D',
39
- _('Move the object in 3D space.'),
41
+ _(
42
+ 'Common features for all 3D objects: position in 3D space (including the Z axis, in addition to X and Y), size (including depth, in addition to width and height), rotation (on X and Y axis, in addition to the Z axis), scale (including Z axis, in addition to X and Y), flipping (on Z axis, in addition to horizontal (Y)/vertical (X) flipping).'
43
+ ),
40
44
  '',
41
45
  'res/conditions/3d_box.svg',
42
46
  'Base3DBehavior',
@@ -1,2 +1,2 @@
1
- var gdjs;(function(s){class d extends s.RuntimeBehavior{constructor(e,r,o){super(e,r,o);this._extraBorder=r.extraBorder||0}updateFromBehaviorData(e,r){return e.extraBorder!==r.extraBorder&&(this._extraBorder=r.extraBorder),!0}doStepPostEvents(e){const r=this.owner.getWidth(),o=this.owner.getHeight(),i=this.owner.getDrawableX()+this.owner.getCenterX(),n=this.owner.getDrawableY()+this.owner.getCenterY(),t=e.getLayer(this.owner.getLayer()),a=Math.sqrt(r*r+o*o)/2;(i+a+this._extraBorder<t.getCameraX()-t.getCameraWidth()/2||i-a-this._extraBorder>t.getCameraX()+t.getCameraWidth()/2||n+a+this._extraBorder<t.getCameraY()-t.getCameraHeight()/2||n-a-this._extraBorder>t.getCameraY()+t.getCameraHeight()/2)&&this.owner.deleteFromScene(e)}setExtraBorder(e){this._extraBorder=e}getExtraBorder(){return this._extraBorder}}s.DestroyOutsideRuntimeBehavior=d,s.registerBehavior("DestroyOutsideBehavior::DestroyOutside",s.DestroyOutsideRuntimeBehavior)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(s){class d extends s.RuntimeBehavior{constructor(t,e,o){super(t,e,o);this._extraBorder=e.extraBorder||0}updateFromBehaviorData(t,e){return t.extraBorder!==e.extraBorder&&(this._extraBorder=e.extraBorder),!0}doStepPostEvents(t){const e=this.owner.getWidth(),o=this.owner.getHeight(),i=this.owner.getDrawableX()+this.owner.getCenterX(),n=this.owner.getDrawableY()+this.owner.getCenterY(),r=t.getLayer(this.owner.getLayer()),a=Math.sqrt(e*e+o*o)/2;(i+a+this._extraBorder<r.getCameraX()-r.getCameraWidth()/2||i-a-this._extraBorder>r.getCameraX()+r.getCameraWidth()/2||n+a+this._extraBorder<r.getCameraY()-r.getCameraHeight()/2||n-a-this._extraBorder>r.getCameraY()+r.getCameraHeight()/2)&&this.owner.deleteFromScene()}setExtraBorder(t){this._extraBorder=t}getExtraBorder(){return this._extraBorder}}s.DestroyOutsideRuntimeBehavior=d,s.registerBehavior("DestroyOutsideBehavior::DestroyOutside",s.DestroyOutsideRuntimeBehavior)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=destroyoutsideruntimebehavior.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.ts"],
4
- "sourcesContent": ["/*\nGDevelop - DestroyOutside Behavior Extension\nCopyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n /**\n * The DestroyOutsideRuntimeBehavior represents a behavior that destroys the object when it leaves the screen.\n */\n export class DestroyOutsideRuntimeBehavior extends gdjs.RuntimeBehavior {\n _extraBorder: any;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner\n ) {\n super(instanceContainer, behaviorData, owner);\n this._extraBorder = behaviorData.extraBorder || 0;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.extraBorder !== newBehaviorData.extraBorder) {\n this._extraBorder = newBehaviorData.extraBorder;\n }\n return true;\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // TODO: This would better be done using the object AABB (getAABB), as (`getCenterX`;`getCenterY`) point\n // is not necessarily in the middle of the object (for sprites for example).\n const ow = this.owner.getWidth();\n const oh = this.owner.getHeight();\n const ocx = this.owner.getDrawableX() + this.owner.getCenterX();\n const ocy = this.owner.getDrawableY() + this.owner.getCenterY();\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n const boundingCircleRadius = Math.sqrt(ow * ow + oh * oh) / 2.0;\n if (\n ocx + boundingCircleRadius + this._extraBorder <\n layer.getCameraX() - layer.getCameraWidth() / 2 ||\n ocx - boundingCircleRadius - this._extraBorder >\n layer.getCameraX() + layer.getCameraWidth() / 2 ||\n ocy + boundingCircleRadius + this._extraBorder <\n layer.getCameraY() - layer.getCameraHeight() / 2 ||\n ocy - boundingCircleRadius - this._extraBorder >\n layer.getCameraY() + layer.getCameraHeight() / 2\n ) {\n //We are outside the camera area.\n this.owner.deleteFromScene(instanceContainer);\n }\n }\n\n /**\n * Set an additional border to the camera viewport as a buffer before the object gets destroyed.\n * @param val Border in pixels.\n */\n setExtraBorder(val: number): void {\n this._extraBorder = val;\n }\n\n /**\n * Get the additional border of the camera viewport buffer which triggers the destruction of an object.\n * @return The additional border around the camera viewport in pixels\n */\n getExtraBorder(): number {\n return this._extraBorder;\n }\n }\n gdjs.registerBehavior(\n 'DestroyOutsideBehavior::DestroyOutside',\n gdjs.DestroyOutsideRuntimeBehavior\n );\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAIS,eAA4C,GAAK,eAAgB,CAGtE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GACvC,KAAK,aAAe,EAAa,aAAe,EAGlD,uBAAuB,EAAiB,EAA0B,CAChE,MAAI,GAAgB,cAAgB,EAAgB,aAClD,MAAK,aAAe,EAAgB,aAE/B,GAGT,iBAAiB,EAAkD,CAGjE,KAAM,GAAK,KAAK,MAAM,WAChB,EAAK,KAAK,MAAM,YAChB,EAAM,KAAK,MAAM,eAAiB,KAAK,MAAM,aAC7C,EAAM,KAAK,MAAM,eAAiB,KAAK,MAAM,aAC7C,EAAQ,EAAkB,SAAS,KAAK,MAAM,YAC9C,EAAuB,KAAK,KAAK,EAAK,EAAK,EAAK,GAAM,EAC5D,AACE,GAAM,EAAuB,KAAK,aAChC,EAAM,aAAe,EAAM,iBAAmB,GAChD,EAAM,EAAuB,KAAK,aAChC,EAAM,aAAe,EAAM,iBAAmB,GAChD,EAAM,EAAuB,KAAK,aAChC,EAAM,aAAe,EAAM,kBAAoB,GACjD,EAAM,EAAuB,KAAK,aAChC,EAAM,aAAe,EAAM,kBAAoB,IAGjD,KAAK,MAAM,gBAAgB,GAQ/B,eAAe,EAAmB,CAChC,KAAK,aAAe,EAOtB,gBAAyB,CACvB,MAAO,MAAK,cAxDT,EAAM,gCA2Db,EAAK,iBACH,yCACA,EAAK,iCAjEC",
4
+ "sourcesContent": ["/*\nGDevelop - DestroyOutside Behavior Extension\nCopyright (c) 2013-2016 Florian Rival (Florian.Rival@gmail.com)\n */\n\nnamespace gdjs {\n /**\n * The DestroyOutsideRuntimeBehavior represents a behavior that destroys the object when it leaves the screen.\n */\n export class DestroyOutsideRuntimeBehavior extends gdjs.RuntimeBehavior {\n _extraBorder: any;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner\n ) {\n super(instanceContainer, behaviorData, owner);\n this._extraBorder = behaviorData.extraBorder || 0;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.extraBorder !== newBehaviorData.extraBorder) {\n this._extraBorder = newBehaviorData.extraBorder;\n }\n return true;\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // TODO: This would better be done using the object AABB (getAABB), as (`getCenterX`;`getCenterY`) point\n // is not necessarily in the middle of the object (for sprites for example).\n const ow = this.owner.getWidth();\n const oh = this.owner.getHeight();\n const ocx = this.owner.getDrawableX() + this.owner.getCenterX();\n const ocy = this.owner.getDrawableY() + this.owner.getCenterY();\n const layer = instanceContainer.getLayer(this.owner.getLayer());\n const boundingCircleRadius = Math.sqrt(ow * ow + oh * oh) / 2.0;\n if (\n ocx + boundingCircleRadius + this._extraBorder <\n layer.getCameraX() - layer.getCameraWidth() / 2 ||\n ocx - boundingCircleRadius - this._extraBorder >\n layer.getCameraX() + layer.getCameraWidth() / 2 ||\n ocy + boundingCircleRadius + this._extraBorder <\n layer.getCameraY() - layer.getCameraHeight() / 2 ||\n ocy - boundingCircleRadius - this._extraBorder >\n layer.getCameraY() + layer.getCameraHeight() / 2\n ) {\n //We are outside the camera area.\n this.owner.deleteFromScene();\n }\n }\n\n /**\n * Set an additional border to the camera viewport as a buffer before the object gets destroyed.\n * @param val Border in pixels.\n */\n setExtraBorder(val: number): void {\n this._extraBorder = val;\n }\n\n /**\n * Get the additional border of the camera viewport buffer which triggers the destruction of an object.\n * @return The additional border around the camera viewport in pixels\n */\n getExtraBorder(): number {\n return this._extraBorder;\n }\n }\n gdjs.registerBehavior(\n 'DestroyOutsideBehavior::DestroyOutside',\n gdjs.DestroyOutsideRuntimeBehavior\n );\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CAIS,eAA4C,GAAK,eAAgB,CAGtE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GACvC,KAAK,aAAe,EAAa,aAAe,EAGlD,uBAAuB,EAAiB,EAA0B,CAChE,MAAI,GAAgB,cAAgB,EAAgB,aAClD,MAAK,aAAe,EAAgB,aAE/B,GAGT,iBAAiB,EAAkD,CAGjE,KAAM,GAAK,KAAK,MAAM,WAChB,EAAK,KAAK,MAAM,YAChB,EAAM,KAAK,MAAM,eAAiB,KAAK,MAAM,aAC7C,EAAM,KAAK,MAAM,eAAiB,KAAK,MAAM,aAC7C,EAAQ,EAAkB,SAAS,KAAK,MAAM,YAC9C,EAAuB,KAAK,KAAK,EAAK,EAAK,EAAK,GAAM,EAC5D,AACE,GAAM,EAAuB,KAAK,aAChC,EAAM,aAAe,EAAM,iBAAmB,GAChD,EAAM,EAAuB,KAAK,aAChC,EAAM,aAAe,EAAM,iBAAmB,GAChD,EAAM,EAAuB,KAAK,aAChC,EAAM,aAAe,EAAM,kBAAoB,GACjD,EAAM,EAAuB,KAAK,aAChC,EAAM,aAAe,EAAM,kBAAoB,IAGjD,KAAK,MAAM,kBAQf,eAAe,EAAmB,CAChC,KAAK,aAAe,EAOtB,gBAAyB,CACvB,MAAO,MAAK,cAxDT,EAAM,gCA2Db,EAAK,iBACH,yCACA,EAAK,iCAjEC",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(s){const k=new s.Logger("Multiplayer"),g=new s.Logger("Multiplayer - Debug");s.Logger.getDefaultConsoleLoggerOutput().discardGroup("Multiplayer - Debug");class je{constructor(S){this.clear=()=>{this.cache.clear(),this.keys=[]};this.maxSize=S,this.cache=new Set,this.keys=[]}has(S){return this.cache.has(S)}add(S){if(this.cache.size>=this.maxSize){const D=this.keys.shift();D&&this.cache.delete(D)}this.cache.add(S),this.keys.push(S)}}class ue{constructor(){this._updates=[]}store(S){this._updates.push(S),this._updates.length>10&&this._updates.shift()}getUpdates(){return this._updates}remove(S){const D=this._updates.indexOf(S);D!==-1&&this._updates.splice(D,1)}clear(){this._updates=[]}}const Te=({target:C,source:S})=>{for(const D in S)S.hasOwnProperty(D)&&!C.hasOwnProperty(D)&&(C[D]=S[D]);for(const D in C)C.hasOwnProperty(D)&&!S.hasOwnProperty(D)&&delete C[D]};s.makeMultiplayerMessageManager=()=>{const C=0,S=0,D=0,Je=0,v=window.performance&&typeof window.performance.now=="function"?window.performance.now.bind(window.performance):Date.now,_e=200,Le=4,U=new je(500);let O={},H={};const xe=1;let me=0,Q=null,W=0,V=new ue;const Ge=1;let de=0,J=null,F=0,B=new ue;const Ee=1;let G=0,E={},pe={},M={},A=[],$=[],K={};const x=({originalMessageName:e,originalData:t,expectedMessageName:n,otherPeerIds:r,shouldCancelMessageIfTimesOut:a,maxNumberOfRetries:o,messageRetryTime:l})=>{!s.multiplayer.isLobbyGameRunning()||(O[n]||(O[n]={}),g.info(`Adding expected message ${n} from ${r.join(", ")}.`),r.forEach(c=>{O[n][c]={acknowledged:!1,lastMessageSentAt:v(),originalMessageName:e,originalData:t,shouldCancelMessageIfTimesOut:a,numberOfRetries:0,maxNumberOfRetries:o||Le,messageRetryTime:l||_e}}))},fe=({sceneNetworkId:e,instanceNetworkId:t})=>(H[e]||(H[e]={}),H[e][t]||0),ye=({sceneNetworkId:e,instanceNetworkId:t,clock:n})=>{H[e]||(H[e]={}),H[e][t]=n},w=(e,t,n)=>{if(!(S>0&&Math.random()<S)){if(D>0&&Math.random()<D){setTimeout(()=>{s.multiplayerPeerJsHelper.sendDataTo(e,t,n)},Je);return}if(C>0){setTimeout(()=>{s.multiplayerPeerJsHelper.sendDataTo(e,t,n)},C);return}s.multiplayerPeerJsHelper.sendDataTo(e,t,n)}},Ue=(e,t,n)=>{if(!e.length)return null;let r=null,a=1/0;for(let o=0;o<e.length;++o){if(e[o].networkId)continue;const l=e[o],c=Math.pow(l.getX()-t,2)+Math.pow(l.getY()-n,2);c<a&&(r=l,a=c)}return r},Z=({runtimeScene:e,objectName:t,instanceNetworkId:n,instanceX:r,instanceY:a,shouldCreateIfNotFound:o})=>{const l=e.getInstancesOf(t);if(!l)return null;let c=l.find(i=>i.networkId===n)||null;if(!c&&r!==void 0&&a!==void 0){g.info(`instance ${t} ${n} not found with network ID, trying to find it with position ${r}/${a}.`);const i=Ue(l,r,a);i&&(g.info(`Found closest instance for object ${t} ${n} with no network ID.`),c=i,c.networkId=n)}if(!c&&o){g.info(`Instance ${n} still not found, Creating instance ${t}.`);const i=e.createObject(t);if(!i)return null;i.networkId=n,c=i}return c},Y="#changeInstanceOwner",he=/#changeInstanceOwner#owner_(\d+)#object_(.+)#instance_(.+)/,We=({objectOwner:e,objectName:t,instanceNetworkId:n,newObjectOwner:r,instanceX:a,instanceY:o,sceneNetworkId:l})=>({messageName:`${Y}#owner_${e}#object_${t}#instance_${n}`,messageData:{previousOwner:e,newOwner:r,instanceX:a,instanceY:o,sceneNetworkId:l}}),ee="#instanceOwnerChanged",Ve=/#instanceOwnerChanged#owner_(\d+)#object_(.+)#instance_(.+)/,be=e=>e.replace(Y,ee),Fe=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(Y)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=he.exec(a);if(!p)return;const f=p[2],u=p[3],m=i.previousOwner,y=i.newOwner,I=i.sceneNetworkId;if(I!==e.networkId){g.info(`Object ${f} is in scene ${I}, but we are on ${e.networkId}. Skipping.`);return}const P=Z({runtimeScene:e,objectName:f,instanceNetworkId:u,instanceX:i.instanceX,instanceY:i.instanceY});if(!P){g.info(`Instance ${u} not found, it must have been destroyed.`);return}const h=P.getBehavior("MultiplayerObject");if(!h){g.info(`Object ${f} does not have the MultiplayerObjectBehavior, cannot change ownership.`);return}const b=h.getPlayerObjectOwnership(),N=b===m||b===y;if(s.multiplayer.isCurrentPlayerHost()&&!N){g.info(`Object ${f} with instance network ID ${u} does not have the expected owner. Wanted to change from ${m} to ${y}, but object has owner ${b}.`);return}g.info(`Changing ownership of object ${f} to ${y}.`),h.playerNumber=y;const _=be(a);if(g.info(`Sending acknowledgment of ownership change of object ${f} from ${m} to ${y} with instance network ID ${u} to ${d}.`),w([d],_,{}),s.multiplayer.isCurrentPlayerHost()){const j=s.multiplayerPeerJsHelper.getAllPeers().filter(R=>R!==d);if(!j.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:_,otherPeerIds:j,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying ownership change of object ${f} with instance network ID ${u} to ${j.join(", ")}.`),w(j,a,i)}})})},Me="#updateInstance",Be=/#updateInstance#owner_(\d+)#object_(.+)#instance_(.+)#scene_(.+)/,Ke=({objectOwner:e,objectName:t,instanceNetworkId:n,objectNetworkSyncData:r,sceneNetworkId:a})=>({messageName:`${Me}#owner_${e}#object_${t}#instance_${n}#scene_${a}`,messageData:r}),Ye=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(Me)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();if(!l.length)return;l.slice().reverse().forEach(i=>{const d=i.getData(),p=i.getSender(),f=Be.exec(a);if(!f)return;const u=parseInt(f[1],10);if(u===s.multiplayer.playerNumber)return;const m=f[2],y=f[3],I=f[4];if(I!==e.networkId){g.info(`Object ${m} is in scene ${I}, but we are on ${e.networkId}. Skipping.`);return}const P=d._clock,h=fe({sceneNetworkId:I,instanceNetworkId:y});if(P<=h)return;const b=Z({runtimeScene:e,objectName:m,instanceNetworkId:y,shouldCreateIfNotFound:!0,instanceX:d.x,instanceY:d.y});if(!b){k.error("Instance could not be found or created.");return}const N=b.getBehavior("MultiplayerObject");if(!N){k.error(`Object ${m} does not have the MultiplayerObjectBehavior, cannot update it.`);return}if(N.getPlayerObjectOwnership()===s.multiplayer.playerNumber){g.info(`Object ${m} with instance network ID ${y} is owned by us ${s.multiplayer.playerNumber}, ignoring update message from ${u}.`);return}if(N.getPlayerObjectOwnership()!==u&&(g.info(`Object ${m} with instance network ID ${y} is owned by ${N.getPlayerObjectOwnership()} on our game, changing ownership to ${u} as part of the update event.`),N.playerNumber=u),b.updateFromNetworkSyncData(d),ye({sceneNetworkId:I,instanceNetworkId:y,clock:P}),N._clock=P,s.multiplayer.isCurrentPlayerHost()){const T=s.multiplayerPeerJsHelper.getAllPeers().filter(j=>j!==p);if(!T.length)return;w(T,a,d)}})})},q="#changeVariableOwner",we=/#changeVariableOwner#owner_(\d+)#variable_(.+)/,qe=({variableOwner:e,variableNetworkId:t,newVariableOwner:n})=>({messageName:`${q}#owner_${e}#variable_${t}`,messageData:{previousOwner:e,newOwner:n}}),te="#variableOwnerChanged",Xe=/#variableOwnerChanged#owner_(\d+)#variable_(.+)/,Ie=e=>e.replace(q,te),ze=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(q)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=we.exec(a);if(!p)return;const f=p[2],u=i.previousOwner,m=i.newOwner,{type:y,name:I,containerId:P}=s.multiplayerVariablesManager.getVariableTypeAndNameFromNetworkId(f);if(y==="scene"&&P!==e.networkId){g.info(`Variable ${I} is in scene ${P}, but we are on ${e.networkId}. Skipping.`);return}const h=P==="game"?e.getGame().getVariables():e.getVariables();if(!h.has(I)){k.error(`Variable with ID ${f} not found whilst syncing. This should not happen.`);return}const b=h.get(I),N=b.getPlayerOwnership(),_=N===u||N===m;if(s.multiplayer.isCurrentPlayerHost()&&!_){g.info(`Variable with ID ${f} does not have the expected owner. Wanted to change from ${u} to ${m}, but variable has owner ${N}.`);return}g.info(`Changing ownership of variable ${I} to ${m}.`),b.setPlayerOwnership(m);const T=Ie(a);if(g.info(`Sending acknowledgment of ownership change of variable with ID ${f} from ${u} to ${m} to ${d}.`),w([d],T,{}),s.multiplayer.isCurrentPlayerHost()){const R=s.multiplayerPeerJsHelper.getAllPeers().filter(z=>z!==d);if(!R.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:T,otherPeerIds:R,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying ownership change of variable with Id ${f} to ${R.join(", ")}.`),w(R,a,i)}})})},Qe=e=>e.startsWith(ne)?at:e.startsWith(ee)?Ve:e.startsWith(te)?Xe:e.startsWith(re)?ct:null,Ze=e=>e.startsWith(ne)||e.startsWith(ee)||e.startsWith(te)||e.startsWith(re),et=()=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(Ze).forEach(r=>{const a=e.get(r);if(!a)return;const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender();g.info(`Received acknowledgment for message ${r}.`);const d=Qe(r);if(!d){k.error(`Invalid acknowledgment message ${r}.`);return}const p=d.exec(r);if(!p){k.error(`Invalid acknowledgment message ${r}.`);return}if(!O[r]||!O[r][i])return;const f=c._clock;if(f!==void 0){const u=p[3],m=p[4],y=fe({sceneNetworkId:m,instanceNetworkId:u});if(f<=y)return;ye({sceneNetworkId:m,instanceNetworkId:u,clock:f})}g.info(`Marking message ${r} as acknowledged from ${i}.`),O[r][i].acknowledged=!0})})},tt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;Object.keys(O).forEach(n=>{const r=O[n],a=Object.keys(r).filter(o=>!r[o].acknowledged);if(!a.length)g.info(`All peers have acknowledged message ${n}.`),delete O[n];else for(const o of a){const{lastMessageSentAt:l,originalMessageName:c,originalData:i,numberOfRetries:d,maxNumberOfRetries:p,messageRetryTime:f}=r[o];if(v()-l>f){if(d>=p){if(g.info(`Giving up on message ${n} for ${o}.`),r[o].shouldCancelMessageIfTimesOut){if(c.startsWith(Y)){const u=he.exec(c);if(!u){delete O[n];return}const m=u[2],y=u[3],I=e.getInstancesOf(m);if(!I){delete O[n];return}let P=I.find(N=>N.networkId===y);if(!P){delete O[n];return}const h=P.getBehavior("MultiplayerObject");if(!h){k.error(`Object ${m} does not have the MultiplayerObjectBehavior, cannot revert ownership.`),delete O[n];return}const b=i.previousOwner;if(b===void 0){delete O[n];return}h.playerNumber=b||0}if(c.startsWith(q)){const u=we.exec(c);if(!u){delete O[n];return}const m=u[2],y=i.previousOwner,{type:I,name:P,containerId:h}=s.multiplayerVariablesManager.getVariableTypeAndNameFromNetworkId(m);if(I==="scene"&&h!==e.networkId){g.info(`Variable ${P} is in scene ${h}, but we are on ${e.networkId}. Skipping ownership revert.`),delete O[n];return}const b=h==="game"?e.getGame().getVariables():e.getVariables();if(!b.has(P)){k.error(`Variable with ID ${m} not found while reverting ownership. This should not happen.`),delete O[n];return}const N=b.get(P);if(y===void 0){delete O[n];return}N.setPlayerOwnership(y||0)}}delete O[n];continue}w([o],c,i),r[o].lastMessageSentAt=v(),r[o].numberOfRetries=d+1}}})},se="#destroyInstance",st=/#destroyInstance#owner_(\d+)#object_(.+)#instance_(.+)#scene_(.+)/,nt=({objectOwner:e,objectName:t,instanceNetworkId:n,sceneNetworkId:r})=>({messageName:`${se}#owner_${e}#object_${t}#instance_${n}#scene_${r}`,messageData:{}}),ne="#instanceDestroyed",at=/#instanceDestroyed#owner_(\d+)#object_(.+)#instance_(.+)/,Pe=e=>e.replace(se,ne),rt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(se)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender();g.info(`Received message ${a} with data ${JSON.stringify(i)}.`);const p=st.exec(a);if(!p||parseInt(p[1],10)===s.multiplayer.playerNumber)return;const u=p[2],m=p[3],y=p[4];if(y!==e.networkId){g.info(`Object ${u} is in scene ${y}, but we are on ${e.networkId}. Skipping.`);return}const I=Z({runtimeScene:e,objectName:u,instanceNetworkId:m}),P=Pe(a);if(!I){g.info("Instance was not found in the scene, sending acknowledgment anyway."),w([d],P,{});return}if(g.info(`Destroying object ${u} with instance network ID ${m}.`),I.deleteFromScene(e),g.info(`Sending acknowledgment of destruction of object ${u} with instance network ID ${m} to ${d}.`),w([d],P,{}),s.multiplayer.isCurrentPlayerHost()){const b=s.multiplayerPeerJsHelper.getAllPeers().filter(N=>N!==d);if(!b.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:P,otherPeerIds:b,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying instance destroyed message for object ${u} with instance network ID ${m} to ${b.join(", ")}.`),w(b,a,i)}})})},ae="#customMessage",ot=/#customMessage#(.+)/,X=e=>`${ae}#${e}`,it=({userMessageName:e,userMessageData:t,senderPlayerNumber:n})=>{const r=s.makeUuid();return{messageName:X(e),messageData:{data:t,uniqueId:r,senderPlayerNumber:n}}},re="#ackCustomMessage",ct=/#ackCustomMessage#(.+)/,Ne=e=>e.replace(ae,re),Oe=(e,t)=>{const n=s.multiplayerPeerJsHelper.getAllPeers(),r=s.multiplayer.getCurrentPlayerNumber(),{messageName:a,messageData:o}=it({userMessageName:e,userMessageData:t,senderPlayerNumber:r}),l=Ne(a);x({originalMessageName:a,originalData:o,expectedMessageName:l,otherPeerIds:n,shouldCancelMessageIfTimesOut:!1}),g.info(`Sending custom message ${e} with data ${JSON.stringify(t)}.`),w(n,a,o),s.multiplayer.isCurrentPlayerHost()&&s.multiplayerPeerJsHelper.getOrCreateMessagesList(a).pushMessage(o,s.multiplayerPeerJsHelper.getCurrentId())},lt=(e,t)=>{const n=t.toJSObject();g.info(`Sending custom message ${e} with data ${JSON.stringify(n)}.`),Oe(e,n)},gt=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return;const a=r.getMessages();if(!a.length)return;g.info(`custom message ${e} has been received.`);let o=!1;return a.forEach(l=>{const i=l.getData().uniqueId,d=`${t}#${i}`;U.has(d)||(U.add(d),o=!0)}),o},Se=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return;const a=r.getMessages();return a.length?a[a.length-1].getData().data:void 0},ut=(e,t)=>{const n=Se(e);!n||(g.info(`Received custom message ${e} with data ${JSON.stringify(n)}.`),t.fromJSObject(n))},mt=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return 0;const a=r.getMessages();return a.length?a[a.length-1].getData().senderPlayerNumber:0},dt=()=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(r=>r.startsWith(ae)).forEach(r=>{const a=e.get(r);if(!a){k.error(`No messages list found for ${r}.`);return}const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender(),d=c.uniqueId;if(g.info(`Received custom message ${r} with data ${JSON.stringify(c)}.`),!ot.exec(r)){k.error(`Invalid custom message ${r}.`);return}const f=`${r}#${d}`;if(U.has(f)){g.info(`Message ${r} has already been processed, skipping.`);return}const u=Ne(r);if(g.info(`Sending acknowledgment of custom message ${r} to ${i}.`),w([i],u,{}),s.multiplayer.isCurrentPlayerHost()){const m=s.multiplayerPeerJsHelper.getAllPeers();if(!m.length)return;x({originalMessageName:r,originalData:c,expectedMessageName:u,otherPeerIds:m,shouldCancelMessageIfTimesOut:!1}),w(m,r,c)}})})},De="#updateScene",ke=({sceneNetworkSyncData:e})=>({messageName:`${De}`,messageData:e}),pt=e=>e.var?Q?JSON.stringify(e.var)!==JSON.stringify(Q.var):!0:!1,ft=()=>v()-me<1e3/xe,yt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=e.getNetworkSyncData({playerNumber:s.multiplayer.getCurrentPlayerNumber(),isHost:s.multiplayer.isCurrentPlayerHost()});if(!t)return;const n=pt(t),r=!ft()||n||W>0;if(n&&(W=3),!r)return;const a=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:o,messageData:l}=ke({sceneNetworkSyncData:t});w(a,o,l),me=v(),Q=t,W=Math.max(W-1,0)},ht=e=>{const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(De)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=i.id;if(s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages()){if(p!==e.networkId){g.info(`Received update of scene ${p}, but we are on ${e.networkId}. Skipping.`);return}e.updateFromNetworkSyncData(i)}else{g.info(`Saving scene ${p} update message for later use.`),V.store(i);return}if(s.multiplayer.isCurrentPlayerHost()){const u=s.multiplayerPeerJsHelper.getAllPeers().filter(m=>m!==d);w(u,a,i)}})})},ve="#updateGame",$e=({gameNetworkSyncData:e})=>({messageName:`${ve}`,messageData:e}),bt=e=>{const t=e.var,n=e.ss;if(!t&&!n)return!1;if(!J||!J.var||!J.ss||t&&JSON.stringify(t)!==JSON.stringify(J.var))return!0;if(n){if(n.length!==J.ss.length)return!0;for(let r=0;r<n.length;++r){const a=n[r],o=J.ss[r];if(a.name!==o.name||a.networkId!==o.networkId)return!0}}return!1},Mt=()=>v()-de<1e3/Ge,wt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=e.getGame().getNetworkSyncData({playerNumber:s.multiplayer.getCurrentPlayerNumber(),isHost:s.multiplayer.isCurrentPlayerHost()});if(!t)return;const n=bt(t),r=!Mt()||n||F>0;if(n&&(F=3),!r)return;const a=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:o,messageData:l}=$e({gameNetworkSyncData:t});w(a,o,l),de=v(),J=t,F=Math.max(F-1,0)},It=e=>{const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(ve)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender();if(s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())e.getGame().updateFromNetworkSyncData(i);else{g.info("Saving game update message for later use."),B.store(i);return}if(s.multiplayer.isCurrentPlayerHost()){const f=s.multiplayerPeerJsHelper.getAllPeers().filter(u=>u!==d);w(f,a,i)}})})},Pt=e=>{B.getUpdates().forEach(t=>{g.info("Reapplying saved update of game."),e.getGame().updateFromNetworkSyncData(t)}),B.clear(),V.getUpdates().forEach(t=>{const n=t.id;if(n!==e.networkId){g.info(`Trying to apply saved update of scene ${n}, but we are on ${e.networkId}. Skipping.`);return}g.info(`Reapplying saved update of scene ${n}.`),e.updateFromNetworkSyncData(t),V.remove(t)})},oe="#heartbeat",Nt=/#heartbeat#(.+)/,ie=()=>{M[s.multiplayer.getCurrentPlayerNumber()]={ping:0,playerId:s.playerAuthentication.getUserId(),username:s.playerAuthentication.getUsername()};for(const e in M)M[e]={...M[e],ping:ce(parseInt(e,10))};return{messageName:`${oe}#${s.multiplayer.getCurrentPlayerNumber()}`,messageData:{now:v(),playersInfo:M}}},Ot=({heartbeatSentAt:e})=>({messageName:`${oe}#${s.multiplayer.getCurrentPlayerNumber()}`,messageData:{sentAt:e,playerId:s.playerAuthentication.getUserId(),username:s.playerAuthentication.getUsername()}}),St=()=>!!G&&v()-G<1e3/Ee,Dt=()=>{if(!s.multiplayer.isCurrentPlayerHost()||!!St())return;const t=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:n,messageData:r}=ie();w(t,n,r),G=v()},kt=()=>{const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(r=>r.startsWith(oe)).forEach(r=>{const a=e.get(r);if(!a)return;const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender(),d=Nt.exec(r);if(!d)return;const p=parseInt(d[1],10);if(pe[i]=p,!s.multiplayer.isCurrentPlayerHost()){const h=s.multiplayer.getCurrentPlayerNumber(),b=Object.keys(M).map(R=>parseInt(R,10)),N=Object.keys(c.playersInfo).map(R=>parseInt(R,10)),_=M[h]&&M[h].ping;if(b.length){const R=N.filter(L=>!b.includes(L)&&L!==h);$.push(...R);const z=b.filter(L=>!N.includes(L));A.push(...z);for(const L of z)K[L]=le(L)}Te({source:c.playersInfo,target:M});const{messageName:T,messageData:j}=Ot({heartbeatSentAt:c.now});w([i],T,j),M[h]!==void 0&&M[h].ping!==void 0&&(s.multiplayer.markConnectionAsConnected(),_===void 0&&$.push(h));return}M[p]||$.push(p);const f=v(),u=c.sentAt,m=Math.round(f-u),y=E[p]||[];y.push(m),y.length>5&&y.shift(),E[p]=y;let I=0;for(const h of y)I+=h;const P=Math.round(I/y.length/2);if(M[p]={ping:P,playerId:c.playerId,username:c.username},$.length){const h=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:b,messageData:N}=ie();w(h,b,N),G=v()}})})},vt=e=>(E[e]||[]).length>0,ce=e=>{const t=M[e];return t&&t.ping||0},$t=()=>{const e=s.multiplayer.getCurrentPlayerNumber();return ce(e)},Re=({runtimeScene:e,playerNumber:t,peerId:n})=>{if(k.info(`Marking player ${t} as disconnected.`),A.push(t),K[t]=le(t),Qt(t),n&&n===s.multiplayer.hostPeerId)if(s.multiplayer.shouldEndLobbyWhenHostLeaves())k.info("Host has disconnected, ending the game."),ge(),s.multiplayer.handleLobbyGameEnded();else{k.info("Host has disconnected, switching host."),s.multiplayer.handleHostDisconnected({runtimeScene:e});return}if(s.multiplayer.isCurrentPlayerHost()){const r=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:a,messageData:o}=ie();w(r,a,o),G=v()}},le=e=>(M[e]||{}).username||K[e]||`Player ${e}`,Rt=e=>(M[e]||{}).playerId||"",Ct=e=>{if(!s.multiplayer.isLobbyGameRunning())return;const t=[],n=s.multiplayerPeerJsHelper.getJustDisconnectedPeers();if(n.length)for(const r of n){const a=pe[r];if(!a)return;k.info(`Player ${a} has disconnected.`),t.push({playerNumber:a,peerId:r})}for(const{playerNumber:r,peerId:a}of t){if(s.multiplayer.isCurrentPlayerHost()){const o=e.getAdhocListOfAllInstances();for(const l of o){const c=l.getBehavior("MultiplayerObject");if(c&&c.getPlayerObjectOwnership()===r){const i=c.getActionOnPlayerDisconnect();i==="DestroyObject"?l.deleteFromScene(e):i==="GiveOwnershipToHost"&&c.removeObjectOwnership()}}}Re({runtimeScene:e,playerNumber:r,peerId:a})}},At=()=>A.length>0,jt=e=>A.includes(e),Tt=()=>A,Ht=()=>A[0]||0,Jt=()=>{const e=A[0];e!==void 0&&(A=A.slice(1),delete K[e])},_t=()=>$.length>0,Lt=e=>$.includes(e),xt=()=>$,Gt=()=>$[0]||0,Et=()=>{$[0]!==void 0&&($=$.slice(1))},Ut=()=>Object.keys(M).map(e=>({playerNumber:parseInt(e,10),playerId:M[e].playerId})),Wt=()=>Object.keys(M).length,Vt=e=>M[e]!==void 0,Ft=()=>M,Ce="#endGame",Bt=()=>({messageName:Ce,messageData:{}}),Kt=()=>{if(!s.multiplayer.isCurrentPlayerHost())return;g.info("Sending endgame message.");const e=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:t,messageData:n}=Bt();w(e,t,n)},Yt=()=>{if(s.multiplayer.isCurrentPlayerHost())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap().get(Ce);!t||!t.getMessages().length||(k.info("Received endgame message."),ge(),s.multiplayer.handleLobbyGameEnded())},Ae="#resumeGame",qt=()=>({messageName:Ae,messageData:{}}),Xt=()=>{if(!s.multiplayer.isCurrentPlayerHost())return;g.info("Sending resumeGame message.");const e=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:t,messageData:n}=qt();w(e,t,n)},zt=e=>{if(s.multiplayer.isCurrentPlayerHost())return;const n=s.multiplayerPeerJsHelper.getAllMessagesMap().get(Ae);!n||!n.getMessages().length||(k.info("Received resumeGame message."),s.multiplayer.resumeGame(e))},ge=()=>{E={},M={},B.clear(),V.clear(),U.clear(),A=[],$=[],O={},H={}},Qt=e=>{delete E[e],delete M[e]};return{sendDataTo:w,addExpectedMessageAcknowledgement:x,handleAcknowledgeMessagesReceived:et,resendClearOrCancelAcknowledgedMessages:tt,createChangeInstanceOwnerMessage:We,createInstanceOwnerChangedMessageNameFromChangeInstanceOwnerMessage:be,handleChangeInstanceOwnerMessagesReceived:Fe,createUpdateInstanceMessage:Ke,handleUpdateInstanceMessagesReceived:Ye,createDestroyInstanceMessage:nt,createInstanceDestroyedMessageNameFromDestroyInstanceMessage:Pe,handleDestroyInstanceMessagesReceived:rt,createChangeVariableOwnerMessage:qe,createVariableOwnerChangedMessageNameFromChangeVariableOwnerMessage:Ie,handleChangeVariableOwnerMessagesReceived:ze,sendCustomMessage:Oe,getCustomMessageData:Se,sendVariableCustomMessage:lt,getVariableCustomMessageData:ut,hasCustomMessageBeenReceived:gt,handleCustomMessagesReceived:dt,getCustomMessageSender:mt,createUpdateSceneMessage:ke,handleUpdateSceneMessagesToSend:yt,handleUpdateSceneMessagesReceived:ht,createUpdateGameMessage:$e,handleUpdateGameMessagesToSend:wt,handleUpdateGameMessagesReceived:It,handleSavedUpdateMessages:Pt,handleHeartbeatsToSend:Dt,handleHeartbeatsReceived:kt,hasReceivedHeartbeatFromPlayer:vt,getPlayerPing:ce,getCurrentPlayerPing:$t,getPlayerUsername:le,getPlayerId:Rt,handleJustDisconnectedPeers:Ct,getConnectedPlayers:Ut,getNumberOfConnectedPlayers:Wt,isPlayerConnected:Vt,getPlayersInfo:Ft,hasAnyPlayerJustLeft:At,hasPlayerJustLeft:jt,getPlayersWhoJustLeft:Tt,getLatestPlayerWhoJustLeft:Ht,removePlayerWhoJustLeft:Jt,markPlayerAsDisconnected:Re,hasAnyPlayerJustJoined:_t,hasPlayerJustJoined:Lt,getPlayersWhoJustJoined:xt,getLatestPlayerWhoJustJoined:Gt,removePlayerWhoJustJoined:Et,sendEndGameMessage:Kt,handleEndGameMessagesReceived:Yt,clearAllMessagesTempData:ge,sendResumeGameMessage:Xt,handleResumeGameMessagesReceived:zt}},s.multiplayerMessageManager=s.makeMultiplayerMessageManager()})(gdjs||(gdjs={}));
1
+ var gdjs;(function(s){const k=new s.Logger("Multiplayer"),g=new s.Logger("Multiplayer - Debug");s.Logger.getDefaultConsoleLoggerOutput().discardGroup("Multiplayer - Debug");class je{constructor(S){this.clear=()=>{this.cache.clear(),this.keys=[]};this.maxSize=S,this.cache=new Set,this.keys=[]}has(S){return this.cache.has(S)}add(S){if(this.cache.size>=this.maxSize){const D=this.keys.shift();D&&this.cache.delete(D)}this.cache.add(S),this.keys.push(S)}}class ue{constructor(){this._updates=[]}store(S){this._updates.push(S),this._updates.length>10&&this._updates.shift()}getUpdates(){return this._updates}remove(S){const D=this._updates.indexOf(S);D!==-1&&this._updates.splice(D,1)}clear(){this._updates=[]}}const Te=({target:C,source:S})=>{for(const D in S)S.hasOwnProperty(D)&&!C.hasOwnProperty(D)&&(C[D]=S[D]);for(const D in C)C.hasOwnProperty(D)&&!S.hasOwnProperty(D)&&delete C[D]};s.makeMultiplayerMessageManager=()=>{const C=0,S=0,D=0,Je=0,v=window.performance&&typeof window.performance.now=="function"?window.performance.now.bind(window.performance):Date.now,_e=200,Le=4,U=new je(500);let O={},H={};const xe=1;let me=0,Q=null,W=0,V=new ue;const Ge=1;let de=0,J=null,F=0,B=new ue;const Ee=1;let G=0,E={},pe={},M={},A=[],$=[],K={};const x=({originalMessageName:e,originalData:t,expectedMessageName:n,otherPeerIds:r,shouldCancelMessageIfTimesOut:a,maxNumberOfRetries:o,messageRetryTime:l})=>{!s.multiplayer.isLobbyGameRunning()||(O[n]||(O[n]={}),g.info(`Adding expected message ${n} from ${r.join(", ")}.`),r.forEach(c=>{O[n][c]={acknowledged:!1,lastMessageSentAt:v(),originalMessageName:e,originalData:t,shouldCancelMessageIfTimesOut:a,numberOfRetries:0,maxNumberOfRetries:o||Le,messageRetryTime:l||_e}}))},fe=({sceneNetworkId:e,instanceNetworkId:t})=>(H[e]||(H[e]={}),H[e][t]||0),ye=({sceneNetworkId:e,instanceNetworkId:t,clock:n})=>{H[e]||(H[e]={}),H[e][t]=n},w=(e,t,n)=>{if(!(S>0&&Math.random()<S)){if(D>0&&Math.random()<D){setTimeout(()=>{s.multiplayerPeerJsHelper.sendDataTo(e,t,n)},Je);return}if(C>0){setTimeout(()=>{s.multiplayerPeerJsHelper.sendDataTo(e,t,n)},C);return}s.multiplayerPeerJsHelper.sendDataTo(e,t,n)}},Ue=(e,t,n)=>{if(!e.length)return null;let r=null,a=1/0;for(let o=0;o<e.length;++o){if(e[o].networkId)continue;const l=e[o],c=Math.pow(l.getX()-t,2)+Math.pow(l.getY()-n,2);c<a&&(r=l,a=c)}return r},Z=({runtimeScene:e,objectName:t,instanceNetworkId:n,instanceX:r,instanceY:a,shouldCreateIfNotFound:o})=>{const l=e.getInstancesOf(t);if(!l)return null;let c=l.find(i=>i.networkId===n)||null;if(!c&&r!==void 0&&a!==void 0){g.info(`instance ${t} ${n} not found with network ID, trying to find it with position ${r}/${a}.`);const i=Ue(l,r,a);i&&(g.info(`Found closest instance for object ${t} ${n} with no network ID.`),c=i,c.networkId=n)}if(!c&&o){g.info(`Instance ${n} still not found, Creating instance ${t}.`);const i=e.createObject(t);if(!i)return null;i.networkId=n,c=i}return c},Y="#changeInstanceOwner",he=/#changeInstanceOwner#owner_(\d+)#object_(.+)#instance_(.+)/,We=({objectOwner:e,objectName:t,instanceNetworkId:n,newObjectOwner:r,instanceX:a,instanceY:o,sceneNetworkId:l})=>({messageName:`${Y}#owner_${e}#object_${t}#instance_${n}`,messageData:{previousOwner:e,newOwner:r,instanceX:a,instanceY:o,sceneNetworkId:l}}),ee="#instanceOwnerChanged",Ve=/#instanceOwnerChanged#owner_(\d+)#object_(.+)#instance_(.+)/,be=e=>e.replace(Y,ee),Fe=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(Y)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=he.exec(a);if(!p)return;const f=p[2],u=p[3],m=i.previousOwner,y=i.newOwner,I=i.sceneNetworkId;if(I!==e.networkId){g.info(`Object ${f} is in scene ${I}, but we are on ${e.networkId}. Skipping.`);return}const P=Z({runtimeScene:e,objectName:f,instanceNetworkId:u,instanceX:i.instanceX,instanceY:i.instanceY});if(!P){g.info(`Instance ${u} not found, it must have been destroyed.`);return}const h=P.getBehavior("MultiplayerObject");if(!h){g.info(`Object ${f} does not have the MultiplayerObjectBehavior, cannot change ownership.`);return}const b=h.getPlayerObjectOwnership(),N=b===m||b===y;if(s.multiplayer.isCurrentPlayerHost()&&!N){g.info(`Object ${f} with instance network ID ${u} does not have the expected owner. Wanted to change from ${m} to ${y}, but object has owner ${b}.`);return}g.info(`Changing ownership of object ${f} to ${y}.`),h.playerNumber=y;const _=be(a);if(g.info(`Sending acknowledgment of ownership change of object ${f} from ${m} to ${y} with instance network ID ${u} to ${d}.`),w([d],_,{}),s.multiplayer.isCurrentPlayerHost()){const j=s.multiplayerPeerJsHelper.getAllPeers().filter(R=>R!==d);if(!j.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:_,otherPeerIds:j,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying ownership change of object ${f} with instance network ID ${u} to ${j.join(", ")}.`),w(j,a,i)}})})},Me="#updateInstance",Be=/#updateInstance#owner_(\d+)#object_(.+)#instance_(.+)#scene_(.+)/,Ke=({objectOwner:e,objectName:t,instanceNetworkId:n,objectNetworkSyncData:r,sceneNetworkId:a})=>({messageName:`${Me}#owner_${e}#object_${t}#instance_${n}#scene_${a}`,messageData:r}),Ye=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(Me)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();if(!l.length)return;l.slice().reverse().forEach(i=>{const d=i.getData(),p=i.getSender(),f=Be.exec(a);if(!f)return;const u=parseInt(f[1],10);if(u===s.multiplayer.playerNumber)return;const m=f[2],y=f[3],I=f[4];if(I!==e.networkId){g.info(`Object ${m} is in scene ${I}, but we are on ${e.networkId}. Skipping.`);return}const P=d._clock,h=fe({sceneNetworkId:I,instanceNetworkId:y});if(P<=h)return;const b=Z({runtimeScene:e,objectName:m,instanceNetworkId:y,shouldCreateIfNotFound:!0,instanceX:d.x,instanceY:d.y});if(!b){k.error("Instance could not be found or created.");return}const N=b.getBehavior("MultiplayerObject");if(!N){k.error(`Object ${m} does not have the MultiplayerObjectBehavior, cannot update it.`);return}if(N.getPlayerObjectOwnership()===s.multiplayer.playerNumber){g.info(`Object ${m} with instance network ID ${y} is owned by us ${s.multiplayer.playerNumber}, ignoring update message from ${u}.`);return}if(N.getPlayerObjectOwnership()!==u&&(g.info(`Object ${m} with instance network ID ${y} is owned by ${N.getPlayerObjectOwnership()} on our game, changing ownership to ${u} as part of the update event.`),N.playerNumber=u),b.updateFromNetworkSyncData(d),ye({sceneNetworkId:I,instanceNetworkId:y,clock:P}),N._clock=P,s.multiplayer.isCurrentPlayerHost()){const T=s.multiplayerPeerJsHelper.getAllPeers().filter(j=>j!==p);if(!T.length)return;w(T,a,d)}})})},q="#changeVariableOwner",we=/#changeVariableOwner#owner_(\d+)#variable_(.+)/,qe=({variableOwner:e,variableNetworkId:t,newVariableOwner:n})=>({messageName:`${q}#owner_${e}#variable_${t}`,messageData:{previousOwner:e,newOwner:n}}),te="#variableOwnerChanged",Xe=/#variableOwnerChanged#owner_(\d+)#variable_(.+)/,Ie=e=>e.replace(q,te),ze=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(q)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=we.exec(a);if(!p)return;const f=p[2],u=i.previousOwner,m=i.newOwner,{type:y,name:I,containerId:P}=s.multiplayerVariablesManager.getVariableTypeAndNameFromNetworkId(f);if(y==="scene"&&P!==e.networkId){g.info(`Variable ${I} is in scene ${P}, but we are on ${e.networkId}. Skipping.`);return}const h=P==="game"?e.getGame().getVariables():e.getVariables();if(!h.has(I)){k.error(`Variable with ID ${f} not found whilst syncing. This should not happen.`);return}const b=h.get(I),N=b.getPlayerOwnership(),_=N===u||N===m;if(s.multiplayer.isCurrentPlayerHost()&&!_){g.info(`Variable with ID ${f} does not have the expected owner. Wanted to change from ${u} to ${m}, but variable has owner ${N}.`);return}g.info(`Changing ownership of variable ${I} to ${m}.`),b.setPlayerOwnership(m);const T=Ie(a);if(g.info(`Sending acknowledgment of ownership change of variable with ID ${f} from ${u} to ${m} to ${d}.`),w([d],T,{}),s.multiplayer.isCurrentPlayerHost()){const R=s.multiplayerPeerJsHelper.getAllPeers().filter(z=>z!==d);if(!R.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:T,otherPeerIds:R,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying ownership change of variable with Id ${f} to ${R.join(", ")}.`),w(R,a,i)}})})},Qe=e=>e.startsWith(ne)?at:e.startsWith(ee)?Ve:e.startsWith(te)?Xe:e.startsWith(re)?ct:null,Ze=e=>e.startsWith(ne)||e.startsWith(ee)||e.startsWith(te)||e.startsWith(re),et=()=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(Ze).forEach(r=>{const a=e.get(r);if(!a)return;const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender();g.info(`Received acknowledgment for message ${r}.`);const d=Qe(r);if(!d){k.error(`Invalid acknowledgment message ${r}.`);return}const p=d.exec(r);if(!p){k.error(`Invalid acknowledgment message ${r}.`);return}if(!O[r]||!O[r][i])return;const f=c._clock;if(f!==void 0){const u=p[3],m=p[4],y=fe({sceneNetworkId:m,instanceNetworkId:u});if(f<=y)return;ye({sceneNetworkId:m,instanceNetworkId:u,clock:f})}g.info(`Marking message ${r} as acknowledged from ${i}.`),O[r][i].acknowledged=!0})})},tt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;Object.keys(O).forEach(n=>{const r=O[n],a=Object.keys(r).filter(o=>!r[o].acknowledged);if(!a.length)g.info(`All peers have acknowledged message ${n}.`),delete O[n];else for(const o of a){const{lastMessageSentAt:l,originalMessageName:c,originalData:i,numberOfRetries:d,maxNumberOfRetries:p,messageRetryTime:f}=r[o];if(v()-l>f){if(d>=p){if(g.info(`Giving up on message ${n} for ${o}.`),r[o].shouldCancelMessageIfTimesOut){if(c.startsWith(Y)){const u=he.exec(c);if(!u){delete O[n];return}const m=u[2],y=u[3],I=e.getInstancesOf(m);if(!I){delete O[n];return}let P=I.find(N=>N.networkId===y);if(!P){delete O[n];return}const h=P.getBehavior("MultiplayerObject");if(!h){k.error(`Object ${m} does not have the MultiplayerObjectBehavior, cannot revert ownership.`),delete O[n];return}const b=i.previousOwner;if(b===void 0){delete O[n];return}h.playerNumber=b||0}if(c.startsWith(q)){const u=we.exec(c);if(!u){delete O[n];return}const m=u[2],y=i.previousOwner,{type:I,name:P,containerId:h}=s.multiplayerVariablesManager.getVariableTypeAndNameFromNetworkId(m);if(I==="scene"&&h!==e.networkId){g.info(`Variable ${P} is in scene ${h}, but we are on ${e.networkId}. Skipping ownership revert.`),delete O[n];return}const b=h==="game"?e.getGame().getVariables():e.getVariables();if(!b.has(P)){k.error(`Variable with ID ${m} not found while reverting ownership. This should not happen.`),delete O[n];return}const N=b.get(P);if(y===void 0){delete O[n];return}N.setPlayerOwnership(y||0)}}delete O[n];continue}w([o],c,i),r[o].lastMessageSentAt=v(),r[o].numberOfRetries=d+1}}})},se="#destroyInstance",st=/#destroyInstance#owner_(\d+)#object_(.+)#instance_(.+)#scene_(.+)/,nt=({objectOwner:e,objectName:t,instanceNetworkId:n,sceneNetworkId:r})=>({messageName:`${se}#owner_${e}#object_${t}#instance_${n}#scene_${r}`,messageData:{}}),ne="#instanceDestroyed",at=/#instanceDestroyed#owner_(\d+)#object_(.+)#instance_(.+)/,Pe=e=>e.replace(se,ne),rt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(se)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender();g.info(`Received message ${a} with data ${JSON.stringify(i)}.`);const p=st.exec(a);if(!p||parseInt(p[1],10)===s.multiplayer.playerNumber)return;const u=p[2],m=p[3],y=p[4];if(y!==e.networkId){g.info(`Object ${u} is in scene ${y}, but we are on ${e.networkId}. Skipping.`);return}const I=Z({runtimeScene:e,objectName:u,instanceNetworkId:m}),P=Pe(a);if(!I){g.info("Instance was not found in the scene, sending acknowledgment anyway."),w([d],P,{});return}if(g.info(`Destroying object ${u} with instance network ID ${m}.`),I.deleteFromScene(),g.info(`Sending acknowledgment of destruction of object ${u} with instance network ID ${m} to ${d}.`),w([d],P,{}),s.multiplayer.isCurrentPlayerHost()){const b=s.multiplayerPeerJsHelper.getAllPeers().filter(N=>N!==d);if(!b.length)return;x({originalMessageName:a,originalData:i,expectedMessageName:P,otherPeerIds:b,shouldCancelMessageIfTimesOut:!1}),g.info(`Relaying instance destroyed message for object ${u} with instance network ID ${m} to ${b.join(", ")}.`),w(b,a,i)}})})},ae="#customMessage",ot=/#customMessage#(.+)/,X=e=>`${ae}#${e}`,it=({userMessageName:e,userMessageData:t,senderPlayerNumber:n})=>{const r=s.makeUuid();return{messageName:X(e),messageData:{data:t,uniqueId:r,senderPlayerNumber:n}}},re="#ackCustomMessage",ct=/#ackCustomMessage#(.+)/,Ne=e=>e.replace(ae,re),Oe=(e,t)=>{const n=s.multiplayerPeerJsHelper.getAllPeers(),r=s.multiplayer.getCurrentPlayerNumber(),{messageName:a,messageData:o}=it({userMessageName:e,userMessageData:t,senderPlayerNumber:r}),l=Ne(a);x({originalMessageName:a,originalData:o,expectedMessageName:l,otherPeerIds:n,shouldCancelMessageIfTimesOut:!1}),g.info(`Sending custom message ${e} with data ${JSON.stringify(t)}.`),w(n,a,o),s.multiplayer.isCurrentPlayerHost()&&s.multiplayerPeerJsHelper.getOrCreateMessagesList(a).pushMessage(o,s.multiplayerPeerJsHelper.getCurrentId())},lt=(e,t)=>{const n=t.toJSObject();g.info(`Sending custom message ${e} with data ${JSON.stringify(n)}.`),Oe(e,n)},gt=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return;const a=r.getMessages();if(!a.length)return;g.info(`custom message ${e} has been received.`);let o=!1;return a.forEach(l=>{const i=l.getData().uniqueId,d=`${t}#${i}`;U.has(d)||(U.add(d),o=!0)}),o},Se=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return;const a=r.getMessages();return a.length?a[a.length-1].getData().data:void 0},ut=(e,t)=>{const n=Se(e);!n||(g.info(`Received custom message ${e} with data ${JSON.stringify(n)}.`),t.fromJSObject(n))},mt=e=>{const t=X(e),r=s.multiplayerPeerJsHelper.getAllMessagesMap().get(t);if(!r)return 0;const a=r.getMessages();return a.length?a[a.length-1].getData().senderPlayerNumber:0},dt=()=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(r=>r.startsWith(ae)).forEach(r=>{const a=e.get(r);if(!a){k.error(`No messages list found for ${r}.`);return}const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender(),d=c.uniqueId;if(g.info(`Received custom message ${r} with data ${JSON.stringify(c)}.`),!ot.exec(r)){k.error(`Invalid custom message ${r}.`);return}const f=`${r}#${d}`;if(U.has(f)){g.info(`Message ${r} has already been processed, skipping.`);return}const u=Ne(r);if(g.info(`Sending acknowledgment of custom message ${r} to ${i}.`),w([i],u,{}),s.multiplayer.isCurrentPlayerHost()){const m=s.multiplayerPeerJsHelper.getAllPeers();if(!m.length)return;x({originalMessageName:r,originalData:c,expectedMessageName:u,otherPeerIds:m,shouldCancelMessageIfTimesOut:!1}),w(m,r,c)}})})},De="#updateScene",ke=({sceneNetworkSyncData:e})=>({messageName:`${De}`,messageData:e}),pt=e=>e.var?Q?JSON.stringify(e.var)!==JSON.stringify(Q.var):!0:!1,ft=()=>v()-me<1e3/xe,yt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=e.getNetworkSyncData({playerNumber:s.multiplayer.getCurrentPlayerNumber(),isHost:s.multiplayer.isCurrentPlayerHost()});if(!t)return;const n=pt(t),r=!ft()||n||W>0;if(n&&(W=3),!r)return;const a=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:o,messageData:l}=ke({sceneNetworkSyncData:t});w(a,o,l),me=v(),Q=t,W=Math.max(W-1,0)},ht=e=>{const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(De)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender(),p=i.id;if(s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages()){if(p!==e.networkId){g.info(`Received update of scene ${p}, but we are on ${e.networkId}. Skipping.`);return}e.updateFromNetworkSyncData(i)}else{g.info(`Saving scene ${p} update message for later use.`),V.store(i);return}if(s.multiplayer.isCurrentPlayerHost()){const u=s.multiplayerPeerJsHelper.getAllPeers().filter(m=>m!==d);w(u,a,i)}})})},ve="#updateGame",$e=({gameNetworkSyncData:e})=>({messageName:`${ve}`,messageData:e}),bt=e=>{const t=e.var,n=e.ss;if(!t&&!n)return!1;if(!J||!J.var||!J.ss||t&&JSON.stringify(t)!==JSON.stringify(J.var))return!0;if(n){if(n.length!==J.ss.length)return!0;for(let r=0;r<n.length;++r){const a=n[r],o=J.ss[r];if(a.name!==o.name||a.networkId!==o.networkId)return!0}}return!1},Mt=()=>v()-de<1e3/Ge,wt=e=>{if(!s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())return;const t=e.getGame().getNetworkSyncData({playerNumber:s.multiplayer.getCurrentPlayerNumber(),isHost:s.multiplayer.isCurrentPlayerHost()});if(!t)return;const n=bt(t),r=!Mt()||n||F>0;if(n&&(F=3),!r)return;const a=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:o,messageData:l}=$e({gameNetworkSyncData:t});w(a,o,l),de=v(),J=t,F=Math.max(F-1,0)},It=e=>{const t=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(t.keys()).filter(a=>a.startsWith(ve)).forEach(a=>{const o=t.get(a);if(!o)return;const l=o.getMessages();!l.length||l.forEach(c=>{const i=c.getData(),d=c.getSender();if(s.multiplayer.isReadyToSendOrReceiveGameUpdateMessages())e.getGame().updateFromNetworkSyncData(i);else{g.info("Saving game update message for later use."),B.store(i);return}if(s.multiplayer.isCurrentPlayerHost()){const f=s.multiplayerPeerJsHelper.getAllPeers().filter(u=>u!==d);w(f,a,i)}})})},Pt=e=>{B.getUpdates().forEach(t=>{g.info("Reapplying saved update of game."),e.getGame().updateFromNetworkSyncData(t)}),B.clear(),V.getUpdates().forEach(t=>{const n=t.id;if(n!==e.networkId){g.info(`Trying to apply saved update of scene ${n}, but we are on ${e.networkId}. Skipping.`);return}g.info(`Reapplying saved update of scene ${n}.`),e.updateFromNetworkSyncData(t),V.remove(t)})},oe="#heartbeat",Nt=/#heartbeat#(.+)/,ie=()=>{M[s.multiplayer.getCurrentPlayerNumber()]={ping:0,playerId:s.playerAuthentication.getUserId(),username:s.playerAuthentication.getUsername()};for(const e in M)M[e]={...M[e],ping:ce(parseInt(e,10))};return{messageName:`${oe}#${s.multiplayer.getCurrentPlayerNumber()}`,messageData:{now:v(),playersInfo:M}}},Ot=({heartbeatSentAt:e})=>({messageName:`${oe}#${s.multiplayer.getCurrentPlayerNumber()}`,messageData:{sentAt:e,playerId:s.playerAuthentication.getUserId(),username:s.playerAuthentication.getUsername()}}),St=()=>!!G&&v()-G<1e3/Ee,Dt=()=>{if(!s.multiplayer.isCurrentPlayerHost()||!!St())return;const t=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:n,messageData:r}=ie();w(t,n,r),G=v()},kt=()=>{const e=s.multiplayerPeerJsHelper.getAllMessagesMap();Array.from(e.keys()).filter(r=>r.startsWith(oe)).forEach(r=>{const a=e.get(r);if(!a)return;const o=a.getMessages();!o.length||o.forEach(l=>{const c=l.getData(),i=l.getSender(),d=Nt.exec(r);if(!d)return;const p=parseInt(d[1],10);if(pe[i]=p,!s.multiplayer.isCurrentPlayerHost()){const h=s.multiplayer.getCurrentPlayerNumber(),b=Object.keys(M).map(R=>parseInt(R,10)),N=Object.keys(c.playersInfo).map(R=>parseInt(R,10)),_=M[h]&&M[h].ping;if(b.length){const R=N.filter(L=>!b.includes(L)&&L!==h);$.push(...R);const z=b.filter(L=>!N.includes(L));A.push(...z);for(const L of z)K[L]=le(L)}Te({source:c.playersInfo,target:M});const{messageName:T,messageData:j}=Ot({heartbeatSentAt:c.now});w([i],T,j),M[h]!==void 0&&M[h].ping!==void 0&&(s.multiplayer.markConnectionAsConnected(),_===void 0&&$.push(h));return}M[p]||$.push(p);const f=v(),u=c.sentAt,m=Math.round(f-u),y=E[p]||[];y.push(m),y.length>5&&y.shift(),E[p]=y;let I=0;for(const h of y)I+=h;const P=Math.round(I/y.length/2);if(M[p]={ping:P,playerId:c.playerId,username:c.username},$.length){const h=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:b,messageData:N}=ie();w(h,b,N),G=v()}})})},vt=e=>(E[e]||[]).length>0,ce=e=>{const t=M[e];return t&&t.ping||0},$t=()=>{const e=s.multiplayer.getCurrentPlayerNumber();return ce(e)},Re=({runtimeScene:e,playerNumber:t,peerId:n})=>{if(k.info(`Marking player ${t} as disconnected.`),A.push(t),K[t]=le(t),Qt(t),n&&n===s.multiplayer.hostPeerId)if(s.multiplayer.shouldEndLobbyWhenHostLeaves())k.info("Host has disconnected, ending the game."),ge(),s.multiplayer.handleLobbyGameEnded();else{k.info("Host has disconnected, switching host."),s.multiplayer.handleHostDisconnected({runtimeScene:e});return}if(s.multiplayer.isCurrentPlayerHost()){const r=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:a,messageData:o}=ie();w(r,a,o),G=v()}},le=e=>(M[e]||{}).username||K[e]||`Player ${e}`,Rt=e=>(M[e]||{}).playerId||"",Ct=e=>{if(!s.multiplayer.isLobbyGameRunning())return;const t=[],n=s.multiplayerPeerJsHelper.getJustDisconnectedPeers();if(n.length)for(const r of n){const a=pe[r];if(!a)return;k.info(`Player ${a} has disconnected.`),t.push({playerNumber:a,peerId:r})}for(const{playerNumber:r,peerId:a}of t){if(s.multiplayer.isCurrentPlayerHost()){const o=e.getAdhocListOfAllInstances();for(const l of o){const c=l.getBehavior("MultiplayerObject");if(c&&c.getPlayerObjectOwnership()===r){const i=c.getActionOnPlayerDisconnect();i==="DestroyObject"?l.deleteFromScene():i==="GiveOwnershipToHost"&&c.removeObjectOwnership()}}}Re({runtimeScene:e,playerNumber:r,peerId:a})}},At=()=>A.length>0,jt=e=>A.includes(e),Tt=()=>A,Ht=()=>A[0]||0,Jt=()=>{const e=A[0];e!==void 0&&(A=A.slice(1),delete K[e])},_t=()=>$.length>0,Lt=e=>$.includes(e),xt=()=>$,Gt=()=>$[0]||0,Et=()=>{$[0]!==void 0&&($=$.slice(1))},Ut=()=>Object.keys(M).map(e=>({playerNumber:parseInt(e,10),playerId:M[e].playerId})),Wt=()=>Object.keys(M).length,Vt=e=>M[e]!==void 0,Ft=()=>M,Ce="#endGame",Bt=()=>({messageName:Ce,messageData:{}}),Kt=()=>{if(!s.multiplayer.isCurrentPlayerHost())return;g.info("Sending endgame message.");const e=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:t,messageData:n}=Bt();w(e,t,n)},Yt=()=>{if(s.multiplayer.isCurrentPlayerHost())return;const t=s.multiplayerPeerJsHelper.getAllMessagesMap().get(Ce);!t||!t.getMessages().length||(k.info("Received endgame message."),ge(),s.multiplayer.handleLobbyGameEnded())},Ae="#resumeGame",qt=()=>({messageName:Ae,messageData:{}}),Xt=()=>{if(!s.multiplayer.isCurrentPlayerHost())return;g.info("Sending resumeGame message.");const e=s.multiplayerPeerJsHelper.getAllPeers(),{messageName:t,messageData:n}=qt();w(e,t,n)},zt=e=>{if(s.multiplayer.isCurrentPlayerHost())return;const n=s.multiplayerPeerJsHelper.getAllMessagesMap().get(Ae);!n||!n.getMessages().length||(k.info("Received resumeGame message."),s.multiplayer.resumeGame(e))},ge=()=>{E={},M={},B.clear(),V.clear(),U.clear(),A=[],$=[],O={},H={}},Qt=e=>{delete E[e],delete M[e]};return{sendDataTo:w,addExpectedMessageAcknowledgement:x,handleAcknowledgeMessagesReceived:et,resendClearOrCancelAcknowledgedMessages:tt,createChangeInstanceOwnerMessage:We,createInstanceOwnerChangedMessageNameFromChangeInstanceOwnerMessage:be,handleChangeInstanceOwnerMessagesReceived:Fe,createUpdateInstanceMessage:Ke,handleUpdateInstanceMessagesReceived:Ye,createDestroyInstanceMessage:nt,createInstanceDestroyedMessageNameFromDestroyInstanceMessage:Pe,handleDestroyInstanceMessagesReceived:rt,createChangeVariableOwnerMessage:qe,createVariableOwnerChangedMessageNameFromChangeVariableOwnerMessage:Ie,handleChangeVariableOwnerMessagesReceived:ze,sendCustomMessage:Oe,getCustomMessageData:Se,sendVariableCustomMessage:lt,getVariableCustomMessageData:ut,hasCustomMessageBeenReceived:gt,handleCustomMessagesReceived:dt,getCustomMessageSender:mt,createUpdateSceneMessage:ke,handleUpdateSceneMessagesToSend:yt,handleUpdateSceneMessagesReceived:ht,createUpdateGameMessage:$e,handleUpdateGameMessagesToSend:wt,handleUpdateGameMessagesReceived:It,handleSavedUpdateMessages:Pt,handleHeartbeatsToSend:Dt,handleHeartbeatsReceived:kt,hasReceivedHeartbeatFromPlayer:vt,getPlayerPing:ce,getCurrentPlayerPing:$t,getPlayerUsername:le,getPlayerId:Rt,handleJustDisconnectedPeers:Ct,getConnectedPlayers:Ut,getNumberOfConnectedPlayers:Wt,isPlayerConnected:Vt,getPlayersInfo:Ft,hasAnyPlayerJustLeft:At,hasPlayerJustLeft:jt,getPlayersWhoJustLeft:Tt,getLatestPlayerWhoJustLeft:Ht,removePlayerWhoJustLeft:Jt,markPlayerAsDisconnected:Re,hasAnyPlayerJustJoined:_t,hasPlayerJustJoined:Lt,getPlayersWhoJustJoined:xt,getLatestPlayerWhoJustJoined:Gt,removePlayerWhoJustJoined:Et,sendEndGameMessage:Kt,handleEndGameMessagesReceived:Yt,clearAllMessagesTempData:ge,sendResumeGameMessage:Xt,handleResumeGameMessagesReceived:zt}},s.multiplayerMessageManager=s.makeMultiplayerMessageManager()})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=messageManager.js.map