internal static void OnActiveSceneChanged(Scene current, Scene _) { if (current.name == "GameCore") { LightColorizer.ClearLSEColorManagers(); ObstacleColorizer.ClearOCColorManagers(); BombColorizer.ClearBNCColorManagers(); NoteColorizer.ClearCNVColorManagers(); SaberColorizer.ClearBSMColorManagers(); } }
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter internal static void OnActiveSceneChanged(Scene current, Scene _) #pragma warning restore SA1313 // Parameter names should begin with lower-case letter { if (current.name == "GameCore") { LightColorizer.ClearLSEColorManagers(); ObstacleColorizer.ClearOCColorManagers(); BombColorizer.ClearBNCColorManagers(); NoteColorizer.ClearCNVColorManagers(); SaberColorizer.ClearBSMColorManagers(); } }
internal static void OnActiveSceneChanged(Scene current, Scene _) { if (current.name == "GameCore") { BombColorizer.Reset(); LightColorizer.Reset(); NoteColorizer.Reset(); ObstacleColorizer.Reset(); SaberColorizer.Reset(); TrackLaneRingsManagerAwake.RingManagers.Clear(); } }
private bool Colorize(ChromaLightSwitchEventEffect __instance, BasicBeatmapEventData beatmapEventData) { if (!TechnicolorConfig.Instance.TechnicolorEnabled) { return(true); } LightColorizer lightColorizer = __instance.Colorizer; bool warm = !ChromaLightSwitchEventEffect.IsColor0(beatmapEventData.value); if (TechnicolorConfig.Instance.TechnicolorLightsGrouping == TechnicolorLightsGrouping.ISOLATED) { foreach (ILightWithId light in lightColorizer.Lights) { Color color = TechnicolorController.GetTechnicolor(warm, beatmapEventData.time + light.GetHashCode(), TechnicolorConfig.Instance.TechnicolorLightsStyle); lightColorizer.Colorize(false, color, color, color, color); __instance.Refresh(true, new[] { light }, beatmapEventData); } return(false); } if (!(TechnicolorController.TechniLightRandom.NextDouble() < TechnicolorConfig.Instance.TechnicolorLightsFrequency)) { return(true); } { Color color = TechnicolorController.GetTechnicolor(warm, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle); switch (TechnicolorConfig.Instance.TechnicolorLightsGrouping) { case TechnicolorLightsGrouping.ISOLATED_GROUP: lightColorizer.Colorize(false, color, color, color, color); break; default: _manager.GlobalColorize(false, color, color, color, color); break; } } return(true); }
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter private static bool Prefix(LightSwitchEventEffect __instance, BeatmapEventData beatmapEventData, BeatmapEventType ____event, LightWithIdManager ____lightManager) #pragma warning restore SA1313 // Parameter names should begin with lower-case letter { if (TechnicolorConfig.Instance.TechnicolorEnabled && beatmapEventData.type == ____event && beatmapEventData.value > 0 && beatmapEventData.value <= 7) { if (TechnicolorConfig.Instance.TechnicolorLightsGrouping == TechnicolorLightsGrouping.ISOLATED) { ____lightManager.SetColorForId(__instance.lightsId, TechnicolorController.GetTechnicolor(beatmapEventData.value > 3, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle)); List <LightWithId>[] lightManagerLights = _lightsWithIdAccessor(ref ____lightManager); List <LightWithId> lights = lightManagerLights[__instance.lightsId]; for (int i = 0; i < lights.Count; i++) { lights[i].ColorWasSet(TechnicolorController.GetTechnicolor(beatmapEventData.value > 3, beatmapEventData.time + lights[i].GetInstanceID(), TechnicolorConfig.Instance.TechnicolorLightsStyle)); } return(false); } else if (TechnicolorController.TechniLightRandom.NextDouble() < TechnicolorConfig.Instance.TechnicolorLightsFrequency) { bool blue = beatmapEventData.value <= 3; switch (TechnicolorConfig.Instance.TechnicolorLightsGrouping) { case TechnicolorLightsGrouping.ISOLATED_GROUP: // ternary operator gore ____event.SetLightingColors( blue ? (Color?)TechnicolorController.GetTechnicolor(false, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle) : null, blue ? null : (Color?)TechnicolorController.GetTechnicolor(true, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle)); break; case TechnicolorLightsGrouping.STANDARD: default: Color?t = TechnicolorController.GetTechnicolor(!blue, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle); LightColorizer.SetAllLightingColors(blue ? null : t, blue ? t : null); break; } } } return(true); }
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); } }
private void RainbowLights() { if (TechnicolorConfig.Instance.TechnicolorLightsGrouping == TechnicolorLightsGrouping.ISOLATED) { LightColorizer.GlobalColorize(false, _gradientLeftColor, _gradientRightColor, _gradientLeftColor, _gradientRightColor); foreach (LightColorizer lightColorizer in LightColorizer.Colorizers.Values) { foreach (ILightWithId light in lightColorizer.Lights) { float seed = Math.Abs(light.GetHashCode()) % 1000; seed *= 0.001f; Color colorLeft = Color.HSVToRGB(Mathf.Repeat((Time.time * TimeMult) + _mismatchSpeedOffset + seed, 1f), 1f, 1f); Color colorRight = Color.HSVToRGB(Mathf.Repeat((Time.time * TimeMult) + seed, 1f), 1f, 1f); lightColorizer.Colorize(new ILightWithId[] { light }, colorLeft, colorRight, colorLeft, colorRight); } } } else { LightColorizer.GlobalColorize(true, _gradientLeftColor, _gradientRightColor, _gradientLeftColor, _gradientRightColor); } }
private static bool Prefix(ChromaLightSwitchEventEffect __instance, BeatmapEventData beatmapEventData, BeatmapEventType ____event) { if (TechnicolorConfig.Instance.TechnicolorEnabled && beatmapEventData.type == ____event && beatmapEventData.value > 0 && beatmapEventData.value <= 7) { bool warm = !__instance.IsColor0(beatmapEventData.value); if (TechnicolorConfig.Instance.TechnicolorLightsGrouping == TechnicolorLightsGrouping.ISOLATED) { LightColorizer lightColorizer = __instance.LightColorizer; foreach (ILightWithId light in lightColorizer.Lights) { Color color = TechnicolorController.GetTechnicolor(warm, beatmapEventData.time + light.GetHashCode(), TechnicolorConfig.Instance.TechnicolorLightsStyle); lightColorizer.Colorize(false, color, color, color, color); __instance.Refresh(true, new ILightWithId[] { light }, beatmapEventData); } return(false); } else if (TechnicolorController.TechniLightRandom.NextDouble() < TechnicolorConfig.Instance.TechnicolorLightsFrequency) { Color color = TechnicolorController.GetTechnicolor(warm, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle); switch (TechnicolorConfig.Instance.TechnicolorLightsGrouping) { case TechnicolorLightsGrouping.ISOLATED_GROUP: ____event.ColorizeLight(false, color, color, color, color); break; case TechnicolorLightsGrouping.STANDARD: default: LightColorizer.GlobalColorize(false, color, color, color, color); break; } } } return(true); }
private static IEnumerator WaitThenStart(ParticleSystemEventEffect instance, BeatmapEventType eventType) { yield return(new WaitForEndOfFrame()); LightColorizer.LSEStart(instance, eventType); }
private void RainbowLights() { LightColorizer.SetAllLightingColors(_gradientLeftColor, _gradientRightColor); LightColorizer.SetAllActiveColors(); }
internal static void InitializeComponents(Transform root, Transform original, List <GameObjectInfo> gameObjectInfos, List <IComponentData> componentDatas, int?lightID) { void GetComponentAndOriginal <T>(Action <T, T> initializeDelegate) { T[] rootComponents = root.GetComponents <T>(); T[] originalComponents = original.GetComponents <T>(); for (int i = 0; i < rootComponents.Length; i++) { initializeDelegate(rootComponents[i], originalComponents[i]); if (Settings.ChromaConfig.Instance !.PrintEnvironmentEnhancementDebug) { Plugin.Logger.Log($"Initialized {typeof(T).Name}"); } } } GetComponentAndOriginal <LightWithIdMonoBehaviour>((rootComponent, originalComponent) => { _lightWithIdMonoBehaviourManagerAccessor(ref rootComponent) = _lightWithIdMonoBehaviourManagerAccessor(ref originalComponent); LightColorizer.RegisterLight(rootComponent, lightID); }); GetComponentAndOriginal <LightWithIds>((rootComponent, originalComponent) => { _lightWithIdsManagerAccessor(ref rootComponent) = _lightWithIdsManagerAccessor(ref originalComponent); LightColorizer.RegisterLight(rootComponent, lightID); }); GetComponentAndOriginal <TrackLaneRing>((rootComponent, originalComponent) => { if (EnvironmentEnhancementManager.RingRotationOffsets.TryGetValue(originalComponent, out Quaternion offset)) { EnvironmentEnhancementManager.RingRotationOffsets.Add(rootComponent, offset); } _ringTransformAccessor(ref rootComponent) = root; _positionOffsetAccessor(ref rootComponent) = _positionOffsetAccessor(ref originalComponent); _posZAccessor(ref rootComponent) = _posZAccessor(ref originalComponent); TrackLaneRingsManager?managerToAdd = null; foreach (TrackLaneRingsManager manager in HarmonyPatches.TrackLaneRingsManagerAwake.RingManagers) { TrackLaneRingsManagerComponentData componentData = componentDatas.OfType <TrackLaneRingsManagerComponentData>().Where(n => n.OldTrackLaneRingsManager == manager).FirstOrDefault(); if (componentData != null) { managerToAdd = componentData.NewTrackLaneRingsManager; } else { TrackLaneRingsManager managerRef = manager; TrackLaneRing[] rings = _ringsAccessor(ref managerRef); if (rings.Contains(originalComponent)) { managerToAdd = manager; } } if (managerToAdd != null) { // ToList() to add and then back ToArray() TrackLaneRing[] rings = _ringsAccessor(ref managerToAdd); List <TrackLaneRing> ringsList = rings?.ToList() ?? new List <TrackLaneRing>(); ringsList.Add(rootComponent); _ringsAccessor(ref managerToAdd) = ringsList.ToArray(); break; } } }); GetComponentAndOriginal <TrackLaneRingsPositionStepEffectSpawner>((rootComponent, originalComponent) => { foreach (TrackLaneRingsManager manager in HarmonyPatches.TrackLaneRingsManagerAwake.RingManagers) { TrackLaneRingsManagerComponentData?componentData = componentDatas.OfType <TrackLaneRingsManagerComponentData>().Where(n => n.OldTrackLaneRingsManager == manager).FirstOrDefault(); if (componentData != null) { _stepSpawnerRingsManagerAccessor(ref rootComponent) = componentData.NewTrackLaneRingsManager !; break; } } }); GetComponentAndOriginal <ChromaRingsRotationEffect>((rootComponent, originalComponent) => { foreach (TrackLaneRingsManager manager in HarmonyPatches.TrackLaneRingsManagerAwake.RingManagers) { TrackLaneRingsManagerComponentData?componentData = componentDatas.OfType <TrackLaneRingsManagerComponentData>().Where(n => n.OldTrackLaneRingsManager == manager).FirstOrDefault(); if (componentData != null) { rootComponent.SetNewRingManager(componentData.NewTrackLaneRingsManager !); break; } } }); GetComponentAndOriginal <TrackLaneRingsRotationEffectSpawner>((rootComponent, originalComponent) => { _rotationEffectSpawnerCallbackControllerAccessor(ref rootComponent) = _rotationEffectSpawnerCallbackControllerAccessor(ref originalComponent); _trackLaneRingsRotationEffectAccessor(ref rootComponent) = rootComponent.GetComponent <ChromaRingsRotationEffect>(); }); GetComponentAndOriginal <Spectrogram>((rootComponent, originalComponent) => _spectrogramDataAccessor(ref rootComponent) = _spectrogramDataAccessor(ref originalComponent)); GetComponentAndOriginal <LightRotationEventEffect>((rootComponent, originalComponent) => _lightCallbackControllerAccessor(ref rootComponent) = _lightCallbackControllerAccessor(ref originalComponent)); GetComponentAndOriginal <LightPairRotationEventEffect>((rootComponent, originalComponent) => { _lightPairCallbackControllerAccessor(ref rootComponent) = _lightPairCallbackControllerAccessor(ref originalComponent); Transform transformL = _transformLAccessor(ref originalComponent); Transform transformR = _transformRAccessor(ref originalComponent); _transformLAccessor(ref rootComponent) = root.GetChild(transformL.GetSiblingIndex()); _transformRAccessor(ref rootComponent) = root.GetChild(transformR.GetSiblingIndex()); // We have to enable the object to tell unity to run Start rootComponent.enabled = true; }); GetComponentAndOriginal <ParticleSystemEventEffect>((rootComponent, originalComponent) => { _particleCallbackControllerAccessor(ref rootComponent) = _particleCallbackControllerAccessor(ref originalComponent); _particleSystemAccessor(ref rootComponent) = root.GetComponent <ParticleSystem>(); rootComponent.enabled = true; }); GetComponentAndOriginal <Mirror>((rootComponent, originalComponent) => { _mirrorRendererAccessor(ref rootComponent) = UnityEngine.Object.Instantiate(_mirrorRendererAccessor(ref originalComponent)); _mirrorMaterialAccessor(ref rootComponent) = UnityEngine.Object.Instantiate(_mirrorMaterialAccessor(ref originalComponent)); }); GameObjectInfo newGameObjectInfo = new GameObjectInfo(root.gameObject); gameObjectInfos.Add(newGameObjectInfo); foreach (Transform transform in root) { int index = transform.GetSiblingIndex(); InitializeComponents(transform, original.GetChild(index), gameObjectInfos, componentDatas, lightID); } }