okgame / CustomRuntimeObjectInstanceContainer.js
zshashz's picture
init
8998596
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?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={}));
//# sourceMappingURL=CustomRuntimeObjectInstanceContainer.js.map