private IEnumerator GenerateChromaStrobe(int type, float endTime, float startTime, int precision, float distanceOffset, List<MapEvent> containersBetween) { Dictionary<float, Color> chromaColors = new Dictionary<float, Color>(); foreach (MapEvent e in containersBetween) { if (e is null) continue; if (e == containersBetween.First()) chromaColors.Add(startTime - distanceOffset, ColourManager.ColourFromInt(e._value)); if (!chromaColors.ContainsKey(e._time)) chromaColors.Add(e._time, ColourManager.ColourFromInt(e._value)); } float distanceInBeats = endTime - startTime; while (distanceInBeats >= 0) { yield return new WaitForEndOfFrame(); float time = endTime - distanceInBeats; float latestPastChromaTime = FindLastChromaTime(time, chromaColors, out float nextChromaTime); int color = ColourManager.ColourToInt(chromaColors.First().Value); if (nextChromaTime != -1 && latestPastChromaTime != -1) { Color from = chromaColors[latestPastChromaTime]; Color to = chromaColors[nextChromaTime]; float distanceBetweenTimes = nextChromaTime - latestPastChromaTime; color = ColourManager.ColourToInt(Color.Lerp(from, to, (time - latestPastChromaTime) / distanceBetweenTimes)); } else if (time >= chromaColors.Last().Key) color = ColourManager.ColourToInt(chromaColors.Last().Value); MapEvent chromaData = new MapEvent(time - distanceOffset, type, color); BeatmapEventContainer chromaContainer = eventsContainer.SpawnObject(chromaData, out _) as BeatmapEventContainer; generatedObjects.Add(chromaContainer); distanceInBeats -= 1 / (float)precision; } }
private void EventPassed(bool initial, int index, BeatmapObject data) { if (!readyToGo || !IsActive) { return; } MapEvent e = data as MapEvent; if (!e.IsUtilityEvent()) //Filter out Ring Spin, Ring Zoom, and Laser Speeds { List <OscMessage> messages = new List <OscMessage>(); //Collection of messages to mass send OscMessage mainMessage = new OscMessage(); mainMessage.address = $"/pb/{e._type}/{e._value}"; messages.Add(mainMessage); if (e._value >= ColourManager.RGB_INT_OFFSET) //If we have a Chroma event in our hands... { Color color = ColourManager.ColourFromInt(e._value); //Grab Chroma color from data OscMessage r = new OscMessage(); OscMessage g = new OscMessage(); //We hvae to make a new message for each RGB value, yay! OscMessage b = new OscMessage(); r.address = $"/exec/\"R\"/{color.r}"; //Color values are floats from 0-1 g.address = $"/exec/\"G\"/{color.g}"; b.address = $"/exec/\"B\"/{color.b}"; messages.AddRange(new List <OscMessage>() { r, g, b }); //Smack these guys into our messages list } foreach (OscMessage message in messages) { osc?.Send(message); //Send those guys down the pipe. } } }
public static void Load() { if (!File.Exists(Application.persistentDataPath + "/ChromaColors.json")) { Debug.Log("Chroma Colors file doesn't exist! Skipping loading..."); return; } try { ColorPresetManager.Presets.Clear(); ColorPresetList presetList = new ColorPresetList("default"); using (StreamReader reader = new StreamReader(Application.persistentDataPath + "/ChromaColors.json")) { JSONNode mainNode = JSON.Parse(reader.ReadToEnd()); foreach (JSONNode n in mainNode["colors"].AsArray) { Color color = n.IsObject ? n.ReadColor(Color.black) : ColourManager.ColourFromInt(n.AsInt); presetList.Colors.Add(color); } } Debug.Log($"Loaded {presetList.Colors.Count} colors!"); ColorPresetManager.Presets.Add("default", presetList); } catch (Exception e) { Debug.LogError(e); } }
private void EventPassed(bool initial, int index, BeatmapObject data) { if (!readyToGo || !IsActive) { return; } MapEvent e = data as MapEvent; if (!e.IsUtilityEvent()) { OscMessage message = new OscMessage(); message.address = $"/CM_EventType{e._type}"; if (e._value >= ColourManager.RGB_INT_OFFSET) { Color color = ColourManager.ColourFromInt(e._value); message.values.Add(color.r); message.values.Add(color.g); message.values.Add(color.b); } else { message.values.Add(e._value); } osc?.Send(message); } }
private void SelectedObject(BeatmapObjectContainer obj) { if (!(obj is BeatmapEventContainer e) || !dropdown.Visible || !Settings.Instance.PickColorFromChromaEvents) { return; } if (e.eventData._value >= ColourManager.RGB_INT_OFFSET) { picker.CurrentColor = ColourManager.ColourFromInt(e.eventData._value); } else { BeatmapEventContainer attached = FindAttachedChromaEvent(e); if (attached) { picker.CurrentColor = ColourManager.ColourFromInt(attached.eventData._value); } } }
private IEnumerator ConvertFromLegacy() { yield return(PersistentUI.Instance.FadeInLoadingScreen()); var events = BeatmapObjectContainerCollection.GetCollectionForType <EventsContainer>(BeatmapObject.Type.EVENT); Dictionary <int, Color?> chromaColorsByEventType = new Dictionary <int, Color?>(); foreach (var obj in events.UnsortedObjects.ToArray()) { MapEvent e = obj as MapEvent; if (chromaColorsByEventType.TryGetValue(e._type, out Color? chroma)) { if (e._value >= ColourManager.RGB_INT_OFFSET) { chromaColorsByEventType[e._type] = ColourManager.ColourFromInt(e._value); events.DeleteObject(e, false, false); continue; } else if (e._value == ColourManager.RGB_RESET) { chromaColorsByEventType[e._type] = null; events.DeleteObject(e, false, false); continue; } if (chroma != null && e._value != MapEvent.LIGHT_VALUE_OFF) { e.GetOrCreateCustomData()["_color"] = chroma; } } else { chromaColorsByEventType.Add(e._type, null); } } events.RefreshPool(true); yield return(PersistentUI.Instance.FadeOutLoadingScreen()); }
private void SelectedObject(BeatmapObject obj) { if (!Settings.Instance.PickColorFromChromaEvents || !dropdown.Visible) { return; } if (obj._customData?.HasKey("_color") ?? false) { picker.CurrentColor = obj._customData["_color"]; } if (!(obj is MapEvent e)) { return; } if (e._value >= ColourManager.RGB_INT_OFFSET) { picker.CurrentColor = ColourManager.ColourFromInt(e._value); } else if (e._lightGradient != null) { picker.CurrentColor = e._lightGradient.StartColor; } }
public void SetEventAppearance(BeatmapEventContainer e) { Color color = Color.white; foreach (TextMeshProUGUI t in e.GetComponentsInChildren <TextMeshProUGUI>()) { Destroy(t.transform.parent.gameObject); } if (e.eventData._type == MapEvent.EVENT_TYPE_LEFT_LASERS_SPEED || e.eventData._type == MapEvent.EVENT_TYPE_RIGHT_LASERS_SPEED) { GameObject instantiate = Instantiate(LaserSpeedPrefab, e.transform); instantiate.transform.localPosition = new Vector3(0, 0.25f, 0); instantiate.GetComponentInChildren <TextMeshProUGUI>().text = e.eventData._value.ToString(); instantiate.GetComponentInChildren <TextMeshProUGUI>().rectTransform.localScale = Vector3.one * (2f / 3); } if (e.eventData.IsUtilityEvent()) { if (e.eventData._type == MapEvent.EVENT_TYPE_RINGS_ROTATE || e.eventData._type == MapEvent.EVENT_TYPE_RINGS_ZOOM) { e.ChangeColor(RingEventsColor); } else { e.ChangeColor(OtherColor); } e.UpdateOffset(Vector3.zero); return; } else { if (e.eventData._value >= ColourManager.RGB_INT_OFFSET) { color = ColourManager.ColourFromInt(e.eventData._value); e.UpdateAlpha(0.75f); } else if (e.eventData._value <= 3) { if (BeatSaberSongContainer.Instance.difficultyData.envColorRight != BeatSaberSong.DEFAULT_RIGHTCOLOR) { color = BeatSaberSongContainer.Instance.difficultyData.envColorRight; } else { color = BlueColor; } } else if (e.eventData._value <= 7) { if (BeatSaberSongContainer.Instance.difficultyData.envColorLeft != BeatSaberSong.DEFAULT_LEFTCOLOR) { color = BeatSaberSongContainer.Instance.difficultyData.envColorLeft; } else { color = RedColor; } } } e.ChangeColor(color); switch (e.eventData._value) { case MapEvent.LIGHT_VALUE_OFF: e.ChangeColor(OffColor); e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_FLASH: e.UpdateOffset(FlashShaderOffset); break; case MapEvent.LIGHT_VALUE_BLUE_FADE: e.UpdateOffset(FadeShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_FLASH: e.UpdateOffset(FlashShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_FADE: e.UpdateOffset(FadeShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_ON: e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_ON: e.UpdateOffset(Vector3.zero); break; } }
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) { StopCoroutine(ChromaGradients[group].Routine); ChromaGradients.Remove(group); ChromaCustomColors.Remove(group); } } if (e._lightGradient != null) { if (ChromaGradients.ContainsKey(group)) { StopCoroutine(ChromaGradients[group].Routine); ChromaGradients.Remove(group); } Gradient gradient = new Gradient(); gradient.GradientEvent = e; gradient.Routine = StartCoroutine(GradientRoutine(e, group)); ChromaGradients.Add(group, gradient); } //Set initial light values if (value <= 3) { mainColor = BlueColor; invertedColor = RedColor; } else if (value <= 7) { mainColor = RedColor; invertedColor = BlueColor; } //Check if it is a PogU new Chroma event if (e._customData?.HasKey("_color") ?? false) { mainColor = invertedColor = e._customData["_color"]; ChromaCustomColors.Remove(group); if (ChromaGradients.ContainsKey(group)) { StopCoroutine(ChromaGradients[group].Routine); ChromaGradients.Remove(group); } } if (ChromaCustomColors.ContainsKey(group)) { mainColor = invertedColor = ChromaCustomColors[group]; } //Check to see if we're soloing any particular event if (SoloAnEventType && e._type != SoloEventType) { mainColor = invertedColor = Color.black; } IEnumerable <LightingEvent> allLights = group.ControllingLights; if (e._customData?.HasKey("_propID") ?? false && Settings.Instance.EmulateChromaAdvanced) { int propID = e._customData["_propID"].AsInt; allLights = group.LightsGroupedByZ[propID]; } IEnumerable <LightingEvent> lights = allLights.Where(x => !x.UseInvertedPlatformColors); IEnumerable <LightingEvent> invertedLights = allLights.Where(x => x.UseInvertedPlatformColors); if (value == MapEvent.LIGHT_VALUE_OFF) { group.ChangeAlpha(0, 0, allLights); } else if (value == MapEvent.LIGHT_VALUE_BLUE_ON || value == MapEvent.LIGHT_VALUE_RED_ON) { group.ChangeColor(mainColor, 0, lights); group.ChangeColor(invertedColor, 0, invertedLights); group.ChangeAlpha(1, 0, lights); group.ChangeAlpha(1, 0, invertedLights); } else if (value == MapEvent.LIGHT_VALUE_BLUE_FLASH || value == MapEvent.LIGHT_VALUE_RED_FLASH) { group.Flash(mainColor, lights); group.Flash(invertedColor, invertedLights); } else if (value == MapEvent.LIGHT_VALUE_BLUE_FADE || value == MapEvent.LIGHT_VALUE_RED_FADE) { group.Fade(mainColor, lights); group.Fade(invertedColor, invertedLights); } }
public void SetEventAppearance(BeatmapEventContainer e) { Color color = Color.white; if (e.GetComponentInChildren <TextMeshProUGUI>()) { Destroy(e.GetComponentInChildren <TextMeshProUGUI>().transform.parent.gameObject); } if (e.eventData._type == MapEvent.EVENT_TYPE_LEFT_LASERS_SPEED || e.eventData._type == MapEvent.EVENT_TYPE_RIGHT_LASERS_SPEED) { GameObject instantiate = Instantiate(LaserSpeedPrefab, e.transform); instantiate.transform.localPosition = new Vector3(0, 0.25f, 0); instantiate.GetComponentInChildren <TextMeshProUGUI>().text = e.eventData._value.ToString(); instantiate.GetComponentInChildren <TextMeshProUGUI>().rectTransform.localScale = new Vector3((2f / 3), (2f / 3), (2f / 3)); } if (e.eventData.IsUtilityEvent()) { e.ChangeColor(OtherColor); e.UpdateOffset(Vector3.zero); return; } else { if (e.eventData._value >= ColourManager.RGB_INT_OFFSET) { color = ColourManager.ColourFromInt(e.eventData._value); e.UpdateAlpha(0.75f); } else { if (e.eventData._value <= 3) { color = BlueColor; } else if (e.eventData._value <= 7) { color = RedColor; } else if (e.eventData._value >= ColourManager.RGB_INT_OFFSET) // not quite sure why this is here, but ill leave it { color = ColourManager.ColourFromInt(e.eventData._value); e.UpdateAlpha(0.75f); } } } e.ChangeColor(color); switch (e.eventData._value) { case MapEvent.LIGHT_VALUE_OFF: e.ChangeColor(OffColor); e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_FLASH: e.UpdateOffset(FlashShaderOffset); break; case MapEvent.LIGHT_VALUE_BLUE_FADE: e.UpdateOffset(FadeShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_FLASH: e.UpdateOffset(FlashShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_FADE: e.UpdateOffset(FadeShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_ON: e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_ON: e.UpdateOffset(Vector3.zero); break; } }
public void SetEventAppearance(BeatmapEventContainer e, bool final = true, bool boost = false) { Color color = Color.white; e.UpdateOffset(Vector3.zero); e.UpdateAlpha(final ? 1.0f : 0.6f); e.UpdateScale(final ? 0.75f : 0.6f); e.ChangeSpotlightSize(1f); if (e.eventData.IsRotationEvent || e.eventData.IsLaserSpeedEvent) { if (e.eventData.IsRotationEvent) { int?rotation = e.eventData.GetRotationDegreeFromValue(); e.UpdateTextDisplay(true, rotation != null ? $"{rotation}°" : "Invalid Rotation"); } else if (e.eventData.IsLaserSpeedEvent) { float speed = e.eventData._value; if (e.eventData._customData != null && e.eventData._customData.HasKey("_preciseSpeed")) { speed = e.eventData._customData["_preciseSpeed"].AsFloat; } e.UpdateTextDisplay(true, speed.ToString()); } } else { e.UpdateTextDisplay(false); } if (e.eventData.IsUtilityEvent) { e.UsePyramidModel = false; if (e.eventData.IsRingEvent) { e.ChangeColor(RingEventsColor); e.ChangeBaseColor(RingEventsColor); } else if (e.eventData._type == MapEvent.EVENT_TYPE_BOOST_LIGHTS) { if (e.eventData._value == 1) { e.ChangeBaseColor(RedBoostColor); e.ChangeColor(BlueBoostColor); } else { e.ChangeBaseColor(RedColor); e.ChangeColor(BlueColor); } e.UpdateOffset(Vector3.forward * 1.05f); e.ChangeFadeSize(cubeBoostEventFadeSize); return; } else { e.ChangeColor(OtherColor); e.ChangeBaseColor(OtherColor); } e.UpdateOffset(Vector3.zero); e.UpdateGradientRendering(); return; } else { if (e.eventData._value >= ColourManager.RGB_INT_OFFSET) { color = ColourManager.ColourFromInt(e.eventData._value); e.UpdateAlpha(final ? 0.9f : 0.6f); } else if (e.eventData._value <= 3) { color = boost ? BlueBoostColor : BlueColor; } else if (e.eventData._value <= 7 && e.eventData._value >= 5) { color = boost ? RedBoostColor : RedColor; } else if (e.eventData._value == 4) { color = OffColor; } if (e.eventData._customData?["_color"] != null && e.eventData._value > 0) { color = e.eventData._customData["_color"]; } } e.UsePyramidModel = Settings.Instance.PyramidEventModels; e.ChangeColor(color); e.ChangeBaseColor(Color.black); switch (e.eventData._value) { case MapEvent.LIGHT_VALUE_OFF: e.ChangeColor(OffColor); e.ChangeBaseColor(OffColor); e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_ON: e.UpdateOffset(Vector3.zero); e.ChangeBaseColor(color); break; case MapEvent.LIGHT_VALUE_BLUE_FLASH: e.UpdateOffset(e.UsePyramidModel ? pyramidFlashShaderOffset : cubeFlashShaderOffset); break; case MapEvent.LIGHT_VALUE_BLUE_FADE: e.UpdateOffset(e.UsePyramidModel ? pyramidFadeShaderOffset : cubeFadeShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_ON: e.UpdateOffset(Vector3.zero); e.ChangeBaseColor(color); break; case MapEvent.LIGHT_VALUE_RED_FLASH: e.UpdateOffset(e.UsePyramidModel ? pyramidFlashShaderOffset : cubeFlashShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_FADE: e.UpdateOffset(e.UsePyramidModel ? pyramidFadeShaderOffset : cubeFadeShaderOffset); break; } e.ChangeFadeSize(e.UsePyramidModel ? pyramidDefaultFadeSize : cubeDefaultFadeSize); if (Settings.Instance.VisualizeChromaGradients) { e.UpdateGradientRendering(); } }
// Colour Events // - Stores two colour values, A and B // - These events have two purposes // - Used to recolour any lighting events placed after them, unless... // - if used immediately after a "data event", their values will influence the data event. // 1,900,000,001 = 1900000001 = A/B // 1,900,000,002 = 1900000002 = AltA/AltB // 1,900,000,003 = 1900000003 = White/Half White // 1,900,000,004 = 1900000004 = Technicolor/Technicolor // 1,900,000,005 = 1900000005 = RandomColor/RandomColor // Data Events // - Require Colour Events before them // - Remember Unity colour uses 0-1, not 0-255 // 1,950,000,001 = 1950000001 = Note Scale Event - Scales all future spawned notes by (A.red * 1.5f) // 1,950,000,002 = 1950000002 = Health Event - Alters the player's health by ((A.red - 0.5f) * 2) // 1,950,000,003 = 1950000003 = Rotate Event - Rotates the player on all three axes by (A.red * 360 on x axis, A.green * 360 on y axis, A.blue * 360 on z axis) // 1,950,000,004 = 1950000004 = Ambient Light Event - Immediately changes the colour of ambient lights to (A) // 1,950,000,005 = 1950000005 = Barrier Colour Event - Changes all future spawned barrier colours to (A) // > 2,000,000,000 = >2000000000 = RGB (see ColourManager.ColourFromInt) public static ChromaEvent ApplyCustomEvent(BeatmapEventData bev, ref ChromaColourEvent unfilledColourEvent) { //ChromaLogger.Log("Checking BEV ||| " + bev.time + "s : " + bev.value + "v"); Color a, b; if (bev.value >= ColourManager.RGB_INT_OFFSET) // > 2,000,000,000 = >2000000000 = RGB (see ColourManager.ColourFromInt) { a = ColourManager.ColourFromInt(bev.value); b = a; if (FillColourEvent(bev, ref unfilledColourEvent, a)) { return(unfilledColourEvent); } } else { switch (bev.value) { case ChromaLightEvent.CHROMA_LIGHT_OFFSET + 1: // 1,900,000,001 = 1900000001 = A/B a = ColourManager.LightA; b = ColourManager.LightB; break; case ChromaLightEvent.CHROMA_LIGHT_OFFSET + 2: // 1,900,000,002 = 1900000002 = AltA/AltB a = ColourManager.LightAltA; b = ColourManager.LightAltB; break; case ChromaLightEvent.CHROMA_LIGHT_OFFSET + 3: // 1,900,000,003 = 1900000003 = White/Half White a = ColourManager.LightWhite; b = ColourManager.LightGrey; break; case ChromaLightEvent.CHROMA_LIGHT_OFFSET + 4: // 1,900,000,004 = 1900000004 = Technicolor/Technicolor a = ColourManager.GetTechnicolour(true, bev.time, ColourManager.TechnicolourStyle.WARM_COLD); b = ColourManager.GetTechnicolour(false, bev.time, ColourManager.TechnicolourStyle.WARM_COLD); break; case ChromaLightEvent.CHROMA_LIGHT_OFFSET + 5: // 1,900,000,005 = 1900000005 = RandomColor/RandomColor a = UnityEngine.Random.ColorHSV(); a.a = 1; b = UnityEngine.Random.ColorHSV(); b.a = 1; break; /* * */ case ChromaEvent.CHROMA_EVENT_SCALE: //1,950,000,001 = 1950000001 = Note Scale Event unfilledColourEvent = new ChromaNoteScaleEvent(bev); return(null); case ChromaEvent.CHROMA_EVENT_HEALTH: //1,950,000,002 = 1950000002 = Health Event unfilledColourEvent = new ChromaHealthEvent(bev); return(null); case ChromaEvent.CHROMA_EVENT_ROTATE: //1,950,000,003 = 1950000003 = Rotate Event unfilledColourEvent = new ChromaRotateEvent(bev); return(null); case ChromaEvent.CHROMA_EVENT_AMBIENT_LIGHT: //1,950,000,004 = 1950000004 = Ambient Light Event unfilledColourEvent = new ChromaAmbientLightEvent(bev); return(null); case ChromaEvent.CHROMA_EVENT_BARRIER_COLOUR: //1,950,000,005 = 1950000005 = Barrier Colour Event unfilledColourEvent = new ChromaBarrierColourEvent(bev); return(null); case ChromaEvent.CHROMA_EVENT_RING_SPEED_MULT: //1,950,000,006 = 1950000006 = Ring Speed Event unfilledColourEvent = new ChromaRingSpeedEvent(bev); return(null); case ChromaEvent.CHROMA_EVENT_RING_PROPAGATION_MULT: //1,950,000,007 = 1950000007 = Ring Prop Event unfilledColourEvent = new ChromaRingPropagationEvent(bev); return(null); case ChromaEvent.CHROMA_EVENT_RING_STEP_MULT: //1,950,000,008 = 1950000008 = Ring Step Event unfilledColourEvent = new ChromaRingStepEvent(bev); return(null); default: return(null); } if (FillColourEvent(bev, ref unfilledColourEvent, a, b)) { return(unfilledColourEvent); } } if (unfilledColourEvent != null) { unfilledColourEvent = null; } return(ChromaEvent.SetChromaEvent(bev, new ChromaLightEvent(bev, a, b))); }
private IEnumerator GenerateOneStrobe(int type, int RepeatingValue, float endTime, float startTime, List <BeatmapObjectContainer> containersBetween) { bool alternateValue = false; float distanceInBeats = endTime - startTime; float originalDistance = distanceInBeats; int alternateValueType = MapEvent.LIGHT_VALUE_OFF; if (RepeatingValue == MapEvent.LIGHT_VALUE_RED_FADE || RepeatingValue == MapEvent.LIGHT_VALUE_RED_FLASH || RepeatingValue == MapEvent.LIGHT_VALUE_RED_ON) { alternateValueType = MapEvent.LIGHT_VALUE_RED_ON; } else { alternateValueType = MapEvent.LIGHT_VALUE_BLUE_ON; } Dictionary <float, Color> chromaColors = new Dictionary <float, Color>(); Dictionary <float, int> eventValues = new Dictionary <float, int>(); eventValues.Add(startTime, RepeatingValue); foreach (BeatmapObjectContainer container in containersBetween) { BeatmapEventContainer e = (container as BeatmapEventContainer); if (container is null || e is null) { continue; } if (e.eventData._value < ColourManager.RGB_INT_OFFSET) { if (e.eventData._value != eventValues.Last().Value) { if (!eventValues.ContainsKey(e.eventData._time)) { eventValues.Add(e.eventData._time, e.eventData._value); } } } else { if (!chromaColors.ContainsKey(e.eventData._time)) { chromaColors.Add(e.eventData._time, ColourManager.ColourFromInt(e.eventData._value)); } } } while (distanceInBeats >= (1 / (float)atsc.gridMeasureSnapping)) { yield return(new WaitForEndOfFrame()); distanceInBeats -= (1 / (float)atsc.gridMeasureSnapping); float latestPastValueTime = eventValues.Keys.Aggregate((x, y) => x >= (endTime - distanceInBeats) && y <= (endTime - distanceInBeats) ? x : startTime); int value = alternateValue ? alternateValueType : eventValues[latestPastValueTime]; if (distanceInBeats == 0) { value = eventValues.Last().Value; } MapEvent data = new MapEvent(endTime - distanceInBeats, type, value); if (alternateValueType != MapEvent.LIGHT_VALUE_OFF && eventValues[latestPastValueTime] != MapEvent.LIGHT_VALUE_OFF) { BeatmapEventContainer eventContainer = eventsContainer.SpawnObject(data) as BeatmapEventContainer; generatedObjects.Add(eventContainer); } if (chromaColors.Count >= 2 && distanceInBeats >= (1 / (float)atsc.gridMeasureSnapping)) { float nextChromaTime; float latestPastChromaTime = FindLastChromaTime(data._time, chromaColors, out nextChromaTime); int color = -1; if (nextChromaTime != -1 && latestPastChromaTime != -1) { Color from = chromaColors[latestPastChromaTime]; Color to = chromaColors[nextChromaTime]; float distanceBetweenTimes = nextChromaTime - latestPastChromaTime; color = ColourManager.ColourToInt(Color.Lerp(from, to, (data._time - latestPastChromaTime) / (distanceBetweenTimes))); } else if (latestPastChromaTime != -1 && nextChromaTime == -1) { color = ColourManager.ColourToInt(chromaColors[latestPastChromaTime]); } else { continue; } MapEvent chromaData = new MapEvent(data._time - (1f / 64f), type, color); BeatmapEventContainer chromaContainer = eventsContainer.SpawnObject(chromaData) as BeatmapEventContainer; generatedObjects.Add(chromaContainer); } alternateValue = !alternateValue; } }
void HandleLights(LightsManager group, int value, MapEvent e) { Color color = 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) { if (ChromaCustomColors.ContainsKey(group)) { ChromaCustomColors[group] = ColourManager.ColourFromInt(value); } else { ChromaCustomColors.Add(group, ColourManager.ColourFromInt(value)); } return; } else if (value == ColourManager.RGB_RESET) { if (ChromaCustomColors.TryGetValue(group, out Color _)) { ChromaCustomColors.Remove(group); } } //Set initial light values if (value <= 3) { color = BlueColor; } else if (value <= 7) { color = RedColor; } if (ChromaCustomColors.ContainsKey(group)) { color = ChromaCustomColors[group]; } //Grab big ring propogation if any TrackLaneRing ring = null; if (e._type == MapEvent.EVENT_TYPE_RING_LIGHTS && e._customData?["_propID"] != null) { if (BigRingManager is null) { return; } int propID = e._customData["_propID"].AsInt; if (propID < BigRingManager.rings.Count()) { ring = BigRingManager.rings[propID]; } } if (value == MapEvent.LIGHT_VALUE_OFF) { group.ChangeAlpha(0, 0, ring); } else if (value == MapEvent.LIGHT_VALUE_BLUE_ON || value == MapEvent.LIGHT_VALUE_RED_ON) { group.ChangeColor(color, 0, ring); group.ChangeAlpha(1, 0, ring); } else if (value == MapEvent.LIGHT_VALUE_BLUE_FLASH || value == MapEvent.LIGHT_VALUE_RED_FLASH) { group.Flash(color, ring); } else if (value == MapEvent.LIGHT_VALUE_BLUE_FADE || value == MapEvent.LIGHT_VALUE_RED_FADE) { group.Fade(color, ring); } }
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); }
public void SetEventAppearance(BeatmapEventContainer e, bool final = true) { Color color = Color.white; e.UpdateAlpha(final ? 1.0f : 0.6f); e.UpdateScale(final ? 0.75f : 0.6f); if (e.eventData.IsRotationEvent || e.eventData.IsLaserSpeedEvent) { if (e.eventData.IsRotationEvent) { int?rotation = e.eventData.GetRotationDegreeFromValue(); e.UpdateTextDisplay(true, rotation != null ? $"{rotation}°" : "Invalid Rotation"); } else { e.UpdateTextDisplay(true, e.eventData._value.ToString()); } } else { e.UpdateTextDisplay(false); } if (e.eventData.IsUtilityEvent) { if (e.eventData.IsRingEvent) { e.ChangeColor(RingEventsColor); } else { e.ChangeColor(OtherColor); } e.UpdateOffset(Vector3.zero); return; } else { if (e.eventData._value >= ColourManager.RGB_INT_OFFSET) { color = ColourManager.ColourFromInt(e.eventData._value); e.UpdateAlpha(final ? 0.9f : 0.6f); } else if (e.eventData._value <= 3) { if (BeatSaberSongContainer.Instance.difficultyData.envColorRight != BeatSaberSong.DEFAULT_RIGHTCOLOR) { color = BeatSaberSongContainer.Instance.difficultyData.envColorRight; } else { color = BlueColor; } } else if (e.eventData._value <= 7 && e.eventData._value >= 5) { if (BeatSaberSongContainer.Instance.difficultyData.envColorLeft != BeatSaberSong.DEFAULT_LEFTCOLOR) { color = BeatSaberSongContainer.Instance.difficultyData.envColorLeft; } else { color = RedColor; } } else if (e.eventData._value == 4) { color = OffColor; } } e.ChangeColor(color); switch (e.eventData._value) { case MapEvent.LIGHT_VALUE_OFF: e.ChangeColor(OffColor); e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_ON: e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_FLASH: e.UpdateOffset(FlashShaderOffset); break; case MapEvent.LIGHT_VALUE_BLUE_FADE: e.UpdateOffset(FadeShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_ON: e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_RED_FLASH: e.UpdateOffset(FlashShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_FADE: e.UpdateOffset(FadeShaderOffset); break; } }
public void EventPassed(BeatmapObject data) { if (!readyToGo) { return; } MapEvent e = data as MapEvent; if (!e.IsUtilityEvent) //Filter out Ring Spin, Ring Zoom, and Laser Speeds { List <OscMessage> messages = new List <OscMessage>(); //Collection of messages to mass send OscMessage mainMessage = new OscMessage(); mainMessage.address = $"/pb/{e._type}/{e._value}"; if (config.Chroma != 1) { if (data._customData.HasKey("_color")) { var colorPart = data._customData["_color"].AsArray; byte r = (byte)(colorPart[0].AsFloat * 255); byte g = (byte)(colorPart[1].AsFloat * 255); byte b = (byte)(colorPart[2].AsFloat * 255); mainMessage.values.Add(r << 16 | g << 8 | b); } else if (data._customData.HasKey("_lightGradient") && data._customData["_lightGradient"].HasKey("_startColor")) { var colorPart = data._customData["_lightGradient"]["_startColor"].AsArray; byte r = (byte)(colorPart[0].AsFloat * 255); byte g = (byte)(colorPart[1].AsFloat * 255); byte b = (byte)(colorPart[2].AsFloat * 255); mainMessage.values.Add(r << 16 | g << 8 | b); } else if (e._value >= ColourManager.RGB_INT_OFFSET) { mainMessage.values.Add(e._value - ColourManager.RGB_INT_OFFSET); } messages.Add(mainMessage); } else { messages.Add(mainMessage); if (e._value >= ColourManager.RGB_INT_OFFSET) //If we have a Chroma event in our hands... { Color color = ColourManager.ColourFromInt(e._value); //Grab Chroma color from data OscMessage r = new OscMessage(); OscMessage g = new OscMessage(); //We hvae to make a new message for each RGB value, yay! OscMessage b = new OscMessage(); r.address = $"/exec/\"R\"/{color.r}"; //Color values are floats from 0-1 g.address = $"/exec/\"G\"/{color.g}"; b.address = $"/exec/\"B\"/{color.b}"; messages.AddRange(new List <OscMessage>() { r, g, b }); //Smack these guys into our messages list } } foreach (OscMessage message in messages) { osc?.Send(message); //Send those guys down the pipe. } } }
public void SetEventAppearance(BeatmapEventContainer e, bool final = true) { Color color = Color.white; e.UpdateAlpha(final ? 1.0f : 0.6f); e.UpdateScale(final ? 0.75f : 0.6f); foreach (TextMeshProUGUI t in e.GetComponentsInChildren <TextMeshProUGUI>()) { Destroy(t.transform.parent.gameObject); } if (e.eventData.IsRotationEvent || e.eventData.IsLaserSpeedEvent) { GameObject instantiate = Instantiate(LaserSpeedPrefab, e.transform); Canvas canvas = instantiate.GetComponentInChildren <Canvas>(); canvas.sortingLayerName = "Default"; instantiate.transform.localPosition = new Vector3(0, 0.25f, 0); TextMeshProUGUI text = instantiate.GetComponentInChildren <TextMeshProUGUI>(); if (e.eventData.IsRotationEvent) { int?rotation = e.eventData.GetRotationDegreeFromValue(); text.text = rotation != null ? $"{rotation}°" : "Invalid Rotation"; } else { text.text = e.eventData._value.ToString(); } text.rectTransform.localScale = Vector3.one * (2f / 3); } if (e.eventData.IsUtilityEvent) { if (e.eventData.IsRingEvent) { e.ChangeColor(RingEventsColor); } else { e.ChangeColor(OtherColor); } e.UpdateOffset(Vector3.zero); return; } else { if (e.eventData._value >= ColourManager.RGB_INT_OFFSET) { color = ColourManager.ColourFromInt(e.eventData._value); e.UpdateAlpha(final ? 0.9f : 0.6f); } else if (e.eventData._value <= 3) { if (BeatSaberSongContainer.Instance.difficultyData.envColorRight != BeatSaberSong.DEFAULT_RIGHTCOLOR) { color = BeatSaberSongContainer.Instance.difficultyData.envColorRight; } else { color = BlueColor; } } else if (e.eventData._value <= 7 && e.eventData._value >= 5) { if (BeatSaberSongContainer.Instance.difficultyData.envColorLeft != BeatSaberSong.DEFAULT_LEFTCOLOR) { color = BeatSaberSongContainer.Instance.difficultyData.envColorLeft; } else { color = RedColor; } } else if (e.eventData._value == 4) { color = OffColor; } } e.ChangeColor(color); switch (e.eventData._value) { case MapEvent.LIGHT_VALUE_OFF: e.ChangeColor(OffColor); e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_ON: e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_BLUE_FLASH: e.UpdateOffset(FlashShaderOffset); break; case MapEvent.LIGHT_VALUE_BLUE_FADE: e.UpdateOffset(FadeShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_ON: e.UpdateOffset(Vector3.zero); break; case MapEvent.LIGHT_VALUE_RED_FLASH: e.UpdateOffset(FlashShaderOffset); break; case MapEvent.LIGHT_VALUE_RED_FADE: e.UpdateOffset(FadeShaderOffset); break; } }