private IEnumerator GradientRoutine(MapEvent gradientEvent, LightsManager group) { MapEvent.ChromaGradient gradient = gradientEvent._lightGradient; Func <float, float> easingFunc = Easing.byName[gradient.EasingType]; float progress = 0; while ((progress = (atsc.CurrentBeat - gradientEvent._time) / gradient.Duration) < 1) { Color lerped = Color.LerpUnclamped(gradient.StartColor, gradient.EndColor, easingFunc(progress)); if (!SoloAnEventType || gradientEvent._type == SoloEventType) { ChromaCustomColors[group] = lerped; group.ChangeColor(lerped.WithAlpha(1), 0, group.ControllingLights); group.ChangeMultiplierAlpha(lerped.a, group.ControllingLights); } yield return(new WaitForEndOfFrame()); } ChromaCustomColors[group] = gradient.EndColor; group.ChangeColor(ChromaCustomColors[group].WithAlpha(1), 0, group.ControllingLights); group.ChangeMultiplierAlpha(ChromaCustomColors[group].a, group.ControllingLights); }
void HandleLights(LightsManager group, int value, MapEvent e) { Color mainColor = Color.white; Color invertedColor = Color.white; if (group is null) { return; //Why go through extra processing for shit that dont exist } //Check if its a legacy Chroma RGB event if (value >= ColourManager.RGB_INT_OFFSET && Settings.Instance.EmulateChromaLite) { if (ChromaCustomColors.ContainsKey(group)) { ChromaCustomColors[group] = ColourManager.ColourFromInt(value); } else { ChromaCustomColors.Add(group, ColourManager.ColourFromInt(value)); } return; } else if (value == ColourManager.RGB_RESET && Settings.Instance.EmulateChromaLite) { if (ChromaCustomColors.ContainsKey(group)) { ChromaCustomColors.Remove(group); } } if (ChromaGradients.ContainsKey(group)) { MapEvent gradientEvent = ChromaGradients[group].GradientEvent; if (atsc.CurrentBeat >= gradientEvent._lightGradient.Duration + gradientEvent._time || !Settings.Instance.EmulateChromaLite) { StopCoroutine(ChromaGradients[group].Routine); ChromaGradients.Remove(group); ChromaCustomColors.Remove(group); } } if (e._lightGradient != null && Settings.Instance.EmulateChromaLite) { if (ChromaGradients.ContainsKey(group)) { StopCoroutine(ChromaGradients[group].Routine); ChromaGradients.Remove(group); } var gradient = new Gradient { GradientEvent = e, Routine = StartCoroutine(GradientRoutine(e, group)) }; // If the gradient is over already then null is returned due to coroutine never yielding if (gradient.Routine != null) { ChromaGradients.Add(group, gradient); } } //Set initial light values if (value <= 3) { mainColor = ColorBoost ? colors.BlueBoostColor : colors.BlueColor; invertedColor = colors.RedColor; } else if (value <= 7) { mainColor = ColorBoost ? colors.RedBoostColor : colors.RedColor; invertedColor = colors.BlueColor; } //Check if it is a PogU new Chroma event if (e._customData?.HasKey("_color") ?? false && Settings.Instance.EmulateChromaLite) { mainColor = invertedColor = e._customData["_color"]; ChromaCustomColors.Remove(group); if (ChromaGradients.ContainsKey(group)) { StopCoroutine(ChromaGradients[group].Routine); ChromaGradients.Remove(group); } } if (ChromaCustomColors.ContainsKey(group) && Settings.Instance.EmulateChromaLite) { mainColor = invertedColor = ChromaCustomColors[group]; group.ChangeMultiplierAlpha(mainColor.a, group.ControllingLights); } //Check to see if we're soloing any particular event if (SoloAnEventType && e._type != SoloEventType) { mainColor = invertedColor = Color.black.WithAlpha(0); } IEnumerable <LightingEvent> allLights = group.ControllingLights; if (e.IsLightIdEvent && Settings.Instance.EmulateChromaAdvanced) { var lightIDArr = e.LightId; allLights = group.ControllingLights.FindAll(x => lightIDArr.Contains(x.lightID)); // Temporarily(?) commented as Debug.LogWarning is expensive //if (allLights.Count() < lightIDArr.Length) //{ // Debug.LogWarning($"Missing lights for {lightIDArr} in event type {e._type}!"); //} } foreach (var light in allLights) { var color = light.UseInvertedPlatformColors ? invertedColor : mainColor; switch (value) { case MapEvent.LIGHT_VALUE_OFF: light.UpdateTargetAlpha(0, 0); light.UpdateMultiplyAlpha(1); break; case MapEvent.LIGHT_VALUE_BLUE_ON: case MapEvent.LIGHT_VALUE_RED_ON: light.UpdateMultiplyAlpha(color.a); light.UpdateTargetColor(color.Multiply(LightsManager.HDR_Intensity), 0); light.UpdateTargetAlpha(1, 0); break; case MapEvent.LIGHT_VALUE_BLUE_FLASH: case MapEvent.LIGHT_VALUE_RED_FLASH: light.UpdateTargetAlpha(1, 0); light.UpdateMultiplyAlpha(color.a); light.UpdateTargetColor(color.Multiply(LightsManager.HDR_Flash_Intensity), 0); light.UpdateTargetColor(color.Multiply(LightsManager.HDR_Intensity), LightsManager.FadeTime); break; case MapEvent.LIGHT_VALUE_BLUE_FADE: case MapEvent.LIGHT_VALUE_RED_FADE: light.UpdateTargetAlpha(1, 0); light.UpdateMultiplyAlpha(color.a); light.UpdateTargetColor(color.Multiply(LightsManager.HDR_Flash_Intensity), 0); if (light.CanBeTurnedOff) { light.UpdateTargetAlpha(0, LightsManager.FadeTime); light.UpdateTargetColor(Color.black, LightsManager.FadeTime); } else { light.UpdateTargetColor(color.Multiply(LightsManager.HDR_Intensity), LightsManager.FadeTime); } break; } } group.SetValue(value); }