var gdjs;(function(r){class a{constructor(){this._elapsedTime=0;this._timeScale=1;this._timeFromStart=0;this._firstFrame=!0;this._timers=new Hashtable;this._firstUpdateDone=!1;this.reset()}reset(){this._elapsedTime=0,this._timeScale=1,this._timeFromStart=0,this._firstFrame=!0,this._timers=new Hashtable}update(e,i){this._firstUpdateDone&&(this._firstFrame=!1),this._firstUpdateDone=!0,this._elapsedTime=Math.min(e,1e3/i),this._elapsedTime*=this._timeScale;for(const t in this._timers.items)this._timers.items.hasOwnProperty(t)&&this._timers.items[t].updateTime(this._elapsedTime);this._timeFromStart+=this._elapsedTime}setTimeScale(e){e>=0&&(this._timeScale=e)}getNetworkSyncData(){const e=new Hashtable;return Object.entries(this._timers.items).forEach(([i,t])=>{e.put(i,t.getNetworkSyncData())}),{elapsedTime:this._elapsedTime,timeScale:this._timeScale,timeFromStart:this._timeFromStart,firstFrame:this._firstFrame,timers:e,firstUpdateDone:this._firstUpdateDone}}updateFromNetworkSyncData(e){e.elapsedTime!==void 0&&(this._elapsedTime=e.elapsedTime),e.timeScale!==void 0&&(this._timeScale=e.timeScale),e.timeFromStart!==void 0&&(this._timeFromStart=e.timeFromStart),e.firstFrame!==void 0&&(this._firstFrame=e.firstFrame),e.timers!==void 0&&(this._timers.clear(),Object.entries(e.timers.items).forEach(([i,t])=>{const s=new r.Timer(t.name);s.updateFromNetworkSyncData(t),this._timers.put(i,s)})),e.firstUpdateDone!==void 0&&(this._firstUpdateDone=e.firstUpdateDone)}getTimeScale(){return this._timeScale}getTimeFromStart(){return this._timeFromStart}isFirstFrame(){return this._firstFrame}getElapsedTime(){return this._elapsedTime}addTimer(e){this._timers.put(e,new r.Timer(e))}hasTimer(e){return this._timers.containsKey(e)}getTimer(e){return this._timers.get(e)}removeTimer(e){this._timers.containsKey(e)&&this._timers.remove(e)}}r.TimeManager=a})(gdjs||(gdjs={}));
//# sourceMappingURL=timemanager.js.map
