Пример #1
0
        public static void RegisterLight(MonoBehaviour lightWithId)
        {
            switch (lightWithId)
            {
            case LightWithIdMonoBehaviour monoBehaviour:
                LSEColorManager monomanager = LSEColorManager.GetLSEColorManager((BeatmapEventType)(monoBehaviour.lightId - 1))?.Where(n => n.Lights != null).First();
                if (monomanager == null)
                {
                    break;
                }

                LightIDTableManager.RegisterIndex(monoBehaviour.lightId - 1, monomanager.Lights.Count);
                monomanager.Lights.Add(monoBehaviour);
                break;

            case LightWithIds lightWithIds:
                IEnumerable <ILightWithId> lightsWithId = ((IEnumerable)_lightWithIdsData.GetValue(lightWithId)).Cast <ILightWithId>();
                foreach (ILightWithId light in lightsWithId)
                {
                    LSEColorManager manager = LSEColorManager.GetLSEColorManager((BeatmapEventType)(light.lightId - 1))?.Where(n => n.Lights != null).First();
                    if (manager == null)
                    {
                        continue;
                    }

                    LightIDTableManager.RegisterIndex(light.lightId - 1, manager.Lights.Count);
                    manager.Lights.Add(light);
                }

                break;
            }
        }
Пример #2
0
        public static void RegisterLight(MonoBehaviour lightWithId, int?lightId)
        {
            LightColorizer lightColorizer;

            switch (lightWithId)
            {
            case LightWithIdMonoBehaviour monoBehaviour:
                lightColorizer = ((BeatmapEventType)(monoBehaviour.lightId - 1)).GetLightColorizer();
                LightIDTableManager.RegisterIndex(monoBehaviour.lightId - 1, lightColorizer.Lights.Count, lightId);
                lightColorizer.Lights.Add(monoBehaviour);

                break;

            case LightWithIds lightWithIds:
                IEnumerable <ILightWithId> lightsWithId = ((IEnumerable)_lightWithIdsData.GetValue(lightWithId)).Cast <ILightWithId>();
                foreach (ILightWithId light in lightsWithId)
                {
                    lightColorizer = ((BeatmapEventType)(light.lightId - 1)).GetLightColorizer();
                    LightIDTableManager.RegisterIndex(light.lightId - 1, lightColorizer.Lights.Count, lightId);
                    lightColorizer.Lights.Add(light);
                }

                break;
            }
        }
Пример #3
0
        private static bool BasicPatch(IDifficultyBeatmap difficultyBeatmap, CustomBeatmapData customBeatmapData)
        {
            IEnumerable <string>?requirements = customBeatmapData.beatmapCustomData.Get <List <object> >("_requirements")?.Cast <string>();
            IEnumerable <string>?suggestions  = customBeatmapData.beatmapCustomData.Get <List <object> >("_suggestions")?.Cast <string>();
            bool chromaRequirement            = (requirements?.Contains(Plugin.REQUIREMENTNAME) ?? false) || (suggestions?.Contains(Plugin.REQUIREMENTNAME) ?? false);

            // please let me remove this shit
            bool legacyOverride = customBeatmapData.beatmapEventsData.Any(n => n.value >= LegacyLightHelper.RGB_INT_OFFSET);

            if (legacyOverride)
            {
                Plugin.Logger.Log("Legacy Chroma Detected...", IPA.Logging.Logger.Level.Warning);
                Plugin.Logger.Log("Please do not use Legacy Chroma Lights for new maps as it is deprecated and its functionality in future versions of Chroma cannot be guaranteed", IPA.Logging.Logger.Level.Warning);
            }

            ChromaController.ToggleChromaPatches((chromaRequirement || legacyOverride) && ChromaConfig.Instance !.CustomColorEventsEnabled);
            ChromaController.DoColorizerSabers = chromaRequirement && ChromaConfig.Instance !.CustomColorEventsEnabled;

            LightIDTableManager.SetEnvironment(difficultyBeatmap.GetEnvironmentInfo().serializedName);

            return(chromaRequirement);
        }
 private static void SetEnvironmentTable(EnvironmentInfoSO environmentInfo)
 {
     LightIDTableManager.SetEnvironment(environmentInfo.serializedName);
 }
Пример #5
0
        private static bool Prefix(LightSwitchEventEffect __instance, BeatmapEventType ____event, Color color)
        {
            if (LightColorManager.LightIDOverride != null)
            {
                List <ILightWithId> lights = __instance.GetLights();
                int type = (int)____event;
                IEnumerable <int> newIds = LightColorManager.LightIDOverride.Select(n => LightIDTableManager.GetActiveTableValue(type, n) ?? n);
                foreach (int id in newIds)
                {
                    if (lights[id].isRegistered)
                    {
                        lights[id].ColorWasSet(color);
                    }
                }

                LightColorManager.LightIDOverride = null;

                return(false);
            }

            // Legacy Prop Id stuff
            if (LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride != null)
            {
                ILightWithId[] lights = LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride;
                for (int i = 0; i < lights.Length; i++)
                {
                    lights[i].ColorWasSet(color);
                }

                LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride = null;

                return(false);
            }

            return(true);
        }
Пример #6
0
        private static bool Prefix(LightSwitchEventEffect __instance, BeatmapEventType ____event, Color color)
        {
            if (LightColorManager.LightIDOverride != null)
            {
                List <ILightWithId> lights = __instance.GetLights();
                int type = (int)____event;
                IEnumerable <int> newIds = LightColorManager.LightIDOverride.Select(n => LightIDTableManager.GetActiveTableValue(type, n) ?? n);
                foreach (int id in newIds)
                {
                    ILightWithId lightWithId = lights.ElementAtOrDefault(id);
                    if (lightWithId != null)
                    {
                        if (lightWithId.isRegistered)
                        {
                            lightWithId.ColorWasSet(color);
                        }
                    }
                    else
                    {
                        ChromaLogger.Log($"Type [{type}] does not contain id [{id}].", IPA.Logging.Logger.Level.Warning);
                    }
                }

                LightColorManager.LightIDOverride = null;

                return(false);
            }

            // Legacy Prop Id stuff
            if (LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride != null)
            {
                ILightWithId[] lights = LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride;
                for (int i = 0; i < lights.Length; i++)
                {
                    lights[i].ColorWasSet(color);
                }

                LightSwitchEventEffectHandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger.LegacyLightOverride = null;

                return(false);
            }

            return(true);
        }
Пример #7
0
        private static void Postfix(IDifficultyBeatmap difficultyBeatmap, EnvironmentInfoSO ____multiplayerEnvironmentInfo)
        {
            LightIDTableManager.SetEnvironment(____multiplayerEnvironmentInfo.serializedName);

            SceneTransitionHelper.Patch(difficultyBeatmap);
        }