Пример #1
0
 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;
     }
 }
Пример #2
0
    internal override void ApplyToMap()
    {
        queuedData._time = (instantiatedContainer.transform.position.z / EditorScaleController.EditorScale)
                           + atsc.CurrentBeat;
        if ((KeybindsController.AltHeld || (Settings.Instance.PlaceOnlyChromaEvents && Settings.Instance.PlaceChromaEvents)) && !queuedData.IsUtilityEvent()) // no more laser speed events gone wack
        {
            MapEvent justChroma = BeatmapObject.GenerateCopy(queuedData);
            justChroma._value = ColourManager.ColourToInt(colorPicker.CurrentColor);
            BeatmapEventContainer container = objectContainerCollection.SpawnObject(justChroma) as BeatmapEventContainer;
            BeatmapActionContainer.AddAction(new BeatmapEventPlacementAction(container, null));
            SelectionController.RefreshMap();
            queuedData = BeatmapObject.GenerateCopy(queuedData);
            return;
        }
        BeatmapEventContainer spawned = objectContainerCollection.SpawnObject(BeatmapObject.GenerateCopy(queuedData)) as BeatmapEventContainer;
        BeatmapEventContainer chroma  = null;

        if (Settings.Instance.PlaceChromaEvents && !queuedData.IsUtilityEvent() && (queuedValue != MapEvent.LIGHT_VALUE_OFF)) // off events arent affected by chroma blocks, no need to create extra ones
        {
            MapEvent chromaData = BeatmapObject.GenerateCopy(queuedData);
            chromaData._time -= 1 / 64f;
            chromaData._value = ColourManager.ColourToInt(colorPicker.CurrentColor);
            chroma            = objectContainerCollection.SpawnObject(chromaData) as BeatmapEventContainer;
        }
        BeatmapActionContainer.AddAction(new BeatmapEventPlacementAction(spawned, chroma));
        SelectionController.RefreshMap();
        queuedData = BeatmapObject.GenerateCopy(queuedData);
    }
Пример #3
0
    public override void OnPhysicsRaycast(RaycastHit hit, Vector3 transformedPoint)
    {
        //this mess of localposition and position assignments are to align the shits up with the grid
        //and to hopefully not cause IndexOutOfRangeExceptions
        instantiatedContainer.transform.localPosition = parentTrack.InverseTransformPoint(hit.point); //f**k transformedpoint we're doing it ourselves
        instantiatedContainer.transform.localPosition = new Vector3(                                  //Time to round
            Mathf.Ceil(instantiatedContainer.transform.localPosition.x) - 0.5f, 0.5f, RoundedTime * EditorScaleController.EditorScale);
        float x = instantiatedContainer.transform.localPosition.x;                                    //Clamp values to prevent exceptions

        instantiatedContainer.transform.localPosition = new Vector3(Mathf.Clamp(x, 0.5f, Mathf.Floor(hit.transform.lossyScale.x * 10) - 0.5f),
                                                                    instantiatedContainer.transform.localPosition.y, instantiatedContainer.transform.localPosition.z);

        //now on to the good shit.
        if (!objectContainerCollection.RingPropagationEditing)
        {
            queuedData._type = BeatmapEventContainer.ModifiedTypeToEventType(Mathf.FloorToInt(instantiatedContainer.transform.localPosition.x));
            queuedData._customData?.Remove("_propID");
        }
        else
        {
            queuedData._type = MapEvent.EVENT_TYPE_RING_LIGHTS;
            int propID = Mathf.FloorToInt(instantiatedContainer.transform.localPosition.x - 1);
            if (propID >= 0)
            {
                if (queuedData._customData is null)
                {
                    queuedData._customData = new SimpleJSON.JSONObject();
                }
                queuedData._customData["_propID"] = propID;
            }
            else
            {
                queuedData._customData?.Remove("_propID");
            }
        }
        if (!PlacePrecisionRotation)
        {
            if (Settings.Instance.PlaceOnlyChromaEvents && Settings.Instance.PlaceChromaEvents && !queuedData.IsRotationEvent)
            {
                queuedData._value = ColourManager.ColourToInt(colorPicker.CurrentColor);
            }
            else
            {
                queuedData._value = queuedValue;
            }
        }
        else
        {
            queuedData._value = 1360 + PrecisionRotationValue;
        }
        if (queuedData._type == MapEvent.EVENT_TYPE_LEFT_LASERS_SPEED || queuedData._type == MapEvent.EVENT_TYPE_RIGHT_LASERS_SPEED)
        {
            if (int.TryParse(laserSpeedInputField.text, out int laserSpeed))
            {
                queuedData._value = laserSpeed;
            }
        }
        UpdateAppearance();
    }
Пример #4
0
    public static void Save()
    {
        JSONObject obj    = new JSONObject();
        JSONArray  colors = new JSONArray();

        foreach (Color color in ColorPresetManager.Get().Colors)
        {
            colors.Add(ColourManager.ColourToInt(color));
        }
        obj.Add("colors", colors);
        using (StreamWriter writer = new StreamWriter(Application.persistentDataPath + "/ChromaColors.json", false))
            writer.Write(obj.ToString());
        Debug.Log("Chroma Colors saved!");
    }
Пример #5
0
    internal override void ApplyToMap()
    {
        queuedData._time = RoundedTime;
        if ((KeybindsController.AltHeld || (Settings.Instance.PlaceOnlyChromaEvents && Settings.Instance.PlaceChromaEvents)) && !queuedData.IsUtilityEvent())
        {
            MapEvent justChroma = BeatmapObject.GenerateCopy(queuedData);
            justChroma._value = ColourManager.ColourToInt(colorPicker.CurrentColor);
            BeatmapEventContainer container = objectContainerCollection.SpawnObject(justChroma, out BeatmapObjectContainer conflicting2) as BeatmapEventContainer;
            BeatmapActionContainer.AddAction(new BeatmapObjectPlacementAction(new List <BeatmapObjectContainer>()
            {
                conflicting2
            },
                                                                              new List <BeatmapObjectContainer>()
            {
                container
            }));
            SelectionController.RefreshMap();
            queuedData = BeatmapObject.GenerateCopy(queuedData);
            return;
        }
        BeatmapEventContainer spawned = objectContainerCollection.SpawnObject(BeatmapObject.GenerateCopy(queuedData), out BeatmapObjectContainer conflicting) as BeatmapEventContainer;
        BeatmapEventContainer chroma  = null;

        if (Settings.Instance.PlaceChromaEvents && !queuedData.IsUtilityEvent() && (queuedValue != MapEvent.LIGHT_VALUE_OFF))
        {
            MapEvent chromaData = BeatmapObject.GenerateCopy(queuedData);
            chromaData._time -= 1 / 64f;
            chromaData._value = ColourManager.ColourToInt(colorPicker.CurrentColor);
            chroma            = objectContainerCollection.SpawnObject(chromaData, out _) as BeatmapEventContainer;
        }
        BeatmapActionContainer.AddAction(new BeatmapObjectPlacementAction(new List <BeatmapObjectContainer>()
        {
            conflicting
        },
                                                                          new List <BeatmapObjectContainer>()
        {
            spawned, chroma
        }));
        SelectionController.RefreshMap();
        queuedData = BeatmapObject.GenerateCopy(queuedData);
    }
Пример #6
0
 public override void OnPhysicsRaycast(RaycastHit hit)
 {
     if (!objectContainerCollection.RingPropagationEditing)
     {
         queuedData._type       = BeatmapEventContainer.ModifiedTypeToEventType(Mathf.RoundToInt(instantiatedContainer.transform.position.x - transform.position.x));
         queuedData._customData = null;
     }
     else
     {
         queuedData._type = MapEvent.EVENT_TYPE_RING_LIGHTS;
         int propID = Mathf.RoundToInt(instantiatedContainer.transform.position.x - transform.position.x) - 1;
         if (propID >= 0)
         {
             if (queuedData._customData is null)
             {
                 queuedData._customData = new SimpleJSON.JSONObject();
             }
             queuedData._customData["_propID"] = propID;
         }
     }
     queuedData._value = Settings.Instance.PlaceOnlyChromaEvents && Settings.Instance.PlaceChromaEvents ? ColourManager.ColourToInt(colorPicker.CurrentColor) : queuedValue;
     if (queuedData._type == MapEvent.EVENT_TYPE_LEFT_LASERS_SPEED || queuedData._type == MapEvent.EVENT_TYPE_RIGHT_LASERS_SPEED)
     {
         if (int.TryParse(laserSpeedInputField.text, out int laserSpeed))
         {
             queuedData._value = laserSpeed;
         }
     }
     UpdateAppearance();
 }
Пример #7
0
    internal override void ApplyToMap()
    {
        if (queuedData._type == MapEvent.EVENT_TYPE_EARLY_ROTATION || queuedData._type == MapEvent.EVENT_TYPE_LATE_ROTATION)
        {
            if (!gridRotation?.IsActive ?? false)
            {
                PersistentUI.Instance.ShowDialogBox("Rotation events are disabled outside of the 360 Degree, 90 Degree, and Lawless characteristics.\n\n" +
                                                    "If you wish to place these events, please create difficulties for the aformentioned characteristics.", null, PersistentUI.DialogBoxPresetType.Ok);
                return;
            }
        }
        if (KeybindsController.ShiftHeld)
        {
            return;
        }
        queuedData._time = RoundedTime;
        if ((KeybindsController.AltHeld || (Settings.Instance.PlaceOnlyChromaEvents && Settings.Instance.PlaceChromaEvents)) && !queuedData.IsUtilityEvent)
        {
            MapEvent justChroma = BeatmapObject.GenerateCopy(queuedData);
            justChroma._value = ColourManager.ColourToInt(colorPicker.CurrentColor);
            BeatmapEventContainer container = objectContainerCollection.SpawnObject(justChroma, out BeatmapObjectContainer conflicting2) as BeatmapEventContainer;
            if (container == null)
            {
                return;
            }
            BeatmapActionContainer.AddAction(new BeatmapObjectPlacementAction(new List <BeatmapObjectContainer>()
            {
                conflicting2
            },
                                                                              new List <BeatmapObjectContainer>()
            {
                container
            }, "Placed a Chroma event."));
            SelectionController.RefreshMap();
            queuedData = BeatmapObject.GenerateCopy(queuedData);
            return;
        }
        BeatmapEventContainer spawned = objectContainerCollection.SpawnObject(BeatmapObject.GenerateCopy(queuedData), out BeatmapObjectContainer conflicting) as BeatmapEventContainer;

        if (spawned == null)
        {
            return;
        }
        BeatmapEventContainer chroma = null;

        if (Settings.Instance.PlaceChromaEvents && !queuedData.IsUtilityEvent && (queuedValue != MapEvent.LIGHT_VALUE_OFF))
        {
            MapEvent chromaData = BeatmapObject.GenerateCopy(queuedData);
            chromaData._time -= 1 / 64f;
            chromaData._value = ColourManager.ColourToInt(colorPicker.CurrentColor);
            chroma            = objectContainerCollection.SpawnObject(chromaData, out _) as BeatmapEventContainer;
        }
        BeatmapActionContainer.AddAction(new BeatmapObjectPlacementAction(new List <BeatmapObjectContainer>()
        {
            conflicting
        },
                                                                          new List <BeatmapObjectContainer>()
        {
            spawned, chroma
        }, "Placed an Event with an attached Chroma event."));
        SelectionController.RefreshMap();
        queuedData = BeatmapObject.GenerateCopy(queuedData);
        tracksManager.RefreshTracks();
        spawned.transform.localEulerAngles = Vector3.zero;
        if (chroma != null)
        {
            chroma.transform.localEulerAngles = Vector3.zero;
        }
    }
Пример #8
0
    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;
        }
    }