void Update() { if (RootDivision == null && Loader.HasLoaded) { RootDivision = Division.Create(transform); RootDivision.SetBounds( new Vector2(-3000f, -3000f), new Vector2(+3000f, +3000f)); using (Utilities.Profiler.Start("Cell partitioning time")) { var placements = Item.GetPlacements <Instance> (CellIds.ToArray()); var insts = placements.ToDictionary(x => x, x => StaticGeometry.Create()); UnityEngine.Debug.Log("Num static geometries " + placements.Count() + "."); totalNumObjects = placements.Count(); foreach (var inst in insts) { inst.Value.Initialize(inst.Key, insts); } // if (NetConfig.IsServer) { if (this.loadParkedVehicles) { var parkedVehicles = Item.GetPlacements <ParkedVehicle> (CellIds.ToArray()); var cars = parkedVehicles.Select(x => VehicleSpawner.Create(x)) .Cast <MapObject>() .ToArray(); UnityEngine.Debug.Log("Num parked vehicles " + parkedVehicles.Count() + "."); RootDivision.AddRange(insts.Values.Cast <MapObject>().Concat(cars)); } else { RootDivision.AddRange(insts.Values.Cast <MapObject>()); } } if (Water != null) { using (Utilities.Profiler.Start("Water load time")) { Water.Initialize(new WaterFile(Config.GetPath("water_path"))); } } _timer = new Stopwatch(); _leaves = RootDivision.ToList(); } if (null == _leaves) { return; } _timer.Reset(); _timer.Start(); numLeavesLoadedThisFrame = 0; numObjectsLoadedThisFrame = 0; foreach (var div in _leaves) { if (float.IsPositiveInfinity(div.LoadOrder)) { break; } numObjectsLoadedThisFrame += div.LoadWhile(() => _timer.Elapsed.TotalSeconds < 1d / 60d); if (_timer.Elapsed.TotalSeconds >= 1d / 60d) { // break; } else { numLeavesLoadedThisFrame++; } } measuredTimes [2] = (float)_timer.Elapsed.TotalMilliseconds; }