public static void Postfix(ref BeatmapData __result, ref BeatmapData beatmapData)
        {
            ChromaJSONBeatmap cMap = ChromaJSONBeatmap.GetChromaBeatmap(beatmapData);

            if (cMap != null)
            {
                ChromaJSONBeatmap.copiedMap = new Tuple <BeatmapData, ChromaJSONBeatmap>(__result, cMap);
            }
        }
        public static void Postfix(ref BeatmapData __result, ref string json, ref float beatsPerMinute, ref float shuffle, ref float shufflePeriod)
        {
            try {
                JSONNode          node       = JSONNode.Parse(json);
                JSONNode          eventsNode = node["_chromaEvents"];
                ChromaJSONBeatmap chromaMap  = new ChromaJSONBeatmap(__result);
                if (eventsNode != null)
                {
                    ChromaJSONEventData.ParseJSONNoteData(eventsNode, ref chromaMap.chromaEvents, ref beatsPerMinute, ref shuffle, ref shufflePeriod);
                }

                /*JSONNode notesNode = node["_chromaEvents"];
                 * if (notesNode != null) {
                 *  BeatmapLineData[] linesData = ChromaJSONNoteData.ParseJSONNoteData(notesNode, __result.beatmapLinesData);
                 *  __result.SetProperty("beatmapLinesData", linesData);
                 * }*/
                chromaMap.Register();
            } catch (Exception e) {
                ChromaLogger.Log(e);
            }
        }
Exemplo n.º 3
0
        public static CustomBeatmap CreateTransformedData(BeatmapData beatmapData, ref ChromaBehaviour chromaBehaviour, ref PlayerSpecificSettings playerSettings, ref BaseGameModeType baseGameMode, ref float bpm)
        {
            ColourManager.TechnicolourLightsForceDisabled = false;

            ChromaLogger.Log("Checking for registered JSONBeatmap for " + beatmapData.ToString() + " (" + ChromaJSONBeatmap.chromaBeatmaps.Count + " registered maps total)");
            ChromaJSONBeatmap chromaInjectmap = ChromaJSONBeatmap.GetChromaBeatmap(beatmapData);

            if (beatmapData == null)
            {
                ChromaLogger.Log("Null beatmapData", ChromaLogger.Level.ERROR);
            }
            if (playerSettings == null)
            {
                ChromaLogger.Log("Null playerSettings", ChromaLogger.Level.ERROR);
            }

            List <CustomBeatmapObject> customBeatmapData = new List <CustomBeatmapObject>();

            beatmapData = beatmapData.GetCopy();
            BeatmapLineData[] beatmapLinesData = beatmapData.beatmapLinesData;
            int[]             array            = new int[beatmapLinesData.Length];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = 0;
            }
            UnityEngine.Random.InitState(0);
            bool flag;

            do
            {
                flag = false;
                float num  = 999999f;
                int   num2 = 0;
                for (int j = 0; j < beatmapLinesData.Length; j++)
                {
                    BeatmapObjectData[] beatmapObjectsData = beatmapLinesData[j].beatmapObjectsData;
                    int num3 = array[j];
                    while (num3 < beatmapObjectsData.Length && beatmapObjectsData[num3].time < num + 0.001f)
                    {
                        flag = true;
                        BeatmapObjectData beatmapObjectData = beatmapObjectsData[num3];
                        float             time = beatmapObjectData.time;
                        if (Mathf.Abs(time - num) < 0.001f)
                        {
                            if (beatmapObjectData.beatmapObjectType == BeatmapObjectType.Note)
                            {
                                num2++;
                            }
                        }
                        else if (time < num)
                        {
                            num = time;
                            if (beatmapObjectData.beatmapObjectType == BeatmapObjectType.Note)
                            {
                                num2 = 1;
                            }
                            else
                            {
                                num2 = 0;
                            }
                        }
                        num3++;
                    }
                }

                CustomBeatmapObject customBeatmapObject = null;
                for (int k = 0; k < beatmapLinesData.Length; k++)
                {
                    BeatmapObjectData[] beatmapObjectsData2 = beatmapLinesData[k].beatmapObjectsData;
                    int num4 = array[k];
                    while (num4 < beatmapObjectsData2.Length && beatmapObjectsData2[num4].time < num + 0.001f)
                    {
                        BeatmapObjectData beatmapObjectData2 = beatmapObjectsData2[num4];
                        if (beatmapObjectData2.beatmapObjectType == BeatmapObjectType.Note)
                        {
                            NoteData noteData = beatmapObjectData2 as NoteData;
                            if (noteData != null)
                            {
                                if (noteData.noteType == NoteType.NoteA || noteData.noteType == NoteType.NoteB)
                                {
                                    customBeatmapObject = new CustomBeatmapNote(beatmapObjectData2 as NoteData);
                                }
                                else if (noteData.noteType == NoteType.Bomb)
                                {
                                    customBeatmapObject = new CustomBeatmapBomb(beatmapObjectData2 as NoteData);
                                }
                            }
                        }
                        else if (beatmapObjectData2.beatmapObjectType == BeatmapObjectType.Obstacle)
                        {
                            ObstacleData obstacle = beatmapObjectData2 as ObstacleData;
                            if (obstacle != null)
                            {
                                customBeatmapObject = new CustomBeatmapBarrier(obstacle);
                            }
                        }
                        array[k]++;
                        num4++;
                        if (customBeatmapObject == null)
                        {
                            ChromaLogger.Log("Null beatmap object! ID:" + beatmapObjectData2.id + " LI:" + beatmapObjectData2.lineIndex + " T:" + beatmapObjectData2.time, ChromaLogger.Level.WARNING);
                        }
                        else
                        {
                            customBeatmapData.Add(customBeatmapObject);                                                                                                                                                                                                                   //CT Added
                        }
                    }
                }
            }while (flag);

            CustomBeatmap customBeatmap = new CustomBeatmap(customBeatmapData);

            try {
                ChromaLogger.Log("Modifying map data...");
                if (beatmapData == null)
                {
                    ChromaLogger.Log("Null beatmapData", ChromaLogger.Level.ERROR);
                }
                if (beatmapData.beatmapEventData == null)
                {
                    ChromaLogger.Log("Null beatmapData.beatmapEventData", ChromaLogger.Level.ERROR);
                }
                ModifyCustomBeatmapEvent?.Invoke(beatmapData.notesCount * beatmapData.beatmapEventData.Length, ref customBeatmap, ref beatmapData, ref playerSettings, ref baseGameMode, ref bpm);
                //ModifyCustomBeatmap(beatmapData.notesCount * beatmapData.beatmapEventData.Length, ref customBeatmap, ref beatmapData, ref playerSettings, ref baseGameMode, ref bpm);
            } catch (Exception e) {
                ChromaLogger.Log("Exception modifying map data...", ChromaLogger.Level.ERROR);
                ChromaLogger.Log(e);
            }

            customBeatmapData = customBeatmap.CustomBeatmapObjects;

            //from Tweaks
            int[] array2 = new int[beatmapLinesData.Length];
            for (int l = 0; l < customBeatmapData.Count; l++)
            {
                BeatmapObjectData beatmapObjectData2 = customBeatmapData[l].Data;
                array2[Mathf.Clamp(beatmapObjectData2.lineIndex, 0, 3)]++; //array2[beatmapObjectData2.lineIndex]++;
            }
            BeatmapLineData[] linesData = new BeatmapLineData[beatmapLinesData.Length];
            for (int m = 0; m < beatmapLinesData.Length; m++)
            {
                linesData[m] = new BeatmapLineData();
                linesData[m].beatmapObjectsData = new BeatmapObjectData[array2[m]];
                array[m] = 0;
            }
            for (int n = 0; n < customBeatmapData.Count; n++)
            {
                BeatmapObjectData beatmapObjectData3 = customBeatmapData[n].Data;
                int lineIndex = Mathf.Clamp(beatmapObjectData3.lineIndex, 0, 3); //beatmapObjectData3.lineIndex;
                linesData[lineIndex].beatmapObjectsData[array[lineIndex]] = beatmapObjectData3;
                array[lineIndex]++;
            }
            BeatmapEventData[] eventsData = new BeatmapEventData[beatmapData.beatmapEventData.Length];
            for (int num5 = 0; num5 < beatmapData.beatmapEventData.Length; num5++)
            {
                BeatmapEventData beatmapEventData = beatmapData.beatmapEventData[num5];
                eventsData[num5] = beatmapEventData.GetCopy();
            }

            if (ChromaConfig.LightshowModifier)
            {
                linesData = new BeatmapLineData[0];
            }

            beatmapData = new BeatmapData(linesData, eventsData);

            if (chromaInjectmap != null)
            {
                chromaInjectmap.Inject(beatmapData);
            }

            customBeatmap.BeatmapData = beatmapData;


            /*
             * LIGHTING EVENTS
             */

            if (ChromaConfig.CustomColourEventsEnabled || ChromaConfig.CustomSpecialEventsEnabled)
            {
                BeatmapEventData[] bevData       = beatmapData.beatmapEventData;
                ChromaColourEvent  unfilledEvent = null;
                for (int i = bevData.Length - 1; i >= 0; i--)
                {
                    //Forcing lane change
                    switch (bevData[i].value)
                    {
                    case ChromaEvent.CHROMA_EVENT_RING_ROTATE_LEFT:
                        bevData[i].SetProperty("type", BeatmapEventType.Event8);
                        break;

                    case ChromaEvent.CHROMA_EVENT_RING_ROTATE_RIGHT:
                        bevData[i].SetProperty("type", BeatmapEventType.Event8);
                        break;

                    case ChromaEvent.CHROMA_EVENT_RING_ROTATE_RESET:
                        bevData[i].SetProperty("type", BeatmapEventType.Event8);
                        break;
                    }

                    ChromaEvent cLight = ApplyCustomEvent(bevData[i], ref unfilledEvent);
                    if (cLight != null)
                    {
                        ColourManager.TechnicolourLightsForceDisabled = true;
                    }
                }
            }

            return(customBeatmap);
        }