Exemplo n.º 1
0
        /*
         *  ------------------
         *  Core Functionality
         *  ------------------
         */

        public void SetPresence()
        {
            // Contains the Stage Name
            string currentDetails = GetCurrentDetails();

            // Contains Stage Details
            string currentGameState = GetGameState();

            // Contains the start of current action.
            Timestamps timeStamps = new Timestamps();
            long       timeStamp  = 0;

            // Images
            Assets assets = new Assets();

            // Set timestamp.
            if ((!_heroes.IsInMainMenu()) && (!_heroes.IsPaused()) && (!_heroes.IsWatchingIngameEvent()))
            {
                // TODO: Bug Here with Seconds

                // Do not set timestamp if paused.
                TimeSpan sinceEpoch = DateTime.UtcNow - new DateTime(1970, 1, 1);
                ;
                timeStamp        = (long)(sinceEpoch.TotalSeconds - (*_heroes.CurrentStageTime).GetTotalSeconds());
                timeStamps.Start = Timestamps.FromUnixTime(timeStamp);
            }

            // Get Image
            if (!_heroes.IsInMainMenu())
            {
                if (_heroes.ImageTranslationDictionary.StageNameTranslator.TryGetValue(*_heroes.StageID, out string stageAssetName))
                {
                    assets.LargeImageKey = stageAssetName;
                }
            }

            // Send to Discord
            _client.SetPresence(new RichPresence()
            {
                Details    = currentDetails,
                Timestamps = timeStamps,
                State      = currentGameState,
                Assets     = assets
            });
        }