Skip to content

Commit

Permalink
Destination arrived event expanded to trigger when arriving at dest…
Browse files Browse the repository at this point in the history
…ination settlements / ground sites.

Resolves #2623
  • Loading branch information
Tkael committed Jun 17, 2024
1 parent 77d1129 commit df024bc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Full details of the variables available for each noted event, and VoiceAttack integrations, are available in the individual [event pages](https://github.com/EDCD/EDDI/wiki/Events).

## 4.0.4-b3
* Events
* `Destination arrived` event expanded to trigger when arriving at destination settlements / ground sites (#2623)

## 4.0.4-b2
* Speech Responder
* Core
Expand Down
4 changes: 2 additions & 2 deletions Events/DestinationArrivedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public class DestinationArrivedEvent : Event

public long? marketID { get; private set; }

public DestinationArrivedEvent ( DateTime timestamp, string invariantName, string localizedName, int threat, long? marketID = null) : base(timestamp, NAME)
public DestinationArrivedEvent ( DateTime timestamp, string invariantName, string localizedName = null, int? threat = null, long? marketID = null) : base(timestamp, NAME)
{
this.invariantName = invariantName;
this.name = string.IsNullOrEmpty( localizedName ) ? invariantName : localizedName;
this.threat = threat;
this.threat = threat ?? 0;
this.marketID = marketID;
}
}
Expand Down
27 changes: 27 additions & 0 deletions StatusMonitor/StatusMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,33 @@ public void PreHandle(Event @event)
{
handleMusicEvent( musicEvent );
}
else if ( @event is SettlementApproachedEvent settlementApproachedEvent )
{
handleSettlementApproachedEvent( settlementApproachedEvent );
}
}

private void handleSettlementApproachedEvent ( SettlementApproachedEvent @event )
{
// Synthesize a `Destination arrived` event when approaching a settlement / location we've been tracking,
// if the journal hasn't already generated a `SupercruiseDestinationDrop` event
if ( !@event.fromLoad &&
currentStatus?.destinationSystemAddress != null &&
currentStatus.destinationSystemAddress == @event.systemAddress &&
currentStatus.destinationBodyId == @event.bodyId &&
( currentStatus.destination_name == @event.name ||
currentStatus.destination_localized_name == @event.name ) )
{
// Retrieve the last `SupercruiseDestinationDrop` event and verify that, if it exists, it does not match the settlement we may be approaching.
if ( !EDDI.Instance.lastEventOfType.TryGetValue( "SupercruiseDestinationDrop",
out var supercruiseDestinationDrop ) ||
!( supercruiseDestinationDrop is DestinationArrivedEvent destinationArrivedEvent ) ||
destinationArrivedEvent.name != @event.name )
{
destinationArrivedEvent = new DestinationArrivedEvent( currentStatus.timestamp, @event.name );
EDDI.Instance.enqueueEvent( destinationArrivedEvent );
}
}
}

private void handleEnteredNormalSpaceEvent( EnteredNormalSpaceEvent @event )
Expand Down

0 comments on commit df024bc

Please sign in to comment.