var gdjs;(function(s){class l extends s.RuntimeInstanceContainer{constructor(e,t){super(e.getGame());this._isLoaded=!1;this._initialInnerArea=null;this._parent=e,this._customObject=t,this._runtimeScene=e.getScene(),this._debuggerRenderer=new s.DebuggerRenderer(this)}addLayer(e){if(this._layers.containsKey(e.name))return;const t=new s.RuntimeCustomObjectLayer(e,this);this._layers.put(e.name,t),this._orderedLayers.push(t)}_unloadContent(){this.onDeletedFromScene(this._parent),this._layers.clear(),this._orderedLayers.length=0}createObject(e,t){const r=super.createObject(e,t);return this._customObject.onChildrenLocationChanged(),r}loadFrom(e,t){this._setOriginalInnerArea(t);for(let r=0,n=t.objects.length;r<n;++r){const i=t.objects[r];e.childrenContent&&s.CustomRuntimeObjectInstanceContainer.hasChildrenConfigurationOverriding(e,t)?this.registerObject({...i,...e.childrenContent[i.name]}):this.registerObject(i)}if(t.layers.length>0)for(let r=0,n=t.layers.length;r<n;++r)this.addLayer(t.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(t.instances,0,0,0,!0),this._setLayerDefaultZOrders(),this._isLoaded=!0}static hasChildrenConfigurationOverriding(e,t){const r=!t.name&&t.instances.length==0;return e.childrenContent?!t.name||r:!1}_setOriginalInnerArea(e){(e.instances.length>0||this.getGame().isInGameEdition())&&(e._initialInnerArea||(e._initialInnerArea={min:[e.areaMinX,e.areaMinY,e.areaMinZ],max:[e.areaMaxX,e.areaMaxY,e.areaMaxZ]}),this._initialInnerArea=e._initialInnerArea)}onDeletedFromScene(e){if(!this._isLoaded)return;const t=this.getAdhocListOfAllInstances();for(let r=0,n=t.length;r<n;++r)t[r].onDeletedFromScene();this._isLoaded=!1}_destroy(){const e=this.getAdhocListOfAllInstances();for(let t=0,r=e.length;t<r;++t)e[t].onDestroyed();super._destroy(),this._onceTriggers=null}_updateObjectsPreRender(){const e=this.getAdhocListOfAllInstances();for(let t=0,r=e.length;t<r;++t){const n=e[t],i=n.getRendererObject();i&&(i.visible=!n.isHidden(),i.visible&&this.getGame().getEffectsManager().updatePreRender(n.getRendererEffects(),n)),this._debugDrawEnabled&&this._debuggerRenderer.renderDebugDraw(e,this._debugDrawShowHiddenInstances,this._debugDrawShowPointsNames,this._debugDrawShowCustomPoints),n.updatePreRender(this)}}_updateObjectsPreEvents(){const e=this.getAdhocListOfAllInstances();for(let t=0,r=e.length;t<r;++t){const n=e[t],i=n.getElapsedTime();if(n.hasNoForces())n.update(this);else{const a=n.getAverageForce(),o=i/1e3;n.setX(n.getX()+a.getX()*o),n.setY(n.getY()+a.getY()*o),n.update(this),n.updateForces(o)}n.updateTimers(i),n.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}_getInitialInnerAreaDepth(){return this._initialInnerArea?this._initialInnerArea.max[2]-this._initialInnerArea.min[2]: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(e,t,r){let n=r||[0,0];return n=this._parent.getLayer(this._customObject.getLayer()).convertCoords(e,t,0,n),this._customObject.applyObjectInverseTransformation(n[0],n[1],n),n}convertInverseCoords(e,t,r){const n=r||[0,0];return this._customObject.applyObjectTransformation(e,t,n),this._parent.getLayer(this._customObject.getLayer()).convertInverseCoords(n[0],n[1],0,n)}getElapsedTime(){return this._customObject.getElapsedTime()}}s.CustomRuntimeObjectInstanceContainer=l})(gdjs||(gdjs={}));
//# sourceMappingURL=CustomRuntimeObjectInstanceContainer.js.map
