static bool Prefix(ref GameplayCoreSceneSetup __instance) { IPALogger log = Plugin._logger; log.Debug("Started patch!"); bool is360 = false; IDifficultyBeatmap difficultyBeatmap = IPAUtils.GetField <GameplayCoreSceneSetupData, GameplayCoreSceneSetup>(__instance, "_sceneSetupData").difficultyBeatmap; BeatmapEventData[] beatmapEventData = difficultyBeatmap.beatmapData.beatmapEventData; SpawnRotationProcessor rotProcessor = new SpawnRotationProcessor(); foreach (BeatmapEventData beatmapEvent in beatmapEventData) { if (!(beatmapEvent.type == BeatmapEventType.Event14 || beatmapEvent.type == BeatmapEventType.Event15)) { continue; } if (rotProcessor.RotationForEventValue(beatmapEvent.value) != 0) { log.Debug("360 is true!"); is360 = true; break; } } if (!is360) { IPAUtils.SetProperty <BeatmapData, int>(difficultyBeatmap.beatmapData, "spawnRotationEventsCount", 0); } return(true); }
public void InitWithConfig(IPALogger logger, IPA.Config.Config conf) { instance = this; Log = logger; this.AddIncriemtGCModeText(); Log.Debug("Logger initialized."); Configuration.PluginConfig.Instance = conf.Generated <Configuration.PluginConfig>(); Log.Debug("Config loaded"); }
public Plugin(Conf conf, IPALogger log, Zenjector zenjector, PluginMetadata metadata) { var config = conf.Generated <Config>(); _harmony = new Harmony(_harmonyID); config.Version = metadata.Version; zenjector .On <PCAppInit>() .Pseudo(Container => { log?.Debug("Initializing Core Bindings"); Container.BindLoggerAsSiraLogger(log); Container.BindInstance(config).AsSingle(); }); zenjector.OnMenu <DisoMenuInstaller>(); zenjector .On <MenuInstaller>() .Register <CommonSoundInstaller>() .Pseudo((ctx, Container) => { if (config.MusicPlayerEnabled) { log?.Debug("Upgrading to our DiPlayer"); var binding = ctx.GetComponent <ZenjectBinding>(); var original = (binding.Components.FirstOrDefault(x => x is SongPreviewPlayer) as SongPreviewPlayer) !; var fader = original.GetComponent <FadeOutSongPreviewPlayerOnSceneTransitionStart>(); var focus = original.GetComponent <SongPreviewPlayerPauseOnInputFocusLost>(); var newPlayer = original.Upgrade <SongPreviewPlayer, DisoPreviewPlayer>(); Container.QueueForInject(newPlayer); Container.Unbind <SongPreviewPlayer>(); Container.Bind(typeof(SongPreviewPlayer), typeof(DisoPreviewPlayer)).To <DisoPreviewPlayer>().FromInstance(newPlayer).AsSingle(); fader.SetField <FadeOutSongPreviewPlayerOnSceneTransitionStart, SongPreviewPlayer>("_songPreviewPlayer", newPlayer); focus.SetField <SongPreviewPlayerPauseOnInputFocusLost, SongPreviewPlayer>("_songPreviewPlayer", newPlayer); } log?.Debug("Exposing UI Audio Manager"); var audioManager = ctx.GetRootGameObjects().ElementAt(0).GetComponentInChildren <BasicUIAudioManager>(); Container.Bind <BasicUIAudioManager>().FromInstance(audioManager).AsSingle(); var gameObject = new GameObject("Audio Sourcer"); var mixer = audioManager.GetField <AudioSource, BasicUIAudioManager>("_audioSource").outputAudioMixerGroup; var clone = gameObject.AddComponent <AudioSource>(); clone.outputAudioMixerGroup = mixer; Container.BindInstance(clone).WithId("audio.sourcer").AsSingle(); }) .Initialized((ctx, Container) => { var manager = Container.ResolveId <SiraUtil.Interfaces.IRegistrar <AudioClip> >(nameof(Managers.DiClickManager)); }); }
public void InitWithConfig(IPALogger logger, IPA.Config.Config conf, Zenjector zenject) { Instance = this; Logger.logger = logger; Log = logger; Log.Info("HRCounter initialized."); Configuration.PluginConfig.Instance = conf.Generated <Configuration.PluginConfig>(); Log.Debug("Config loaded"); AssetBundleManager.LoadAssetBundle(); zenject.Install <GameplayHearRateInstaller>(Location.Player); zenject.Install <Installers.GameplayCoreInstaller>(Location.Player); // we don't want to popup the pause menu during multiplayer, that's not gonna help anything! zenject.Install <GamePauseInstaller>(Location.StandardPlayer | Location.CampaignPlayer); Log.Debug("Installers!"); }
internal static void Sira(this IPA.Logging.Logger logger, string message) { if (Environment.GetCommandLineArgs().Contains("--siralog")) { logger.Debug(message); } }
public override void CounterInit() { if (PluginConfig.Instance.HideDuringReplay && Utils.Utils.IsInReplay()) { _logger.Info("We are in a replay, Counter hides."); return; } if (!Refresh()) { _logger.Info("Can't Refresh"); _logger.Info("Please check your settings about data source and the link or id."); return; } CreateCounter(); Utils.GamePause.GameStart(); try { _bpmDownloader.Start(); _logger.Info("Start updating heart rate"); } catch (Exception e) { _logger.Critical("Could not start bpm downloader."); _logger.Error(e.Message); _logger.Debug(e); _bpmDownloader.Stop(); return; } Start(); _logger.Info("Start updating counter text"); }
public void Init(IPALogger logger, Zenjector zenjector) { Logger = logger; Logger.Debug("Logger Initialized."); zenjector.Install <HttpPlayerInstaller>(Location.Player); zenjector.Install <HttpAppInstaller>(Location.App); this._harmony = new Harmony(HARMONY_ID); }
public void Init(IPALogger logger, Config conf) { Logger.log = logger; logger.Debug("Loading HttpText Plugin"); BSEvents.lateMenuSceneLoadedFresh += OnMenuSceneLoadedFresh; BSEvents.gameSceneLoaded += OnGameSceneActive; config = conf.Generated <PluginConfig>(); }
public void Init(IPALogger log, PluginMetadata meta, Zenjector zenjector) { Instance = this; _meta = meta; Logger = log; Logger.Debug("Logger initialized."); zenjector.OnApp <SRMAppInstaller>(); zenjector.OnMenu <SRMInstaller>(); }
public void Init(IPALogger logger, IPA.Config.Config conf) { Instance = this; Log = logger; Log.Info("VisibleHitboxes initialized."); Config.Instance = conf.Generated <Config>(); Log.Debug("Config loaded"); }
/// <summary> /// Called when the plugin is first loaded by IPA (either when the game starts or when the plugin is enabled if it starts disabled). /// [Init] methods that use a Constructor or called before regular methods like InitWithConfig. /// Only use [Init] with one Constructor. /// </summary> public void Init(IPALogger logger, Config conf, Zenjector zenjector) { Instance = this; Log = logger; Log.Info("UltimateFireworks initialized."); Configuration.PluginConfig.Instance = conf.Generated <Configuration.PluginConfig>(); Log.Debug("Config loaded"); _harmony = new Harmony(HARMONY_ID); zenjector.OnMenu <Installer.Installer>(); }
/// <summary> /// Called when the plugin is first loaded by IPA (either when the game starts or when the plugin is enabled if it starts disabled). /// [Init] methods that use a Constructor or called before regular methods like InitWithConfig. /// Only use [Init] with one Constructor. /// </summary> public void Init(IPALogger logger, Config conf, Zenjector zenjector) { Instance = this; Log = logger; Log.Info("BeatmapInformation initialized."); Configuration.PluginConfig.Instance = conf.Generated <Configuration.PluginConfig>(); Log.Debug("Config loaded"); zenjector.Install <BMInfoGameInstaller>(Location.Player); zenjector.Install <BMInfoMenuInstaller>(Location.Menu); }
public void InitWithConfig(IPALogger logger, Zenjector zenjector, Config conf) { Instance = this; Log = logger; Log.Info("NJOCheck initialized."); Configuration.PluginConfig.Instance = conf.Generated <Configuration.PluginConfig>(); Log.Debug("Config loaded"); zenjector.OnMenu <NJOMenuInstaller>(); }
public void Init(IPALogger _logger, Zenjector zenjector) { Instance = this; Logger = _logger; Logger.Debug("Logger initialized."); #if DEBUG zenjector.OnApp <TestInstaller>(); //zenjector.OnGame<TestInstaller>().Expose<ScoreController>(); #endif webSocketServer = new Server.Server(); zenjector.OnGame <ClientInstaller>(false); zenjector.On <GameCoreSceneSetup>().Pseudo((_) => {}).Expose <ScoreUIController>(); }
public void Initialize() { _logger.Debug("HRController Init"); if (_bpmDownloader == null) { _logger.Warn("BPM Downloader is null!"); return; } _bpmDownloader.OnHRUpdate += OnHRUpdateInternalHandler; try { _bpmDownloader.Start(); _logger.Info("Start updating heart rate"); } catch (Exception e) { _logger.Error($"Could not start bpm downloader. {e.Message}"); _logger.Debug(e); _bpmDownloader.OnHRUpdate -= OnHRUpdateInternalHandler; _bpmDownloader.Stop(); } }
public void Init(IPALogger logger, [Config.Prefer("json")] IConfigProvider cfgProvider) { Logger.log = logger; configProvider = cfgProvider; config = cfgProvider.MakeLink <PluginConfig>((p, v) => { if (v.Value == null || v.Value.RegenerateConfig) { p.Store(v.Value = new PluginConfig() { RegenerateConfig = false }); } config = v; }); logger.Debug("Initialize Complete!"); }
public void Init(IPALogger logger)//, [Config.Prefer("json")] Config conf) { log = logger; log?.Debug("Logger initialized."); //config = conf.Generated<BeatSyncConfig>(); var readerLogger = new Logging.BeatSyncFeedReaderLogger(SongFeedReaders.Logging.LoggingController.DefaultLogController); SongFeedReaders.Logging.LoggingController.DefaultLogger = readerLogger; BeatSyncLib.Logger.log = new BeatSyncLogger(logger); ConfigManager = new ConfigManager(); ConfigInitialized = ConfigManager.InitializeConfig(); if (ConfigInitialized) { modConfig = ConfigManager.Config; config = ConfigManager.Config.BeatSyncConfig; SettingsUI = new UI.SettingsUI(modConfig); } }
public void Init(IPA.Logging.Logger log) { if (_init) { return; } _init = true; logger = log; harmonyInstance = HarmonyInstance.Create("slaynash.discordpresence"); gameObject = Resources.FindObjectsOfTypeAll <MonoBehaviour>().First(c => c.GetType().Name == "PluginComponent"); try { logger.Info("Initializing"); logger.Info("Starting Discord RichPresence"); var handlers = new DiscordRpc.EventHandlers(); DiscordRpc.Initialize(DiscordAppID, ref handlers, false, string.Empty); logger.Info("Fetching nonpublic fields"); _gameplayCoreSceneSetupDataField = typeof(GameplayCoreSceneSetup).GetField("_sceneSetupData", BindingFlags.NonPublic | BindingFlags.Instance); _oneColorBeatmapCharacteristic = typeof(GameplayCoreSceneSetup).GetField("_oneColorBeatmapCharacteristic", BindingFlags.NonPublic | BindingFlags.Instance); _90DegreeBeatmapCharacteristic = typeof(GameplayCoreSceneSetup).GetField("_90DegreeBeatmapCharacteristic", BindingFlags.NonPublic | BindingFlags.Instance); _360DegreeBeatmapCharacteristic = typeof(GameplayCoreSceneSetup).GetField("_360DegreeBeatmapCharacteristic", BindingFlags.NonPublic | BindingFlags.Instance); #if DEBUG logger.Debug("Discord Presence - Field SceneSetup<GameplayCoreSceneSetupData>._sceneSetupData: " + _gameplayCoreSceneSetupDataField); #endif if (_gameplayCoreSceneSetupDataField == null) { logger.Error("Unable to fetch SceneSetup<GameplayCoreSceneSetupData>._sceneSetupData"); return; } logger.Info("Init done !"); } catch (Exception e) { logger.Error("Unable to initialize plugin:\n" + e); } }
public Plugin(IPALogger _logger) { instance = this; log = _logger; log?.Debug("Logger initialized."); if (_init) { return; } _init = true; logger = log; harmonyInstance = new Harmony(HarmonyId); gameObject = Resources.FindObjectsOfTypeAll <MonoBehaviour>() .First(c => c.GetType().Name == "PluginComponent"); try { logger?.Info("Initializing"); logger?.Info("Starting Discord RichPresence"); var handlers = new DiscordRpc.EventHandlers(); DiscordRpc.Initialize(DiscordAppID, ref handlers, false, string.Empty); logger?.Info("Fetching nonpublic fields"); _gameplayCoreSceneSetupDataField = typeof(GameplayCoreSceneSetupData).GetField("_sceneSetupData", BindingFlags.NonPublic | BindingFlags.Instance); _oneColorBeatmapCharacteristic = typeof(GameplayCoreSceneSetupData).GetField("_oneColorBeatmapCharacteristic", BindingFlags.NonPublic | BindingFlags.Instance); _90DegreeBeatmapCharacteristic = typeof(GameplayCoreSceneSetupData).GetField("_90DegreeBeatmapCharacteristic", BindingFlags.NonPublic | BindingFlags.Instance); _360DegreeBeatmapCharacteristic = typeof(GameplayCoreSceneSetupData).GetField("_360DegreeBeatmapCharacteristic", BindingFlags.NonPublic | BindingFlags.Instance); logger?.Info("Init done !"); } catch (Exception e) { logger?.Error("Unable to initialize plugin:\n" + e); } }
public void Debug(object message) { _logger.Debug(message?.ToString()); }
public Plugin(Logger logger) { Plugin.logger = logger; logger.Debug("Plugin.Init"); }
public Plugin(Logger logger) { Log = logger; Log.Debug("Logger initialised."); harmony = new Harmony(HarmonyId); }
private IEnumerator UpdatePresenceAfterFrame() { // Wait for next frame yield return(true); // Fetch all required objects _mainFlowCoordinator = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().FirstOrDefault(); _gameplaySetup = Resources.FindObjectsOfTypeAll <GameplayCoreSceneSetup>().FirstOrDefault(); if (_z == null) { _z = Resources.FindObjectsOfTypeAll <Component>().FirstOrDefault(c => c != null && c.GetType().Name == "Z"); if (_z == null) { logger.Warn("No element of type \"Z\" found. Maybe the game isn't running a version of ScoreSaber supporting replay ?"); } } if (_gameplaySetup != null) { _mainSetupData = _gameplayCoreSceneSetupDataField.GetValue(_gameplaySetup) as GameplayCoreSceneSetupData; } #if DEBUG logger.Debug("_gameplaySetup: " + _gameplaySetup); logger.Debug("_gameplayCoreSceneSetupDataField: " + _gameplayCoreSceneSetupDataField); logger.Debug("_mainSetupData: " + _mainSetupData); GetFlowTypeHumanReadable(); // Used to debug print values #endif // Check if every required object is found if (_mainSetupData == null || _gameplaySetup == null || _mainFlowCoordinator == null) { logger.Error("Error finding the scriptable objects required to update presence. (_mainSetupData: " + (_mainSetupData == null ? "N/A" : "OK") + ", _gameplaySetup: " + (_gameplaySetup == null ? "N/A" : "OK") + ", _mainFlowCoordinator: " + (_mainFlowCoordinator == null ? "N/A" : "OK")); Presence.details = "Playing"; DiscordRpc.UpdatePresence(Presence); yield break; } // Set presence main values IDifficultyBeatmap diff = _mainSetupData.difficultyBeatmap; Presence.details = $"{diff.level.songName} | {diff.difficulty.Name()}"; Presence.state = ""; if (_z != null) { //Console.WriteLine("--------------------------"); FieldInfo[] fields = _z.GetType().GetFields((BindingFlags)(-1)); foreach (FieldInfo fi in fields) { if (fi.FieldType.Name == "Mode" && fi.GetValue(_z).ToString() == "Playback") { Presence.state += "[Replay] "; } //logger.Debug("Discord Presence - [" + fi.Name + ": " + fi.FieldType.Name + "] => " + fi.GetValue(_z)); } } if (diff.level.levelID.Contains('∎')) { Presence.state += "Custom | "; } if (_mainSetupData.practiceSettings != null) { Presence.state += "Practice | "; } Presence.state += GetFlowTypeHumanReadable() + " "; #if DEBUG logger.Debug("Discord Presence - diff.parentDifficultyBeatmapSet.beatmapCharacteristic: " + diff.parentDifficultyBeatmapSet.beatmapCharacteristic); logger.Debug("Discord Presence - _gameplaySetup._oneColorBeatmapCharacteristic: " + typeof(GameplayCoreSceneSetup).GetField("_oneColorBeatmapCharacteristic", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(_gameplaySetup)); #endif // Update gamemode (Standard / One Saber / No Arrow) if (_mainSetupData.gameplayModifiers.noArrows || diff.parentDifficultyBeatmapSet.beatmapCharacteristic.ToString().ToLower().Contains("noarrow")) { _gamemode = GameMode.NoArrows; } else if (diff.parentDifficultyBeatmapSet.beatmapCharacteristic == (BeatmapCharacteristicSO)_oneColorBeatmapCharacteristic.GetValue(_gameplaySetup)) { _gamemode = GameMode.OneSaber; } else if (diff.parentDifficultyBeatmapSet.beatmapCharacteristic.ToString().ToLower().Contains("90degree")) { _gamemode = GameMode.NinetyDegree; } else if (diff.parentDifficultyBeatmapSet.beatmapCharacteristic.ToString().ToLower().Contains("360degree")) { _gamemode = GameMode.ThreeSixtyDegree; } else { _gamemode = GameMode.Standard; } string gameplayModeText = _gamemode == GameMode.OneSaber ? "One Saber" : _gamemode == GameMode.NoArrows ? "No Arrow" : _gamemode == GameMode.NinetyDegree ? "90º" : _gamemode == GameMode.ThreeSixtyDegree ? "360º" : "Standard"; Presence.state += gameplayModeText; // Set music speak if (_mainSetupData.practiceSettings != null) { if (_mainSetupData.practiceSettings.songSpeedMul != 1.0f) { Presence.state += " | Speed x" + _mainSetupData.practiceSettings.songSpeedMul; } } else { if (_mainSetupData.gameplayModifiers.songSpeedMul != 1.0f) { Presence.state += " | Speed x" + _mainSetupData.gameplayModifiers.songSpeedMul; } } // Set common gameplay modifiers if (_mainSetupData.gameplayModifiers.noFail) { Presence.state += " | No Fail"; } if (_mainSetupData.gameplayModifiers.instaFail) { Presence.state += " | Instant Fail"; } if (_mainSetupData.gameplayModifiers.disappearingArrows) { Presence.state += " | Disappearing Arrows"; } if (_mainSetupData.gameplayModifiers.ghostNotes) { Presence.state += " | Ghost Notes"; } Presence.largeImageKey = "default"; Presence.largeImageText = "Beat Saber"; Presence.smallImageKey = GetFlowTypeHumanReadable() == "Party" ? "party" : _gamemode == GameMode.OneSaber ? "one_saber" : _gamemode == GameMode.NoArrows ? "no_arrows" : _gamemode == GameMode.NinetyDegree ? "90" : _gamemode == GameMode.ThreeSixtyDegree ? "360" : "solo"; Presence.smallImageText = gameplayModeText; Presence.startTimestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; // Set startTimestamp offset if we are in training mode if (_mainSetupData.practiceSettings != null) { #if DEBUG logger.Debug("Discord Presence - _mainSetupData.practiceSettings.startSongTime: " + _mainSetupData.practiceSettings.startSongTime); #endif if (_mainSetupData.practiceSettings.startInAdvanceAndClearNotes) { Presence.startTimestamp -= (long)Mathf.Max(0f, _mainSetupData.practiceSettings.startSongTime - 3f); } else { Presence.startTimestamp -= (long)_mainSetupData.practiceSettings.startSongTime; } } DiscordRpc.UpdatePresence(Presence); }
public void OnApplicationStart() { logger.Debug("OnApplicationStart"); ApplyHarmonyPatches(); }
public static void Log(string message) { log.Debug(message); }
public void Debug(string message) { logSource.Debug(message); }
/// <summary> /// Called when the plugin is first loaded by IPA (either when the game starts or when the plugin is enabled if it starts disabled). /// [Init] methods that use a Constructor or called before regular methods like InitWithConfig. /// Only use [Init] with one Constructor. /// </summary> public void Init(IPALogger logger) { instance = this; log = logger; log.Debug("Logger initialized."); }
public void InitWithConfig(Config conf) { config = conf.Generated <PluginConfig>(); log.Debug("Config loaded"); }