Exemplo n.º 1
0
 public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
 {
     if (scene.name == "MenuCore")
     {
         Gamemode.Init();
         CreateUI();
     }
 }
Exemplo n.º 2
0
        public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
        {
            if (scene.name == "MenuCore")
            {
                Gamemode.Init();

                ToggleOption enableToggle = GameplaySettingsUI.CreateToggleOption(GameplaySettingsPanels.ModifiersRight, "No Fail+", "Activates No Fail in party mode with no effect on score", null, 0);
                enableToggle.GetValue  = config.Value.Enable;
                enableToggle.OnToggle += (bool enabled) => {
                    config.Value.Enable = enabled;
                };
            }
        }
Exemplo n.º 3
0
        public void OnApplicationStart()
        {
            if (instance != null)
            {
                return;
            }
            instance = this;

            PluginTickerScript.TouchInstance();

            server = new HTTPServer(statusManager);
            server.InitServer();

            SceneManager.activeSceneChanged += OnActiveSceneChanged;

            Gamemode.Init();
        }
Exemplo n.º 4
0
        public void OnStart()
        {
            BSEvents.OnLoad();
            Sprites.Init();
            Gamemode.Init();
            GetUserInfo.UpdateUserInfo();
            HarmonyPatcher.Patch();
            Executor.Init();
            Client.Init();
            Gameplay.Init();
            Jukebox.Init();
            ItemManager.Init();
            ScoreManager.Init();

            BSEvents.menuSceneLoadedFresh   += BSEventsOnmenuSceneLoadedFresh;
            BSEvents.gameSceneActive        += BSEventsOngameSceneActive;
            SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;

            log.Info("Beat Saber 99 started");
        }
Exemplo n.º 5
0
        private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
        {
            if (arg0.name == "MenuCore")
            {
                Gamemode.Init();
                modEnable = false;
                var settingsSubmenu = SettingsUI.CreateSubMenu("AutoPause");
                var modenabled      = settingsSubmenu.AddBool("AutoPause Enabled");
                modenabled.GetValue += delegate { return(ModPrefs.GetBool("AutoPause | Main", "Enabled", true, true)); };
                modenabled.SetValue += delegate(bool value) { ModPrefs.SetBool("AutoPause | Main", "Enabled", value); };

                var pausebool = settingsSubmenu.AddBool("FPS Pause");
                pausebool.GetValue += delegate { return(ModPrefs.GetBool("AutoPause | Main", "FPSCheckerOn", false, true)); };
                pausebool.SetValue += delegate(bool value) { ModPrefs.SetBool("AutoPause | Main", "FPSCheckerOn", value); };

                var voices = settingsSubmenu.AddBool("Voices");
                voices.GetValue += delegate { return(ModPrefs.GetBool("AutoPause | Main", "Voices", true, true)); };
                voices.SetValue += delegate(bool value) { ModPrefs.SetBool("AutoPause | Main", "Voices", value); };

                float[] fpsValues    = { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 };
                var     fpsThreshold = settingsSubmenu.AddList("FPS Threshold", fpsValues);
                fpsThreshold.GetValue    += delegate { return(ModPrefs.GetFloat("AutoPause | Main", "FPSThreshold", 40, true)); };
                fpsThreshold.SetValue    += delegate(float value) { ModPrefs.SetFloat("AutoPause | Main", "FPSThreshold", value); };
                fpsThreshold.FormatValue += delegate(float value) { return(string.Format("{0:0}", value)); };

                var reaction = settingsSubmenu.AddList("Reaction Time", numnums);
                reaction.GetValue    += delegate { return(ModPrefs.GetFloat("AutoPause | Main", "ResponseTime", .2f, true)); };
                reaction.SetValue    += delegate(float value) { ModPrefs.SetFloat("AutoPause | Main", "ResponseTime", value); };
                reaction.FormatValue += delegate(float value) { return(string.Format("{0:0.00}", value)); };

                Log.AutoPause("Settings Created");
            }

            if (arg0.name == "MenuCore" && firstTime == true)
            {
                firstTime = false;
                TextObject.OnLoad();
                ///Despacito 2
            }
        }
Exemplo n.º 6
0
        private void OnActiveSceneChanged(Scene oldScene, Scene newScene)
        {
            GameStatus gameStatus = statusManager.gameStatus;

            gameStatus.scene = newScene.name;

            if (newScene.name == "MenuCore")
            {
                // Menu
                gameStatus.scene = "Menu";

                Gamemode.Init();

                // TODO: get the current song, mode and mods while in menu
                gameStatus.ResetMapInfo();

                gameStatus.ResetPerformance();

                // Release references for AfterCutScoreBuffers that don't resolve due to player leaving the map before finishing.
                noteCutMapping.Clear();

                statusManager.EmitStatusUpdate(ChangedProperties.AllButNoteCut, "menu");
            }
            else if (newScene.name == "GameCore")
            {
                // In game
                gameStatus.scene = "Song";

                gamePauseManager = FindFirstOrDefault <GamePauseManager>();
                scoreController  = FindFirstOrDefault <ScoreController>();
                gameplayManager  = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().FirstOrDefault() as MonoBehaviour ?? Resources.FindObjectsOfTypeAll <MissionLevelGameplayManager>().FirstOrDefault();
                beatmapObjectCallbackController  = FindFirstOrDefault <BeatmapObjectCallbackController>();
                gameplayModifiersSO              = FindFirstOrDefault <GameplayModifiersModelSO>();
                audioTimeSyncController          = FindFirstOrDefault <AudioTimeSyncController>();
                playerHeadAndObstacleInteraction = FindFirstOrDefault <PlayerHeadAndObstacleInteraction>();
                gameEnergyCounter = FindFirstOrDefault <GameEnergyCounter>();

                gameplayCoreSceneSetupData = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData;

                // Register event listeners
                // private GameEvent GamePauseManager#_gameDidPauseSignal
                AddSubscriber(gamePauseManager, "_gameDidPauseSignal", OnGamePause);
                // private GameEvent GamePauseManager#_gameDidResumeSignal
                AddSubscriber(gamePauseManager, "_gameDidResumeSignal", OnGameResume);
                // public ScoreController#noteWasCutEvent<NoteData, NoteCutInfo, int multiplier> // called after AfterCutScoreBuffer is created
                scoreController.noteWasCutEvent += OnNoteWasCut;
                // public ScoreController#noteWasMissedEvent<NoteData, int multiplier>
                scoreController.noteWasMissedEvent += OnNoteWasMissed;
                // public ScoreController#scoreDidChangeEvent<int, int> // score
                scoreController.scoreDidChangeEvent += OnScoreDidChange;
                // public ScoreController#comboDidChangeEvent<int> // combo
                scoreController.comboDidChangeEvent += OnComboDidChange;
                // public ScoreController#multiplierDidChangeEvent<int, float> // multiplier, progress [0..1]
                scoreController.multiplierDidChangeEvent += OnMultiplierDidChange;
                // private GameEvent GameplayManager#_levelFinishedSignal
                AddSubscriber(gameplayManager, "_levelFinishedSignal", OnLevelFinished);
                // private GameEvent GameplayManager#_levelFailedSignal
                AddSubscriber(gameplayManager, "_levelFailedSignal", OnLevelFailed);
                // public event Action<BeatmapEventData> BeatmapObjectCallbackController#beatmapEventDidTriggerEvent
                beatmapObjectCallbackController.beatmapEventDidTriggerEvent += OnBeatmapEventDidTrigger;

                IDifficultyBeatmap diff  = gameplayCoreSceneSetupData.difficultyBeatmap;
                IBeatmapLevel      level = diff.level;

                gameStatus.partyMode = Gamemode.IsPartyActive;
                gameStatus.mode      = Gamemode.GameMode;

                gameplayModifiers = gameplayCoreSceneSetupData.gameplayModifiers;
                PlayerSpecificSettings playerSettings   = gameplayCoreSceneSetupData.playerSpecificSettings;
                PracticeSettings       practiceSettings = gameplayCoreSceneSetupData.practiceSettings;

                float songSpeedMul = gameplayModifiers.songSpeedMul;
                if (practiceSettings != null)
                {
                    songSpeedMul = practiceSettings.songSpeedMul;
                }
                float modifierMultiplier = gameplayModifiersSO.GetTotalMultiplier(gameplayModifiers);

                gameStatus.songName        = level.songName;
                gameStatus.songSubName     = level.songSubName;
                gameStatus.songAuthorName  = level.songAuthorName;
                gameStatus.levelAuthorName = level.levelAuthorName;
                gameStatus.songBPM         = level.beatsPerMinute;
                gameStatus.noteJumpSpeed   = diff.noteJumpMovementSpeed;
                gameStatus.songHash        = level.levelID.Substring(0, Math.Min(32, level.levelID.Length));
                gameStatus.songTimeOffset  = (long)(level.songTimeOffset * 1000f / songSpeedMul);
                gameStatus.length          = (long)(level.beatmapLevelData.audioClip.length * 1000f / songSpeedMul);
                gameStatus.start           = GetCurrentTime() - (long)(audioTimeSyncController.songTime * 1000f / songSpeedMul);
                if (practiceSettings != null)
                {
                    gameStatus.start -= (long)(practiceSettings.startSongTime * 1000f / songSpeedMul);
                }
                gameStatus.paused          = 0;
                gameStatus.difficulty      = diff.difficulty.Name();
                gameStatus.notesCount      = diff.beatmapData.notesCount;
                gameStatus.bombsCount      = diff.beatmapData.bombsCount;
                gameStatus.obstaclesCount  = diff.beatmapData.obstaclesCount;
                gameStatus.environmentName = level.environmentSceneInfo.sceneName;

                gameStatus.maxScore = ScoreController.MaxModifiedScoreForMaxRawScore(ScoreController.MaxRawScoreForNumberOfNotes(diff.beatmapData.notesCount), gameplayModifiers, gameplayModifiersSO);
                gameStatus.maxRank  = RankModel.MaxRankForGameplayModifiers(gameplayModifiers, gameplayModifiersSO).ToString();

                try {
                    // From https://support.unity3d.com/hc/en-us/articles/206486626-How-can-I-get-pixels-from-unreadable-textures-
                    var texture   = level.GetCoverImageTexture2DAsync(CancellationToken.None).Result;
                    var active    = RenderTexture.active;
                    var temporary = RenderTexture.GetTemporary(
                        texture.width,
                        texture.height,
                        0,
                        RenderTextureFormat.Default,
                        RenderTextureReadWrite.Linear
                        );

                    Graphics.Blit(texture, temporary);
                    RenderTexture.active = temporary;

                    var cover = new Texture2D(texture.width, texture.height);
                    cover.ReadPixels(new Rect(0, 0, temporary.width, temporary.height), 0, 0);
                    cover.Apply();

                    RenderTexture.active = active;
                    RenderTexture.ReleaseTemporary(temporary);

                    gameStatus.songCover = System.Convert.ToBase64String(
                        ImageConversion.EncodeToPNG(cover)
                        );
                } catch {
                    gameStatus.songCover = null;
                }

                gameStatus.ResetPerformance();

                gameStatus.modifierMultiplier  = modifierMultiplier;
                gameStatus.songSpeedMultiplier = songSpeedMul;
                gameStatus.batteryLives        = gameEnergyCounter.batteryLives;

                gameStatus.modObstacles          = gameplayModifiers.enabledObstacleType.ToString();
                gameStatus.modInstaFail          = gameplayModifiers.instaFail;
                gameStatus.modNoFail             = gameplayModifiers.noFail;
                gameStatus.modBatteryEnergy      = gameplayModifiers.batteryEnergy;
                gameStatus.modDisappearingArrows = gameplayModifiers.disappearingArrows;
                gameStatus.modNoBombs            = gameplayModifiers.noBombs;
                gameStatus.modSongSpeed          = gameplayModifiers.songSpeed.ToString();
                gameStatus.modNoArrows           = gameplayModifiers.noArrows;
                gameStatus.modGhostNotes         = gameplayModifiers.ghostNotes;
                gameStatus.modFailOnSaberClash   = gameplayModifiers.failOnSaberClash;
                gameStatus.modStrictAngles       = gameplayModifiers.strictAngles;
                gameStatus.modFastNotes          = gameplayModifiers.fastNotes;

                gameStatus.staticLights = playerSettings.staticLights;
                gameStatus.leftHanded   = playerSettings.leftHanded;
                gameStatus.swapColors   = playerSettings.swapColors;
                gameStatus.playerHeight = playerSettings.playerHeight;
                gameStatus.disableSFX   = playerSettings.disableSFX;
                gameStatus.noHUD        = playerSettings.noTextsAndHuds;
                gameStatus.advancedHUD  = playerSettings.advancedHud;

                statusManager.EmitStatusUpdate(ChangedProperties.AllButNoteCut, "songStart");
            }
        }