Exemple #1
0
        private void Initialize()
        {
            if (EditorSceneManager.loadedSceneCount > 0 && SceneManager.GetActiveScene().name == lastScene)
            {
                return;
            }

            lastScene = SceneManager.GetActiveScene().name;

            //ChangeActiveForgelightGame the Active Game.
            string             activeGame     = null;
            ForgelightGameInfo activeGameInfo = null;

            //The data saved to the current scene.
            if (!string.IsNullOrEmpty(ForgelightMonoBehaviour.Instance.ForgelightGame))
            {
                activeGame = ForgelightMonoBehaviour.Instance.ForgelightGame;
            }

            if (!string.IsNullOrEmpty(activeGame))
            {
                activeGameInfo = Config.GetForgelightGameInfo(activeGame);
            }

            if (activeGameInfo == null)
            {
                activeGameInfo = Config.ForgelightEditorPrefs.ActiveForgelightGame;
            }

            if (!string.IsNullOrEmpty(activeGameInfo?.Name) && !string.IsNullOrEmpty(activeGameInfo.RelativeResourceDirectory) && !string.IsNullOrEmpty(activeGameInfo.PackDirectory))
            {
                ForgelightGameFactory.ChangeActiveForgelightGame(activeGame);
            }
        }
        public ForgelightGame(ForgelightGameInfo gameInfo)
        {
            this.GameInfo = gameInfo;
            Packs         = new List <Pack>();
            AssetsByType  = new ConcurrentDictionary <AssetType, List <AssetRef> >();

            foreach (Enum type in Enum.GetValues(typeof(AssetType)))
            {
                AssetsByType.TryAdd((AssetType)type, new List <AssetRef>());
            }
        }
        /// <summary>
        /// Deserializes and initializes the raw state data for the given forgelight game.
        /// Loads pack files into memory, and sets up references to required assets.
        /// </summary>
        public void ChangeActiveForgelightGame(string name)
        {
            ForgelightGameInfo info = ForgelightExtension.Instance.Config.GetForgelightGameInfo(name);

            ForgelightGame forgelightGame = new ForgelightGame(info);

            if (!Directory.Exists(info.FullResourceDirectory))
            {
                Debug.LogError("Could not find directory for game " + name + "!\n" +
                               "Please update Assets/Forgelight/state.json to the correct path, or remove the game from the file if it no-longer exists.");
                return;
            }

            forgelightGame.LoadPackFiles(0.0f, 0.7f);
            forgelightGame.InitializeMaterialDefinitionManager();
            forgelightGame.UpdateActors(0.7f, 0.8f);
            forgelightGame.UpdateZones(0.8f, 0.9f);
            forgelightGame.UpdateAreas(0.9f, 1.0f);

            forgelightGame.OnLoadComplete();

            UpdateActiveForgelightGame(forgelightGame);
        }