private LSEColorManager(MonoBehaviour mono, BeatmapEventType type) { _lse = mono; _type = type; InitializeSOs(mono, "_lightColor0", ref _lightColor0, ref _lightColor0_Original, ref _mLightColor0); InitializeSOs(mono, "_highlightColor0", ref _lightColor0, ref _lightColor0_Original, ref _mHighlightColor0); InitializeSOs(mono, "_lightColor1", ref _lightColor1, ref _lightColor1_Original, ref _mLightColor1); InitializeSOs(mono, "_highlightColor1", ref _lightColor1, ref _lightColor1_Original, ref _mHighlightColor1); if (mono is LightSwitchEventEffect lse) { InitializeSOs(mono, "_lightColor0Boost", ref _lightColor0Boost, ref _lightColor0Boost_Original, ref _mLightColor0Boost); InitializeSOs(mono, "_highlightColor0Boost", ref _lightColor0Boost, ref _lightColor0Boost_Original, ref _mHighlightColor0Boost); InitializeSOs(mono, "_lightColor1Boost", ref _lightColor1Boost, ref _lightColor1Boost_Original, ref _mLightColor1Boost); InitializeSOs(mono, "_highlightColor1Boost", ref _lightColor1Boost, ref _lightColor1Boost_Original, ref _mHighlightColor1Boost); _supportBoostColor = true; Lights = lse.GetField <LightWithIdManager, LightSwitchEventEffect>("_lightManager").GetField <List <ILightWithId>[], LightWithIdManager>("_lights")[lse.lightsId]; IDictionary <int, List <ILightWithId> > lightsPreGroup = new Dictionary <int, List <ILightWithId> >(); foreach (ILightWithId light in Lights) { if (light is MonoBehaviour monoBehaviour) { int z = Mathf.RoundToInt(monoBehaviour.transform.position.z); if (lightsPreGroup.TryGetValue(z, out List <ILightWithId> list)) { list.Add(light); } else { list = new List <ILightWithId>() { light }; lightsPreGroup.Add(z, list); } } } LightsPropagationGrouped = new ILightWithId[lightsPreGroup.Count][]; int i = 0; foreach (List <ILightWithId> lightList in lightsPreGroup.Values) { if (lightList is null) { continue; } LightsPropagationGrouped[i] = lightList.ToArray(); i++; } } }
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); }
public override void UnregisterLight(ILightWithId light) { manager.UnregisterLight(light); }
private LSEColorManager(MonoBehaviour mono, BeatmapEventType type) { _lse = mono; _type = type; InitializeSOs(mono, "_lightColor0", ref _lightColor0, ref _lightColor0_Original, ref _mLightColor0); InitializeSOs(mono, "_highlightColor0", ref _lightColor0, ref _lightColor0_Original, ref _mHighlightColor0); InitializeSOs(mono, "_lightColor1", ref _lightColor1, ref _lightColor1_Original, ref _mLightColor1); InitializeSOs(mono, "_highlightColor1", ref _lightColor1, ref _lightColor1_Original, ref _mHighlightColor1); if (mono is LightSwitchEventEffect lse) { InitializeSOs(mono, "_lightColor0Boost", ref _lightColor0Boost, ref _lightColor0Boost_Original, ref _mLightColor0Boost); InitializeSOs(mono, "_highlightColor0Boost", ref _lightColor0Boost, ref _lightColor0Boost_Original, ref _mHighlightColor0Boost); InitializeSOs(mono, "_lightColor1Boost", ref _lightColor1Boost, ref _lightColor1Boost_Original, ref _mLightColor1Boost); InitializeSOs(mono, "_highlightColor1Boost", ref _lightColor1Boost, ref _lightColor1Boost_Original, ref _mHighlightColor1Boost); _supportBoostColor = true; LightWithIdManager lightManager = lse.GetField <LightWithIdManager, LightSwitchEventEffect>("_lightManager"); Lights = lightManager.GetField <List <ILightWithId>[], LightWithIdManager>("_lights")[lse.lightsId].ToList(); IDictionary <int, List <ILightWithId> > lightsPreGroup = new Dictionary <int, List <ILightWithId> >(); TrackLaneRingsManager[] managers = Object.FindObjectsOfType <TrackLaneRingsManager>(); foreach (ILightWithId light in Lights) { if (light is MonoBehaviour monoBehaviour) { int z = Mathf.RoundToInt(monoBehaviour.transform.position.z); TrackLaneRing ring = monoBehaviour.GetComponentInParent <TrackLaneRing>(); if (ring != null) { TrackLaneRingsManager mngr = managers.FirstOrDefault(it => it.Rings.IndexOf(ring) >= 0); if (mngr != null) { z = 1000 + mngr.Rings.IndexOf(ring); } } if (lightsPreGroup.TryGetValue(z, out List <ILightWithId> list)) { list.Add(light); } else { list = new List <ILightWithId>() { light }; lightsPreGroup.Add(z, list); } } } LightsPropagationGrouped = new ILightWithId[lightsPreGroup.Count][]; int i = 0; foreach (List <ILightWithId> lightList in lightsPreGroup.Values) { if (lightList is null) { continue; } LightsPropagationGrouped[i] = lightList.ToArray(); i++; } } }
internal LightColorizer(LightSwitchEventEffect lightSwitchEventEffect, BeatmapEventType beatmapEventType) { _lightSwitchEventEffect = lightSwitchEventEffect; _eventType = beatmapEventType; InitializeSO("_lightColor0", 0); InitializeSO("_highlightColor0", 0); InitializeSO("_lightColor1", 1); InitializeSO("_highlightColor1", 1); InitializeSO("_lightColor0Boost", 2); InitializeSO("_highlightColor0Boost", 2); InitializeSO("_lightColor1Boost", 3); InitializeSO("_highlightColor1Boost", 3); // AAAAAA PROPAGATION STUFFF LightWithIdManager lightManager = _lightManagerAccessor(ref lightSwitchEventEffect); Lights = _lightsAccessor(ref lightManager)[lightSwitchEventEffect.lightsId].ToList(); IDictionary <int, List <ILightWithId> > lightsPreGroup = new Dictionary <int, List <ILightWithId> >(); TrackLaneRingsManager[] managers = UnityEngine.Object.FindObjectsOfType <TrackLaneRingsManager>(); foreach (ILightWithId light in Lights) { if (light is MonoBehaviour monoBehaviour) { int z = Mathf.RoundToInt(monoBehaviour.transform.position.z); TrackLaneRing ring = monoBehaviour.GetComponentInParent <TrackLaneRing>(); if (ring != null) { TrackLaneRingsManager mngr = managers.FirstOrDefault(it => it.Rings.IndexOf(ring) >= 0); if (mngr != null) { z = 1000 + mngr.Rings.IndexOf(ring); } } if (lightsPreGroup.TryGetValue(z, out List <ILightWithId> list)) { list.Add(light); } else { list = new List <ILightWithId>() { light }; lightsPreGroup.Add(z, list); } } } LightsPropagationGrouped = new ILightWithId[lightsPreGroup.Count][]; int i = 0; foreach (List <ILightWithId> lightList in lightsPreGroup.Values) { if (lightList is null) { continue; } LightsPropagationGrouped[i] = lightList.ToArray(); i++; } // ok we done Colorizers.Add(beatmapEventType, this); }