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);
        }
示例#2
0
        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);
        }
示例#3
0
 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();
            }
        }
示例#5
0
 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();
     }
 }
示例#6
0
        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;
                    }
                }
            }
        }
示例#7
0
 public static void Add(MiscConfigObject Object)
 {
     Root.miscConfigObjects.Add(Object);
 }
示例#8
0
 public static string Serialize(MiscConfigObject Object)
 {
     return(Object.name + "_" + Object.showInMenu + "_" + Object.showInGame);
 }