var gdjs;(function(s){class n{constructor(e){this._obstaclesRBush=new rbush}static getManager(e){return e.pathfindingObstaclesManager||(e.pathfindingObstaclesManager=new s.PathfindingObstaclesManager(e)),e.pathfindingObstaclesManager}addObstacle(e){e.currentRBushAABB?e.currentRBushAABB.updateAABBFromOwner():e.currentRBushAABB=new s.BehaviorRBushAABB(e),this._obstaclesRBush.insert(e.currentRBushAABB)}removeObstacle(e){this._obstaclesRBush.remove(e.currentRBushAABB)}getAllObstaclesAround(e,t,a,r){const i=s.staticObject(n.prototype.getAllObstaclesAround);i.minX=e-a,i.minY=t-a,i.maxX=e+a,i.maxY=t+a;const h=this._obstaclesRBush.search(i);r.length=0,h.forEach(o=>r.push(o.behavior))}}s.PathfindingObstaclesManager=n;class g extends s.RuntimeBehavior{constructor(e,t,a){super(e,t,a);this._oldX=0;this._oldY=0;this._oldWidth=0;this._oldHeight=0;this._registeredInManager=!1;this.currentRBushAABB=null;this._impassable=t.impassable,this._cost=t.cost,this._manager=n.getManager(e)}updateFromBehaviorData(e,t){return e.impassable!==t.impassable&&this.setImpassable(t.impassable),e.cost!==t.cost&&this.setCost(t.cost),!0}onDestroy(){this._manager&&this._registeredInManager&&this._manager.removeObstacle(this)}doStepPreEvents(e){!this.activated()&&this._registeredInManager?(this._manager.removeObstacle(this),this._registeredInManager=!1):this.activated()&&!this._registeredInManager&&(this._manager.addObstacle(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._registeredInManager&&(this._manager.removeObstacle(this),this._manager.addObstacle(this)),this._oldX=this.owner.getX(),this._oldY=this.owner.getY(),this._oldWidth=this.owner.getWidth(),this._oldHeight=this.owner.getHeight())}doStepPostEvents(e){}getAABB(){return this.owner.getAABB()}onActivate(){this._registeredInManager||(this._manager.addObstacle(this),this._registeredInManager=!0)}onDeActivate(){!this._registeredInManager||(this._manager.removeObstacle(this),this._registeredInManager=!1)}getCost(){return this._cost}setCost(e){this._cost=e}isImpassable(){return this._impassable}setImpassable(e){this._impassable=e}}s.PathfindingObstacleRuntimeBehavior=g,s.registerBehavior("PathfindingBehavior::PathfindingObstacleBehavior",s.PathfindingObstacleRuntimeBehavior)})(gdjs||(gdjs={}));
//# sourceMappingURL=pathfindingobstacleruntimebehavior.js.map
