示例#1
0
        internal static void ColorLightSwitch(MonoBehaviour monobehaviour, BeatmapEventData beatmapEventData)
        {
            if (!ChromaEventDatas.TryGetValue(beatmapEventData, out ChromaEventData chromaEventData))
            {
                return;
            }

            ChromaLightEventData chromaData = (ChromaLightEventData)chromaEventData;

            Color?color = null;

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

            if (monobehaviour is LightSwitchEventEffect lightSwitchEventEffect)
            {
                object lightID = chromaData.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 = chromaData.PropID;
                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;
                    }
                }

                ChromaLightEventData.GradientObjectData gradientObject = chromaData.GradientObject;
                if (gradientObject != null)
                {
                    color = ChromaGradientController.AddGradient(gradientObject, beatmapEventData.type, beatmapEventData.time);
                }
            }

            Color?colorData = chromaData.ColorData;

            if (colorData.HasValue)
            {
                color = colorData;
                ChromaGradientController.CancelGradient(beatmapEventData.type);
            }

            if (color.HasValue)
            {
                monobehaviour.SetLightingColors(color.Value, color.Value, color.Value, color.Value);
            }
            else if (!ChromaGradientController.IsGradientActive(beatmapEventData.type))
            {
                monobehaviour.Reset();
            }
        }
示例#2
0
        internal static void ColorLightSwitch(BeatmapEventData beatmapEventData)
        {
            ChromaEventData?chromaData = TryGetEventData(beatmapEventData);

            if (chromaData == null)
            {
                return;
            }

            Color?color = null;

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

            object?lightID = chromaData.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 = chromaData.PropID;

            if (propID != null)
            {
                ILightWithId[][] lights = beatmapEventData.type.GetLightColorizer().LightsPropagationGrouped;
                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;
                }
            }

            ChromaEventData.GradientObjectData?gradientObject = chromaData.GradientObject;
            if (gradientObject != null)
            {
                color = ChromaGradientController.AddGradient(gradientObject, beatmapEventData.type, beatmapEventData.time);
            }

            Color?colorData = chromaData.ColorData;

            if (colorData.HasValue)
            {
                color = colorData;
                ChromaGradientController.CancelGradient(beatmapEventData.type);
            }

            if (color.HasValue)
            {
                Color finalColor = color.Value;
                beatmapEventData.type.ColorizeLight(false, finalColor, finalColor, finalColor, finalColor);
            }
            else if (!ChromaGradientController.IsGradientActive(beatmapEventData.type))
            {
                beatmapEventData.type.ColorizeLight(false, null, null, null, null);
            }
        }
示例#3
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        internal static void ColorLightSwitch(MonoBehaviour monobehaviour, BeatmapEventData beatmapEventData)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            monobehaviour.SetLastValue(beatmapEventData.value);

            Color?color = null;

            // 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)
                    {
                        ILightWithId[] lights     = lightSwitchEventEffect.GetLights();
                        int            lightCount = lights.Length;
                        switch (lightID)
                        {
                        case List <object> lightIDobjects:
                            int[] lightIDArray = lightIDobjects.Select(n => System.Convert.ToInt32(n)).ToArray();
                            List <ILightWithId> overrideLights = new List <ILightWithId>();
                            for (int i = 0; i < lightIDArray.Length; i++)
                            {
                                if (lightCount > lightIDArray[i])
                                {
                                    overrideLights.Add(lights[lightIDArray[i]]);
                                }
                            }

                            SetOverrideLightWithIds(overrideLights.ToArray());

                            break;

                        case long lightIDint:
                            if (lightCount > lightIDint)
                            {
                                SetOverrideLightWithIds(lights[lightIDint]);
                            }

                            break;
                        }
                    }

                    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]]);
                                }
                            }

                            SetOverrideLightWithIds(overrideLights.ToArray());

                            break;

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

                            break;
                        }
                    }

                    dynamic gradientObject = Trees.at(dynData, LIGHTGRADIENT);
                    if (gradientObject != null)
                    {
                        color = ChromaGradientController.AddGradient(gradientObject, beatmapEventData.type, beatmapEventData.time);
                    }
                }

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

            if (color.HasValue)
            {
                monobehaviour.SetLightingColors(color.Value, color.Value, color.Value, color.Value);
            }
            else if (!ChromaGradientController.IsGradientActive(beatmapEventData.type))
            {
                monobehaviour.Reset();
            }
        }
示例#4
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);
            }
        }