public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true) { UseChunkLoading = false; conflicting = LoadedContainers.FirstOrDefault(x => x.objectData._time == obj._time && (obj as MapEvent)._type == (x.objectData as MapEvent)._type && (obj as MapEvent)._customData == (x.objectData as MapEvent)._customData ); if (conflicting != null && removeConflicting) { DeleteObject(conflicting); } BeatmapEventContainer beatmapEvent = BeatmapEventContainer.SpawnEvent(obj as MapEvent, ref eventPrefab, ref eventAppearanceSO); beatmapEvent.transform.SetParent(GridTransform); beatmapEvent.UpdateGridPosition(); if (RingPropagationEditing && (obj as MapEvent)._type == MapEvent.EVENT_TYPE_RING_LIGHTS) { int pos = 0; if (!(obj._customData is null)) { pos = obj._customData["_propID"].AsInt + 1; } Debug.Log(pos); beatmapEvent.transform.localPosition = new Vector3(pos + 0.5f, 0.5f, beatmapEvent.transform.localPosition.z); } LoadedContainers.Add(beatmapEvent); SelectionController.RefreshMap(); return(beatmapEvent); }
public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true, bool refreshMap = true) { UseChunkLoading = false; conflicting = null; if (removeConflicting) { conflicting = LoadedContainers.FirstOrDefault(x => x.objectData._time == obj._time && (obj as MapEvent)._type == (x.objectData as MapEvent)._type && (obj as MapEvent)._customData == (x.objectData as MapEvent)._customData ); if (conflicting != null) { DeleteObject(conflicting, true, $"Conflicted with a newer object at time {obj._time}"); } } BeatmapEventContainer beatmapEvent = BeatmapEventContainer.SpawnEvent(this, obj as MapEvent, ref eventPrefab, ref eventAppearanceSO, ref tracksManager); beatmapEvent.transform.SetParent(GridTransform); beatmapEvent.UpdateGridPosition(); LoadedContainers.Add(beatmapEvent); if (refreshMap) { SelectionController.RefreshMap(); } if (PropagationEditing) { UpdatePropagationMode(); } return(beatmapEvent); }
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; } }
public BeatmapEventDeletionAction(BeatmapEventContainer placedEvent, BeatmapEventContainer chroma) : base(placedEvent) { chromaEvent = chroma; if (chroma != null) { chromaData = chromaEvent.eventData; } }
private void PlayToggle(bool isPlaying) { eventTypesHash.Clear(); lastEvents.Clear(); lastChromaEvents.Clear(); if (isPlaying) { BeatmapEventContainer[] allEvents = events.LoadedContainers.Cast<BeatmapEventContainer>().Reverse().ToArray(); foreach(BeatmapEventContainer e in allEvents) { if (!e.eventData.IsChromaEvent && e.eventData._time <= atsc.CurrentBeat && eventTypesHash.Add(e.eventData._type)) { lastEvents.Add(e); } } foreach (BeatmapEventContainer e in allEvents) { if (e.eventData.IsChromaEvent && e.eventData._time <= atsc.CurrentBeat && eventTypesHash.Contains(e.eventData._type)) { lastChromaEvents.Add(e); } } MapEvent blankEvent = new MapEvent(0, 0, 0); for (int i = 0; i < 16; i++) { if (!eventTypesHash.Contains(i)) { blankEvent._type = i; if (blankEvent.IsRingEvent || blankEvent.IsRotationEvent) continue; descriptor.EventPassed(false, 0, blankEvent); continue; } //Grab all the events of the type, and that are behind current beat BeatmapEventContainer regular = lastEvents.Find(x => x.eventData._type == i); BeatmapEventContainer chroma = lastChromaEvents.Find(x => x.eventData._type == i); MapEvent regularData = regular?.eventData ?? null; MapEvent chromaData = chroma?.eventData ?? null; //Past the last event, or an Off event if theres none, it is a ring event, or if there is a fade if (regularData._value != MapEvent.LIGHT_VALUE_BLUE_FADE && regularData._value != MapEvent.LIGHT_VALUE_RED_FADE && !regularData.IsRingEvent) descriptor.EventPassed(false, 0, regularData); else if (!regularData.IsRingEvent && !regularData.IsRotationEvent) descriptor.EventPassed(false, 0, new MapEvent(0, i, 0)); //Make sure that light turn off if (!regularData.IsUtilityEvent) { if (chromaData != null) descriptor.EventPassed(false, 0, chromaData); else descriptor.EventPassed(false, 0, new MapEvent(0, i, ColourManager.RGB_RESET)); } } } else descriptor.KillLights(); }
private IEnumerator GenerateStrobeCoroutine(int valueA, int valueB, bool regular, bool chroma, bool dynamic, bool swapColors, int interval, int chromaOffset) { generatedObjects.Clear(); //yield return PersistentUI.Instance.FadeInLoadingScreen(); List <BeatmapEventContainer> containers = SelectionController.SelectedObjects.Where(x => x is BeatmapEventContainer).Cast <BeatmapEventContainer>().ToList(); //Grab selected objects List <BeatmapObject> conflictingObjects = new List <BeatmapObject>(); //For the Action //Order by type, then by descending time containers = containers.OrderBy(x => x.eventData._type).ThenByDescending(x => x.eventData._time).ToList(); for (var i = 0; i < 15; i++) { if (containers.Count(x => (x.objectData as MapEvent)._type == i) >= 2) { List <BeatmapEventContainer> filteredContainers = containers.Where(x => x.eventData._type == i).ToList(); BeatmapEventContainer end = filteredContainers.First(); BeatmapEventContainer start = filteredContainers.Last(); List <BeatmapEventContainer> containersBetween = eventsContainer.LoadedContainers.Where(x => (x.objectData as MapEvent)._type == i && //Grab all events between start and end point. x.objectData._time >= start.objectData._time && x.objectData._time <= end.objectData._time ).OrderBy(x => x.objectData._time).Cast <BeatmapEventContainer>().ToList(); List <MapEvent> regularEventData = containersBetween.Select(x => x.eventData).Where(x => x._value < ColourManager.RGB_INT_OFFSET).ToList(); List <MapEvent> chromaEvents = new List <MapEvent>() { FindAttachedChromaEvent(start)?.eventData }; chromaEvents.AddRange(containersBetween.Where(x => x.eventData._value >= ColourManager.RGB_INT_OFFSET).Select(x => x.eventData)); chromaEvents = chromaEvents.Where(x => x != null).DistinctBy(x => x._time).ToList(); conflictingObjects.AddRange(chromaEvents.Concat(regularEventData)); foreach (BeatmapEventContainer e in containersBetween) { eventsContainer.DeleteObject(e); } if (regular) { yield return(StartCoroutine(GenerateRegularStrobe(i, valueA, valueB, end.eventData._time, start.eventData._time, swapColors, dynamic, interval, regularEventData))); } if (chroma && chromaEvents.Count > 0) { yield return(StartCoroutine(GenerateChromaStrobe(i, end.eventData._time, start.eventData._time, interval, 1f / chromaOffset, chromaEvents))); } } } generatedObjects.OrderBy(x => x.objectData._time); SelectionController.RefreshMap(); //yield return PersistentUI.Instance.FadeOutLoadingScreen(); SelectionController.DeselectAll(); SelectionController.SelectedObjects.AddRange(generatedObjects); SelectionController.RefreshSelectionMaterial(false); BeatmapActionContainer.AddAction(new StrobeGeneratorGenerationAction(generatedObjects, conflictingObjects)); generatedObjects.Clear(); }
public static BeatmapEventContainer SpawnEvent(MapEvent data, ref GameObject prefab, ref EventAppearanceSO eventAppearanceSO) { BeatmapEventContainer container = Instantiate(prefab).GetComponent <BeatmapEventContainer>(); container.eventData = data; container.eventAppearance = eventAppearanceSO; eventAppearanceSO.SetEventAppearance(container); return(container); }
private BeatmapEventContainer FindAttachedChromaEvent(BeatmapEventContainer container) { return eventsContainer.LoadedContainers.Where((BeatmapObjectContainer x) => (x.objectData as MapEvent)._type == container.eventData._type && //Ensure same type !(x.objectData as MapEvent).IsUtilityEvent && //And that they are not utility x.objectData._time <= container.eventData._time && //dont forget to make sure they're actually BEHIND a container. (x.objectData as MapEvent)._value >= ColourManager.RGB_INT_OFFSET //And they be a Chroma event. ).OrderByDescending(x => x.objectData._time).FirstOrDefault() as BeatmapEventContainer; }
private BeatmapEventContainer FindAttachedChromaEvent(BeatmapEventContainer container) { return(eventsContainer.LoadedContainers.Where((BeatmapObjectContainer x) => (x.objectData as MapEvent)._type == container.eventData._type && //Ensure same type !(x.objectData as MapEvent).IsUtilityEvent() && //And that they are not utility x.objectData._time >= container.eventData._time - (1f / 16f) && //They are close enough behind said container x.objectData._time <= container.eventData._time && //dont forget to make sure they're actually BEHIND a container. (x.objectData as MapEvent)._value >= ColourManager.RGB_INT_OFFSET //And they be a Chroma event. ).FirstOrDefault() as BeatmapEventContainer); }
void PlatformLoaded(PlatformDescriptor descriptor) { for (int i = 0; i < 16; i++) { int modified = BeatmapEventContainer.EventTypeToModifiedType(i); GameObject instantiate = Instantiate(LayerInstantiate, LayerInstantiate.transform.parent); instantiate.transform.localPosition = new Vector3(modified, 0, 0); try { switch (i) { case 8: instantiate.GetComponentInChildren <TextMeshProUGUI>().text = "Ring Rotation"; instantiate.GetComponentInChildren <TextMeshProUGUI>().font = UtilityAsset; break; case 9: instantiate.GetComponentInChildren <TextMeshProUGUI>().text = "Small Ring Zoom"; instantiate.GetComponentInChildren <TextMeshProUGUI>().font = UtilityAsset; break; case 12: instantiate.GetComponentInChildren <TextMeshProUGUI>().text = "Left Laser Speed"; instantiate.GetComponentInChildren <TextMeshProUGUI>().font = UtilityAsset; break; case 13: instantiate.GetComponentInChildren <TextMeshProUGUI>().text = "Right Laser Speed"; instantiate.GetComponentInChildren <TextMeshProUGUI>().font = UtilityAsset; break; case 14: instantiate.GetComponentInChildren <TextMeshProUGUI>().text = "Rotation (Include Current Time)"; instantiate.GetComponentInChildren <TextMeshProUGUI>().font = UtilityAsset; break; case 15: instantiate.GetComponentInChildren <TextMeshProUGUI>().text = "Rotation (Exclude Current Time)"; instantiate.GetComponentInChildren <TextMeshProUGUI>().font = UtilityAsset; break; default: LightsManager e = descriptor.LightingManagers[i]; instantiate.GetComponentInChildren <TextMeshProUGUI>().text = e?.gameObject.name; instantiate.GetComponentInChildren <TextMeshProUGUI>().font = AvailableAsset; break; } } catch { } } LayerInstantiate.SetActive(false); }
private void AttemptToSelect() { if (highlightedIndex >= EventGridOffset) { int gridOffset = highlightedIndex - EventGridOffset; //Take the difference gridOffset = BeatmapEventContainer.ModifiedTypeToEventType(gridOffset); //And turn from modified to event type BeatmapObjectContainer highlighting = events.LoadedContainers.Where( (BeatmapObjectContainer x) => x.objectData._time >= atsc.CurrentBeat - 1 / 64f && //Check time, within a small margin x.objectData._time <= atsc.CurrentBeat + 1 / 64f && //Check time, within a small margin (x.objectData as MapEvent)._type == gridOffset //Check type against what we calculated earlier ).FirstOrDefault(); if (highlighting != null) { SelectOrDeselect(highlighting); } } else //For the notes grid, check notes first then obstacles. { BeatmapObjectContainer highlighting = notes.LoadedContainers.Where( (BeatmapObjectContainer x) => x.objectData._time >= atsc.CurrentBeat - 1 / 64f && //Check time, within a small margin x.objectData._time <= atsc.CurrentBeat + 1 / 64f && //Check time, within a small margin (x.objectData as BeatmapNote)._lineIndex == highlightedIndex && //Check index (x.objectData as BeatmapNote)._lineLayer == highlightedLayer //Check layer ).FirstOrDefault(); //Grab first instance (Or null if there is none) if (highlighting != null) { SelectOrDeselect(highlighting); } else { highlighting = obstacles.LoadedContainers.Where((BeatmapObjectContainer x) => (x.objectData as BeatmapObstacle)._lineIndex <= highlightedIndex && //If it's between the left side (x.objectData as BeatmapObstacle)._lineIndex + ((x.objectData as BeatmapObstacle)._width - 1) >= highlightedIndex && //...and the right (x.objectData as BeatmapObstacle)._duration + x.objectData._time >= atsc.CurrentBeat && //If it's between the end point in time x.objectData._time <= atsc.CurrentBeat && //...and the beginning point in time (x.objectData as BeatmapObstacle)._type == wallType //And, for good measure, if they match types. ).FirstOrDefault(); if (highlighting != null) { SelectOrDeselect(highlighting); } } } }
private IEnumerator GenerateRegularStrobe(int type, int ValueA, int ValueB, float endTime, float startTime, bool alternateColors, bool dynamic, int precision, List<MapEvent> containersBetween) { List<int> alternatingTypes = new List<int>() { ValueA, ValueB }; int typeIndex = 0; if (alternateColors) { if (ValueA > 4 && ValueA < 8) alternatingTypes.Add(ValueA - 4); //Adds inverse colors (Red -> Blue) for both values if we're alternating else if (ValueA > 0) alternatingTypes.Add(ValueA + 4); else alternatingTypes.Add(ValueA); if (ValueB > 4 && ValueB < 8) alternatingTypes.Add(ValueB - 4); else if (ValueB > 0) alternatingTypes.Add(ValueB + 4); else alternatingTypes.Add(ValueB); } alternatingTypes = alternatingTypes.Distinct().ToList(); float distanceInBeats = endTime - startTime; float originalDistance = distanceInBeats; while (distanceInBeats >= 0) { yield return new WaitForEndOfFrame(); if (typeIndex >= alternatingTypes.Count) typeIndex = 0; IEnumerable<MapEvent> any = containersBetween.Where(x => x._time <= endTime - distanceInBeats && x != containersBetween.First() && x != containersBetween.Last()); if (any.Any() && dynamic) { alternatingTypes[0] = any.Last()._value; if (alternateColors && alternatingTypes.Count <= 4) { if (alternatingTypes.Count == 1) alternatingTypes.Add(ValueB); if (alternatingTypes.Count > 2) { if (alternatingTypes[0] > 4 && alternatingTypes[0] < 8) alternatingTypes[3] = alternatingTypes[0] - 4; else if (alternatingTypes[0] > 0) alternatingTypes[3] = alternatingTypes[0] + 4; } } } int value = alternatingTypes[typeIndex]; typeIndex++; MapEvent data = new MapEvent(endTime - distanceInBeats, type, value); BeatmapEventContainer eventContainer = eventsContainer.SpawnObject(data, out _, false) as BeatmapEventContainer; generatedObjects.Add(eventContainer); distanceInBeats -= 1 / (float)precision; } }
public IEnumerator GenerateStrobeCoroutine() { generatedObjects.Clear(); if (atsc.gridMeasureSnapping >= 32) { PersistentUI.Instance.DisplayMessage("This could take a while!", PersistentUI.DisplayMessageType.BOTTOM); } //yield return PersistentUI.Instance.FadeInLoadingScreen(); List <BeatmapObjectContainer> containers = SelectionController.SelectedObjects; //Grab selected objects List <BeatmapObjectContainer> notGeneratedObjects = new List <BeatmapObjectContainer>(); //For the Action containers = containers.Where((BeatmapObjectContainer x) => (x is BeatmapEventContainer)).ToList(); //Filter Event containers //Order by type, then by descending time containers = containers.OrderBy(x => (x.objectData as MapEvent)._type).ThenByDescending(x => x.objectData._time).ToList(); for (var i = 0; i < 15; i++) { if (containers.Count(x => (x.objectData as MapEvent)._type == i) >= 2) { List <BeatmapObjectContainer> filteredContainers = containers.Where(x => (x.objectData as MapEvent)._type == i).ToList(); BeatmapEventContainer end = filteredContainers.First() as BeatmapEventContainer; BeatmapEventContainer start = filteredContainers.Last() as BeatmapEventContainer; List <BeatmapObjectContainer> containersBetween = eventsContainer.LoadedContainers.Where(x => (x.objectData as MapEvent)._type == i && //Grab all events between start and end point. x.objectData._time >= start.objectData._time && x.objectData._time <= end.objectData._time ).OrderBy(x => x.objectData._time).ToList(); containersBetween.Add(FindAttachedChromaEvent(start)); //Add the first Chroma RGB event so gradients can work notGeneratedObjects.Add(filteredContainers.First()); //for the love of god please work notGeneratedObjects.AddRange(containersBetween); //Add this to our list of objects that are here from the start. yield return(StartCoroutine(GenerateOneStrobe(start.eventData._type, eventPreview.queuedData._value, end.objectData._time, start.objectData._time, containersBetween))); } } generatedObjects.OrderBy(x => x.objectData._time); generatedObjects.RemoveAll(x => notGeneratedObjects.Contains(x)); SelectionController.RefreshMap(); //yield return PersistentUI.Instance.FadeOutLoadingScreen(); SelectionController.DeselectAll(); SelectionController.SelectedObjects.AddRange(generatedObjects); SelectionController.SelectedObjects.AddRange(notGeneratedObjects); SelectionController.RefreshSelectionMaterial(false); BeatmapActionContainer.AddAction(new StrobeGeneratorGenerationAction(generatedObjects, notGeneratedObjects)); generatedObjects.Clear(); }
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); } } }
public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = false, bool refreshMap = true) { UseChunkLoading = false; conflicting = null; if (removeConflicting) { conflicting = LoadedContainers.FirstOrDefault(x => x.objectData._time == obj._time && (obj as MapEvent)._type == (x.objectData as MapEvent)._type && (obj as MapEvent)._customData == (x.objectData as MapEvent)._customData ); if (conflicting != null) { DeleteObject(conflicting, true, $"Conflicted with a newer object at time {obj._time}"); } } BeatmapEventContainer beatmapEvent = BeatmapEventContainer.SpawnEvent(this, obj as MapEvent, ref eventPrefab, ref eventAppearanceSO, ref tracksManager); beatmapEvent.transform.SetParent(GridTransform); beatmapEvent.UpdateGridPosition(); if (RingPropagationEditing && (obj as MapEvent)._type == MapEvent.EVENT_TYPE_RING_LIGHTS) { int pos = 0; if (!(obj._customData is null) && (obj._customData["_propID"].IsNumber)) { pos = (obj._customData["_propID"]?.AsInt ?? -1) + 1; } beatmapEvent.transform.localPosition = new Vector3(pos + 0.5f, 0.5f, beatmapEvent.transform.localPosition.z); } LoadedContainers.Add(beatmapEvent); if (refreshMap) { SelectionController.RefreshMap(); } if (RingPropagationEditing) { UpdateRingPropagationMode(); } return(beatmapEvent); }
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; } }
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(); } }
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) { 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; } }
public void UpdateLabels(bool isRingPropagation, int lanes = 16) { foreach (Transform children in LayerInstantiate.transform.parent.transform) { if (children.gameObject.activeSelf) { Destroy(children.gameObject); } } for (int i = 0; i < lanes; i++) { int modified = BeatmapEventContainer.EventTypeToModifiedType(i); GameObject instantiate = Instantiate(LayerInstantiate, LayerInstantiate.transform.parent); instantiate.SetActive(true); instantiate.transform.localPosition = new Vector3(isRingPropagation ? i : modified, 0, 0); try { TextMeshProUGUI textMesh = instantiate.GetComponentInChildren <TextMeshProUGUI>(); if (isRingPropagation) { textMesh.font = UtilityAsset; if (i == 0) { textMesh.text = "All rings"; textMesh.font = RedAsset; } else { textMesh.text = "RING " + i.ToString(); if (i % 2 == 0) { textMesh.font = UtilityAsset; } else { textMesh.font = AvailableAsset; } } } else { switch (i) { case 8: textMesh.font = UtilityAsset; textMesh.text = "Ring Rotation"; break; case 9: textMesh.font = UtilityAsset; textMesh.text = "Small Ring Zoom"; break; case 12: textMesh.text = "Left Laser Speed"; textMesh.font = UtilityAsset; break; case 13: textMesh.text = "Right Laser Speed"; textMesh.font = UtilityAsset; break; case 14: textMesh.text = "Rotation (Include Current Time)"; textMesh.font = UtilityAsset; break; case 15: textMesh.text = "Rotation (Exclude Current Time)"; textMesh.font = UtilityAsset; break; default: if (LightingManagers.Length > i) { LightsManager customLight = LightingManagers[i]; textMesh.text = customLight?.name; textMesh.font = AvailableAsset; } else { Destroy(textMesh); } break; } } } catch { } } }
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; } }
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 ShiftSelection(int leftRight, int upDown) { foreach (BeatmapObjectContainer con in SelectedObjects) { if (con is BeatmapNoteContainer note) { if (note.mapNoteData._lineIndex >= 1000) { note.mapNoteData._lineIndex += Mathf.RoundToInt((1f / atsc.gridMeasureSnapping) * 1000 * leftRight); if (note.mapNoteData._lineIndex < 1000) { note.mapNoteData._lineIndex = 1000; } } else if (note.mapNoteData._lineIndex <= -1000) { note.mapNoteData._lineIndex += Mathf.RoundToInt((1f / atsc.gridMeasureSnapping) * 1000 * leftRight); if (note.mapNoteData._lineIndex > -1000) { note.mapNoteData._lineIndex = -1000; } } else { note.mapNoteData._lineIndex += leftRight; } note.mapNoteData._lineLayer += upDown; } else if (con is BeatmapObstacleContainer obstacle) { if (obstacle.obstacleData._lineIndex >= 1000) { obstacle.obstacleData._lineIndex += Mathf.RoundToInt((1f / atsc.gridMeasureSnapping) * 1000 * leftRight); if (obstacle.obstacleData._lineIndex < 1000) { obstacle.obstacleData._lineIndex = 1000; } } else if (obstacle.obstacleData._lineIndex <= -1000) { obstacle.obstacleData._lineIndex += Mathf.RoundToInt((1f / atsc.gridMeasureSnapping) * 1000 * leftRight); if (obstacle.obstacleData._lineIndex > -1000) { obstacle.obstacleData._lineIndex = -1000; } } else { obstacle.obstacleData._lineIndex += leftRight; } obstacle.obstacleData._time += ((1f / atsc.gridMeasureSnapping) * upDown); } else if (con is BeatmapEventContainer e) { e.eventData._time += ((1f / atsc.gridMeasureSnapping) * upDown); if (eventPlacement.objectContainerCollection.RingPropagationEditing) { int pos = -1 + leftRight; if (con.objectData._customData != null && con.objectData._customData["_propID"].IsNumber) { pos = (con.objectData?._customData["_propID"]?.AsInt ?? -1) + leftRight; } if (e.eventData._type != MapEvent.EVENT_TYPE_RING_LIGHTS) { e.UpdateAlpha(0); pos = -1; } else { if (pos < -1) { pos = -1; } if (pos > 14) { pos = 14; } } con.transform.localPosition = new Vector3(pos + 0.5f, 0.5f, con.transform.localPosition.z); if (pos == -1) { con.objectData._customData?.Remove("_propID"); } else { con.objectData._customData["_propID"] = pos; } } else { if (e.eventData._customData != null && e.eventData._customData["_propID"] != null) { e.eventData._customData["_propID"] = e.eventData._customData["_propID"].AsInt + leftRight; } int modified = BeatmapEventContainer.EventTypeToModifiedType(e.eventData._type); modified += leftRight; if (modified < 0) { modified = 0; } if (modified > 15) { modified = 15; } e.eventData._type = BeatmapEventContainer.ModifiedTypeToEventType(modified); e.RefreshAppearance(); if (e.eventData.IsRotationEvent || e.eventData._type - leftRight == MapEvent.EVENT_TYPE_LATE_ROTATION || e.eventData._type - leftRight == MapEvent.EVENT_TYPE_EARLY_ROTATION) { tracksManager.RefreshTracks(); } } } con.UpdateGridPosition(); if (eventPlacement.objectContainerCollection.RingPropagationEditing) { eventPlacement.objectContainerCollection.RingPropagationEditing = eventPlacement.objectContainerCollection.RingPropagationEditing; } } RefreshMap(); }
public void UpdateLabels(bool isPropagation, int eventType, int lanes = 16) { foreach (Transform children in LayerInstantiate.transform.parent.transform) { if (children.gameObject.activeSelf) { Destroy(children.gameObject); } } for (int i = 0; i < lanes; i++) { int modified = BeatmapEventContainer.EventTypeToModifiedType(i); GameObject instantiate = Instantiate(LayerInstantiate, LayerInstantiate.transform.parent); instantiate.SetActive(true); instantiate.transform.localPosition = new Vector3(isPropagation ? i : modified, 0, 0); try { TextMeshProUGUI textMesh = instantiate.GetComponentInChildren <TextMeshProUGUI>(); if (isPropagation) { textMesh.font = UtilityAsset; if (i == 0) { textMesh.text = "All Lights"; textMesh.font = RedAsset; } else { textMesh.text = $"{LightingManagers[eventType].name} ID {i}"; if (i % 2 == 0) { textMesh.font = UtilityAsset; } else { textMesh.font = AvailableAsset; } } } else { switch (i) { case MapEvent.EVENT_TYPE_RINGS_ROTATE: textMesh.font = UtilityAsset; textMesh.text = "Ring Rotation"; break; case MapEvent.EVENT_TYPE_RINGS_ZOOM: textMesh.font = UtilityAsset; textMesh.text = "Ring Zoom"; break; case MapEvent.EVENT_TYPE_LEFT_LASERS_SPEED: textMesh.text = "Left Laser Speed"; textMesh.font = UtilityAsset; break; case MapEvent.EVENT_TYPE_RIGHT_LASERS_SPEED: textMesh.text = "Right Laser Speed"; textMesh.font = UtilityAsset; break; case MapEvent.EVENT_TYPE_EARLY_ROTATION: textMesh.text = "Rotation (Early)"; textMesh.font = UtilityAsset; break; case MapEvent.EVENT_TYPE_LATE_ROTATION: textMesh.text = "Rotation (Late)"; textMesh.font = UtilityAsset; break; default: if (LightingManagers.Length > i) { LightsManager customLight = LightingManagers[i]; textMesh.text = customLight?.name; textMesh.font = AvailableAsset; } else { Destroy(textMesh); } break; } } } catch { } } }