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;
    }
예제 #2
0
파일: World.cs 프로젝트: pipe01/MulTUNG
        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);
        }
예제 #3
0
    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();
    }