public static void LoadAll() { MegaMeshManager.ClearReferences(); BehaviorManager.AllowedToUpdate = false; // don't let circuitry updates f**k us up while we're loading the game BehaviorManager.ClearAllLists(); // remove all existing stuff in the world before loading the new stuff ObjectInfo[] saveobjects = UnityEngine.Object.FindObjectsOfType <ObjectInfo>(); // all active instances of SaveObject foreach (ObjectInfo save in saveobjects) { UnityEngine.Object.Destroy(save.gameObject); } List <SavedObjectV2> TopLevelObjects = (List <SavedObjectV2>)FileUtilities.LoadFromFile(RegionsPath, "world.tung"); if (TopLevelObjects != null) { foreach (SavedObjectV2 save in TopLevelObjects) { SavedObjectUtilities.LoadSavedObject(save); } } RecalculateAllClustersEverywhereWithDelay(); try { LoadPlayerPosition(); } catch { ES3.DeleteFile(PlayersPath + "/player"); } GameplayUIManager.UIState = UIState.None; }
public static void Deserialize(byte[] data) { //Clear scene MegaMeshManager.ClearReferences(); BehaviorManager.ClearAllLists(); foreach (ObjectInfo objectInfo in GameObject.FindObjectsOfType <ObjectInfo>()) { GameObject.Destroy(objectInfo.gameObject); } SavedWorld world; //Deserialize the data into a SavedWorld using (MemoryStream mem = new MemoryStream(Compressor.Decompress(data))) { world = (SavedWorld) new BinaryFormatter().Deserialize(mem); } //Run on Unity thread MulTUNG.SynchronizationContext.Send(_ => { //Load all the objects from the save foreach (var item in world.TopLevelObjects) { SavedObjectUtilities.LoadSavedObject(item); } SaveManager.RecalculateAllClustersEverywhereWithDelay(); }, null); }
public static void LoadLegacySave() { MegaMeshManager.ClearReferences(); BehaviorManager.AllowedToUpdate = false; // don't let circuitry updates f**k us up while we're loading the game BehaviorManager.ClearAllLists(); List <SavedObject> TopLevelObjects = ES3.Load <List <SavedObject> >("TopLevelObjects", "saves/" + SaveManager.SaveName + ".tung"); foreach (SavedObject save in TopLevelObjects) { LoadLegacySaveObject(save, null); } LegacyLoadPlayer(SaveManager.SaveName); SaveManager.RecalculateAllClustersEverywhereWithDelay(); MegaMeshManager.AddComponentsEverywhere(); GameplayUIManager.UIState = UIState.None; }
private void Awake() { GameplayUIManager.UIState = UIState.MainMenu; Instance = this; MegaMeshManager.ClearReferences(); BehaviorManager.ClearAllLists(); ShowMainMenu(); string CurrentVersion = "0.2.0"; string LastLoadedVersion = Settings.Get("LastLoadedVersion", CurrentVersion); if (LastLoadedVersion != CurrentVersion) { ES3.DeleteFile("settings.txt"); } // some settings are obsolete and must be reset EverythingHider.UnHideEverything(); }