var gdjs;(function(s){class l{constructor(e){this._platformRBush=new rbush}static getManager(e){return e.platformsObjectsManager||(e.platformsObjectsManager=new s.PlatformObjectsManager(e)),e.platformsObjectsManager}addPlatform(e){e.currentRBushAABB?e.currentRBushAABB.updateAABBFromOwner():e.currentRBushAABB=new s.BehaviorRBushAABB(e),this._platformRBush.insert(e.currentRBushAABB)}removePlatform(e){this._platformRBush.remove(e.currentRBushAABB)}getAllPlatformsAround(e,t,n){const o=e.getWidth(),g=e.getHeight(),f=e.getDrawableX()+e.getCenterX(),m=e.getDrawableY()+e.getCenterY(),a=s.staticObject(l.prototype.getAllPlatformsAround);a.minX=f-o/2-t,a.minY=m-g/2-t,a.maxX=f+o/2+t,a.maxY=m+g/2+t;const c=this._platformRBush.search(a);n.length=0;for(let d=0;d<c.length;d++){const u=c[d].behavior,h=u.owner.getAABB();h.min[0]<=a.maxX&&h.min[1]<=a.maxY&&h.max[0]>=a.minX&&h.max[1]>=a.minY&&n.push(u)}}}s.PlatformObjectsManager=l;const r=class extends s.RuntimeBehavior{constructor(e,t,n){super(e,t,n);this._oldX=0;this._oldY=0;this._oldWidth=0;this._oldHeight=0;this._oldAngle=0;this.currentRBushAABB=null;this._registeredInManager=!1;this._platformType=t.platformType,t.platformType==="Ladder"?this._platformType=r.LADDER:t.platformType==="Jumpthru"?this._platformType=r.JUMPTHRU:this._platformType=r.NORMALPLATFORM,this._canBeGrabbed=t.canBeGrabbed||!1,this._yGrabOffset=t.yGrabOffset||0,this._manager=l.getManager(e)}applyBehaviorOverriding(e){return e.platformType!==void 0&&this.changePlatformType(e.platformType),e.canBeGrabbed!==void 0&&(this._canBeGrabbed=e.canBeGrabbed),e.yGrabOffset!==void 0&&(this._yGrabOffset=e.yGrabOffset),!0}trackChangesAndUpdateManagerIfNeeded(){!this.activated()&&this._registeredInManager?(this._manager.removePlatform(this),this._registeredInManager=!1):this.activated()&&!this._registeredInManager&&(this._manager.addPlatform(this),this._registeredInManager=!0),(this._oldX!==this.owner.getX()||this._oldY!==this.owner.getY()||this._oldWidth!==this.owner.getWidth()||this._oldHeight!==this.owner.getHeight()||this._oldAngle!==this.owner.getAngle())&&(this._registeredInManager&&(this._manager.removePlatform(this),this._manager.addPlatform(this)),this._oldX=this.owner.getX(),this._oldY=this.owner.getY(),this._oldWidth=this.owner.getWidth(),this._oldHeight=this.owner.getHeight(),this._oldAngle=this.owner.getAngle())}getNetworkSyncData(e){return super.getNetworkSyncData(e)}updateFromNetworkSyncData(e,t){super.updateFromNetworkSyncData(e,t),this.trackChangesAndUpdateManagerIfNeeded()}onCreated(){this.trackChangesAndUpdateManagerIfNeeded()}onDestroy(){this._manager&&this._registeredInManager&&this._manager.removePlatform(this)}doStepPreEvents(e){this.trackChangesAndUpdateManagerIfNeeded()}doStepPostEvents(e){}onActivate(){this._registeredInManager||(this._manager.addPlatform(this),this._registeredInManager=!0)}onDeActivate(){!this._registeredInManager||(this._manager.removePlatform(this),this._registeredInManager=!1)}changePlatformType(e){e==="Ladder"?this._platformType=r.LADDER:e==="Jumpthru"?this._platformType=r.JUMPTHRU:this._platformType=r.NORMALPLATFORM}getPlatformType(){return this._platformType}canBeGrabbed(){return this._canBeGrabbed}getYGrabOffset(){return this._yGrabOffset}static isOnPlatformTest(e,t,n){const o=e.getBehavior(n);return o?o.isOnFloorObject(t):!1}};let i=r;i.NORMALPLATFORM=0,i.NORMALPLAFTORM=r.NORMALPLATFORM,i.JUMPTHRU=1,i.LADDER=2,s.PlatformRuntimeBehavior=i,s.registerBehavior("PlatformBehavior::PlatformBehavior",s.PlatformRuntimeBehavior)})(gdjs||(gdjs={}));
//# sourceMappingURL=platformruntimebehavior.js.map
