From bde8f9c00a5e98e23aec982c8a11dd3a7ec118cc Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 15 Apr 2024 01:37:22 +0200 Subject: [PATCH] Added combat to RPC --- .../EliteDangerousApiDiscordRichPresence.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Discord/EliteAPI.Discord/EliteDangerousApiDiscordRichPresence.cs b/Discord/EliteAPI.Discord/EliteDangerousApiDiscordRichPresence.cs index beafefa1..96f28f07 100644 --- a/Discord/EliteAPI.Discord/EliteDangerousApiDiscordRichPresence.cs +++ b/Discord/EliteAPI.Discord/EliteDangerousApiDiscordRichPresence.cs @@ -50,6 +50,7 @@ public async Task StartAsync() _api.Events.On(OnMarketBuy); _api.Events.On(OnMarketSell); _api.Events.On(OnDestinationStatus); + _api.Events.On(OnUnderAttack); _api.Events.On(OnShutdown); _api.Events.On(e => @@ -432,6 +433,25 @@ private void OnDestinationStatus(DestinationStatusEvent @event, EventContext con }); } + private void OnUnderAttack(UnderAttackEvent @event, EventContext context) + { + if (context.IsRaisedDuringCatchup) + return; + + _client.SetPresence(new RichPresence + { + Details = "In active combat", + State = $"near {_currentBody}", + Assets = new Assets + { + LargeImageKey = "combat", + SmallImageKey = "ed", + SmallImageText = "EliteAPI" + }, + Timestamps = new Timestamps { Start = _playingSince } + }); + } + private void OnShutdown(ShutdownEvent @event, EventContext context) { if (context.IsRaisedDuringCatchup)