static void Postfix(ReleaseInfoViewController __instance, ref MainSettingsModel ____mainSettingsModel, ref bool firstActivation, ref TextPageScrollView ____textPageScrollView, ref TextAsset ____releaseNotesTextAsset, ref TextAsset ____firstTextAsset) { if (firstActivation) { SidePanelUtil.ReleaseInfoEnabled(__instance, ____textPageScrollView, ____mainSettingsModel.playingForTheFirstTime ? ____firstTextAsset.text : ____releaseNotesTextAsset.text); } }
public static void LoadSettingsModel() { mainSettingsModel = UnityEngine.Resources.FindObjectsOfTypeAll <MainSettingsModel>().FirstOrDefault(); if (mainSettingsModel) { ChromaLogger.Log("Found settings model", ChromaLogger.Level.DEBUG); oldHaptics = mainSettingsModel.controllersRumbleEnabled; } }
private void Awake() { this.playerController = FindObjectOfType <PlayerController>(); mainSettingsModel = Resources.FindObjectsOfTypeAll <MainSettingsModel>().FirstOrDefault(); previousForwardHand = ConfigOptions.instance.LeftHanded ? XRNode.RightHand : XRNode.LeftHand; var pauseAnimationController = Object.FindObjectOfType <PauseAnimationController>(); if (pauseAnimationController != null) { pauseAnimationController.resumeFromPauseAnimationDidFinishEvent += this.ResumeFromPauseAnimationDidFinishEvent; } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { var val = (value ?? "").ToString(); if (!MainSettingsModel.IsValidRecordingPath(val)) { return(new ValidationResult(false, "Path is not valid or access denied")); } else { return(ValidationResult.ValidResult); } }
private static MainSettings LoadFromConfig() { MainSettings settings = new MainSettings(); try { using (FileStream stream = File.OpenRead(Path.Combine(settings.DefaultFolder, FILENAME))) using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) { JsonSerializer serializer = new JsonSerializer(); MainSettingsModel model = (MainSettingsModel)(serializer.Deserialize(reader, typeof(MainSettingsModel))); settings.UploadOnStop = model.UploadOnStop; switch (model.UploadServiceName) { case "imgur": case "giphy": case "gfycat": { settings.UploadServiceName = model.UploadServiceName; } break; default: break; } if (model.Recordings != null) { double delayMs = model.Recordings.Delay.TotalMilliseconds; if (33.0 <= delayMs && delayMs <= ushort.MaxValue) { settings.Recordings.Delay = (int)(delayMs); } if (model.Recordings.Folder != null) { settings.Recordings.Folder = model.Recordings.Folder; } } } } catch { } return(settings); }
public void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene) { try { if (scene.name == "Menu") { if (model == null) { model = Resources.FindObjectsOfTypeAll <MainSettingsModel>().FirstOrDefault(); rumble = model.controllersRumbleEnabled; } model.controllersRumbleEnabled = rumble; } if (SceneUtils.isGameScene(scene) && Settings.OneColour && TweakManager.IsPartyMode()) { StartCoroutine(WaitForLoad()); } } catch (Exception e) { Console.WriteLine("Tweaks (OneColour) done f****d up: " + e); } }
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene) { try { this._playerController = FindObjectOfType <PlayerController>(); if (scene.buildIndex == 1) { IsLeftSaberOn = true; if (_beatmapObjectSpawnController != null) { _beatmapObjectSpawnController.noteWasCutEvent -= this.HandleNoteWasCutEvent; } if (_mainSettingsModel != null && stored) { StartCoroutine(RestoreNoEnergy()); } } if (scene.buildIndex == 5) { var _mainGameSceneSetup = FindObjectOfType <MainGameSceneSetup>(); this._gameSongController = FindObjectOfType <GameSongController>(); this._noteCutEffectSpawner = FindObjectOfType <NoteCutEffectSpawner>(); this._beatmapObjectSpawnController = FindObjectOfType <BeatmapObjectSpawnController>(); _noteCutHapticEffect = ReflectionUtil.GetPrivateField <NoteCutHapticEffect>(_noteCutEffectSpawner, "_noteCutHapticEffect"); _hapticFeedbackController = ReflectionUtil.GetPrivateField <HapticFeedbackController>(_noteCutHapticEffect, "_hapticFeedbackController"); _mainSettingsModel = ReflectionUtil.GetPrivateField <MainSettingsModel>(_hapticFeedbackController, "_mainSettingsModel"); _mainSettingsModel.controllersRumbleEnabled = true; this._mainGameSceneSetupData = ReflectionUtil.GetPrivateField <MainGameSceneSetupData>(_mainGameSceneSetup, "_mainGameSceneSetupData"); if (!stored) { storedNoEnergy = _mainGameSceneSetupData.gameplayOptions.noEnergy; } stored = true; if (_mainGameSceneSetupData.gameplayMode == GameplayMode.SoloNoArrows) { BeatmapDataModel _beatmapDataModel = ReflectionUtil.GetPrivateField <BeatmapDataModel>(_mainGameSceneSetup, "_beatmapDataModel"); BeatmapData beatmapData = CreateTransformedBeatmapData(_mainGameSceneSetupData.difficultyLevel.beatmapData, _mainGameSceneSetupData.gameplayOptions, _mainGameSceneSetupData.gameplayMode); if (beatmapData != null) { _beatmapDataModel.beatmapData = beatmapData; ReflectionUtil.SetPrivateField(_mainGameSceneSetup, "_beatmapDataModel", _beatmapDataModel); } if (Plugin.IsOneColorModeOn) { _mainGameSceneSetupData.gameplayOptions.noEnergy = true; _sabers = FindObjectsOfType <Saber>(); Saber targetSaber = (Plugin.IsColorRed) ? _playerController.leftSaber : _playerController.rightSaber; Saber otherSaber = (Plugin.IsColorRed) ? _playerController.rightSaber : _playerController.leftSaber; if (targetSaber == null || otherSaber == null) { return; } 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); if (Plugin.IsColorRed) { ReflectionUtil.SetPrivateField(_playerController, "_rightSaber", targetSaber); ReflectionUtil.SetPrivateField(_playerController, "_leftSaber", newSaber); } else { ReflectionUtil.SetPrivateField(_playerController, "_leftSaber", targetSaber); ReflectionUtil.SetPrivateField(_playerController, "_rightSaber", newSaber); } _playerController.leftSaber.gameObject.SetActive(IsLeftSaberOn); if (_beatmapObjectSpawnController != null) { _beatmapObjectSpawnController.noteWasCutEvent += this.HandleNoteWasCutEvent; } } } } } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } }
private void SpawnController_ScaleRemoveCut(BeatmapObjectSpawnController arg1, NoteController controller, NoteCutInfo arg3) { NoteData note = controller.noteData; Transform noteTransform = controller.noteTransform; // Log("DESPAWN" + noteTransform.localScale.ToString()); if (noteTransform.localScale.x != 1) { noteTransform.localScale = new Vector3(1f, 1f, 1f); } // Log("DESPAWN" + noteTransform.localScale.ToString()); // if (modifiedNotes[note.id] != null) // note = modifiedNotes[note.id]; FloatBehavior behavior = noteTransform.gameObject.GetComponent <FloatBehavior>(); if (behavior != null) { noteTransform.localPosition = new Vector3(behavior.originalX, behavior.originalY, noteTransform.localPosition.z); GameObject.Destroy(behavior); } if (GMPUI.oneColor) { if (!defaultRumble) { return; } _noteCutEffectSpawner = UnityEngine.Object.FindObjectOfType <NoteCutEffectSpawner>(); if (_noteCutEffectSpawner != null) { _noteCutHapticEffect = ReflectionUtil.GetPrivateField <NoteCutHapticEffect>(_noteCutEffectSpawner, "_noteCutHapticEffect"); } if (_noteCutHapticEffect != null) { _hapticFeedbackController = ReflectionUtil.GetPrivateField <HapticFeedbackController>(_noteCutHapticEffect, "_hapticFeedbackController"); } if (_hapticFeedbackController != null) { _mainSettingsModelOneC = ReflectionUtil.GetPrivateField <MainSettingsModel>(_hapticFeedbackController, "_mainSettingsModel"); } if (_mainSettingsModelOneC == null) { return; } Vector3 notePos = controller.noteTransform.position; Vector3 leftPos = player.leftSaber.transform.position; leftPos += player.leftSaber.transform.forward * 0.5f; Vector3 rightPos = player.rightSaber.transform.position; rightPos += player.rightSaber.transform.forward * 0.5f; float leftDist = Vector3.Distance(leftPos, notePos); float rightDist = Vector3.Distance(rightPos, notePos); // Log(leftDist.ToString() + " " + rightDist.ToString()); _mainSettingsModelOneC.controllersRumbleEnabled.value = true; Saber.SaberType targetType = (leftDist > rightDist) ? Saber.SaberType.SaberB : Saber.SaberType.SaberA; if (!(Mathf.Abs(leftDist - rightDist) <= 0.2f)) { _noteCutHapticEffect.HitNote(targetType); } else { _noteCutHapticEffect.HitNote(Saber.SaberType.SaberA); _noteCutHapticEffect.HitNote(Saber.SaberType.SaberB); } _mainSettingsModel.controllersRumbleEnabled.value = false; } }
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene) { if (scene.name == ("MenuCore")) { activateDuringIsolated = false; Log("Switched to Menu"); SharedCoroutineStarter.instance.StartCoroutine(GrabPP()); var controllers = Resources.FindObjectsOfTypeAll <VRController>(); if (controllers != null) { foreach (VRController controller in controllers) { if (controller != null) { if (controller.ToString() == "ControllerLeft (VRController)") { leftController = controller; } if (controller.ToString() == "ControllerRight (VRController)") { rightController = controller; } } // Log(controller.ToString()); } // Log("Left:" + leftController.ToString()); // Log("Right: " + rightController.ToString()); } } if (scene.name == "GameCore") { RemovePatches(); } if (_mainSettingsModel == null) { var menu = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().FirstOrDefault(); if (menu != null) { _mainSettingsModel = menu.GetField <MainSettingsModel>("_mainSettingsModel"); _mainSettingsModel.Load(true); Log("RUMBLE: " + _mainSettingsModel.controllersRumbleEnabled.ToString()); if (!setDefaultRumble) { defaultRumble = _mainSettingsModel.controllersRumbleEnabled; ModPrefs.SetInt("GameplayModifiersPlus", "GameRumbleSetting", _mainSettingsModel.controllersRumbleEnabled ? 1 : 0); setDefaultRumble = true; Log("Set Default Rumble Value"); } } } if (_mainSettingsModel != null) { defaultRumble = ModPrefs.GetInt("GameplayModifiersPlus", "GameRumbleSetting", -1, false) != 1 ? false : true; _mainSettingsModel.controllersRumbleEnabled.value = defaultRumble; _mainSettingsModel.Save(); } paused = false; if (!customColorsInstalled) { if (colorA != null) { colorA.SetColor(defColorA); } if (colorB != null) { colorB.SetColor(defColorB); } } // try // { if (scene.name == "EmptyTransition") { Log("Resetting Chat Powers Object"); if (chatPowers != null) { GameObject.Destroy(chatPowers); } } if (chatPowers == null) { Log("Null Creation of Chat Powers Object"); chatPowers = new GameObject("Chat Powers"); GameObject.DontDestroyOnLoad(chatPowers); twitchPowers = chatPowers.AddComponent <TwitchPowers>(); } // } // catch(Exception ex) // { // Log(ex.ToString()); // } GMPDisplay display = chatPowers.GetComponent <GMPDisplay>(); if (display != null) { display.Destroy(); GameObject.Destroy(display); } ReadPrefs(); if (GMPUI.chatIntegration && twitchPluginInstalled) { if (twitchPowers != null) { cooldowns.ResetCooldowns(); TwitchPowers.ResetPowers(false); twitchPowers.StopAllCoroutines(); } if (ChatConfig.resetChargesEachLevel) { charges = 0; } } // twitchCommands.StopAllCoroutines(); haveSongNJS = false; if (soundIsPlaying == true) { gnomeSound.Stop(); } soundIsPlaying = false; isValidScene = false; playerInfo = false; modifiersInit = false; if (arg0.name == "EmpyTransition" && chatPowers != null) { GameObject.Destroy(chatPowers); } if (scene.name == "GameCore") { Log("Isolated: " + BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); isValidScene = true; if (BS_Utils.Gameplay.Gamemode.IsIsolatedLevel && !activateDuringIsolated) { Log("Isolated Level, not activating"); return; } // Log("Pre GrabGrab"); GameObject.Destroy(GameObject.Find("Color Setter")); environmentColorsSetter = Resources.FindObjectsOfTypeAll <EnvironmentColorsSetter>().FirstOrDefault(); soundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault(); spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault(); energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().First(); energyPanel = Resources.FindObjectsOfTypeAll <GameEnergyUIPanel>().First(); ColorManager = Resources.FindObjectsOfTypeAll <ColorManager>().First(); levelData = BS_Utils.Plugin.LevelData; // Log("Post GrabGrab"); if (spawnController != null) { spawnController.noteDidStartJumpEvent += SpawnController_ModifiedJump; spawnController.noteWasCutEvent += SpawnController_ScaleRemoveCut; spawnController.noteWasMissedEvent += SpawnController_ScaleRemoveMiss; } else { Log("Spawn Controller Null"); } // Log("Post GrabGrab 2"); currentSongSpeed = levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; BS_Utils.Plugin.LevelDidFinishEvent += LevelData_didFinishEvent; // Log("Post GrabGrab 3"); if (!Multiplayer.MultiMain.multiActive.Value) { if (GMPUI.chatIntegration && ChatConfig.maxCharges > 0 && twitchPluginInstalled) { chatPowers.AddComponent <GMPDisplay>(); } if (GMPUI.chatIntegration && ChatConfig.timeForCharges > 0 && twitchPluginInstalled) { twitchPowers.StartCoroutine(TwitchPowers.ChargeOverTime()); } } // Log("Post GrabGrab 4"); pauseManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().First(); var colors = Resources.FindObjectsOfTypeAll <SimpleColorSO>(); // Log("Pre Color"); foreach (SimpleColorSO color in colors) { // Log(color.name); if (color.name == "BaseNoteColor1") { colorA = color; } if (color.name == "BaseNoteColor0") { colorB = color; } } oldColorA.SetColor(colorA); oldColorB.SetColor(colorB); // Log("Pre ChatInt"); // Log(colorA.color.ToString()); if (GMPUI.chatIntegration && charges <= ChatConfig.maxCharges && twitchPluginInstalled) { charges += ChatConfig.chargesPerLevel; if (charges > ChatConfig.maxCharges) { charges = ChatConfig.maxCharges; } // TryAsyncMessage("Current Charges: " + charges); } // Log("Pre Audio/Player"); // ReflectionUtil.SetProperty(typeof(PracticePlugin.Plugin), "TimeScale", 1f); AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault(); if (AudioTimeSync != null) { songAudio = AudioTimeSync.GetField <AudioSource>("_audioSource"); if (songAudio == null) { Log("Audio null"); } // Log("Object Found"); } //Get Sabers player = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault(); if (player != null) { playerInfo = true; } else { playerInfo = false; Log("Player is null"); } CheckGMPModifiers(); } }