public bool TryGetStoredDataForChunk(Vector3Int chunkID, out IChunkData storedData)
        {
            if (SaveUtils.DoSave)
            {
                Profiler.BeginSample("LoadingSavedChunkData");
                if (serialiser.TryLoad(chunkID.ToString(), out var data))
                {
                    storedData = InitialiseChunkDataFromSaved((ChunkSaveData)data, chunkID);
                    storedData.FullyGenerated = false;//This prevents saving it again if nothing changes.
                    return(true);
                }
                Profiler.EndSample();
            }
            else
            {
                if (ModifiedChunkData.TryGetValue(chunkID, out var data))
                {
                    storedData = data;
                    return(true);
                }
            }

            storedData = null;
            return(false);
        }
Example #2
0
        public void OnLoadSelectedClicked()
        {
            if (saveGameList.TryGetSelected(out var worldName))
            {
                SaveUtils.WorldName = worldName;

                BinarySerialiser serialiser = new BinarySerialiser(SaveUtils.CurrentWorldSaveDirectory, ".seed");
                int seed = 0;
                if (serialiser.TryLoad("worldSeed", out var seedObj))
                {
                    seed = (int)seedObj;
                    SceneMessagePasser.SetMessage(new SeedMessage()
                    {
                        seed = seed
                    });
                }

                SceneManager.LoadScene(mainMenu.gameScene);
            }
        }