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 Plugin(IPALogger logger, IPA.Config.Config config) { Log = logger; Log.Info("Initializing"); SceneManager.activeSceneChanged += SceneChanged; PluginConfig.Instance = config.Generated <PluginConfig>(); Instance = this; MenuButtons.instance.RegisterButton(new MenuButton("Forecast", "See your Weather", new System.Action(LoadForCastUI))); PluginConfig.Instance.audioSFXVolume = Mathf.Clamp(PluginConfig.Instance.audioSFXVolume, 0f, 1f); MiscConfig.Read(); var harmony = new Harmony("com.FutureMapper.Weather"); harmony.PatchAll(Assembly.GetExecutingAssembly()); }
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 void SetData(Effect eff) { currectEff = eff; string IndependentName = eff.GetNameWithoutSceneName(); string Game = IndependentName + "Game"; string Menu = IndependentName + "Menu"; bool showGame = false; bool showMenu = false; if (eff.IsEffectSeperateType()) { Plugin.Log.Info(IndependentName + " Is Independent Type"); Effect effGame = EffectModel.GetEffectByName(Game); Effect effMenu = EffectModel.GetEffectByName(Menu); bool val = EffectModel.GetEffectEnabledByName(IndependentName); effGame.enabled = val; effMenu.enabled = val; showGame = effGame.Desc.WorksInGame; showMenu = effMenu.Desc.WorksInMenu; } else { Plugin.Log.Info(IndependentName + " Is Not Independent Type"); eff.enabled = EffectModel.GetEffectEnabledByName(eff.Desc.EffectName); showGame = eff.Desc.WorksInGame; showMenu = eff.Desc.WorksInMenu; } text.text = IndependentName; enabledToggle.GetComponentInChildren <Toggle>().isOn = EffectModel.GetEffectEnabledByName(eff.Desc.EffectName); Toggle menu = menuToggle.GetComponentInChildren <Toggle>(); Toggle game = gameToggle.GetComponentInChildren <Toggle>(); menu.interactable = showMenu; game.interactable = showGame; menu.isOn = MiscConfig.ReadObject(IndependentName).showInMenu; game.isOn = MiscConfig.ReadObject(IndependentName).showInGame; }
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; } } } }