Пример #1
0
        private void LoadWorldScene()
        {
            SceneStorage sceneLoader = new SceneStorage();

            this.world = GameWorld.Create(sceneLoader.Load(), rand);
            this.scene = world.Scene;
        }
        // This code is commented out because it is no longer used. It used to
        // migrate data inside of the prefab into the scene object. Now, we just
        // don't store scene objects inside of the prefab (we lose the ability to
        // save the state from play-mode, but that's okay)

        /// <summary>
        /// Attempts to migrate prefab storage into scene storage.
        /// </summary>
        private static void MigratePrefabIntoSceneStorage <T>()
            where T : fiPersistentEditorStorageItem
        {
            // Only try to do the migration once (per type)
            if (_didMigrate.Add(typeof(T)) == false)
            {
                return;
            }

            // We cannot migrate data while playing -- scene storage will not be
            // persisted
            if (Application.isPlaying)
            {
                return;
            }

            var prefabStorage = PrefabStorage.GetComponent <fiBaseStorageComponent <T> >();
            var sceneStorage  = SceneStorage.GetComponent <fiBaseStorageComponent <T> >();

            // Nothing to migrate.
            if (prefabStorage == null || prefabStorage.Data == null)
            {
                return;
            }

            // Migrate everything into scene storage
            var toRemove = new List <fiUnityObjectReference>();

            foreach (var entry in prefabStorage.Data)
            {
                if (AssetDatabase.Contains(entry.Key.Target))
                {
                    // data should stay in prefab storage, as the UnityObject
                    // target does not live in the scene
                    continue;
                }

                if (sceneStorage.Data.ContainsKey(entry.Key) == false)
                {
                    // move directly into scene storage
                    sceneStorage.Data[entry.Key] = entry.Value;
                }
                else
                {
                    // copy into scene storage
                    sceneStorage.Data[entry.Key].CopyFromAndClear(prefabStorage.Data[entry.Key]);
                }

                toRemove.Add(entry.Key);
            }
            foreach (var item in toRemove)
            {
                prefabStorage.Data.Remove(item);
            }

            fiLateBindings.EditorUtility.SetDirty(sceneStorage);
            fiLateBindings.EditorUtility.SetDirty(prefabStorage);
        }
Пример #3
0
        private void LoadScene()
        {
            selectionContainer.Unselect();

            var storage = new SceneStorage();

            this.scene = storage.Load();

            if (scene != null)
            {
                scene.PhysicsWorld.ContactManager.ContactFilter = (a, b) => false;
            }

            ingameRenderer.Scene = scene;
        }
    // clears scene-specific values and re-acquires scene-specific references
    void ClearAndUpdateSceneReferences()
    {
        // reset persistent, scene-specific values
        currentRealm    = realmViewing = 0;
        isTransitioning = false;
        realmCameras.Clear();
        tilePrefabIdx = 0;

        // acquire necessary scene references()
        SceneStorage sceneStorage = GameObject.Find("Scene Storage").GetComponent <SceneStorage>();

        if (sceneStorage)
        {
            realms       = sceneStorage.realms;
            worldFloor   = sceneStorage.worldFloor;
            worldEditLog = sceneStorage.worldEditLog;
        }

        // setup world edit mode
        if (DEVELOPMENT_WorldEditor)
        {
            // acquire log to record world edits
            worldEditLog = sceneStorage.worldEditLog;

            // instantiate text for which type of block will be placed
            GameObject checkTextExists = GameObject.Find("Realm Type Text");
            if (checkTextExists)
            {
                realmTypeText = checkTextExists.GetComponent <Text>();
            }
            else
            {
                Debug.LogError("RealmManager could not acquire Realm Type Text object");
            }
            realmTypeText.enabled = DEVELOPMENT_WorldEditor;
            SetRealmTypeText(Realm.Default);
        }

        CreateRealmCameras();
    }
Пример #5
0
        private bool SaveScene()
        {
            var storage = new SceneStorage();

            return(storage.Save(scene));
        }
Пример #6
0
 static Game()
 {
     LoadObject();
     Scene = new SceneStorage();
     Event = new EventManager();
 }