public void Awake()
        {
            beatmapObjectCallbackController = GetComponent <BeatmapObjectCallbackController>();
            var initData = beatmapObjectCallbackController.GetField <BeatmapObjectCallbackController.InitData, BeatmapObjectCallbackController>("_initData");

            audioTimeSyncController = beatmapObjectCallbackController.GetField <IAudioTimeSource, BeatmapObjectCallbackController>("_audioTimeSource") as AudioTimeSyncController;
            spawningStartTime       = initData.spawningStartTime;
            songTime                 = audioTimeSyncController.songTime;
            songDeltaTime            = audioTimeSyncController.songTime; // first delta is the point the song starts at, not 0
            eventLoopbackCallbackIds = new Dictionary <string, int>();
            SetNewBeatmapData(initData.beatmapData);
            Plugin.invokeCallbackControllerAwake(this);
        }
Exemplo n.º 2
0
        public static IEnumerator NoArrows()
        {
            yield return(new WaitForSeconds(0f));

            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            BeatmapObjectData[] objects;
            NoteData            note;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        note = beatmapObject as NoteData;

                        note.SetNoteToAnyCutDirection();
                    }
                }
            }
            //    dataModel.beatmapData = beatmapData;
        }
Exemplo n.º 3
0
        public static IEnumerator MadScience(float length)
        {
            yield return(new WaitForSeconds(0f));

            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            List <BeatmapObjectData> objects;
            float start = Plugin.songAudio.time + 2;
            float end   = start + length + 2f;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData.ToList();
                for (int i = 0; i < objects.Count; ++i)
                {
                    BeatmapObjectData beatmapObject = objects[i];
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        objects.Add(NoteToWall(beatmapObject, Plugin.levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.beatsPerMinute));
                    }
                }
                objects = objects.OrderBy(o => o.time).ToList();
                line.beatmapObjectsData = objects.ToArray();
                objects.Clear();
            }
            yield return(new WaitForSeconds(length + 2f));

            callbackController.SetField("_beatmapData", beatmapData);
        }
Exemplo n.º 4
0
        public void ReadMap()
        {
            //   yield return new WaitForSeconds(1f);
            var   lineData        = _callbackController.GetField <IReadonlyBeatmapData, BeatmapObjectCallbackController>("_beatmapData").beatmapLinesData;
            float firstObjectTime = _songAudio.clip.length;
            float lastObjectTime  = -1f;

            foreach (var line in lineData)
            {
                foreach (var beatmapObject in line.beatmapObjectsData)
                {
                    switch (beatmapObject.beatmapObjectType)
                    {
                    case BeatmapObjectType.Note:
                        if (beatmapObject.time < firstObjectTime)
                        {
                            firstObjectTime = beatmapObject.time;
                        }
                        if (beatmapObject.time > lastObjectTime)
                        {
                            lastObjectTime = beatmapObject.time;
                        }
                        break;

                    case BeatmapObjectType.Obstacle:
                        ObstacleData obstacle = beatmapObject as ObstacleData;
                        if (!(obstacle.lineIndex == 0 && obstacle.width == 1) && !(obstacle.lineIndex == 3 && obstacle.width == 1))
                        {
                            if (beatmapObject.time < firstObjectTime)
                            {
                                firstObjectTime = beatmapObject.time;
                            }
                            if (beatmapObject.time > lastObjectTime)
                            {
                                lastObjectTime = beatmapObject.time;
                            }
                        }
                        break;
                    }
                }
            }
            if (firstObjectTime > 5f)
            {
                _skippableIntro = Config.AllowIntroSkip;
                _introSkipTime  = firstObjectTime - 2f;
            }
            if ((_songAudio.clip.length - lastObjectTime) >= 5f)
            {
                _skippableOutro     = Config.AllowOutroSkip;
                _outroSkipTime      = _songAudio.clip.length - 1.5f;
                _lastObjectSkipTime = lastObjectTime + 0.5f;
            }
            _init = true;
            Logger.log.Debug($"Skippable Intro: {_skippableIntro} | Skippable Outro: {_skippableOutro}");
            Logger.log.Debug($"First Object Time: {firstObjectTime} | Last Object Time: {lastObjectTime}");
            Logger.log.Debug($"Intro Skip Time: {_introSkipTime} | Outro Skip Time: {_outroSkipTime}");
        }
Exemplo n.º 5
0
        public bool IsChromaActive()
        {
            BeatmapObjectCallbackController s = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
            BeatmapData _beatmapData          = s?.GetField <BeatmapData, BeatmapObjectCallbackController>("_beatmapData");
            var         beatmap = SongCore.Collections.RetrieveDifficultyData(BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap).additionalDifficultyData;

            return(beatmap._requirements.Contains("Chroma") || beatmap._suggestions.Contains("Chroma") ||
                   (_beatmapData?.beatmapEventData?.Any(n => n.value >= 2000000000) ?? false));
        }
Exemplo n.º 6
0
        public static IEnumerator RandomBombs(float length)
        {
            var text = GameObject.Find("Chat Powers").GetComponent <GamePlayModifiersPlus.TwitchStuff.GMPDisplay>().activeCommandText;

            text.text += " Bombs | ";


            yield return(new WaitForSeconds(0f));

            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            BeatmapObjectData[] objects;
            NoteData            note;
            float start = Plugin.songAudio.time + 2;
            float end   = start + length + 2f;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        if (beatmapObject.time > start && beatmapObject.time < end)
                        {
                            try
                            {
                                //                        Plugin.Log("Attempting to Convert to Bomb");
                                note = beatmapObject as NoteData;

                                int randMax = (int)((1 / ChatConfig.bombsChance) * 100);
                                int randMin = 100;
                                int random  = Random.Range(1, randMax);

                                //                Plugin.Log("Min: " + randMin + " Max: " + randMax + " Number: " + random);

                                if (random <= randMin || ChatConfig.bombsChance == 1)
                                {
                                    note.SetProperty("noteType", NoteType.Bomb);
                                }
                            }
                            catch (System.Exception ex)
                            {
                                Plugin.Log(ex.ToString());
                            }
                        }
                    }
                }
            }
            yield return(new WaitForSeconds(length + 2f));

            text.text = text.text.Replace(" Bombs | ", "");
            callbackController.SetField("_beatmapData", beatmapData);
        }
Exemplo n.º 7
0
        private IEnumerator TransformMap()
        {
            yield return(new WaitForSecondsRealtime(0.01f));

            if (BS_Utils.Plugin.LevelData.Mode == BS_Utils.Gameplay.Mode.Multiplayer)
            {
                yield break;
            }

            var config = Configuration.instance.ConfigurationData;

            // Set up for One Color
            if (config.OneColor && !config.NoArrowsRandom)
            {
                this.useLeft =
                    (config.PlayMode == PlayMode.BeatSaber && config.UseLeftSaber) ||
                    (config.PlayMode == PlayMode.DarthMaul && config.UseLeftController) ||
                    (config.PlayMode == PlayMode.BeatSpear && config.UseLeftSpear);

                this.undesiredNoteType = this.useLeft ? ColorType.ColorB : ColorType.ColorA;
            }

            try
            {
                BeatmapObjectCallbackController callbackController = null;
                BeatmapData beatmapData = null;
                BeatmapObjectCallbackController[] callbackControllers = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>();
                foreach (BeatmapObjectCallbackController cbc in callbackControllers)
                {
                    if (cbc.GetField <BeatmapData>("_beatmapData") != null)
                    {
                        callbackController = cbc;
                        beatmapData        = callbackController.GetField <BeatmapData>("_beatmapData");
                    }
                }
                if (config.NoArrowsRandom)
                {
                    // Transform the map to No Arrows Random using the ingame algorithm first
                    AlternativePlay.Logger.Info($"Transforming NoArrowsRandom for song: {this.currentBeatmap.level.songName}");
                    var transformedBeatmap = BeatmapDataNoArrowsTransform.CreateTransformedData(beatmapData);
                    callbackController.SetNewBeatmapData(transformedBeatmap);
                }

                // Transform every note
                this.TransformNotes(beatmapData);

                // Touch Notes speed detection is not handled here but in the HarmonyPatches
            }
            catch (Exception e)
            {
                AlternativePlay.Logger.Error($"Transforming Error: {this.currentBeatmap.level.songName}");
                AlternativePlay.Logger.Error($"Error Message: {e.Message}");
                AlternativePlay.Logger.Error($"Stack Trace: {e.StackTrace}");
            }
        }
Exemplo n.º 8
0
        IEnumerator ReadEvents()
        {
            yield return(new WaitForSeconds(0f));

            BeatmapObjectCallbackController beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>()
                                                                              .FirstOrDefault();
            BeatmapData dataModel = beatmapObjectCallbackController.GetField <BeatmapData>("_beatmapData");

            BeatmapData beatmapData = ReadBeatmapEvents(dataModel);

            //ChromaLogger.Log("Events read!");
        }
Exemplo n.º 9
0
        public static IEnumerator Reverse(float length)
        {
            var text = GameObject.Find("Chat Powers").GetComponent <GamePlayModifiersPlus.TwitchStuff.GMPDisplay>().activeCommandText;

            text.text += " Reverse | ";
            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            BeatmapObjectData[] objects;
            NoteData            note;
            float start = Plugin.songAudio.time + 2;
            float end   = start + length + 2f;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        if (beatmapObject.time > start && beatmapObject.time < end)
                        {
                            note = beatmapObject as NoteData;

                            note.SwitchNoteType();
                            //                           note.MirrorTransformCutDirection();
                            //                           note.MirrorLineIndex(4);
                        }
                    }
                }
            }

            yield return(new WaitForSeconds(2f));

            GMPUI.reverse = true;
            AdjustNjsOrOffset();
            Plugin.reverseSound.Play();
            DestroyNotes();
            //Code to show some kinda prompt here maybe
            yield return(new WaitForSeconds(length));

            GMPUI.reverse = false;
            AdjustNjsOrOffset();
            //Code to destroy notes here
            Plugin.reverseSound.Play();
            DestroyNotes();

            text.text = text.text.Replace(" Reverse | ", "");
        }
Exemplo n.º 10
0
        public static void StaticLights()
        {
            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            float start     = Plugin.songAudio.time;
            int?  nextIndex = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>()?.FirstOrDefault()?.GetField <int>("_nextEventIndex");

            BeatmapEventData[] newData = new BeatmapEventData[beatmapData.beatmapEventData.Length];
            if (nextIndex.HasValue)
            {
                newData[nextIndex.Value]     = new BeatmapEventData(start + .01f, BeatmapEventType.Event0, 1);
                newData[nextIndex.Value + 1] = new BeatmapEventData(start + .01f, BeatmapEventType.Event4, 1);
            }
            beatmapData.SetProperty("beatmapEventData", newData);
        }
Exemplo n.º 11
0
        IEnumerator GrabLight()
        {
            yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().Any() && Resources.FindObjectsOfTypeAll <ColorManager>().Any() && Resources.FindObjectsOfTypeAll <ColorSchemeSO>().Any()));

            Ec = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
            Logger.log.Info("Found LightController");
            Ec.beatmapEventDidTriggerEvent += EventHappened;
            cm = Resources.FindObjectsOfTypeAll <ColorManager>().LastOrDefault();
            ColorScheme ColorScheme = cm.GetField <ColorScheme>("_colorScheme");

            Logger.log.Info(ColorScheme.colorSchemeName.ToString());
            Logger.log.Info("Sending environment colors");
            var         beatmap      = SongCore.Collections.RetrieveDifficultyData(BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap)?.additionalDifficultyData;
            BeatmapData _beatmapData = Ec?.GetField <BeatmapData>("_beatmapData");

            //Chroma setup

            if (beatmap == null)
            {
                Logger.log.Info("Disable Chroma");
                port.Write(new byte[] { (byte)CHROMATYPE, (byte)0 }, 0, 2);
            }
            else
            if (beatmap._requirements.Contains("Chroma") || beatmap._suggestions.Contains("Chroma") || (_beatmapData?.beatmapEventsData?.Any(n => n.value >= 2000000000) ?? false))
            {
                //Enable chroma
                Logger.log.Info("enable Chroma");
                port.Write(new byte[] { (byte)CHROMATYPE, (byte)1 }, 0, 2);
            }
            else
            {
                Logger.log.Info("Disable Chroma");
                port.Write(new byte[] { (byte)CHROMATYPE, (byte)0 }, 0, 2);
            }
            //Color setup
            Color32?left         = ColorScheme.environmentColor0;
            Color32?right        = ColorScheme.environmentColor1;
            int     onebyteleft  = ((left.Value.r / 32) << 5) + ((left.Value.g / 32) << 2) + (left.Value.b / 64);
            int     onebyteright = ((right.Value.r / 32) << 5) + ((right.Value.g / 32) << 2) + (right.Value.b / 64);

            port.Write(new byte[] { LEFTCOLOR, (byte)onebyteleft }, 0, 2);
            port.Write(new byte[] { RIGHTCOLOR, (byte)onebyteright }, 0, 2);
            Logger.log.Info(right.ToString());
            Logger.log.Info(left.ToString());
            port.Write(new byte[] { TURNOFFALLLIGHTS, 0 }, 0, 2);
        }
Exemplo n.º 12
0
        public static void MirrorSection(float length)
        {
            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            BeatmapObjectData[] objects;
            NoteData            note;
            ObstacleData        obstacle;
            float start = Plugin.songAudio.time + 4f;
            float end   = start + length;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        if (beatmapObject.time > start && beatmapObject.time < end)
                        {
                            note = beatmapObject as NoteData;
                            note.SwitchNoteType();
                            if (note.noteType != NoteType.Bomb)
                            {
                                note.MirrorTransformCutDirection();
                            }
                            note.MirrorLineIndex(4);
                        }
                    }
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Obstacle)
                    {
                        if (beatmapObject.time > start && beatmapObject.time < end)
                        {
                            obstacle = beatmapObject as ObstacleData;
                            obstacle.MirrorLineIndex(4);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        public void ReplaceNextXNotesWith(float duration, Action <NoteData> callback)
        {
            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            BeatmapObjectData[] objects;
            NoteData            note;

            var spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault();

            if (spawnController == null)
            {
                Plugin.log.Info("Spawn manager was null!");
            }

            var movementData =
                spawnController.GetField <BeatmapObjectSpawnMovementData>("_beatmapObjectSpawnMovementData");


            float start = (Time.time - Jukebox.instance.songStart) + movementData.spawnAheadTime + 0.1f;
            float end   = start + duration + 2f;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        if (beatmapObject.time > start && beatmapObject.time < end)
                        {
                            note = beatmapObject as NoteData;
                            if (note != null)
                            {
                                callback?.Invoke(note);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public static IEnumerator TempNoArrows(float length)
        {
            var text = GameObject.Find("Chat Powers").GetComponent <GamePlayModifiersPlus.TwitchStuff.GMPDisplay>().activeCommandText;

            text.text += " NoArrows | ";
            yield return(new WaitForSeconds(0f));

            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            BeatmapObjectData[] objects;
            NoteData            note;
            float start = Plugin.songAudio.time + 2;
            float end   = start + length + 2f;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        if (beatmapObject.time > start && beatmapObject.time < end)
                        {
                            note = beatmapObject as NoteData;

                            note.SetNoteToAnyCutDirection();
                            note.TransformNoteAOrBToRandomType();
                        }
                    }
                }
            }
            yield return(new WaitForSeconds(length + 2f));

            text.text = text.text.Replace(" NoArrows | ", "");
            //    dataModel.beatmapData = beatmapData;
        }
Exemplo n.º 15
0
        public static IEnumerator PermaEncasement(float start)
        {
            yield return(new WaitForSeconds(0f));

            float startTime    = start;
            float durationTime = Plugin.songAudio.clip.length;


            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            List <BeatmapObjectData> objects;

            objects = beatmapData.beatmapLinesData[0].beatmapObjectsData.ToList();
            objects.Add(new ObstacleData(14131, startTime, -1, (ObstacleType)4000, durationTime, 1001));
            objects.Add(new ObstacleData(14132, startTime, 4, (ObstacleType)4000, durationTime, 1001));
            objects.Add(new ObstacleData(14133, startTime, -1, (ObstacleType)1001, durationTime, 6500));
            objects.Add(new ObstacleData(14134, startTime, -1, (ObstacleType)5000, durationTime, 6500));
            objects = objects.OrderBy(o => o.time).ToList();
            beatmapData.beatmapLinesData[0].beatmapObjectsData = objects.ToArray();
            objects.Clear();
        }
Exemplo n.º 16
0
        public static IEnumerator PermaReverse()
        {
            yield return(new WaitForSecondsRealtime(1f));

            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            BeatmapObjectData[] objects;
            NoteData            note;
            float start = Plugin.songAudio.time + 2;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        if (beatmapObject.time > start)
                        {
                            note = beatmapObject as NoteData;

                            note.SwitchNoteType();
                            //                           note.MirrorTransformCutDirection();
                            //                           note.MirrorLineIndex(4);
                        }
                    }
                }
            }

            yield return(new WaitForSeconds(2f));

            AdjustNjsOrOffset();
            Plugin.reverseSound.Play();
            DestroyNotes();
        }
Exemplo n.º 17
0
        internal static IEnumerator DelayedStart()
        {
            yield return(new WaitForEndOfFrame());

            AudioTimeSyncController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().First();
            BeatmapObjectSpawnController beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().First();
            BeatmapObjectManager         beatmapObjectManager         = _beatmapObjectSpawnAccessor(ref beatmapObjectSpawnController) as BeatmapObjectManager;

            SongBPM = beatmapObjectSpawnController.currentBpm;
            BeatmapObjectCallbackController coreSetup   = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            IReadonlyBeatmapData            beatmapData = coreSetup.GetField <IReadonlyBeatmapData, BeatmapObjectCallbackController>("_beatmapData");

            beatmapObjectManager.noteWasCutEvent -= NoteColorizer.ColorizeSaber;
            beatmapObjectManager.noteWasCutEvent += NoteColorizer.ColorizeSaber;

            if (ChromaConfig.Instance.LightshowModifier)
            {
                foreach (BeatmapLineData b in beatmapData.beatmapLinesData)
                {
                    BeatmapLineData refBeatmapLineData = b;
                    _beatmapObjectsDataAccessor(ref refBeatmapLineData) = b.beatmapObjectsData.Where((source, index) => b.beatmapObjectsData[index].beatmapObjectType != BeatmapObjectType.Note).ToList();
                }

                foreach (Saber saber in Resources.FindObjectsOfTypeAll <Saber>())
                {
                    saber.gameObject.SetActive(false);
                }

                BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Chroma");

                if (ChromaConfig.Instance.PlayersPlace)
                {
                    GameObject.Find("PlayersPlace")?.SetActive(false);
                }

                if (ChromaConfig.Instance.Spectrograms)
                {
                    GameObject.Find("Spectrograms")?.SetActive(false);
                }

                if (ChromaConfig.Instance.BackColumns)
                {
                    GameObject.Find("BackColumns")?.SetActive(false);
                }

                if (ChromaConfig.Instance.Buildings)
                {
                    GameObject.Find("Buildings")?.SetActive(false);
                }
            }

            if (Harmony.HasAnyPatches(HARMONYID))
            {
                if (beatmapData is CustomBeatmapData customBeatmap)
                {
                    if (ChromaConfig.Instance.EnvironmentEnhancementsEnabled)
                    {
                        // Spaghetti code below until I can figure out a better way of doing this
                        dynamic       dynData       = customBeatmap.beatmapCustomData;
                        List <object> objectsToKill = Trees.at(dynData, "_environmentRemoval");
                        if (objectsToKill != null)
                        {
                            IEnumerable <GameObject> gameObjects = Resources.FindObjectsOfTypeAll <GameObject>();
                            foreach (string s in objectsToKill.Cast <string>())
                            {
                                if (s == "TrackLaneRing" || s == "BigTrackLaneRing")
                                {
                                    foreach (GameObject n in gameObjects.Where(obj => obj.name.Contains(s)))
                                    {
                                        if (s == "TrackLaneRing" && n.name.Contains("Big"))
                                        {
                                            continue;
                                        }

                                        n.SetActive(false);
                                    }
                                }
                                else
                                {
                                    foreach (GameObject n in gameObjects
                                             .Where(obj => obj.name.Contains(s) && (obj.scene.name?.Contains("Environment") ?? false) && (!obj.scene.name?.Contains("Menu") ?? false)))
                                    {
                                        n.SetActive(false);
                                    }
                                }
                            }
                        }
                    }
                }

                // please let me kill legacy
                LegacyLightHelper.Activate(beatmapData.beatmapEventsData);
            }
        }
Exemplo n.º 18
0
        public static IEnumerator OneColor()
        {
            yield return(new WaitForSeconds(0f));

            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            BeatmapObjectData[] objects;
            NoteData            note;

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        note = beatmapObject as NoteData;
                        note.SetProperty("noteType", NoteType.NoteB);
                    }
                }
            }
            //Adjust Sabers for one color
            yield return(new WaitForSeconds(0.2f));

            var leftSaberType = Plugin.player.leftSaber.GetField <SaberTypeObject>("_saberType");

            try
            {
                leftSaberType.SetField("_saberType", Saber.SaberType.SaberB);
            }
            catch (System.Exception ex)
            {
                Plugin.Log(ex.ToString());
            }

            //     Plugin.Log("2 " + Plugin.player.leftSaber.saberType.ToString());
            if (Plugin.customColorsInstalled)
            {
                Plugin.ResetCustomColorsSabers(Plugin.oldColorB, Plugin.oldColorB);
            }

            /*
             * var playerController = Resources.FindObjectsOfTypeAll<PlayerController>().First();
             * Saber targetSaber = playerController.rightSaber;
             * Saber otherSaber = playerController.leftSaber;
             * var targetCopy = Instantiate(targetSaber.gameObject);
             * Saber newSaber = targetCopy.GetComponent<Saber>();
             * targetCopy.transform.parent = targetSaber.transform.parent;
             * targetCopy.transform.localPosition = Vector3.zero;
             * targetCopy.transform.localRotation = Quaternion.identity;
             * targetSaber.transform.parent = otherSaber.transform.parent;
             * targetSaber.transform.localPosition = Vector3.zero;
             * targetSaber.transform.localRotation = Quaternion.identity;
             * otherSaber.gameObject.SetActive(false);
             *
             * ReflectionUtil.SetPrivateField(playerController, "_leftSaber", targetSaber);
             * ReflectionUtil.SetPrivateField(playerController, "_rightSaber", newSaber);
             *
             * playerController.leftSaber.gameObject.SetActive(true);
             */
            //    dataModel.beatmapData = beatmapData;
        }
Exemplo n.º 19
0
        public static IEnumerator ExtraLanes()
        {
            yield return(new WaitForSeconds(0f));

            MappingExtensions.Plugin.ForceActivateForSong();
            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            Plugin.Log("Grabbed BeatmapData");
            BeatmapObjectData[] objects;
            NoteData            note;

            System.Collections.Generic.List <float> claimedCenterTimes = new System.Collections.Generic.List <float>();
            System.Collections.Generic.List <float> noteTimes          = new System.Collections.Generic.List <float>();
            System.Collections.Generic.List <float> doubleTimes        = new System.Collections.Generic.List <float>();
            //Iterate through once to log double times
            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        note = beatmapObject as NoteData;

                        if (noteTimes.Contains(note.time))
                        {
                            doubleTimes.Add(note.time);
                        }
                        else
                        {
                            noteTimes.Add(note.time);
                        }
                    }
                }
            }
            noteTimes.Clear();

            foreach (BeatmapLineData line in beatmapData.beatmapLinesData)
            {
                objects = line.beatmapObjectsData;
                foreach (BeatmapObjectData beatmapObject in objects)
                {
                    if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note)
                    {
                        note = beatmapObject as NoteData;
                        if (GMPUI.sixLanes || GMPUI.fiveLanes)
                        {
                            if (!doubleTimes.Contains(note.time))// || GMPUI.laneShift)
                            {
                                if (note.lineIndex == 0 && Random.Range(1, 4) >= 2)
                                {
                                    note.MirrorLineIndex(0);
                                }
                                // line index 3
                                if (note.lineIndex == 3 && Random.Range(1, 4) >= 2)
                                {
                                    note.MirrorLineIndex(8);
                                }
                            }
                        }
                        if (GMPUI.fourLayers)
                        {
                            if (note.noteLineLayer == NoteLineLayer.Top && Random.Range(1, 4) > 2)
                            {
                                note.SetProperty("noteLineLayer", (NoteLineLayer)3);
                            }
                        }
                        int newIndex = 0;
                        if (GMPUI.fiveLanes)
                        {
                            switch (note.lineIndex)
                            {
                            case 0:
                                newIndex = 1500;
                                break;

                            case 1:
                                newIndex = UnityEngine.Random.Range(0, 10) > 3 || claimedCenterTimes.Contains(note.time) ? 1500 : 2500;
                                if (Random.Range(0, 8) > 6)
                                {
                                    newIndex = -1500;
                                }
                                break;

                            case 2:
                                newIndex = UnityEngine.Random.Range(0, 10) > 3 || claimedCenterTimes.Contains(note.time) ? 3500 : 2500;
                                if (Random.Range(0, 8) > 6)
                                {
                                    newIndex = 4500;
                                }
                                break;

                            case 3:
                                newIndex = 3500;
                                break;

                            default:
                                if (note.lineIndex < 0)
                                {
                                    newIndex = -1500;
                                }
                                if (note.lineIndex > 3)
                                {
                                    newIndex = 4500;
                                }
                                break;
                            }
                            note.SetProperty("lineIndex", newIndex);
                            note.SetProperty("flipLineIndex", newIndex);
                            if (newIndex == 2500)
                            {
                                claimedCenterTimes.Add(note.time);
                            }
                        }

                        if (!doubleTimes.Contains(note.time))
                        {
                            if (GMPUI.laneShift)
                            {
                                if (!(note.lineIndex >= 1000 || note.lineIndex <= -1000))
                                {
                                    int shiftedIndex = (note.lineIndex * 1000) + (UnityEngine.Random.Range(1, 8) * 100);
                                    if (note.lineIndex < 0)
                                    {
                                        shiftedIndex = (note.lineIndex * 1000) - (UnityEngine.Random.Range(1, 8) * 100);
                                    }
                                    if (note.lineIndex == 0)
                                    {
                                        shiftedIndex = 1000 + (UnityEngine.Random.Range(1, 8) * 100);
                                    }
                                    note.SetProperty("lineIndex", shiftedIndex);
                                    note.SetProperty("flipLineIndex", shiftedIndex);
                                }
                                else if (note.lineIndex >= 1000 && note.lineIndex <= 4500)
                                {
                                    int shiftedIndex = note.lineIndex + (UnityEngine.Random.Range(1, 7) * 100);
                                    note.SetProperty("lineIndex", shiftedIndex);
                                    note.SetProperty("flipLineIndex", shiftedIndex);
                                }
                            }
                        }

                        if (GMPUI.angleShift && !((int)note.cutDirection >= 1000))
                        {
                            int angle = 1000;
                            switch (note.cutDirection)
                            {
                            case NoteCutDirection.Any:
                                angle = -1;
                                break;

                            case NoteCutDirection.Down:
                                angle = 1000;
                                break;

                            case NoteCutDirection.DownLeft:
                                angle = 1045;
                                break;

                            case NoteCutDirection.Left:
                                angle = 1090;
                                break;

                            case NoteCutDirection.UpLeft:
                                angle = 1135;
                                break;

                            case NoteCutDirection.Up:
                                angle = 1180;
                                break;

                            case NoteCutDirection.UpRight:
                                angle = 1225;
                                break;

                            case NoteCutDirection.Right:
                                angle = 1270;
                                break;

                            case NoteCutDirection.DownRight:
                                angle = 1315;
                                break;
                            }
                            if (angle == 2000)
                            {
                                //Do Nothing for now
                            }
                            else if (angle >= 1000)
                            {
                                angle += Random.Range(-30, 30);
                                angle  = Mathf.Clamp(angle, 1000, 1360);
                                note.SetProperty("cutDirection", angle);
                            }
                        }

                        noteTimes.Add(note.time);
                    }
                }
            }
            //    dataModel.beatmapData = beatmapData;
        }
Exemplo n.º 20
0
        private IEnumerator TransformMap()
        {
            yield return(new WaitForSecondsRealtime(0.1f));

            var config = Configuration.instance.ConfigurationData;

            // Set up for One Color
            if (config.OneColor && !config.NoArrowsRandom)
            {
                this.useLeft =
                    (config.PlayMode == PlayMode.BeatSaber && config.UseLeftSaber) ||
                    (config.PlayMode == PlayMode.DarthMaul && config.UseLeftController) ||
                    (config.PlayMode == PlayMode.BeatSpear && config.UseLeftSpear);

                this.undesiredNoteType = this.useLeft ? ColorType.ColorB : ColorType.ColorA;

                // Change the other saber to desired type
                SaberType desiredSaberType = this.useLeft ? SaberType.SaberA : SaberType.SaberB;
                var       saberObject      = new GameObject("SaberTypeObject").AddComponent <SaberTypeObject>();
                saberObject.SetField("_saberType", desiredSaberType);

                var   player      = Resources.FindObjectsOfTypeAll <SaberManager>().FirstOrDefault();
                Saber saberToSwap = this.useLeft ? player.rightSaber : player.leftSaber;
                saberToSwap.SetField("_saberType", saberObject);
            }

            try
            {
                BeatmapObjectCallbackController callbackController = null;
                BeatmapData beatmapData = null;
                BeatmapObjectCallbackController[] callbackControllers = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>();
                foreach (BeatmapObjectCallbackController cbc in callbackControllers)
                {
                    if (cbc.GetField <BeatmapData>("_beatmapData") != null)
                    {
                        callbackController = cbc;
                        beatmapData        = callbackController.GetField <BeatmapData>("_beatmapData");
                    }
                }
                //BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll<BeatmapObjectCallbackController>().FirstOrDefault();
                // BeatmapData beatmapData = callbackController.GetField<BeatmapData>("_beatmapData");
                if (config.NoArrowsRandom)
                {
                    // Transform the map to No Arrows Random using the ingame algorithm first
                    AlternativePlay.Logger.Info($"Transforming NoArrowsRandom for song: {this.currentBeatmap.level.songName}");
                    var transformedBeatmap = BeatmapDataNoArrowsTransform.CreateTransformedData(beatmapData);
                    callbackController.SetNewBeatmapData(transformedBeatmap);
                }

                // Transform every note
                var allNoteObjects = beatmapData.beatmapLinesData
                                     .SelectMany(line => line.beatmapObjectsData)
                                     .Where(objectData => objectData.beatmapObjectType == BeatmapObjectType.Note)
                                     .ToList();
                allNoteObjects.ForEach(beatmapObject =>
                {
                    var note = beatmapObject as NoteData;

                    // Transform for NoArrows or TouchNotes here but do not if NoArrowsRandom was already applied
                    if ((config.NoArrows || config.TouchNotes) && !config.NoArrowsRandom)
                    {
                        note.SetNoteToAnyCutDirection();
                    }

                    // Transform for One Color if this is the other note type
                    if (config.OneColor && note.colorType == this.undesiredNoteType)
                    {
                        note.SwitchNoteColorType();
                    }
                });
                // Touch Notes speed detection is not handled here but in the HarmonyPatches
            }
            catch
            {
                AlternativePlay.Logger.Info($"Transforming Error: {this.currentBeatmap.level.songName}");
            }

            // Touch Notes speed detection is not handled here but in the HarmonyPatches
        }
Exemplo n.º 21
0
        private IEnumerator TransformMap()
        {
            yield return(new WaitForSecondsRealtime(0.1f));

            // Set up for One Color
            if (ConfigOptions.instance.OneColor && !ConfigOptions.instance.NoArrowsRandom)
            {
                this.useLeft =
                    (ConfigOptions.instance.PlayMode == PlayMode.BeatSaber && ConfigOptions.instance.UseLeftSaber) ||
                    (ConfigOptions.instance.PlayMode == PlayMode.DarthMaul && ConfigOptions.instance.UseLeftController) ||
                    (ConfigOptions.instance.PlayMode == PlayMode.BeatSpear && ConfigOptions.instance.UseLeftSpear);

                this.undesiredNoteType = this.useLeft ? NoteType.NoteB : NoteType.NoteA;

                // Change the other saber to desired type
                Saber.SaberType desiredSaberType = this.useLeft ? Saber.SaberType.SaberA : Saber.SaberType.SaberB;
                var             saberObject      = new GameObject("SaberTypeObject").AddComponent <SaberTypeObject>();
                saberObject.SetField("_saberType", desiredSaberType);

                var   player      = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault();
                Saber saberToSwap = this.useLeft ? player.rightSaber : player.leftSaber;
                saberToSwap.SetField("_saberType", saberObject);

                if (ConfigOptions.instance.RemoveOtherSaber && ConfigOptions.instance.PlayMode == PlayMode.BeatSaber)
                {
                    // Hide the off color saber
                    Saber saberToHide = ConfigOptions.instance.UseLeftSaber ? this.playerController.rightSaber : this.playerController.leftSaber;
                    saberToHide.gameObject.SetActive(false);
                }
            }

            // Get the in memory beat map
            BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First();
            BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData");

            if (ConfigOptions.instance.NoArrowsRandom)
            {
                // Transform the map to No Arrows Random using the ingame algorithm first
                Logging.Info($"Transforming NoArrowsRandom for song: {this.currentBeatmap.level.songName}");
                var transformedBeatmap = BeatmapDataNoArrowsTransform.CreateTransformedData(beatmapData, true);
                callbackController.SetNewBeatmapData(transformedBeatmap);
            }

            // Transform every note
            var allNoteObjects = beatmapData.beatmapLinesData
                                 .SelectMany(line => line.beatmapObjectsData)
                                 .Where(objectData => objectData.beatmapObjectType == BeatmapObjectType.Note)
                                 .ToList();

            allNoteObjects.ForEach(beatmapObject =>
            {
                var note = beatmapObject as NoteData;

                // Transform for NoArrows or TouchNotes here but do not if NoArrowsRandom was already applied
                if ((ConfigOptions.instance.NoArrows || ConfigOptions.instance.TouchNotes) && !ConfigOptions.instance.NoArrowsRandom)
                {
                    note.SetNoteToAnyCutDirection();
                }

                // Transform for One Color if this is the other note type
                if (ConfigOptions.instance.OneColor && note.noteType == undesiredNoteType)
                {
                    note.SwitchNoteType();
                }
            });

            // Touch Notes speed detection is not handled here but in the HarmonyPatches
        }