private void GameToggleClicked(bool value) { Plugin.Log.Info("GameToggleClicked"); currectEff.showInGame = value; currectEff.SetActiveRefs(); MiscConfigObject configObject = MiscConfig.ReadObject(EffectModel.GetNameWithoutSceneName(currectEff.Desc.EffectName)); configObject.showInGame = value; MiscConfig.WriteToObject(configObject); }
public static MiscConfigObject ReadObject(string name) { string[] arrLine = File.ReadAllLines(path); MiscConfigObject Out = new MiscConfigObject(name, true, true); for (int i = 0; i < arrLine.Length; i++) { string line = arrLine[i]; Out = Deserialize(line); } return(Out); }
public static void WriteToObject(MiscConfigObject Object) { string[] arrLine = File.ReadAllLines(path); for (int i = 0; i < arrLine.Length; i++) { string line = arrLine[i]; string[] parts = line.Split('_'); if (parts[0] == Object.name) { arrLine[i] = Serialize(Object); } } File.WriteAllLines(path, arrLine); }
private void MenuToggleClicked(bool value) { Plugin.Log.Info("MenuToggleClicked"); currectEff.showInMenu = value; currectEff.SetActiveRefs(); MiscConfigObject configObject = MiscConfig.ReadObject(EffectModel.GetNameWithoutSceneName(currectEff.Desc.EffectName)); configObject.showInMenu = value; MiscConfig.WriteToObject(configObject); if (value) { currectEff.SetSceneMaterials(); } if (!value) { currectEff.RemoveSceneMaterials(); } }
public void SetActiveRefs() { if (!hasFullSetRefs) { SetRefs(); return; } MeshRenderer[] mrs = Resources.FindObjectsOfTypeAll <MeshRenderer>(); for (int i = 0; i < BundleLoader.effects.Count; i++) { Effect eff = BundleLoader.effects[i]; string NameToUse = EffectModel.GetNameWithoutSceneName(eff.Desc.EffectName); if (MiscConfig.hasObject(NameToUse)) { //Plugin.Log.Info("Misc Config has Object! " + NameToUse); MiscConfigObject Object = MiscConfig.ReadObject(NameToUse); eff.showInMenu = Object.showInMenu; eff.showInGame = Object.showInGame; } else { MiscConfig.Add(new MiscConfigObject(NameToUse, eff.showInMenu, eff.showInGame)); } for (int x = 0; x < mrs.Length; x++) { MeshRenderer mr = mrs[x]; if (mr.material.name.Contains("Note") || mr.gameObject.name.Contains("building") || mr.gameObject.name.Contains("speaker")) { eff.TrySetNoteMateral(mr); } else { continue; } } eff.SetActiveRefs(); } }
public async void SetRefs() { hasFullSetRefs = true; Plugin.Log.Info("SetRefs " + CurrentScene.name); WeatherDataRoot weatherInfo = await WeatherFinder.GetWeatherData(); MeshRenderer[] mrs = Resources.FindObjectsOfTypeAll <MeshRenderer>(); //Plugin.Log.Info("SetRefs 1"); if (CurrentScene.name == Plugin.menu) { BundleLoader.WeatherPrefab.SetActive(PluginConfig.Instance.enabledInMenu); } if (CurrentScene.name == Plugin.game) { BundleLoader.WeatherPrefab.SetActive(PluginConfig.Instance.enabledInGameplay); } BundleLoader.effects.Clear(); for (int x = 0; x < weatherInfo.weather.Length; x++) { WeatherData data = weatherInfo.weather[x]; EffectModel.EnableEffect(data.main, true); } for (int i = 0; i < gameObject.transform.childCount; i++) { //Plugin.Log.Info(i.ToString()); Transform Child = gameObject.transform.GetChild(i); Child.gameObject.SetActive(true); EffectDiscriptor efd = Child.gameObject.GetComponent <EffectDiscriptor>(); string NameToUse = EffectModel.GetNameWithoutSceneName(efd.EffectName); Child.gameObject.GetComponentsInChildren <AudioSource>().ToList().ForEach((AudioSource s) => { s.volume = PluginConfig.Instance.audioSFXVolume; }); efd.gameObject.SetActive(true); efd.transform.GetChild(0).gameObject.SetActive(true); Effect eff = new Effect(efd, Child.gameObject, PluginConfig.Instance.enabledEffects.Any((string str) => { return(str == efd.EffectName); })); if (MiscConfig.hasObject(NameToUse)) { //Plugin.Log.Info("Misc Config has Object! " + NameToUse); MiscConfigObject Object = MiscConfig.ReadObject(NameToUse); eff.showInMenu = Object.showInMenu; eff.showInGame = Object.showInGame; } else { MiscConfig.Add(new MiscConfigObject(NameToUse, eff.showInMenu, eff.showInGame)); MiscConfig.Write(); } eff.SetActiveRefs(); BundleLoader.effects.Add(eff); //Plugin.Log.Info("Replacing " + mrs.Length.ToString ()); for (int x = 0; x < mrs.Length; x++) { MeshRenderer mr = mrs[x]; if (mr.material.name.Contains("Note") || mr.gameObject.name.Contains("building") || mr.gameObject.name.Contains("speaker")) { eff.TrySetNoteMateral(mr); } else { continue; } } } }
public static void Add(MiscConfigObject Object) { Root.miscConfigObjects.Add(Object); }
public static string Serialize(MiscConfigObject Object) { return(Object.name + "_" + Object.showInMenu + "_" + Object.showInGame); }