Beispiel #1
0
 public void OnPlugActiveSceneChanged(Scene prevScene, Scene scene)
 {
     if (scene.name == "MenuViewControllers" && prevScene.name == "EmptyTransition")
     {
         hueManager = new HueManager();
         if (hueManager.Ready == true)
         {
             BSMLSettings.instance.AddSettingsMenu("Hue", "Chroma.Settings.hue.bsml", ChromaSettingsUI.instance);
             BSMLSettings.instance.RemoveSettingsMenu(ChromaHueConnectUI.instance);
         }
         else
         {
             BSMLSettings.instance.AddSettingsMenu("Chroma", "Chroma.Settings.settings.bsml", ChromaHueConnectUI.instance);
         }
     }
 }
Beispiel #2
0
 internal static void OnActiveSceneChanged(Scene prevScene, Scene current)
 {
     if (current.name == "GameCore")
     {
         LightColorizer.ClearLSEColorManagers();
         ObstacleColorizer.ClearOCColorManagers();
         BombColorizer.ClearBNCColorManagers();
         NoteColorizer.ClearCNVColorManagers();
         SaberColorizer.ClearBSMColorManagers();
     }
     if (current.name == "MenuViewControllers" && ChromaConfig.Instance.HueEnabled == true)
     {
         HueManager.Disconnect(LightInfo.client);
     }
     if (current.name == "EmptyTransition" && prevScene.name == "MenuViewControllers" && ChromaConfig.Instance.HueEnabled == true)
     {
         hueCts.Cancel();
         hueCts = new System.Threading.CancellationTokenSource();
         HueManager.connect(hueCts.Token);
     }
 }
Beispiel #3
0
        internal static void ColorLightSwitch(MonoBehaviour monobehaviour, BeatmapEventData beatmapEventData)
        {
            monobehaviour.SetLastValue(beatmapEventData.value);

            Color?color = null;
            bool  gradi = false;

            // legacy was a mistake
            color = LegacyLightHelper.GetLegacyColor(beatmapEventData) ?? color;

            if (beatmapEventData is CustomBeatmapEventData customData)
            {
                dynamic dynData = customData.customData;
                if (monobehaviour is LightSwitchEventEffect lightSwitchEventEffect)
                {
                    object lightID = Trees.at(dynData, LIGHTID);
                    if (lightID != null)
                    {
                        switch (lightID)
                        {
                        case List <object> lightIDobjects:
                            LightIDOverride = lightIDobjects.Select(n => System.Convert.ToInt32(n)).ToList();

                            break;

                        case long lightIDint:
                            LightIDOverride = new List <int> {
                                (int)lightIDint
                            };

                            break;
                        }
                    }

                    // propID is now DEPRECATED!!!!!!!!
                    object propID = Trees.at(dynData, PROPAGATIONID);
                    if (propID != null)
                    {
                        ILightWithId[][] lights = lightSwitchEventEffect.GetLightsPropagationGrouped();
                        int lightCount          = lights.Length;
                        switch (propID)
                        {
                        case List <object> propIDobjects:
                            int[] propIDArray = propIDobjects.Select(n => System.Convert.ToInt32(n)).ToArray();
                            List <ILightWithId> overrideLights = new List <ILightWithId>();
                            for (int i = 0; i < propIDArray.Length; i++)
                            {
                                if (lightCount > propIDArray[i])
                                {
                                    overrideLights.AddRange(lights[propIDArray[i]]);
                                }
                            }

                            SetLegacyPropIdOverride(overrideLights.ToArray());

                            break;

                        case long propIDlong:
                            if (lightCount > propIDlong)
                            {
                                SetLegacyPropIdOverride(lights[propIDlong]);
                            }

                            break;
                        }
                    }

                    dynamic gradientObject = Trees.at(dynData, LIGHTGRADIENT);
                    if (gradientObject != null)
                    {
                        color = ChromaGradientController.AddGradient(gradientObject, beatmapEventData.type, beatmapEventData.time);
                        if (Settings.ChromaConfig.Instance.HueEnabled == true)
                        {
                            HueManager.ProcessEvent(beatmapEventData, null, gradientObject);
                        }
                        gradi = true;
                    }
                }

                Color?colorData = ChromaUtils.GetColorFromData(dynData);
                if (colorData.HasValue)
                {
                    color = colorData;
                    ChromaGradientController.CancelGradient(beatmapEventData.type);
                    gradi = false;
                }
            }

            if (color.HasValue)
            {
                monobehaviour.SetLightingColors(color.Value, color.Value, color.Value, color.Value);
            }
            else if (!ChromaGradientController.IsGradientActive(beatmapEventData.type))
            {
                monobehaviour.Reset();
            }
            if (Settings.ChromaConfig.Instance.HueEnabled == true && gradi == false)
            {
                HueManager.ProcessEvent(beatmapEventData, color);
            }
        }