Пример #1
0
        public void OnApplicationStart()
        {
            if (_init)
            {
                return;
            }
            _init = true;
            SceneManager.sceneLoaded += SceneManagerOnSceneLoaded;

            var handlers = new DiscordRpc.EventHandlers();

            DiscordRpc.Initialize(DiscordAppID, ref handlers, false, string.Empty);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }