Skip to content

Commit

Permalink
Simplify Safe event trigger - users can make it more discerning in …
Browse files Browse the repository at this point in the history
…their scripts if they choose.
  • Loading branch information
Tkael committed Aug 8, 2021
1 parent 39a0b8a commit 28f0ac6
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions StatusMonitor/StatusMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class StatusMonitor : EDDIMonitor
private const int pollingIntervalRelaxedMs = 5000;

// Miscellaneous tracking
private bool in_combat;
private bool gliding;
private bool jumping;
private EnteredNormalSpaceEvent lastEnteredNormalSpaceEvent;
Expand Down Expand Up @@ -470,22 +469,9 @@ public void handleStatus(Status thisStatus)
fuelLog = null;
}
// Detect whether we're in combat
if (!in_combat && thisStatus.in_danger)
if (lastStatus.in_danger && !thisStatus.in_danger)
{
// We're in combat
in_combat = true;
}
if (in_combat && !thisStatus.in_danger)
{
// We may still be in combat but the immediate danger has passed
if ((thisStatus.vehicle == Constants.VEHICLE_LEGS && thisStatus.selected_weapon.Contains("Unarmed"))
|| (thisStatus.vehicle == Constants.VEHICLE_SRV && !thisStatus.srv_turret_deployed)
|| (thisStatus.vehicle == Constants.VEHICLE_SHIP && !thisStatus.hardpoints_deployed))
{
// We're safe
in_combat = false;
EDDI.Instance.enqueueEvent(new SafeEvent(DateTime.UtcNow) { fromLoad = false });
}
EDDI.Instance.enqueueEvent(new SafeEvent(DateTime.UtcNow) { fromLoad = false });
}

// Pass the change in status to all subscribed processes
Expand Down

0 comments on commit 28f0ac6

Please sign in to comment.