Skip to content

Commit

Permalink
Added combat to RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
Somfic committed Apr 14, 2024
1 parent 1964aa5 commit bde8f9c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Discord/EliteAPI.Discord/EliteDangerousApiDiscordRichPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public async Task StartAsync()
_api.Events.On<MarketBuyEvent>(OnMarketBuy);
_api.Events.On<MarketSellEvent>(OnMarketSell);
_api.Events.On<DestinationStatusEvent>(OnDestinationStatus);
_api.Events.On<UnderAttackEvent>(OnUnderAttack);
_api.Events.On<ShutdownEvent>(OnShutdown);

_api.Events.On<LocationEvent>(e =>
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bde8f9c

Please sign in to comment.