diff --git a/Influx/Influx/InfluxStatisticsClient.cs b/Influx/Influx/InfluxStatisticsClient.cs index 43599c5..f795b8f 100644 --- a/Influx/Influx/InfluxStatisticsClient.cs +++ b/Influx/Influx/InfluxStatisticsClient.cs @@ -240,6 +240,7 @@ internal sealed class InfluxStatisticsClient : IDisposable .Tag("build", sub.Build) .Field("level", sub.Level) .Field("predicted_level", sub.PredictedLevel) + .Field("state", (int)sub.State) .Timestamp(date, WritePrecision.S)); } } diff --git a/Influx/SubmarineTracker/EState.cs b/Influx/SubmarineTracker/EState.cs new file mode 100644 index 0000000..3408bce --- /dev/null +++ b/Influx/SubmarineTracker/EState.cs @@ -0,0 +1,8 @@ +namespace Influx.SubmarineTracker; + +public enum EState +{ + NoVoyage, + Returned, + Voyage, +} diff --git a/Influx/SubmarineTracker/Submarine.cs b/Influx/SubmarineTracker/Submarine.cs index fcf7aeb..ac27ce4 100644 --- a/Influx/SubmarineTracker/Submarine.cs +++ b/Influx/SubmarineTracker/Submarine.cs @@ -14,6 +14,13 @@ public sealed class Submarine { (uint predictedLevel, double _) = ((uint, double))@delegate.GetType().GetMethod("PredictExpGrowth")!.Invoke(@delegate, Array.Empty())!; PredictedLevel = (ushort)predictedLevel; + + bool onVoyage = (bool)@delegate.GetType().GetMethod("IsOnVoyage")!.Invoke(@delegate, Array.Empty())!; + bool returned = (bool)@delegate.GetType().GetMethod("IsDone")!.Invoke(@delegate, Array.Empty())!; + if (onVoyage) + State = returned ? EState.Returned : EState.Voyage; + else + State = EState.NoVoyage; } catch (Exception) { @@ -25,4 +32,5 @@ public sealed class Submarine public ushort Level { get; } public ushort PredictedLevel { get; } public Build Build { get; } + public EState State { get; } } diff --git a/Influx/SubmarineTracker/SubmarineStats.cs b/Influx/SubmarineTracker/SubmarineStats.cs index 145c351..00926ef 100644 --- a/Influx/SubmarineTracker/SubmarineStats.cs +++ b/Influx/SubmarineTracker/SubmarineStats.cs @@ -12,4 +12,5 @@ public sealed class SubmarineStats public required string Bow { get; init; } public required string Bridge { get; init; } public required string Build { get; init; } + public required EState State { get; init; } } diff --git a/Influx/SubmarineTracker/SubmarineTrackerIpc.cs b/Influx/SubmarineTracker/SubmarineTrackerIpc.cs index dc66c55..6c40781 100644 --- a/Influx/SubmarineTracker/SubmarineTrackerIpc.cs +++ b/Influx/SubmarineTracker/SubmarineTrackerIpc.cs @@ -52,6 +52,7 @@ internal sealed class SubmarineTrackerIpc Bow = y.Build.BowIdentifier, Bridge = y.Build.BridgeIdentifier, Build = y.Build.FullIdentifier, + State = y.State, }).ToList()); } else