/// <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) { JObject info = ForgelightExtension.Instance.Config.GetForgelightGameInfo(name); string packDirectory = (string)info["pack_directory"]; string resourceDirectory = (string)info["resource_directory"]; ForgelightGame forgelightGame = new ForgelightGame(name, packDirectory, resourceDirectory); if (!Directory.Exists(resourceDirectory)) { 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); }
/// <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 alias = directoryInfo.Name; string resourceDirectory = Application.dataPath + "/Resources/" + alias; ForgelightGame forgelightGame = new ForgelightGame(alias, path, resourceDirectory); forgelightGame.LoadPackFiles(0.0f, 0.25f); forgelightGame.InitializeMaterialDefinitionManager(); forgelightGame.ImportModels(0.3f, 0.6f); forgelightGame.ImportTerrain(0.6f, 0.9f); 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); }
public void DeleteForgelightGame(ForgelightGame forgelightGame) { CheckExtensionState(); extensionState["forgelight_games"][forgelightGame.Name].Remove(); WriteStateToDisk(); }
public void UpdateForgelightGame(ForgelightGame forgelightGame, bool isActive) { CheckExtensionState(); JObject info = (JObject)extensionState["forgelight_games"][forgelightGame.Name]; info["is_active_game"] = isActive; WriteStateToDisk(); }
private void UpdateActiveForgelightGame(ForgelightGame newGame) { if (ActiveForgelightGame != null) { ForgelightExtension.Instance.Config.UpdateForgelightGame(ActiveForgelightGame, false); } ActiveForgelightGame = newGame; ForgelightExtension.Instance.Config.UpdateForgelightGame(newGame, true); ForgelightMonoBehaviour.Instance.ForgelightGame = newGame.Name; }
public void SaveNewForgelightGame(ForgelightGame forgelightGame) { CheckExtensionState(); JObject gameElement = new JObject(); gameElement.Add("pack_directory", forgelightGame.PackDirectory); gameElement.Add("resource_directory", forgelightGame.ResourceDirectory); gameElement.Add("is_active_game", true); ((JObject)extensionState["forgelight_games"])[forgelightGame.Name] = gameElement; WriteStateToDisk(); }