public void Init(OnlinePlayerController newOwner)
        {
            BeatmapObjectCallbackController original = FindObjectsOfType <BeatmapObjectCallbackController>().First(x => !(x is OnlineBeatmapCallbackController));

            foreach (FieldInfo info in original.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).Where(x => !x.Name.ToLower().Contains("event")))
            {
                info.SetValue(this, info.GetValue(original));
            }

            owner = newOwner;

            _beatmapObjectDataCallbackCacheList = new List <BeatmapObjectData>();
            _beatmapObjectCallbackData          = new List <BeatmapObjectCallbackData>();

            _beatmapDataModel = new GameObject("CustomBeatmapDataModel").AddComponent <BeatmapDataModel>();
            if (BS_Utils.Plugin.LevelData.IsSet)
            {
                LevelOptionsInfo   levelInfo   = owner.playerInfo.updateInfo.playerLevelOptions;
                IDifficultyBeatmap diffBeatmap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.beatmapLevelData.difficultyBeatmapSets.First(x => x.beatmapCharacteristic.serializedName == owner.playerInfo.updateInfo.playerLevelOptions.characteristicName).difficultyBeatmaps.First(x => x.difficulty == owner.playerInfo.updateInfo.playerLevelOptions.difficulty);
                BeatmapData        data        = diffBeatmap.beatmapData;

                _beatmapDataModel.beatmapData = BeatDataTransformHelper.CreateTransformedBeatmapData(data, levelInfo.modifiers.ToGameplayModifiers(), PracticeSettings.defaultPracticeSettings, PlayerSpecificSettings.defaultSettings);
                HandleBeatmapDataModelDidChangeBeatmapData();

                Plugin.log.Info($"Set custom BeatmapDataModel for difficulty {levelInfo.difficulty}");
            }
        }
Exemplo n.º 2
0
        static bool Prefix(IReadonlyBeatmapData beatmapData, ref IReadonlyBeatmapData __result)
        {
            if (!Configuration.PluginConfig.Instance.wallsInZenMode)
            {
                return(true);
            }

            BeatmapData copyWithoutBeatmapObjects = beatmapData.GetCopyWithoutBeatmapObjects();

            BeatmapData.CopyBeatmapObjectsWaypointsOnly(beatmapData, copyWithoutBeatmapObjects);

            foreach (BeatmapObjectData beatmapObjectData in beatmapData.beatmapObjectsData)
            {
                if (beatmapObjectData.beatmapObjectType != BeatmapObjectType.Obstacle)
                {
                    continue;
                }

                copyWithoutBeatmapObjects.AddBeatmapObjectData(beatmapObjectData.GetCopy());
            }

            __result = copyWithoutBeatmapObjects;

            return(false);
        }
Exemplo n.º 3
0
        static bool Prefix(BeatmapData beatmapData, ref BeatmapData __result)
        {
            BeatmapEventData[]      beatmapEventData = beatmapData.beatmapEventData;
            List <BeatmapEventData> list             = new List <BeatmapEventData>(beatmapEventData.Length);

            list.Add(new BeatmapEventData(0f, BeatmapEventType.Event0, 1));
            list.Add(new BeatmapEventData(0f, BeatmapEventType.Event4, 1));
            foreach (BeatmapEventData beatmapEventData2 in beatmapEventData)
            {
                if (beatmapEventData2.type.IsRotationEvent())
                {
                    list.Add(beatmapEventData2);
                }
            }

            if (beatmapData is CustomBeatmapData customBeatmap)
            {
                __result = new CustomBeatmapData(beatmapData.GetBeatmapLineDataCopy(), list.ToArray(), customBeatmap.customEventData, customBeatmap.beatmapCustomData, customBeatmap.levelCustomData);
            }
            else
            {
                __result = new BeatmapData(beatmapData.GetBeatmapLineDataCopy(), list.ToArray());
            }
            return(false);
        }
Exemplo n.º 4
0

        
Exemplo n.º 5
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static void Postfix(BeatmapData __result, float startBpm)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (__result == null)
            {
                return;
            }

            if (__result is CustomBeatmapData customBeatmapData)
            {
                TrackManager trackManager = new TrackManager(customBeatmapData);
                foreach (BeatmapLineData beatmapLineData in customBeatmapData.beatmapLinesData)
                {
                    foreach (BeatmapObjectData beatmapObjectData in beatmapLineData.beatmapObjectsData)
                    {
                        dynamic customData;
                        if (beatmapObjectData is CustomObstacleData || beatmapObjectData is CustomNoteData || beatmapObjectData is WaypointData)
                        {
                            customData = beatmapObjectData;
                        }
                        else
                        {
                            continue;
                        }

                        dynamic dynData = customData.customData;

                        // TODO: account for base game bpm changes
                        // for per object njs and spawn offset
                        float bpm = startBpm;
                        dynData.bpm = bpm;

                        // for epic tracks thing
                        string trackName = Trees.at(dynData, TRACK);
                        if (trackName != null)
                        {
                            dynData.track = trackManager.AddTrack(trackName);
                        }
                    }
                }

                customBeatmapData.customData.tracks = trackManager.Tracks;

                IEnumerable <dynamic> pointDefinitions = (IEnumerable <dynamic>)Trees.at(customBeatmapData.customData, POINTDEFINITIONS);
                if (pointDefinitions == null)
                {
                    return;
                }

                PointDefinitionManager pointDataManager = new PointDefinitionManager();
                foreach (dynamic pointDefintion in pointDefinitions)
                {
                    string          pointName = Trees.at(pointDefintion, NAME);
                    PointDefinition pointData = PointDefinition.DynamicToPointData(Trees.at(pointDefintion, POINTS));
                    pointDataManager.AddPoint(pointName, pointData);
                }

                customBeatmapData.customData.pointDefinitions = pointDataManager.PointData;
            }
        }
Exemplo n.º 6
0
            bool ICJDHandler.GetField(BeatmapData beatmap, string field, out object obj)
            {
                try
                {
                    if (!_isValid)
                    {
                        obj = null;
                        return(false);
                    }

                    var dict = _cjdLevelCustomDataType.GetValue(beatmap) as Dictionary <string, object>;

                    if (dict == null || !dict.TryGetValue(field, out obj))
                    {
                        obj = null;
                        return(false);
                    }

                    if (obj == null)
                    {
                        return(false);
                    }

                    return(true);
                }
                catch (Exception)
                {
                    obj = null;
                    return(false);
                }
            }
Exemplo n.º 7
0
        private async void ReloadBeatmap()
        {
            string filePath  = Path.Combine(_currentLevel.customLevelPath, _currentDiffBeatmap.beatmapFilename);
            string leveljson = File.ReadAllText(filePath);
            //Load new beatmapdata asynchronously
            BeatmapData newBeatmap = await _levelLoader.LoadBeatmapDataAsync(_currentLevel.customLevelPath, _currentDiffBeatmap.beatmapFilename, _currentLevel.standardLevelInfoSaveData, _cancelSource.Token);

            GameplayCoreSceneSetupData     gameSetup = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData;
            EnvironmentEffectsFilterPreset environmentEffectsFilterPreset = ((BeatmapDifficulty)(Enum.Parse(typeof(BeatmapDifficulty), _currentDiffBeatmap.difficulty)) == BeatmapDifficulty.ExpertPlus) ? gameSetup.playerSpecificSettings.environmentEffectsFilterExpertPlusPreset : gameSetup.playerSpecificSettings.environmentEffectsFilterDefaultPreset;

            newBeatmap = (BeatmapData)BeatmapDataTransformHelper.CreateTransformedBeatmapData(newBeatmap, _currentLevel, gameSetup.gameplayModifiers, gameSetup.practiceSettings, gameSetup.playerSpecificSettings.leftHanded, environmentEffectsFilterPreset, gameSetup.environmentInfo.environmentIntensityReductionOptions);
            //Hotswap Beatmap

            ResetTimeSync();
            DestroyObjects();
            ResetNoteCutSoundEffects();
            _callbackController.SetField("_spawningStartTime", _songStartTime);
            _callbackController.SetNewBeatmapData(newBeatmap);
            //Unpause
            if (_pauseController.GetField <bool>("_paused"))
            {
                CheckPracticePlugin();
                _pauseController.HandlePauseMenuManagerDidPressContinueButton();
            }
            _queuedLoad = false;
        }
Exemplo n.º 8
0
        public static IEnumerator NoArrows()
        {
            Plugin.Log("Starting");

            yield return(new WaitForSeconds(0f));

            GameplayCoreSceneSetup gameplayCoreSceneSetup = Resources.FindObjectsOfTypeAll <GameplayCoreSceneSetup>().First();
            BeatmapDataModel       dataModel = gameplayCoreSceneSetup.GetField <BeatmapDataModel>("_beatmapDataModel");

            Plugin.Log(dataModel.beatmapData.bombsCount.ToString());
            BeatmapData beatmapData = dataModel.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.º 9
0
        public static BeatmapData CreateTransformedBeatmapData(BeatmapData beatmapData, GameplayOptions gameplayOptions, GameplayMode gameplayMode)
        {
            BeatmapData beatmapData2 = beatmapData;

            if (gameplayOptions.mirror)
            {
                beatmapData2 = BeatDataMirrorTransform.CreateTransformedData(beatmapData2);
            }
            if (gameplayMode == GameplayMode.SoloNoArrows)
            {
                beatmapData2 = BeatmapDataNoArrowsTransform.CreateTransformedData(beatmapData2);
            }
            if (gameplayOptions.obstaclesOption != GameplayOptions.ObstaclesOption.All)
            {
                beatmapData2 = BeatmapDataObstaclesTransform.CreateTransformedData(beatmapData2, gameplayOptions.obstaclesOption);
            }
            if (beatmapData2 == beatmapData)
            {
                beatmapData2 = beatmapData.GetCopy();
            }
            if (gameplayOptions.staticLights)
            {
                BeatmapEventData[] beatmapEventData = new BeatmapEventData[]
                {
                    new BeatmapEventData(0f, BeatmapEventType.Event0, 1),
                    new BeatmapEventData(0f, BeatmapEventType.Event4, 1)
                };
                beatmapData2 = new BeatmapData(beatmapData2.beatmapLinesData, beatmapEventData);
            }
            return(beatmapData2);
        }
Exemplo n.º 10
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.º 11
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.º 12
0
        internal BeatSaver_DifficultyBeatmap(BeatSaver_DifficultyBeatmapSet p_Parent, BeatSaver_CustomBeatmapLevel p_BSBeatmapLevel, BeatmapCharacteristicSO p_CharacteristicSO, BeatmapDifficulty p_Difficulty, BeatmapCharacteristicDifficulty p_CharacteristicDifficulty)
        {
            level = p_BSBeatmapLevel;
            parentDifficultyBeatmapSet = p_Parent;
            difficulty              = p_Difficulty;
            noteJumpMovementSpeed   = p_CharacteristicDifficulty.NoteJumpSpeed;
            noteJumpStartBeatOffset = p_CharacteristicDifficulty.NoteJumpSpeedOffset;
            beatmapData             = new BeatmapData(4);

            /// From DefaultRating
            switch (p_Difficulty)
            {
            case BeatmapDifficulty.Easy:        difficultyRank = 1; break;

            case BeatmapDifficulty.Normal:      difficultyRank = 3; break;

            case BeatmapDifficulty.Hard:        difficultyRank = 5; break;

            case BeatmapDifficulty.Expert:      difficultyRank = 7; break;

            case BeatmapDifficulty.ExpertPlus:  difficultyRank = 9; break;
            }

            for (int l_I = 0; l_I < p_CharacteristicDifficulty.Notes; ++l_I)
            {
                beatmapData.AddBeatmapObjectData(NoteData.CreateBasicNoteData(0f, 0, NoteLineLayer.Base, ColorType.ColorA, NoteCutDirection.Any));
            }
        }
Exemplo n.º 13
0
 private BeatmapData CreateTransformedBeatmapData(BeatmapData beatmapData, PlayerSpecificSettings playerSettings, BaseGameModeType baseGameMode)
 {
     try {
         if (beatmapData == null)
         {
             throw new Exception("Null beatmapData");
         }
         if (ChromaConfig.CustomMapCheckingEnabled)
         {
             /*if (ModeActive(ChromaMode.DOUBLES_DOTS) || ModeActive(ChromaMode.DOUBLES_MONO) || ModeActive(ChromaMode.DOUBLES_REMOVED) || ModeActive(ChromaMode.INVERT_COLOUR) || ModeActive(ChromaMode.MIRROR_DIRECTION) || ModeActive(ChromaMode.MIRROR_POSITION) || ModeActive(ChromaMode.MONOCHROME) || ModeActive(ChromaMode.NO_ARROWS) || ModeActive(ChromaMode.RANDOM_COLOURS_CHROMA) || ModeActive(ChromaMode.RANDOM_COLOURS_INTENSE) || ModeActive(ChromaMode.RANDOM_COLOURS_ORIGINAL) || ModeActive(ChromaMode.RANDOM_COLOURS_TRUE)) {*/
             ChromaLogger.Log("Attempting map modification...");
             //return ChromaToggle.Beatmap.Z_MapModifier.CreateTransformedData(beatmapData, modes);
             ChromaBehaviour chroma        = this;
             CustomBeatmap   customBeatmap = ChromaMapModifier.CreateTransformedData(beatmapData, ref chroma, ref playerSettings, ref baseGameMode, ref songBPM);
             if (customBeatmap == null)
             {
                 ChromaLogger.Log("Major error sir, beatmap data failed!", ChromaLogger.Level.WARNING);
                 return(beatmapData);
             }
             else
             {
                 return(customBeatmap.BeatmapData);
             }
         }
     } catch (Exception e) {
         ChromaLogger.Log("Error creating transformed map data...");
         ChromaLogger.Log(e, ChromaLogger.Level.ERROR);
     }
     return(beatmapData);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Perform both the NoArrows and the OneColor transform here based on the
        /// configuration data.
        /// </summary>
        private void TransformNotes(BeatmapData beatmapData)
        {
            var config = Configuration.instance.ConfigurationData;

            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)
                {
                    this.FlipNoteType(note);
                }
            });
        }
Exemplo n.º 15
0
        public Beatmap(Input input)
        {
            if (input.BeatmapId == null)
            {
                throw new Exception("No beatmap link provided");
            }

            Task <BeatmapData[]> beatmapRequest     = OsuApi.Beatmap(input.BeatmapId, input.ModRequestNumber ?? 0, input.Gamemode);
            Task <ScoreData[]>   leaderboardRequest = OsuApi.Leaderboard(input.BeatmapId, input.Gamemode);

            Task.WhenAll(
                beatmapRequest,
                leaderboardRequest
                ).Wait();

            beatmap     = beatmapRequest.Result[0];
            leaderboard = leaderboardRequest.Result;

            CountLeaderboardFullCombo();

            difficultyCalculator = new DifficultyCalculator(input.BeatmapId, input.Gamemode, input.ModNumber);
            difficulty           = difficultyCalculator.Calculate();

            Embed = CreateEmbed();
        }
Exemplo n.º 16
0
 internal void SetNewBeatmapData(BeatmapData beatmapData)
 {
     foreach (CustomEventCallbackData customEventCallbackData in _customEventCallbackData)
     {
         customEventCallbackData.nextEventIndex = 0;
     }
 }
Exemplo n.º 17
0
    public void PopulateBeatmapSelect(int bmdIndex)
    {
        BeatmapData bmd = OszUnpacker.bmds[bmdIndex];

        foreach (BeatmapUIObj beatmap in beatmaps)
        {
            ObjectPooling.inst.ReturnToPool(beatmap.gameObject, "Beatmap UI");
        }
        beatmaps.Clear();

        bool moreThanSeven = bmd.mapInfos.Count > 7;

        if (moreThanSeven)
        {
            beatmapHolder.sizeDelta        = new Vector2(sizePerNewObj * bmd.mapInfos.Count, beatmapHolder.sizeDelta.y);
            beatmapHolder.anchoredPosition = new Vector2(105, beatmapHolder.anchoredPosition.y);
        }
        else
        {
            beatmapHolder.sizeDelta        = new Vector2(245, beatmapHolder.sizeDelta.y);
            beatmapHolder.anchoredPosition = new Vector2(0, beatmapHolder.anchoredPosition.y);
        }

        for (int i = 0; i < bmd.mapInfos.Count; i++)
        {
            BeatmapUIObj beatmapObj = ObjectPooling.inst.SpawnFromPool("Beatmap UI", beatmapHolder.transform.position, beatmapHolder.transform.rotation).GetComponent <BeatmapUIObj>();
            beatmapObj.AssignBmData(bmdIndex, scroll);
            beatmapObj.AssignBmInfo(i);
            beatmapObj.mainImg.SizeToFillParent();
            beatmapObj.transform.SetSiblingIndex(i);
            beatmaps.Add(beatmapObj);
        }
    }
Exemplo n.º 18
0
        /// <summary>
        /// Load a Beatmap from a BeatmapData that should have all the data needed
        /// to make up a Beatmap.
        /// </summary>
        /// <param name="data">The BeatmapData object to load from.</param>
        /// <returns>The beatmap created from the BeatmapData</returns>
        public static Beatmap LoadLight(BeatmapData data)
        {
            Beatmap parsed = new Beatmap();

            parsed.FullyLoaded = false;

            // Path names
            parsed.Path     = data.path;
            parsed.FileName = data.fileName;

            // Background
            parsed.Background = data.backgroundPath;

            // Audio
            parsed.Audio       = data.audioPath;
            parsed.PreviewTime = data.audioPreviewTime;

            // Metadata
            parsed.Artist  = data.artist;
            parsed.Title   = data.title;
            parsed.Version = data.version;
            parsed.Mapper  = data.mapper;

            // Game Data
            parsed.KeyCount   = data.keyCount;
            parsed.Difficulty = data.difficulty;

            return(parsed);
        }
Exemplo n.º 19
0
        public static void ToggleNoodlePatches(bool value, BeatmapData beatmapData, float defaultNoteJumpMovementSpeed, float defaultNoteJumpStartBeatOffset)
        {
            if (value)
            {
                if (!Harmony.HasAnyPatches(HARMONYID))
                {
                    NoodlePatches.ForEach(n => harmony.Patch(n.originalMethod,
                                                             n.prefix != null ? new HarmonyMethod(n.prefix) : null,
                                                             n.postfix != null ? new HarmonyMethod(n.postfix) : null,
                                                             n.transpiler != null ? new HarmonyMethod(n.transpiler) : null));
                }

                // var njs/spawn offset stuff below

                // there is some ambiguity with these variables but who frikkin cares
                float _startHalfJumpDurationInBeats = 4;
                float _maxHalfJumpDistance          = 18;
                float _moveDuration = 0.5f;

                foreach (BeatmapLineData beatmapLineData in beatmapData.beatmapLinesData)
                {
                    foreach (BeatmapObjectData beatmapObjectData in beatmapLineData.beatmapObjectsData)
                    {
                        dynamic customData;
                        if (beatmapObjectData is CustomObstacleData || beatmapObjectData is CustomNoteData)
                        {
                            customData = beatmapObjectData;
                        }
                        else
                        {
                            return;
                        }
                        dynamic dynData = customData.customData;
                        float   noteJumpMovementSpeed   = (float?)Trees.at(dynData, NOTEJUMPSPEED) ?? defaultNoteJumpMovementSpeed;
                        float   noteJumpStartBeatOffset = (float?)Trees.at(dynData, SPAWNOFFSET) ?? defaultNoteJumpStartBeatOffset;

                        // how do i not repeat this in a reasonable way
                        float num  = 60f / (float)Trees.at(dynData, "bpm");
                        float num2 = _startHalfJumpDurationInBeats;
                        while (noteJumpMovementSpeed * num * num2 > _maxHalfJumpDistance)
                        {
                            num2 /= 2f;
                        }
                        num2 += noteJumpStartBeatOffset;
                        if (num2 < 1f)
                        {
                            num2 = 1f;
                        }
                        float _jumpDuration = num * num2 * 2f;
                        dynData.aheadTime = _moveDuration + _jumpDuration * 0.5f;
                    }
                    beatmapLineData.beatmapObjectsData = beatmapLineData.beatmapObjectsData.OrderBy(n => n.time - (float)((dynamic)n).customData.aheadTime).ToArray();
                }
            }
            else
            {
                harmony.UnpatchAll(HARMONYID);
            }
        }
 internal static void PostfixHelper(ref IReadonlyBeatmapData __result, BeatmapData beatmapData)
 {
     if (beatmapData is CustomBeatmapData customBeatmapData)
     {
         __result = new CustomBeatmapData(beatmapData,
                                          customBeatmapData.customEventData, customBeatmapData.customData, customBeatmapData.beatmapCustomData, customBeatmapData.levelCustomData);
     }
 }
Exemplo n.º 21
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));

            GameplayCoreSceneSetup gameplayCoreSceneSetup = Resources.FindObjectsOfTypeAll <GameplayCoreSceneSetup>().First();
            BeatmapDataModel       dataModel = gameplayCoreSceneSetup.GetField <BeatmapDataModel>("_beatmapDataModel");

            Plugin.Log("Grabbed dataModel");
            BeatmapData beatmapData = dataModel.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 / Plugin.ChatConfig.bombChance) * 100);
                                int randMin = 100;
                                int random  = Random.Range(1, randMax);

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

                                if (random <= randMin || Plugin.ChatConfig.bombChance == 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 | ", "");
            dataModel.beatmapData = beatmapData;
        }
Exemplo n.º 22
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));
        }
        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);
            }
        }
Exemplo n.º 24
0
 public CustomBeatmapData(BeatmapData data, CustomEventData[] customEventData, dynamic customData, dynamic beatmapCustomData, dynamic levelCustomData)
     : base(200)
 {
     base.CopyBeatmapEvents(data, this);
     base.CopyBeatmapObjects(data, this);
     this.customData        = customData;
     this.customEventData   = customEventData;
     this.beatmapCustomData = beatmapCustomData;
     this.levelCustomData   = levelCustomData;
 }
Exemplo n.º 25
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.º 26
0
        IEnumerator ReadEvents()
        {
            yield return(new WaitForSeconds(0f));

            GameplayCoreSceneSetup gameplayCoreSceneSetup = Resources.FindObjectsOfTypeAll <GameplayCoreSceneSetup>().First();
            BeatmapDataModel       dataModel = gameplayCoreSceneSetup.GetField <BeatmapDataModel>("_beatmapDataModel");

            BeatmapData beatmapData = ReadBeatmapEvents(dataModel.beatmapData, ChromaLiteConfig.RGBLightsEnabled, ChromaLiteConfig.SpecialEventsEnabled);

            //ChromaLogger.Log("Events read!");
        }
Exemplo n.º 27
0
        private Dictionary <string, string> GetManiaData(ScoreData score, BeatmapData beatmap)
        {
            var data = new Dictionary <string, string>();

            data.Add("accuracy", $"{Math.Round(OsuHelper.CalculateAccuracy(score, input.Gamemode) * 100, 2)}%");
            data.Add("hits", $"{score.CountGeki}/{score.Count300 }/{score.CountKatu}/{score.Count100}/{score.Count50}/{score.CountMiss}");
            data.Add("combo", $"{score.MaxCombo}x");
            data.Add("stats", $"**Keys** {Math.Round(beatmap.DiffSize, 2)} **OD** {Math.Round(beatmap.DiffOverall, 2)} **HP** {Math.Round(beatmap.DiffDrain, 2)}");

            return(data);
        }
Exemplo n.º 28
0
        public override BeatmapData GetCopy()
        {
            BeatmapData baseCopy     = base.GetCopy();
            var         copiedEvents = new Dictionary <string, List <CustomEventData> >();

            foreach (var pair in customEventData)
            {
                copiedEvents[pair.Key] = pair.Value.Select(e => e.GetCopy()).ToList();
            }
            return(new CustomBeatmapData(baseCopy.beatmapLinesData, baseCopy.beatmapEventData, copiedEvents, copy(beatmapCustomData), copy(levelCustomData)));
        }
Exemplo n.º 29
0
        public void CleanBeatmap()
        {
            BeatmapData newBeatmapData = (callbackController.GetField <IReadonlyBeatmapData, BeatmapCallbacksController>("_beatmapData") as BeatmapData).GetFilteredCopy(x => {
                if (x is GameNote || x is GameObstacle)
                {
                    return(null);
                }
                return(x);
            });

            callbackController.SetField("_beatmapData", newBeatmapData as IReadonlyBeatmapData);
        }
Exemplo n.º 30
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!");
        }