public void UpdatePresence(EsoCharacter character)
        {
            if (!this.Main.EsoIsRunning || character == null)
            {
                return;
            }

            this.PresenceData.state   = ((character.InDungeon) ? (Zones.Trials.IsValid(character.Zone) || Zones.Dungeons.IsValid(character.Zone) ? $"In a dungeon{((character.GroupRole != null) ? $" as {character.GroupRole}" : (character.PreferredGroupRoles.Length > 0) ? $" as {String.Join(", ", character.PreferredGroupRoles)}" : "")}" : $"Venturing through a Delve") : "Roaming Tamriel");
            this.PresenceData.details = $"{((this.ShowCharacterName) ? character.Name : character.Account)} ({((character.IsChampion) ? "CP" : "Level ")}{character.Level})";

            if (this.ShowPartyInfo)
            {
                this.PresenceData.partyMax  = ((character.GroupSize <= 4) ? 4 : ((character.GroupSize <= 12) ? 12 : 24));
                this.PresenceData.partySize = character.GroupSize;
            }

            else
            {
                this.PresenceData.partyMax  = 0;
                this.PresenceData.partySize = 0;
            }

            this.PresenceData.largeImageKey  = ((character.InDungeon) ? ((Zones.Trials.IsValid(character.Zone)) ? Zones.Trials.Get(character.Zone) : Zones.Dungeons.Get(character.Zone)) : Zones.Locations.Get(character.Zone));
            this.PresenceData.largeImageText = character.Zone;

            if (character.InDungeon && (Zones.Trials.IsValid(character.Zone) || Zones.Dungeons.IsValid(character.Zone)))
            {
                this.PresenceData.startTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
                this.PresenceData.smallImageKey  = $"difficulty_{character.DungeonDifficulty.ToLower()}";
                this.PresenceData.smallImageText = $"{character.DungeonDifficulty} Mode";
            }

            else
            {
                this.PresenceData.startTimestamp = this.Main.StartTimestamp;
                this.PresenceData.smallImageKey  = String.Empty;
                this.PresenceData.smallImageText = String.Empty;
            }

            DiscordRpc.UpdatePresence(this.PresenceData);
        }
예제 #2
0
        public void UpdatePresence(EsoCharacter character)
        {
            if (!this.Main.EsoIsRunning || character == null)
            {
                return;
            }

            // Character | Account (Level|CP)
            this.PresenceData.details = $"{((this.ShowCharacterName) ? character.Name : character.Account)} ({((character.IsChampion) ? "CP" : "Level ")}{character.Level})";

            // State + Image + Time Data

            this.PresenceData.state = character.QuestName;

            this.PresenceData.largeImageKey = Image_Keys.Locations.Get(character.Zone);

            // Try to get image for parent zone if not found; will probably still return default
            if (this.PresenceData.largeImageKey == "default")
            {
                this.PresenceData.largeImageKey = Image_Keys.Locations.Get(character.ParentZone);
            }

            this.PresenceData.largeImageText = (character.SubZone != null && character.SubZone.Length > 0) ? character.SubZone : character.Zone;
            this.PresenceData.smallImageKey  = $"class_{character.Class.ToLower()}";
            this.PresenceData.smallImageText = character.Class;

            this.PresenceData.startTimestamp = this.Main.StartTimestamp;

            if (character.InDungeon)
            {
                this.PresenceData.largeImageText = character.Dungeon;

                if (Image_Keys.Trials.IsValid(character.Dungeon) || Image_Keys.Dungeons.IsValid(character.Dungeon))
                {
                    this.PresenceData.state = (character.GroupRole != null) ? character.GroupRole : "";

                    // Don't update timestamp if in same dungeon instance
                    if (this._latestInstance != null &&
                        !(this._latestInstance.InDungeon &&
                          this._latestInstance.Dungeon == character.Dungeon &&
                          this._latestInstance.DungeonDifficulty == character.DungeonDifficulty
                          )
                        )
                    {
                        this.PresenceData.startTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
                    }

                    this.PresenceData.largeImageKey  = (Image_Keys.Trials.IsValid(character.Dungeon)) ? Image_Keys.Trials.Get(character.Dungeon) : Image_Keys.Dungeons.Get(character.Dungeon);
                    this.PresenceData.smallImageKey  = $"difficulty_{character.DungeonDifficulty.ToLower()}";
                    this.PresenceData.smallImageText = $"{character.DungeonDifficulty} Mode";
                }
            }

            // Party Data

            this.PresenceData.partyMax  = 0;
            this.PresenceData.partySize = 0;

            if (this.ShowPartyInfo)
            {
                this.PresenceData.partyMax  = ((character.GroupSize <= 4) ? 4 : ((character.GroupSize <= 12) ? 12 : 24));
                this.PresenceData.partySize = character.GroupSize;
            }

            DiscordRpc.UpdatePresence(this.PresenceData);
            this._latestInstance = character;
        }