/// <summary> /// Loads a new forgelight game that does not currently exist. /// </summary> /// <param name="path"></param> private void LoadNewForgelightGame(string path) { DirectoryInfo directoryInfo = Directory.GetParent(path).Parent; if (directoryInfo == null) { return; } string name = directoryInfo.Name; string resourceDirectory = "Resources/" + name; ForgelightGame forgelightGame = new ForgelightGame(new ForgelightGameInfo(name, path, resourceDirectory)); forgelightGame.LoadPackFiles(0.0f, 0.05f); forgelightGame.InitializeMaterialDefinitionManager(); if (!forgelightGame.ImportModels(0.05f, 0.6f)) { return; } if (!forgelightGame.ImportTerrain(0.6f, 0.9f)) { return; } forgelightGame.UpdateActors(0.9f, 0.93f); forgelightGame.UpdateZones(0.93f, 0.97f); forgelightGame.UpdateAreas(0.97f, 1.0f); forgelightGame.OnLoadComplete(); ForgelightExtension.Instance.Config.SaveNewForgelightGame(forgelightGame); UpdateActiveForgelightGame(forgelightGame); }
/// <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); }