internal static IEnumerator DelayedStart(BeatmapObjectSpawnController beatmapObjectSpawnController) { yield return(new WaitForEndOfFrame()); BeatmapObjectSpawnController = beatmapObjectSpawnController; // prone to breaking if anything else implements these interfaces BeatmapObjectManager beatmapObjectManager = _beatmapObjectSpawnAccessor(ref beatmapObjectSpawnController) as BeatmapObjectManager; BeatmapObjectCallbackController coreSetup = _callbackControllerAccessor(ref beatmapObjectSpawnController) as BeatmapObjectCallbackController; IAudioTimeSource = _audioTimeSourceAccessor(ref coreSetup); IReadonlyBeatmapData beatmapData = _beatmapDataAccessor(ref coreSetup); beatmapObjectManager.noteWasCutEvent -= NoteColorizer.ColorizeSaber; beatmapObjectManager.noteWasCutEvent += NoteColorizer.ColorizeSaber; if (Harmony.HasAnyPatches(HARMONYID)) { if (beatmapData is CustomBeatmapData customBeatmap) { if (ChromaConfig.Instance.EnvironmentEnhancementsEnabled) { EnvironmentEnhancementManager.Init(customBeatmap, beatmapObjectSpawnController.noteLinesDistance); } } // please let me kill legacy LegacyLightHelper.Activate(beatmapData.beatmapEventsData); } }
internal static IEnumerator DelayedStart(BeatmapObjectSpawnController beatmapObjectSpawnController) { yield return(new WaitForEndOfFrame()); BeatmapObjectSpawnController = beatmapObjectSpawnController; // prone to breaking if anything else implements these interfaces BeatmapObjectManager beatmapObjectManager = (BeatmapObjectManager)_beatmapObjectSpawnAccessor(ref beatmapObjectSpawnController); BeatmapObjectCallbackController coreSetup = (BeatmapObjectCallbackController)_callbackControllerAccessor(ref beatmapObjectSpawnController); IAudioTimeSource = _audioTimeSourceAccessor(ref coreSetup); IReadonlyBeatmapData beatmapData = _beatmapDataAccessor(ref coreSetup); beatmapObjectManager.noteWasCutEvent -= NoteColorizer.ColorizeSaber; beatmapObjectManager.noteWasCutEvent += NoteColorizer.ColorizeSaber; if (ChromaIsActive) { if (beatmapData is CustomBeatmapData customBeatmap) { if (ChromaConfig.Instance !.EnvironmentEnhancementsEnabled) { EnvironmentEnhancementManager.Init(customBeatmap, beatmapObjectSpawnController.noteLinesDistance); } } try { // please let me kill legacy LegacyLightHelper.Activate(beatmapData.beatmapEventsData); } catch (System.Exception e) { Plugin.Logger.Log("Could not run Legacy Chroma Lights"); Plugin.Logger.Log(e); } } }
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(); } }
internal static IEnumerator DelayedStart() { yield return(new WaitForEndOfFrame()); AudioTimeSyncController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().First(); BeatmapObjectSpawnController beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().First(); BeatmapObjectManager beatmapObjectManager = _beatmapObjectSpawnAccessor(ref beatmapObjectSpawnController) as BeatmapObjectManager; SongBPM = beatmapObjectSpawnController.currentBpm; BeatmapObjectCallbackController coreSetup = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First(); IReadonlyBeatmapData beatmapData = coreSetup.GetField <IReadonlyBeatmapData, BeatmapObjectCallbackController>("_beatmapData"); beatmapObjectManager.noteWasCutEvent -= NoteColorizer.ColorizeSaber; beatmapObjectManager.noteWasCutEvent += NoteColorizer.ColorizeSaber; if (ChromaConfig.Instance.LightshowModifier) { foreach (BeatmapLineData b in beatmapData.beatmapLinesData) { BeatmapLineData refBeatmapLineData = b; _beatmapObjectsDataAccessor(ref refBeatmapLineData) = b.beatmapObjectsData.Where((source, index) => b.beatmapObjectsData[index].beatmapObjectType != BeatmapObjectType.Note).ToList(); } foreach (Saber saber in Resources.FindObjectsOfTypeAll <Saber>()) { saber.gameObject.SetActive(false); } BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Chroma"); if (ChromaConfig.Instance.PlayersPlace) { GameObject.Find("PlayersPlace")?.SetActive(false); } if (ChromaConfig.Instance.Spectrograms) { GameObject.Find("Spectrograms")?.SetActive(false); } if (ChromaConfig.Instance.BackColumns) { GameObject.Find("BackColumns")?.SetActive(false); } if (ChromaConfig.Instance.Buildings) { GameObject.Find("Buildings")?.SetActive(false); } } if (Harmony.HasAnyPatches(HARMONYID)) { if (beatmapData is CustomBeatmapData customBeatmap) { if (ChromaConfig.Instance.EnvironmentEnhancementsEnabled) { // Spaghetti code below until I can figure out a better way of doing this dynamic dynData = customBeatmap.beatmapCustomData; List <object> objectsToKill = Trees.at(dynData, "_environmentRemoval"); if (objectsToKill != null) { IEnumerable <GameObject> gameObjects = Resources.FindObjectsOfTypeAll <GameObject>(); foreach (string s in objectsToKill.Cast <string>()) { if (s == "TrackLaneRing" || s == "BigTrackLaneRing") { foreach (GameObject n in gameObjects.Where(obj => obj.name.Contains(s))) { if (s == "TrackLaneRing" && n.name.Contains("Big")) { continue; } n.SetActive(false); } } else { foreach (GameObject n in gameObjects .Where(obj => obj.name.Contains(s) && (obj.scene.name?.Contains("Environment") ?? false) && (!obj.scene.name?.Contains("Menu") ?? false))) { n.SetActive(false); } } } } } } // please let me kill legacy LegacyLightHelper.Activate(beatmapData.beatmapEventsData); } }
#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(); } }
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); } }
internal static IEnumerator DelayedStart(BeatmapObjectSpawnController beatmapObjectSpawnController) { yield return(new WaitForEndOfFrame()); BeatmapObjectSpawnController = beatmapObjectSpawnController; // prone to breaking if anything else implements these interfaces BeatmapObjectManager beatmapObjectManager = _beatmapObjectSpawnAccessor(ref beatmapObjectSpawnController) as BeatmapObjectManager; BeatmapObjectCallbackController coreSetup = _callbackControllerAccessor(ref beatmapObjectSpawnController) as BeatmapObjectCallbackController; IAudioTimeSource = _audioTimeSourceAccessor(ref coreSetup); IReadonlyBeatmapData beatmapData = _beatmapDataAccessor(ref coreSetup); beatmapObjectManager.noteWasCutEvent -= NoteColorizer.ColorizeSaber; beatmapObjectManager.noteWasCutEvent += NoteColorizer.ColorizeSaber; if (Harmony.HasAnyPatches(HARMONYID)) { if (beatmapData is CustomBeatmapData customBeatmap) { if (ChromaConfig.Instance.EnvironmentEnhancementsEnabled) { // Spaghetti code below until I can figure out a better way of doing this dynamic dynData = customBeatmap.beatmapCustomData; List <object> objectsToKill = Trees.at(dynData, ENVIRONMENTREMOVAL); // seriously what the f**k beat games // GradientBackground permanently yeeted because it looks awful and can ruin multi-colored chroma maps if (objectsToKill == null) { objectsToKill = new List <object>(); } objectsToKill.Add("GradientBackground"); if (objectsToKill != null) { IEnumerable <GameObject> gameObjects = Resources.FindObjectsOfTypeAll <GameObject>(); foreach (string s in objectsToKill.Cast <string>()) { if (s == "TrackLaneRing" || s == "BigTrackLaneRing") { foreach (GameObject n in gameObjects.Where(obj => obj.name.Contains(s))) { if (s == "TrackLaneRing" && n.name.Contains("Big")) { continue; } n.SetActive(false); } } else { foreach (GameObject n in gameObjects .Where(obj => obj.name.Contains(s) && (obj.scene.name?.Contains("Environment") ?? false) && (!obj.scene.name?.Contains("Menu") ?? false))) { n.SetActive(false); } } } } } } // please let me kill legacy LegacyLightHelper.Activate(beatmapData.beatmapEventsData); } }
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); } }