private IEnumerator SaveMap(string filename) { WorldSerialization blob = new WorldSerialization(); ActionProgressBar.UpdateProgress("Saving Terrain", 0f); yield return(null); yield return(null); terrainManager.Save(ref blob); ActionProgressBar.UpdateProgress("Saving Prefabs", 0.33f); yield return(null); yield return(null); prefabManager.Save(ref blob); ActionProgressBar.UpdateProgress("Saving Paths", 0.66f); yield return(null); yield return(null); pathManager.Save(ref blob); ActionProgressBar.UpdateProgress("Saving File", 0.95f); yield return(null); yield return(null); blob.Save(filename); ActionProgressBar.Close(); }
public IEnumerator Initialize(string assetPath) { ActionProgressBar.UpdateProgress("Loading Asset Bundles...", 0f); yield return(null); if (!string.IsNullOrEmpty(assetPath)) { Debug.Log("Loading Bundles..."); FileSystem.Backend = new AssetBundleBackend(assetPath); if (!FileSystem.Backend.isError) { bundlePath = assetPath; GameManifest.Load(); } else { Debug.Log("Error Loading Bundles: " + FileSystem.Backend.loadingError); } } terrainManager = gameObject.GetOrAddComponent <TerrainManager>(); prefabManager = gameObject.GetOrAddComponent <PrefabManager>(); pathManager = gameObject.GetOrAddComponent <PathManager>(); ActionProgressBar.Close(); Debug.Log("Ready!"); }
public IEnumerator Load(World.Data world) { ActionProgressBar.UpdateProgress("Loading Map Prefabs", 0f); yield return(null); yield return(null); Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < world.prefabData.Count; i++) { if (sw.Elapsed.TotalSeconds > 1f || i == 0 || i == world.prefabData.Count - 1) { ActionProgressBar.UpdateProgress("Loading Map Prefabs", (float)world.prefabData.Count / (float)i); yield return(null); yield return(null); sw.Reset(); } ProtoBuf.PrefabData prefabData = world.prefabData[i]; CreatePrefab(StringPool.Get(prefabData.id), prefabData.category, prefabData.position, prefabData.rotation, prefabData.scale); } sw.Stop(); }
protected void Grow(MethodInvoker afterwards) { Program.AssertOnEventThread(); if (shrunk) { shrunk = false; //First, clear all the anchors. Unanchor(); //Next, grow the window BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(delegate(object o, DoWorkEventArgs e) { int expectedHeight = ClientSize.Height + dx; while (ClientSize.Height < expectedHeight) { Program.Invoke(this, delegate() { ClientSize = new Size(ClientSize.Width, (int)(((2.0 * ClientSize.Height) / 3.0) + (expectedHeight / 3.0) + 1.0)); }); Thread.Sleep(50); } }); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(delegate(object o, RunWorkerCompletedEventArgs e) { Program.Invoke(this, delegate() { MinimumSize = new Size(MinimumSize.Width, MinimumSize.Height + dx); //and put the anchors back Reanchor(); //Finnally, show the progress bar and label ClearAction(); ActionStatusLabel.Show(); ActionProgressBar.Show(); ProgressSeparator.Show(); afterwards(); }); }); worker.RunWorkerAsync(); } else { afterwards(); } }
private void OnPreprocessAsset() { Selection.objects = new Object[0]; WriteTextureMaps(); WritePathData(); UnloadAssetBundles(); ActionProgressBar.Close(); }
private static void OnScriptsReloaded() { if (WorldManager.Instance == null) { WorldManager.Instance = GameObject.FindObjectOfType <WorldManager>(); } if (WorldManager.Instance != null && !string.IsNullOrEmpty(PlayerPrefs.GetString("RustInstallPath"))) { WorldManager.Instance.ValidateFileSystem(); } ActionProgressBar.Close(); }
public IEnumerator CreateNew(int size, int splat, int biome) { yield return(EditorCoroutineUtility.StartCoroutine(Cleanup(), this)); ActionProgressBar.UpdateProgress("Creating New World Data...", 0f); yield return(null); yield return(null); world = World.NewDataFromSize(size, splat, biome); EditorCoroutineUtility.StartCoroutine(LoadMap(world), this); ActionProgressBar.Close(); Debug.Log("World Loaded!"); }
private IEnumerator LoadMap(string filename) { yield return(EditorCoroutineUtility.StartCoroutine(Cleanup(), this)); WorldSerialization blob = new WorldSerialization(); ActionProgressBar.UpdateProgress("Loading Map...", 0f); yield return(null); yield return(null); blob.Load(filename); world = World.WorldToTerrain(blob); yield return(EditorCoroutineUtility.StartCoroutine(LoadMap(world), this)); ActionProgressBar.Close(); Debug.Log("World Loaded!"); }
public IEnumerator Cleanup() { ActionProgressBar.UpdateProgress("Cleaning Map Contents", 0f); yield return(null); yield return(null); if (terrainManager) { ActionProgressBar.UpdateProgress("Destroying Terrain", 0f); yield return(null); yield return(null); terrainManager.Cleanup(); } if (prefabManager) { ActionProgressBar.UpdateProgress("Destroying Prefabs", 0.33f); yield return(null); yield return(null); prefabManager.Cleanup(); } if (pathManager) { ActionProgressBar.UpdateProgress("Destroying Paths", 0.66f); yield return(null); yield return(null); pathManager.Cleanup(); } ActionProgressBar.Close(); }
public IEnumerator Load(World.Data world) { ActionProgressBar.UpdateProgress("Loading Map Prefabs", 0f); yield return(null); yield return(null); Stopwatch sw = Stopwatch.StartNew(); if (Parent == null) { FindOrCreateParent(); } for (int i = 0; i < world.pathData.Count; i++) { if (sw.Elapsed.TotalSeconds > 1f || i == 0 || i == world.pathData.Count - 1) { ActionProgressBar.UpdateProgress("Loading Map Paths", (float)world.pathData.Count / (float)i); yield return(null); yield return(null); sw.Reset(); } ProtoBuf.PathData serializedData = world.pathData[i]; PathData pathData = new GameObject(serializedData.name).AddComponent <PathData>(); pathData.transform.SetParent(Parent); pathData.Set(serializedData); } sw.Stop(); }
public IEnumerator Load(World.Data world) { ActionProgressBar.UpdateProgress("Loading Terrain", 0f); yield return(null); yield return(null); Splat = new SplatMap(world.splatMap); Alpha = new AlphaMap(world.alphaMap); Biome = new BiomeMap(world.biomeMap); Topology = new TopologyMap(world.topologyMap); Water = new WaterMap(world.waterMap); TerrainData terrainData = new TerrainData(); terrainData.alphamapResolution = Mathf.Clamp(Mathf.NextPowerOfTwo((int)(world.size.x * 0.50f)), 16, 2048); terrainData.baseMapResolution = Mathf.NextPowerOfTwo((int)((float)(world.size.x) * 0.01f)); terrainData.heightmapResolution = Mathf.NextPowerOfTwo((int)((float)(world.size.x) * 0.5f)) + 1; terrainData.size = world.size; terrainData.SetHeights(0, 0, world.landHeightMap); Terrain = Terrain.CreateTerrainGameObject(terrainData).GetComponent <Terrain>(); Terrain.name = Terrain.tag = "Terrain"; Terrain.gameObject.layer = 8; Terrain.transform.position = -0.5f * terrainData.size; Terrain.gameObject.AddComponent <PositionLock>(); SetSplatMaps(PaintType.Splat); CreateWaterPlane(world.size.x); }
protected void Shrink() { Program.AssertOnEventThread(); if (!shrunk) { shrunk = true; //First, clear all the anchors. Unanchor(); //Next, hide the progress bar and label ClearAction(); ActionStatusLabel.Hide(); ActionProgressBar.Hide(); ProgressSeparator.Hide(); //Finnally, shrink the window and put the anchors back MinimumSize = new Size(MinimumSize.Width, MinimumSize.Height - dx); ClientSize = new Size(ClientSize.Width, ClientSize.Height - dx); Reanchor(); } }
public void Save(ref WorldSerialization blob) { ActionProgressBar.UpdateProgress("Saving Prefabs", 0f); List <ProtoBuf.PrefabData> prefabList = new List <ProtoBuf.PrefabData>(); PrefabData[] prefabData = UnityEngine.Object.FindObjectsOfType <PrefabData>(); if (prefabData?.Length > 0) { for (int i = 0; i < prefabData.Length; i++) { PrefabData data = prefabData[i]; if (prefabData == null || data.gameObject == null) { continue; } prefabList.Add(data.GetPrefabData()); } } blob.world.prefabs = prefabList; }