Files
GdevelopMMOTestv1/Export/pixi-renderers/DebuggerPixiRenderer.js
T

3 lines
3.5 KiB
JavaScript

var gdjs;(function(b){class y{constructor(d){this._debugDraw=null;this._debugDrawContainer=null;this._instanceContainer=d,this._debugDrawRenderedObjectsPoints={},this._debugDraw=null}getRendererObject(){return this._debugDrawContainer}renderDebugDraw(d,w,_,R){const D=this._instanceContainer.getRenderer().getRendererObject();(!this._debugDraw||!this._debugDrawContainer)&&(this._debugDrawContainer=new PIXI.Container,this._debugDraw=new PIXI.Graphics,this._debugDrawContainer.addChild(this._debugDraw),D&&D.addChild(this._debugDrawContainer));const n=this._debugDraw;for(let r in this._debugDrawRenderedObjectsPoints)this._debugDrawRenderedObjectsPoints[r].wasRendered=!1;const u=(r,e,t,l,i)=>{n.line.color=t,n.fill.color=t,n.drawCircle(l,i,3),_&&(r[e]||(r[e]=new PIXI.Text(e,{fill:t,fontSize:12}),this._debugDrawContainer.addChild(r[e])),r[e].position.set(l,i))};n.clear(),n.beginFill(),n.alpha=.8,n.lineStyle(2,255,1);const c=[0,0];for(let r=0;r<d.length;r++){const e=d[r],t=this._instanceContainer.getLayer(e.getLayer());if((!e.isVisible()||!t.isVisible())&&!w||!e.getRendererObject())continue;const i=e.getAABB();n.fill.alpha=.2,n.line.color=7835368,n.fill.color=7835368;const a=[];a.push.apply(a,t.applyLayerTransformation(i.min[0],i.min[1],0,c)),a.push.apply(a,t.applyLayerTransformation(i.max[0],i.min[1],0,c)),a.push.apply(a,t.applyLayerTransformation(i.max[0],i.max[1],0,c)),a.push.apply(a,t.applyLayerTransformation(i.min[0],i.max[1],0,c)),n.drawPolygon(a)}for(let r=0;r<d.length;r++){const e=d[r],t=this._instanceContainer.getLayer(e.getLayer());if((!e.isVisible()||!t.isVisible())&&!w||!e.getRendererObject())continue;const i=e.id;this._debugDrawRenderedObjectsPoints[i]||(this._debugDrawRenderedObjectsPoints[i]={wasRendered:!0,points:{}});const a=this._debugDrawRenderedObjectsPoints[i];a.wasRendered=!0;const m=t.getCameraX(),C=t.getCameraY();let f=t.getCameraWidth()/2,h=t.getCameraHeight()/2;if(t.getCameraRotation()!==0){const o=f+h;f=o,h=o}for(const o of e.getHitBoxesAround(m-f,C-h,m+f,C+h)){const g=[];o.vertices.forEach(s=>{s=t.applyLayerTransformation(s[0],s[1],0,c),g.push(s[0]),g.push(s[1])}),n.fill.alpha=0,n.line.alpha=.5,n.line.color=16711680,n.drawPolygon(g)}n.fill.alpha=.3;const P=t.applyLayerTransformation(e.getCenterXInScene(),e.getCenterYInScene(),0,c);u(a.points,"Center",16776960,P[0],P[1]);const p=t.applyLayerTransformation(e.getX(),e.getY(),0,c);if(u(a.points,"Position",16711680,p[0],p[1]),e instanceof b.SpriteRuntimeObject){let o=e.getPointPosition("origin");(Math.abs(o[0]-p[0])>=1||Math.abs(o[1]-p[1])>=1)&&(o=t.applyLayerTransformation(o[0],o[1],0,c),u(a.points,"Origin",16711680,o[0],o[1]))}if(R&&e instanceof b.SpriteRuntimeObject){const o=e._animator.getCurrentFrame();if(!o)continue;for(const g in o.points.items){let s=e.getPointPosition(g);s=t.applyLayerTransformation(s[0],s[1],0,c),u(a.points,g,255,s[0],s[1])}}}for(const r in this._debugDrawRenderedObjectsPoints){const e=this._debugDrawRenderedObjectsPoints[r];if(e.wasRendered)continue;const t=e.points;for(const l in t)this._debugDrawContainer.removeChild(t[l])}n.endFill()}clearDebugDraw(){if(this._debugDraw&&this._debugDraw.clear(),this._debugDrawContainer){this._debugDrawContainer.destroy({children:!0});const d=this._instanceContainer.getRenderer().getRendererObject();d&&d.removeChild(this._debugDrawContainer)}this._debugDraw=null,this._debugDrawContainer=null,this._debugDrawRenderedObjectsPoints={}}}b.DebuggerPixiRenderer=y,b.DebuggerRenderer=b.DebuggerPixiRenderer})(gdjs||(gdjs={}));
//# sourceMappingURL=DebuggerPixiRenderer.js.map