diff --git a/ObservatoryFramework/Files/BackPackFile.cs b/ObservatoryFramework/Files/BackPackFile.cs
index d2bde67..78e28b2 100644
--- a/ObservatoryFramework/Files/BackPackFile.cs
+++ b/ObservatoryFramework/Files/BackPackFile.cs
@@ -13,17 +13,17 @@ public class BackpackFile : JournalBase
///
/// List of all items carried.
///
- public ImmutableList Items { get; init; }
+ public IReadOnlyCollection Items { get; init; }
///
/// List of all components carried.
///
- public ImmutableList Components { get; init; }
+ public IReadOnlyCollection Components { get; init; }
///
/// List of player consumable items carried.
///
- public ImmutableList Consumables { get; init; }
+ public IReadOnlyCollection Consumables { get; init; }
///
/// List of all data currently stored by the player.
///
- public ImmutableList Data { get; init; }
+ public IReadOnlyCollection Data { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/CargoFile.cs b/ObservatoryFramework/Files/CargoFile.cs
index e5b0db2..c19112d 100644
--- a/ObservatoryFramework/Files/CargoFile.cs
+++ b/ObservatoryFramework/Files/CargoFile.cs
@@ -21,5 +21,5 @@ public class CargoFile : JournalBase
///
/// List of full cargo details.
///
- public ImmutableList Inventory { get; init; }
+ public IReadOnlyCollection Inventory { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Converters/MaterialCompositionConverter.cs b/ObservatoryFramework/Files/Converters/MaterialCompositionConverter.cs
index 440c923..0acfcf8 100644
--- a/ObservatoryFramework/Files/Converters/MaterialCompositionConverter.cs
+++ b/ObservatoryFramework/Files/Converters/MaterialCompositionConverter.cs
@@ -9,9 +9,9 @@ namespace Observatory.Framework.Files.Converters;
/// The format used for materials changed from an object with a key for each material to an array of objects containing "name" and "percent".
/// Need to handle both if we're going to read historical data. This reads the old format into a class reflecting the new structure.
///
-public class MaterialCompositionConverter : JsonConverter>
+public class MaterialCompositionConverter : JsonConverter>
{
- public override ImmutableList Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public override IReadOnlyCollection Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.StartObject)
{
@@ -38,13 +38,14 @@ public class MaterialCompositionConverter : JsonConverter>(ref reader, options)!;
+ return JsonSerializer.Deserialize>(ref reader, options)!;
}
- public override void Write(Utf8JsonWriter writer, ImmutableList value,
+ public override void Write(Utf8JsonWriter writer, IReadOnlyCollection value,
JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value, options);
diff --git a/ObservatoryFramework/Files/Converters/MaterialConverter.cs b/ObservatoryFramework/Files/Converters/MaterialConverter.cs
index f005bdb..532e2e7 100644
--- a/ObservatoryFramework/Files/Converters/MaterialConverter.cs
+++ b/ObservatoryFramework/Files/Converters/MaterialConverter.cs
@@ -9,9 +9,9 @@ namespace Observatory.Framework.Files.Converters;
/// The format used for materials changed from an object with a key for each material to an array of objects containing "name" and "percent".
/// Need to handle both if we're going to read historical data. This reads the old format into a class reflecting the new structure.
///
-public class MaterialConverter : JsonConverter>
+public class MaterialConverter : JsonConverter>
{
- public override ImmutableList Read(ref Utf8JsonReader reader, Type typeToConvert,
+ public override IReadOnlyCollection Read(ref Utf8JsonReader reader, Type typeToConvert,
JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.StartObject)
@@ -41,13 +41,13 @@ public class MaterialConverter : JsonConverter>
}
}
- return materialComposition.ToImmutableList();
+ return materialComposition;
}
- return JsonSerializer.Deserialize>(ref reader, options)!;
+ return JsonSerializer.Deserialize>(ref reader, options)!;
}
- public override void Write(Utf8JsonWriter writer, ImmutableList value, JsonSerializerOptions options)
+ public override void Write(Utf8JsonWriter writer, IReadOnlyCollection value, JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value, options);
}
diff --git a/ObservatoryFramework/Files/Converters/MutableStringDoubleConverter.cs b/ObservatoryFramework/Files/Converters/MutableStringDoubleConverter.cs
deleted file mode 100644
index 7bbfe6f..0000000
--- a/ObservatoryFramework/Files/Converters/MutableStringDoubleConverter.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Text.Json;
-using System.Text.Json.Serialization;
-
-namespace Observatory.Framework.Files.Converters;
-
-class MutableStringDoubleConverter : JsonConverter
-{
- public override object Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- if (reader.TokenType == JsonTokenType.String)
- return reader.GetString();
- return reader.GetDouble();
- }
-
- public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOptions options)
- {
- if (value.GetType() == typeof(string))
- writer.WriteStringValue((string)value);
- else
- writer.WriteNumberValue((double)value);
- }
-}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Converters/NumberOrStringConverter.cs b/ObservatoryFramework/Files/Converters/NumberOrStringConverter.cs
new file mode 100644
index 0000000..edcf9e6
--- /dev/null
+++ b/ObservatoryFramework/Files/Converters/NumberOrStringConverter.cs
@@ -0,0 +1,21 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using Observatory.Framework.Files.ParameterTypes;
+
+namespace Observatory.Framework.Files.Converters;
+
+class NumberOrStringConverter : JsonConverter
+{
+ public override NumberOrString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ return reader.TokenType == JsonTokenType.String ? new NumberOrString(reader.GetString()) : new NumberOrString(reader.GetDouble());
+ }
+
+ public override void Write(Utf8JsonWriter writer, NumberOrString value, JsonSerializerOptions options)
+ {
+ if (value.IsString)
+ writer.WriteStringValue(value.StringValue!);
+ else
+ writer.WriteNumberValue(value.DoubleValue!.Value);
+ }
+}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Converters/StarPosConverter.cs b/ObservatoryFramework/Files/Converters/StarPosConverter.cs
index 5dd1c37..6ee5fb6 100644
--- a/ObservatoryFramework/Files/Converters/StarPosConverter.cs
+++ b/ObservatoryFramework/Files/Converters/StarPosConverter.cs
@@ -1,21 +1,22 @@
using System.Text.Json;
using System.Text.Json.Serialization;
+using Observatory.Framework.Files.Journal.Travel;
namespace Observatory.Framework.Files.Converters;
///
/// Converting the ordered array of coordinates from the journal to a named tuple for clarity.
///
-public class StarPosConverter : JsonConverter<(double x, double y, double z)>
+public class StarPosConverter : JsonConverter
{
- public override (double x, double y, double z) Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public override StarPos Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
- var values = (double[])JsonSerializer.Deserialize(ref reader, typeof(double[]));
+ var values = JsonSerializer.Deserialize(ref reader, options)!;
- return (x: values[0], y: values[1], z: values[2]);
+ return new StarPos { X = values[0], Y = values[1], Z = values[2] };
}
- public override void Write(Utf8JsonWriter writer, (double x, double y, double z) value, JsonSerializerOptions options)
+ public override void Write(Utf8JsonWriter writer, StarPos value, JsonSerializerOptions options)
{
JsonSerializer.Serialize(writer, value, options);
}
diff --git a/ObservatoryFramework/Files/FCMaterialsFile.cs b/ObservatoryFramework/Files/FCMaterialsFile.cs
index de8b70b..c81b82a 100644
--- a/ObservatoryFramework/Files/FCMaterialsFile.cs
+++ b/ObservatoryFramework/Files/FCMaterialsFile.cs
@@ -13,5 +13,5 @@ public class FCMaterialsFile : JournalBase
///
/// List of items in stock and in demand from the carrier bartender.
///
- public ImmutableList Items { get; init; }
+ public IReadOnlyCollection Items { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Combat/Bounty.cs b/ObservatoryFramework/Files/Journal/Combat/Bounty.cs
index 3f6f593..4ebdf59 100644
--- a/ObservatoryFramework/Files/Journal/Combat/Bounty.cs
+++ b/ObservatoryFramework/Files/Journal/Combat/Bounty.cs
@@ -6,7 +6,7 @@ namespace Observatory.Framework.Files.Journal.Combat;
public class Bounty : JournalBase
{
public override string Event => "Bounty";
- public ImmutableList Rewards { get; init; }
+ public IReadOnlyCollection Rewards { get; init; }
public string PilotName { get; set; }
public string PilotName_Localised { get; set; }
public string Target { get; init; }
diff --git a/ObservatoryFramework/Files/Journal/Combat/Died.cs b/ObservatoryFramework/Files/Journal/Combat/Died.cs
index b1f32cf..4631e45 100644
--- a/ObservatoryFramework/Files/Journal/Combat/Died.cs
+++ b/ObservatoryFramework/Files/Journal/Combat/Died.cs
@@ -10,5 +10,5 @@ public class Died : JournalBase
public string KillerName_Localised { get; init; }
public string KillerShip { get; init; }
public string KillerRank { get; init; }
- public ImmutableList Killers { get; init; }
+ public IReadOnlyCollection Killers { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Exploration/CodexEntry.cs b/ObservatoryFramework/Files/Journal/Exploration/CodexEntry.cs
index a637f07..7405fa2 100644
--- a/ObservatoryFramework/Files/Journal/Exploration/CodexEntry.cs
+++ b/ObservatoryFramework/Files/Journal/Exploration/CodexEntry.cs
@@ -71,7 +71,7 @@ public class CodexEntry : JournalBase
///
/// List of trais of the scanned item.
///
- public ImmutableList Traits { get; init; }
+ public ICollection Traits { get; init; }
///
/// Value of the codex entry when sold to Universal Cartographics.
///
diff --git a/ObservatoryFramework/Files/Journal/Exploration/MultiSellExplorationData.cs b/ObservatoryFramework/Files/Journal/Exploration/MultiSellExplorationData.cs
index f957a2c..48ce20c 100644
--- a/ObservatoryFramework/Files/Journal/Exploration/MultiSellExplorationData.cs
+++ b/ObservatoryFramework/Files/Journal/Exploration/MultiSellExplorationData.cs
@@ -12,7 +12,7 @@ public class MultiSellExplorationData : JournalBase
///
/// List of all sold first discoveries.
///
- public ImmutableList Discovered { get; init; }
+ public IReadOnlyCollection Discovered { get; init; }
///
/// Base value of total sold data.
///
diff --git a/ObservatoryFramework/Files/Journal/Exploration/SAAScanComplete.cs b/ObservatoryFramework/Files/Journal/Exploration/SAAScanComplete.cs
index 9c475aa..e2158f8 100644
--- a/ObservatoryFramework/Files/Journal/Exploration/SAAScanComplete.cs
+++ b/ObservatoryFramework/Files/Journal/Exploration/SAAScanComplete.cs
@@ -23,11 +23,11 @@ public class SAAScanComplete : JournalBase
///
/// This property is indicated with strikethrough in Frontier's documentation and is likely unused.
///
- public ImmutableList Discoverers { get; init; }
+ public ICollection Discoverers { get; init; }
///
/// This property is indicated with strikethrough in Frontier's documentation and is likely unused.
///
- public ImmutableList Mappers { get; init; }
+ public ICollection Mappers { get; init; }
///
/// Number of probes fired to complete the surface scan.
///
diff --git a/ObservatoryFramework/Files/Journal/Exploration/SAASignalsFound.cs b/ObservatoryFramework/Files/Journal/Exploration/SAASignalsFound.cs
index eade1fd..7925e7b 100644
--- a/ObservatoryFramework/Files/Journal/Exploration/SAASignalsFound.cs
+++ b/ObservatoryFramework/Files/Journal/Exploration/SAASignalsFound.cs
@@ -24,9 +24,9 @@ public class SAASignalsFound : JournalBase
///
/// List of signals found.
///
- public ImmutableList Signals { get; init; }
+ public IReadOnlyCollection Signals { get; init; }
///
/// List of genuses present.
///
- public ImmutableList Genuses { get; init; }
+ public IReadOnlyCollection Genuses { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Exploration/Scan.cs b/ObservatoryFramework/Files/Journal/Exploration/Scan.cs
index d2480c1..27a326c 100644
--- a/ObservatoryFramework/Files/Journal/Exploration/Scan.cs
+++ b/ObservatoryFramework/Files/Journal/Exploration/Scan.cs
@@ -22,7 +22,7 @@ public class Scan : ScanBaryCentre
///
/// List which reflects Frontier's JSON structure for the "Parents" object. Use of Parent property is recommended instead.
///
- public ImmutableList Parents {
+ public IReadOnlyCollection Parents {
get => _Parents;
init
{
@@ -43,15 +43,16 @@ public class Scan : ScanBaryCentre
ParentList.Add((ParentType.Star, parent.Star.GetValueOrDefault(0)));
}
}
- Parent = ParentList.ToImmutableList();
- }
+
+ Parent = ParentList;
+ }
}
///
/// "Parents" object rearranged into more intuitive structure for ease of use.
///
[JsonIgnore]
- public ImmutableList<(ParentType ParentType, int Body)> Parent { get; init; }
- private ImmutableList _Parents;
+ public IReadOnlyCollection<(ParentType ParentType, int Body)> Parent { get; init; }
+ private IReadOnlyCollection _Parents;
///
/// Body distance from system arrival point in light-seconds.
///
@@ -79,7 +80,7 @@ public class Scan : ScanBaryCentre
///
/// List containing full breakdown of atmospheric components and their relative percentages.
///
- public ImmutableList AtmosphereComposition { get; init; }
+ public IReadOnlyCollection AtmosphereComposition { get; init; }
///
/// Descriptive string for type of volcanism present, or an empty string for none, e.g. "major silicate vapour geysers volcanism".
///
@@ -112,7 +113,7 @@ public class Scan : ScanBaryCentre
/// List containing full breakdown of prospectable surface materials and their relative percentages.
///
[JsonConverter(typeof(MaterialCompositionConverter))]
- public ImmutableList Materials { get; init; }
+ public IReadOnlyCollection Materials { get; init; }
///
/// Overall composition of body, expressed as percentages of ice, rock, and metal.
///
@@ -129,7 +130,7 @@ public class Scan : ScanBaryCentre
///
/// List of all planetary or stellar ring systems around the body.
///
- public ImmutableList Rings { get; init; }
+ public IReadOnlyCollection Rings { get; init; }
///
/// Description of the minable material abundance. Possible values inclue "PristineResources", "MajorResources", "CommonResources", "LowResources", and "DepletedResources".
///
diff --git a/ObservatoryFramework/Files/Journal/Exploration/SellExplorationData.cs b/ObservatoryFramework/Files/Journal/Exploration/SellExplorationData.cs
index 27bc5f2..60ca367 100644
--- a/ObservatoryFramework/Files/Journal/Exploration/SellExplorationData.cs
+++ b/ObservatoryFramework/Files/Journal/Exploration/SellExplorationData.cs
@@ -11,11 +11,11 @@ public class SellExplorationData : JournalBase
///
/// List of systems for which data was sold.
///
- public ImmutableList Systems { get; init; }
+ public ICollection Systems { get; init; }
///
/// List of first discovered bodies.
///
- public ImmutableList Discovered { get; init; }
+ public ICollection Discovered { get; init; }
///
/// Base value of sold data.
///
diff --git a/ObservatoryFramework/Files/Journal/FleetCarrier/CarrierJump.cs b/ObservatoryFramework/Files/Journal/FleetCarrier/CarrierJump.cs
index c7621ae..8375359 100644
--- a/ObservatoryFramework/Files/Journal/FleetCarrier/CarrierJump.cs
+++ b/ObservatoryFramework/Files/Journal/FleetCarrier/CarrierJump.cs
@@ -24,5 +24,5 @@ public class CarrierJump : FSDJump
public StationService StationServices { get; init; }
public string StationEconomy { get; init; }
public string StationEconomy_Localised { get; init; }
- public ImmutableList StationEconomies { get; init; }
+ public IReadOnlyCollection StationEconomies { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/FleetCarrier/CarrierStats.cs b/ObservatoryFramework/Files/Journal/FleetCarrier/CarrierStats.cs
index bbec47b..60a191f 100644
--- a/ObservatoryFramework/Files/Journal/FleetCarrier/CarrierStats.cs
+++ b/ObservatoryFramework/Files/Journal/FleetCarrier/CarrierStats.cs
@@ -19,7 +19,7 @@ public class CarrierStats : JournalBase
public bool PendingDecommission { get; init; }
public CarrierSpaceUsage SpaceUsage { get; init; }
public ParameterTypes.CarrierFinance Finance { get; init; }
- public ImmutableList Crew { get; init; }
- public ImmutableList ShipPacks { get; init; }
- public ImmutableList ModulePacks { get; init; }
+ public IReadOnlyCollection Crew { get; init; }
+ public IReadOnlyCollection ShipPacks { get; init; }
+ public IReadOnlyCollection ModulePacks { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/BackpackChange.cs b/ObservatoryFramework/Files/Journal/Odyssey/BackpackChange.cs
index ed48c01..f18e4c3 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/BackpackChange.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/BackpackChange.cs
@@ -6,6 +6,6 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
public class BackpackChange : JournalBase
{
public override string Event => "BackpackChange";
- public ImmutableList Added { get; init; }
- public ImmutableList Removed { get; init; }
+ public IReadOnlyCollection Added { get; init; }
+ public IReadOnlyCollection Removed { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/BackpackMaterials.cs b/ObservatoryFramework/Files/Journal/Odyssey/BackpackMaterials.cs
index 26b27e3..dc849c1 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/BackpackMaterials.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/BackpackMaterials.cs
@@ -6,8 +6,8 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
public class BackpackMaterials : JournalBase
{
public override string Event => "BackpackMaterials";
- public ImmutableList Items { get; init; }
- public ImmutableList Components { get; init; }
- public ImmutableList Consumables { get; init; }
- public ImmutableList Data { get; init; }
+ public IReadOnlyCollection Items { get; init; }
+ public IReadOnlyCollection Components { get; init; }
+ public IReadOnlyCollection Consumables { get; init; }
+ public IReadOnlyCollection Data { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/BuyMicroResources.cs b/ObservatoryFramework/Files/Journal/Odyssey/BuyMicroResources.cs
index 67476e0..bbd5eea 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/BuyMicroResources.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/BuyMicroResources.cs
@@ -15,5 +15,5 @@ public class BuyMicroResources : JournalBase
public int Price { get; init; }
public ulong MarketID { get; init; }
public int TotalCount { get; init; }
- public ImmutableList MicroResources { get; init; }
+ public IReadOnlyCollection MicroResources { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/CreateSuitLoadout.cs b/ObservatoryFramework/Files/Journal/Odyssey/CreateSuitLoadout.cs
index 11be02f..2c3f5bf 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/CreateSuitLoadout.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/CreateSuitLoadout.cs
@@ -6,6 +6,6 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
public class CreateSuitLoadout : DeleteSuitLoadout
{
public override string Event => "CreateSuitLoadout";
- public ImmutableList Modules { get; init; }
- public ImmutableList SuitMods { get; init; }
+ public IReadOnlyCollection Modules { get; init; }
+ public ICollection SuitMods { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/SellMicroResources.cs b/ObservatoryFramework/Files/Journal/Odyssey/SellMicroResources.cs
index 4a677c1..885000d 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/SellMicroResources.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/SellMicroResources.cs
@@ -6,7 +6,7 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
public class SellMicroResources : JournalBase
{
public override string Event => "SellMicroResources";
- public ImmutableList MicroResources { get; init; }
+ public IReadOnlyCollection MicroResources { get; init; }
public int Price { get; init; }
public ulong MarketID { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/SellOrganicData.cs b/ObservatoryFramework/Files/Journal/Odyssey/SellOrganicData.cs
index 9abfbc9..659c492 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/SellOrganicData.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/SellOrganicData.cs
@@ -7,5 +7,5 @@ public class SellOrganicData : JournalBase
{
public override string Event => "SellOrganicData";
public ulong MarketID { get; init; }
- public ImmutableList BioData { get; init; }
+ public IReadOnlyCollection BioData { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/ShipLockerMaterials.cs b/ObservatoryFramework/Files/Journal/Odyssey/ShipLockerMaterials.cs
index 4613b16..b19da7f 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/ShipLockerMaterials.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/ShipLockerMaterials.cs
@@ -6,8 +6,8 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
public class ShipLockerMaterials : JournalBase
{
public override string Event => "ShipLockerMaterials";
- public ImmutableList Items { get; init; }
- public ImmutableList Components { get; init; }
- public ImmutableList Consumables { get; init; }
- public ImmutableList Data { get; init; }
+ public IReadOnlyCollection Items { get; init; }
+ public IReadOnlyCollection Components { get; init; }
+ public IReadOnlyCollection Consumables { get; init; }
+ public IReadOnlyCollection Data { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/TradeMicroResources.cs b/ObservatoryFramework/Files/Journal/Odyssey/TradeMicroResources.cs
index f47abac..0b7d9b3 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/TradeMicroResources.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/TradeMicroResources.cs
@@ -7,7 +7,7 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
public class TradeMicroResources : JournalBase
{
public override string Event => "TradeMicroResources";
- public ImmutableList Offered { get; init; }
+ public IReadOnlyCollection Offered { get; init; }
public string Received { get; init; }
[JsonConverter(typeof(JsonStringEnumConverter))]
public MicroCategory Category { get; init; }
diff --git a/ObservatoryFramework/Files/Journal/Odyssey/TransferMicroResources.cs b/ObservatoryFramework/Files/Journal/Odyssey/TransferMicroResources.cs
index 9b2ab33..599db43 100644
--- a/ObservatoryFramework/Files/Journal/Odyssey/TransferMicroResources.cs
+++ b/ObservatoryFramework/Files/Journal/Odyssey/TransferMicroResources.cs
@@ -6,5 +6,5 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
public class TransferMicroResources : JournalBase
{
public override string Event => "TransferMicroResources";
- public ImmutableList Transfers { get; init; }
+ public IReadOnlyCollection Transfers { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Other/ApproachSettlement.cs b/ObservatoryFramework/Files/Journal/Other/ApproachSettlement.cs
index 17b5ab9..0bcca7b 100644
--- a/ObservatoryFramework/Files/Journal/Other/ApproachSettlement.cs
+++ b/ObservatoryFramework/Files/Journal/Other/ApproachSettlement.cs
@@ -16,7 +16,7 @@ public class ApproachSettlement : JournalBase
public float Longitude { get; init; }
public int BodyID { get; init; }
public string BodyName { get; init; }
- public ImmutableList StationEconomies { get; init; }
+ public IReadOnlyCollection StationEconomies { get; init; }
public string StationEconomy { get; init; }
public string StationEconomy_Localised { get; init; }
public Faction StationFaction { get; init; }
diff --git a/ObservatoryFramework/Files/Journal/Other/CargoTransfer.cs b/ObservatoryFramework/Files/Journal/Other/CargoTransfer.cs
index 7705314..f3b997f 100644
--- a/ObservatoryFramework/Files/Journal/Other/CargoTransfer.cs
+++ b/ObservatoryFramework/Files/Journal/Other/CargoTransfer.cs
@@ -6,5 +6,5 @@ namespace Observatory.Framework.Files.Journal.Other;
public class CargoTransfer : JournalBase
{
public override string Event => "CargoTransfer";
- public ImmutableList Transfers { get; init; }
+ public IReadOnlyCollection Transfers { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Other/ProspectedAsteroid.cs b/ObservatoryFramework/Files/Journal/Other/ProspectedAsteroid.cs
index 9f1bb00..29a55fe 100644
--- a/ObservatoryFramework/Files/Journal/Other/ProspectedAsteroid.cs
+++ b/ObservatoryFramework/Files/Journal/Other/ProspectedAsteroid.cs
@@ -6,7 +6,7 @@ namespace Observatory.Framework.Files.Journal.Other;
public class ProspectedAsteroid : JournalBase
{
public override string Event => "ProspectedAsteroid";
- public ImmutableList Materials { get; init; }
+ public IReadOnlyCollection Materials { get; init; }
public string Content { get; init; }
public string Content_Localised { get; init; }
public string MotherlodeMaterial { get; init; }
diff --git a/ObservatoryFramework/Files/Journal/Other/RebootRepair.cs b/ObservatoryFramework/Files/Journal/Other/RebootRepair.cs
index 592e1fd..dab38cc 100644
--- a/ObservatoryFramework/Files/Journal/Other/RebootRepair.cs
+++ b/ObservatoryFramework/Files/Journal/Other/RebootRepair.cs
@@ -5,5 +5,5 @@ namespace Observatory.Framework.Files.Journal.Other;
public class RebootRepair : JournalBase
{
public override string Event => "RebootRepair";
- public ImmutableList Modules { get; init; }
+ public ICollection Modules { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Other/Synthesis.cs b/ObservatoryFramework/Files/Journal/Other/Synthesis.cs
index 769f6f6..d8c7b07 100644
--- a/ObservatoryFramework/Files/Journal/Other/Synthesis.cs
+++ b/ObservatoryFramework/Files/Journal/Other/Synthesis.cs
@@ -11,5 +11,5 @@ public class Synthesis : JournalBase
public string Name { get; init; }
[JsonConverter(typeof(MaterialConverter))]
- public ImmutableList Materials { get; init; }
+ public IReadOnlyCollection Materials { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Other/WingJoin.cs b/ObservatoryFramework/Files/Journal/Other/WingJoin.cs
index 851e0b1..09efd98 100644
--- a/ObservatoryFramework/Files/Journal/Other/WingJoin.cs
+++ b/ObservatoryFramework/Files/Journal/Other/WingJoin.cs
@@ -5,5 +5,5 @@ namespace Observatory.Framework.Files.Journal.Other;
public class WingJoin : JournalBase
{
public override string Event => "WingJoin";
- public ImmutableList Others { get; init; }
+ public ICollection Others { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Powerplay/PowerplayVoucher.cs b/ObservatoryFramework/Files/Journal/Powerplay/PowerplayVoucher.cs
index 648b437..4c41fd4 100644
--- a/ObservatoryFramework/Files/Journal/Powerplay/PowerplayVoucher.cs
+++ b/ObservatoryFramework/Files/Journal/Powerplay/PowerplayVoucher.cs
@@ -5,5 +5,5 @@ namespace Observatory.Framework.Files.Journal.Powerplay;
public class PowerplayVoucher : PowerplayJoin
{
public override string Event => "PowerplayVoucher";
- public ImmutableList Systems { get; init; }
+ public ICollection Systems { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Startup/Cargo.cs b/ObservatoryFramework/Files/Journal/Startup/Cargo.cs
index 89d63cd..fede8e4 100644
--- a/ObservatoryFramework/Files/Journal/Startup/Cargo.cs
+++ b/ObservatoryFramework/Files/Journal/Startup/Cargo.cs
@@ -8,5 +8,5 @@ public class Cargo : JournalBase
public override string Event => "Cargo";
public string Vessel { get; init; }
public int Count { get; init; }
- public ImmutableList Inventory { get; init; }
+ public IReadOnlyCollection Inventory { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Startup/Loadout.cs b/ObservatoryFramework/Files/Journal/Startup/Loadout.cs
index d19d3e8..3e163e1 100644
--- a/ObservatoryFramework/Files/Journal/Startup/Loadout.cs
+++ b/ObservatoryFramework/Files/Journal/Startup/Loadout.cs
@@ -19,5 +19,5 @@ public class Loadout : JournalBase
public double MaxJumpRange { get; init; }
public ulong Rebuy { get; init; }
public bool Hot { get; init; }
- public ImmutableList Modules { get; init; }
+ public IReadOnlyCollection Modules { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Startup/Materials.cs b/ObservatoryFramework/Files/Journal/Startup/Materials.cs
index 7cbf19d..8e8cbbc 100644
--- a/ObservatoryFramework/Files/Journal/Startup/Materials.cs
+++ b/ObservatoryFramework/Files/Journal/Startup/Materials.cs
@@ -1,13 +1,13 @@
-using System.Collections.Immutable;
-using Observatory.Framework.Files.ParameterTypes;
+namespace Observatory.Framework.Files.Journal.Startup;
-namespace Observatory.Framework.Files.Journal.Startup;
+using System.Collections.Immutable;
+using ParameterTypes;
public class Materials : JournalBase
{
public override string Event => "Materials";
- public ImmutableList Raw { get; init; }
- public ImmutableList Manufactured { get; init; }
- public ImmutableList Encoded { get; init; }
+ public virtual IReadOnlyCollection Raw { get; init; }
+ public virtual IReadOnlyCollection Manufactured { get; init; }
+ public virtual IReadOnlyCollection Encoded { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Startup/Missions.cs b/ObservatoryFramework/Files/Journal/Startup/Missions.cs
index d7b098c..f5a82a5 100644
--- a/ObservatoryFramework/Files/Journal/Startup/Missions.cs
+++ b/ObservatoryFramework/Files/Journal/Startup/Missions.cs
@@ -6,7 +6,7 @@ namespace Observatory.Framework.Files.Journal.Startup;
public class Missions : JournalBase
{
public override string Event => "Missions";
- public ImmutableList Active { get; init; }
- public ImmutableList Failed { get; init; }
- public ImmutableList Complete { get; init; }
+ public IReadOnlyCollection Active { get; init; }
+ public IReadOnlyCollection Failed { get; init; }
+ public IReadOnlyCollection Complete { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Startup/Progress.cs b/ObservatoryFramework/Files/Journal/Startup/Progress.cs
index bdf06fc..57e1ac9 100644
--- a/ObservatoryFramework/Files/Journal/Startup/Progress.cs
+++ b/ObservatoryFramework/Files/Journal/Startup/Progress.cs
@@ -1,6 +1,38 @@
namespace Observatory.Framework.Files.Journal.Startup;
-public class Progress : Rank
+public class Progress : JournalBase
{
public override string Event => "Progress";
+ ///
+ /// percent progress towards next rank
+ ///
+ public int Combat { get; init; }
+ ///
+ /// percent progress towards next rank
+ ///
+ public int Trade { get; init; }
+ ///
+ /// percent progress towards next rank
+ ///
+ public int Explore { get; init; }
+ ///
+ /// percent progress towards next rank
+ ///
+ public int CQC { get; init; }
+ ///
+ /// percent progress towards next rank
+ ///
+ public int Soldier { get; init; }
+ ///
+ /// percent progress towards next rank
+ ///
+ public int Exobiologist { get; init; }
+ ///
+ /// percent progress towards next rank
+ ///
+ public int Empire { get; init; }
+ ///
+ /// percent progress towards next rank
+ ///
+ public int Federation { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Startup/Statistics.cs b/ObservatoryFramework/Files/Journal/Startup/Statistics.cs
index 64e79bd..9f1a2c4 100644
--- a/ObservatoryFramework/Files/Journal/Startup/Statistics.cs
+++ b/ObservatoryFramework/Files/Journal/Startup/Statistics.cs
@@ -21,11 +21,11 @@ public class Statistics : JournalBase
public Crew Crew { get; init; }
public Multicrew Multicrew { get; init; }
[JsonPropertyName("TG_ENCOUNTERS")]
- public Thargoid Thargoid { get; init; }
+ public Thargoid? Thargoid { get; init; }
[JsonPropertyName("Material_Trader_Stats")]
public MaterialTrader MaterialTrader { get; init; }
- public CQC CQC { get; init; }
+ public CQC? CQC { get; init; }
[JsonPropertyName("FLEETCARRIER")]
- public ParameterTypes.FleetCarrier FleetCarrier { get; init; }
+ public ParameterTypes.FleetCarrier? FleetCarrier { get; init; }
public Exobiology Exobiology { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/CommunityGoal.cs b/ObservatoryFramework/Files/Journal/StationServices/CommunityGoal.cs
index 8d7ee6f..ef98b8b 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/CommunityGoal.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/CommunityGoal.cs
@@ -6,5 +6,5 @@ namespace Observatory.Framework.Files.Journal.StationServices;
public class CommunityGoal : JournalBase
{
public override string Event => "CommunityGoal";
- public ImmutableList CurrentGoals { get; init; }
+ public IReadOnlyCollection CurrentGoals { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/EngineerCraft.cs b/ObservatoryFramework/Files/Journal/StationServices/EngineerCraft.cs
index 3c39147..590bd32 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/EngineerCraft.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/EngineerCraft.cs
@@ -21,6 +21,6 @@ public class EngineerCraft : JournalBase
public float Quality { get; init; }
public string ApplyExperimentalEffect { get; init; }
[JsonConverter(typeof(MaterialConverter))]
- public ImmutableList Ingredients { get; init; }
- public ImmutableList Modifiers { get; init; }
+ public IReadOnlyCollection Ingredients { get; init; }
+ public IReadOnlyCollection Modifiers { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/EngineerProgress.cs b/ObservatoryFramework/Files/Journal/StationServices/EngineerProgress.cs
index 66236db..a5dcead 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/EngineerProgress.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/EngineerProgress.cs
@@ -7,13 +7,38 @@ namespace Observatory.Framework.Files.Journal.StationServices;
public class EngineerProgress : JournalBase
{
public override string Event => "EngineerProgress";
- public string Engineer { get; init; }
- public ulong EngineerID { get; init; }
- public int Rank { get; init; }
- public int RankProgress { get; init; }
+ public string? Engineer { get; set; }
+ public ulong? EngineerID { get; set; }
+ public int? Rank { get; set; }
+ public int? RankProgress { get; set; }
[JsonConverter(typeof(JsonStringEnumConverter))]
- public Progress Progress { get; init; }
+ public Progress? Progress { get; set; }
- public ImmutableList Engineers { get; init; }
-}
\ No newline at end of file
+ public IReadOnlyCollection Engineers { get; set; }
+}
+//{ "timestamp":"2024-05-25T04:44:34Z", "event":"EngineerProgress",
+//"Engineers":[
+//{ "Engineer":"Hera Tani", "EngineerID":300090, "Progress":"Known" },
+//{ "Engineer":"Professor Palin", "EngineerID":300220, "Progress":"Invited" },
+//{ "Engineer":"Felicity Farseer", "EngineerID":300100, "Progress":"Unlocked", "RankProgress":0, "Rank":5 },
+//{ "Engineer":"Eleanor Bresa", "EngineerID":400011, "Progress":"Known" },
+//{ "Engineer":"Hero Ferrari", "EngineerID":400003, "Progress":"Known" },
+//{ "Engineer":"Jude Navarro", "EngineerID":400001, "Progress":"Known" },
+//{ "Engineer":"Etienne Dorn", "EngineerID":300290, "Progress":"Unlocked", "RankProgress":0, "Rank":5 },
+//{ "Engineer":"Lori Jameson", "EngineerID":300230, "Progress":"Known" },
+//{ "Engineer":"Liz Ryder", "EngineerID":300080, "Progress":"Unlocked", "RankProgress":86, "Rank":3 },
+//{ "Engineer":"Rosa Dayette", "EngineerID":400012, "Progress":"Known" },
+//{ "Engineer":"Juri Ishmaak", "EngineerID":300250, "Progress":"Unlocked", "RankProgress":0, "Rank":1 },
+//{ "Engineer":"Zacariah Nemo", "EngineerID":300050, "Progress":"Known" },
+//{ "Engineer":"Mel Brandon", "EngineerID":300280, "Progress":"Known" },
+//{ "Engineer":"Selene Jean", "EngineerID":300210, "Progress":"Unlocked", "RankProgress":11, "Rank":3 },
+//{ "Engineer":"Marco Qwent", "EngineerID":300200, "Progress":"Unlocked", "RankProgress":27, "Rank":4 },
+//{ "Engineer":"Chloe Sedesi", "EngineerID":300300, "Progress":"Invited" },
+//{ "Engineer":"Baltanos", "EngineerID":400010, "Progress":"Known" },
+//{ "Engineer":"Petra Olmanova", "EngineerID":300130, "Progress":"Unlocked", "RankProgress":0, "Rank":5 },
+//{ "Engineer":"The Dweller", "EngineerID":300180, "Progress":"Unlocked", "RankProgress":0, "Rank":1 },
+//{ "Engineer":"Elvira Martuuk", "EngineerID":300160, "Progress":"Unlocked", "RankProgress":52, "Rank":3 },
+//{ "Engineer":"Tod 'The Blaster' McQuinn", "EngineerID":300260, "Progress":"Unlocked", "RankProgress":15, "Rank":4 },
+//{ "Engineer":"Domino Green", "EngineerID":400002, "Progress":"Invited" } ] }
+//
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/MassModuleStore.cs b/ObservatoryFramework/Files/Journal/StationServices/MassModuleStore.cs
index c2d842c..8b4dcb1 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/MassModuleStore.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/MassModuleStore.cs
@@ -9,5 +9,5 @@ public class MassModuleStore : JournalBase
public ulong MarketID { get; init; }
public string Ship { get; init; }
public ulong ShipID { get; init; }
- public ImmutableList- Items { get; init; }
+ public IReadOnlyCollection
- Items { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/MissionCompleted.cs b/ObservatoryFramework/Files/Journal/StationServices/MissionCompleted.cs
index af5a27d..c7115ba 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/MissionCompleted.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/MissionCompleted.cs
@@ -23,9 +23,9 @@ public class MissionCompleted : JournalBase
[JsonConverter(typeof(StringIntConverter))]
public int Donation { get; init; }
public long Donated { get; init; }
- public ImmutableList
PermitsAwarded { get; init; }
- public ImmutableList CommodityReward { get; init; }
- public ImmutableList MaterialsReward { get; init; }
+ public ICollection PermitsAwarded { get; init; }
+ public IReadOnlyCollection CommodityReward { get; init; }
+ public IReadOnlyCollection MaterialsReward { get; init; }
public string DestinationSystem { get; init; }
public string DestinationStation { get; init; }
public string DestinationSettlement { get; init; }
@@ -33,5 +33,5 @@ public class MissionCompleted : JournalBase
public string NewDestinationStation { get; init; }
public int KillCount { get; init; }
public string TargetFaction { get; init; }
- public ImmutableList FactionEffects { get; init; }
+ public IReadOnlyCollection FactionEffects { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/RedeemVoucher.cs b/ObservatoryFramework/Files/Journal/StationServices/RedeemVoucher.cs
index d5bd64e..4fc3c7b 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/RedeemVoucher.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/RedeemVoucher.cs
@@ -13,6 +13,6 @@ public class RedeemVoucher : JournalBase
public long Amount { get; init; }
public string Faction { get; init; }
public float BrokerPercentage { get; init; }
- public ImmutableList Factions { get; init; }
+ public IReadOnlyCollection Factions { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/Repair.cs b/ObservatoryFramework/Files/Journal/StationServices/Repair.cs
index 70a7c88..9aa7de7 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/Repair.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/Repair.cs
@@ -7,5 +7,5 @@ public class Repair : JournalBase
public override string Event => "Repair";
public string Item { get; init; }
public int Cost { get; init; }
- public ImmutableList Items { get; init; }
+ public ICollection Items { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/StoredModules.cs b/ObservatoryFramework/Files/Journal/StationServices/StoredModules.cs
index 1d27d95..efe023e 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/StoredModules.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/StoredModules.cs
@@ -12,5 +12,5 @@ public class StoredModules : JournalBase
///
public string StationName { get; init; }
public ulong MarketID { get; init; }
- public ImmutableList Items { get; init; }
+ public IReadOnlyCollection Items { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/StoredShips.cs b/ObservatoryFramework/Files/Journal/StationServices/StoredShips.cs
index 87a1fdb..5ed5f07 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/StoredShips.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/StoredShips.cs
@@ -12,6 +12,6 @@ public class StoredShips : JournalBase
///
public string StationName { get; init; }
public string StarSystem { get; init; }
- public ImmutableList ShipsHere { get; init; }
- public ImmutableList ShipsRemote { get; init; }
+ public IReadOnlyCollection ShipsHere { get; init; }
+ public IReadOnlyCollection ShipsRemote { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/StationServices/TechnologyBroker.cs b/ObservatoryFramework/Files/Journal/StationServices/TechnologyBroker.cs
index d9e5cf6..ec18a87 100644
--- a/ObservatoryFramework/Files/Journal/StationServices/TechnologyBroker.cs
+++ b/ObservatoryFramework/Files/Journal/StationServices/TechnologyBroker.cs
@@ -8,7 +8,7 @@ public class TechnologyBroker : JournalBase
public override string Event => "TechnologyBroker";
public string BrokerType { get; init; }
public ulong MarketID { get; init; }
- public ImmutableList ItemsUnlocked { get; init; }
- public ImmutableList Commodities { get; init; }
- public ImmutableList Materials { get; init; }
+ public IReadOnlyCollection ItemsUnlocked { get; init; }
+ public IReadOnlyCollection Commodities { get; init; }
+ public IReadOnlyCollection Materials { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/Journal/Travel/Docked.cs b/ObservatoryFramework/Files/Journal/Travel/Docked.cs
index 083eb4e..f039d14 100644
--- a/ObservatoryFramework/Files/Journal/Travel/Docked.cs
+++ b/ObservatoryFramework/Files/Journal/Travel/Docked.cs
@@ -81,7 +81,7 @@ public class Docked : JournalBase
private get => StationEconomy_Localised;
init => StationEconomy_Localised = value;
}
- public ImmutableList StationEconomies { get; init; }
+ public IReadOnlyCollection StationEconomies { get; init; }
[Obsolete("StationState is a rundundant property. Use StationEconomy to potentially reduce unnecessary checks.")]
public string StationState { get; init; }
diff --git a/ObservatoryFramework/Files/Journal/Travel/FSDJump.cs b/ObservatoryFramework/Files/Journal/Travel/FSDJump.cs
index d19aa70..68451e2 100644
--- a/ObservatoryFramework/Files/Journal/Travel/FSDJump.cs
+++ b/ObservatoryFramework/Files/Journal/Travel/FSDJump.cs
@@ -11,7 +11,7 @@ public class FSDJump : JournalBase
public string StarSystem { get; init; }
public ulong SystemAddress { get; init; }
[JsonConverter(typeof(StarPosConverter))]
- public (double x, double y, double z) StarPos { get; init; }
+ public StarPos StarPos { get; init; }
public string Body { get; init; }
public int BodyID { get; init; }
public string BodyType { get; init; }
@@ -33,9 +33,9 @@ public class FSDJump : JournalBase
public string SystemSecurity_Localised { get; init; }
public long Population { get; init; }
public bool Wanted { get; init; }
- public ImmutableList Factions { get; init; }
- public ImmutableList Conflicts { get; init; }
- public ImmutableList Powers { get; init; }
+ public IReadOnlyCollection Factions { get; init; }
+ public IReadOnlyCollection Conflicts { get; init; }
+ public ICollection Powers { get; init; }
public string PowerplayState { get; init; }
public bool Taxi { get; init; }
public bool Multicrew { get; init; }
diff --git a/ObservatoryFramework/Files/Journal/Travel/Location.cs b/ObservatoryFramework/Files/Journal/Travel/Location.cs
index 60ac74f..88cba4a 100644
--- a/ObservatoryFramework/Files/Journal/Travel/Location.cs
+++ b/ObservatoryFramework/Files/Journal/Travel/Location.cs
@@ -8,14 +8,17 @@ namespace Observatory.Framework.Files.Journal.Travel;
public class Location : JournalBase
{
public override string Event => "Location";
+
[JsonConverter(typeof(IntBoolFlexConverter))]
public bool Docked { get; init; }
+
public double DistFromStarLS { get; init; }
-
+
///
/// Name of the station at which this event occurred.
///
public string StationName { get; init; }
+
public string StationType { get; init; }
public float Longitude { get; init; }
public float Latitude { get; init; }
@@ -23,18 +26,20 @@ public class Location : JournalBase
[JsonConverter(typeof(LegacyFactionConverter))]
public Faction StationFaction { get; init; }
+
public string StationGovernment { get; init; }
public string StationGovernment_Localised { get; init; }
public string StationAllegiance { get; init; }
- public ImmutableList StationServices { get; init; }
+ public ICollection StationServices { get; init; }
public string StationEconomy { get; init; }
public string StationEconomy_Localised { get; init; }
- public ImmutableList StationEconomies { get; init; }
+ public IReadOnlyCollection StationEconomies { get; init; }
public string StarSystem { get; init; }
public ulong SystemAddress { get; init; }
[JsonConverter(typeof(StarPosConverter))]
- public (double x, double y, double z) StarPos { get; init; }
+ public StarPos StarPos { get; init; }
+
public string SystemAllegiance { get; init; }
public string SystemEconomy { get; init; }
public string SystemEconomy_Localised { get; init; }
@@ -48,16 +53,24 @@ public class Location : JournalBase
public string Body { get; init; }
public int BodyID { get; init; }
public string BodyType { get; init; }
- public ImmutableList Factions { get; init; }
+ public IReadOnlyCollection Factions { get; init; }
[JsonConverter(typeof(LegacyFactionConverter))]
public DetailedFaction SystemFaction { get; init; }
- public ImmutableList Conflicts { get; init; }
- public ImmutableList Powers { get; init; }
+
+ public IReadOnlyCollection Conflicts { get; init; }
+ public ICollection Powers { get; init; }
public string PowerplayState { get; init; }
public bool Taxi { get; init; }
public bool Multicrew { get; init; }
public bool OnFoot { get; init; }
public bool InSRV { get; init; }
public ThargoidWar ThargoidWar { get; init; }
+}
+
+public class StarPos
+{
+ public double X { get; set; }
+ public double Y { get; set; }
+ public double Z { get; set; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/MarketFile.cs b/ObservatoryFramework/Files/MarketFile.cs
index 12860a5..25b6da0 100644
--- a/ObservatoryFramework/Files/MarketFile.cs
+++ b/ObservatoryFramework/Files/MarketFile.cs
@@ -29,5 +29,5 @@ public class MarketFile : JournalBase
///
/// List of all commodities available in the market.
///
- public ImmutableList Items { get; init; }
+ public IReadOnlyCollection Items { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/ModuleInfoFile.cs b/ObservatoryFramework/Files/ModuleInfoFile.cs
index 9d037bc..42dcbba 100644
--- a/ObservatoryFramework/Files/ModuleInfoFile.cs
+++ b/ObservatoryFramework/Files/ModuleInfoFile.cs
@@ -13,5 +13,5 @@ public class ModuleInfoFile : JournalBase
///
/// List of all equipped modules.
///
- public ImmutableList Modules { get; init; }
+ public IReadOnlyCollection Modules { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/NavRouteFile.cs b/ObservatoryFramework/Files/NavRouteFile.cs
index 91fed0b..705f3ef 100644
--- a/ObservatoryFramework/Files/NavRouteFile.cs
+++ b/ObservatoryFramework/Files/NavRouteFile.cs
@@ -13,5 +13,5 @@ public class NavRouteFile : JournalBase
///
/// List of star systems and their locations in the current route.
///
- public ImmutableList Route { get; init; }
+ public IReadOnlyCollection Route { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/OutfittingFile.cs b/ObservatoryFramework/Files/OutfittingFile.cs
index 0262c91..587289f 100644
--- a/ObservatoryFramework/Files/OutfittingFile.cs
+++ b/ObservatoryFramework/Files/OutfittingFile.cs
@@ -29,5 +29,5 @@ public class OutfittingFile : JournalBase
///
/// List of all available parts in shipyard.
///
- public ImmutableList Items { get; init; }
+ public IReadOnlyCollection Items { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/ParameterTypes/DetailedFaction.cs b/ObservatoryFramework/Files/ParameterTypes/DetailedFaction.cs
index 2e0f538..688b31b 100644
--- a/ObservatoryFramework/Files/ParameterTypes/DetailedFaction.cs
+++ b/ObservatoryFramework/Files/ParameterTypes/DetailedFaction.cs
@@ -10,6 +10,6 @@ public class DetailedFaction : Faction
public string Happiness { get; init; }
public string Happiness_Localised { get; init; }
public float MyReputation { get; init; }
- public ImmutableList RecoveringStates { get; init; }
- public ImmutableList ActiveStates { get; init; }
+ public IReadOnlyCollection RecoveringStates { get; init; }
+ public IReadOnlyCollection ActiveStates { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/ParameterTypes/Engineering.cs b/ObservatoryFramework/Files/ParameterTypes/Engineering.cs
index 7090bd0..34a607b 100644
--- a/ObservatoryFramework/Files/ParameterTypes/Engineering.cs
+++ b/ObservatoryFramework/Files/ParameterTypes/Engineering.cs
@@ -18,5 +18,5 @@ public class Engineering
public string ExperimentalEffect { get; init; }
- public ImmutableList Modifiers { get; init; }
+ public IReadOnlyCollection Modifiers { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/ParameterTypes/FactionEffect.cs b/ObservatoryFramework/Files/ParameterTypes/FactionEffect.cs
index c765b71..123617c 100644
--- a/ObservatoryFramework/Files/ParameterTypes/FactionEffect.cs
+++ b/ObservatoryFramework/Files/ParameterTypes/FactionEffect.cs
@@ -7,8 +7,8 @@ namespace Observatory.Framework.Files.ParameterTypes;
public class FactionEffect
{
public string Faction { get; init; }
- public ImmutableList Effects { get; init; }
- public ImmutableList Influence { get; init; }
+ public IReadOnlyCollection Effects { get; init; }
+ public IReadOnlyCollection Influence { get; init; }
[JsonConverter(typeof(RepInfConverter))]
public int Reputation { get; init; }
[JsonConverter(typeof(JsonStringEnumConverter))]
diff --git a/ObservatoryFramework/Files/ParameterTypes/Modifiers.cs b/ObservatoryFramework/Files/ParameterTypes/Modifiers.cs
index 19ffa60..1d69cd9 100644
--- a/ObservatoryFramework/Files/ParameterTypes/Modifiers.cs
+++ b/ObservatoryFramework/Files/ParameterTypes/Modifiers.cs
@@ -7,30 +7,33 @@ public class Modifiers
{
public string Label { get; init; }
- [JsonConverter(typeof(MutableStringDoubleConverter))]
- public object Value
- {
- get
- {
- if (!string.IsNullOrEmpty(ValueString))
- return ValueString;
- return ValueNumeric;
- }
-
- init
- {
- if (value.GetType() == typeof(string))
- ValueString = value.ToString();
- else
- ValueNumeric = (double)value;
- }
- }
-
+ [JsonConverter(typeof(NumberOrStringConverter))]
+ public NumberOrString Value { get; set; }
+
public double OriginalValue { get; init; }
[JsonConverter(typeof(IntBoolConverter))]
public bool LessIsGood { get; init; }
+}
- private double ValueNumeric;
- private string ValueString;
+public class NumberOrString
+{
+ public NumberOrString()
+ { }
+
+ public NumberOrString(string value)
+ {
+ StringValue = value;
+ IsString = true;
+ }
+
+ public NumberOrString(double value)
+ {
+ DoubleValue = value;
+ IsDouble = true;
+ }
+ public string? StringValue { get; init; }
+ public bool IsString { get; init; }
+ public double? DoubleValue { get; init; }
+ public bool IsDouble { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/ParameterTypes/Route.cs b/ObservatoryFramework/Files/ParameterTypes/Route.cs
index 91e8a67..2871b34 100644
--- a/ObservatoryFramework/Files/ParameterTypes/Route.cs
+++ b/ObservatoryFramework/Files/ParameterTypes/Route.cs
@@ -1,5 +1,6 @@
using System.Text.Json.Serialization;
using Observatory.Framework.Files.Converters;
+using Observatory.Framework.Files.Journal.Travel;
namespace Observatory.Framework.Files.ParameterTypes;
@@ -8,6 +9,6 @@ public class Route
public string StarSystem { get; init; }
public ulong SystemAddress { get; init; }
[JsonConverter(typeof(StarPosConverter))]
- public (double x, double y, double z) StarPos { get; init; }
+ public StarPos StarPos { get; init; }
public string StarClass { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/ParameterTypes/SuitModule.cs b/ObservatoryFramework/Files/ParameterTypes/SuitModule.cs
index c49eb4b..363e2a3 100644
--- a/ObservatoryFramework/Files/ParameterTypes/SuitModule.cs
+++ b/ObservatoryFramework/Files/ParameterTypes/SuitModule.cs
@@ -8,5 +8,5 @@ public class SuitModule
public string ModuleName { get; init; }
public ulong SuitModuleID { get; init; }
public int Class { get; init; }
- public ImmutableList WeaponMods { get; init; }
+ public ICollection WeaponMods { get; init; }
}
\ No newline at end of file
diff --git a/ObservatoryFramework/Files/ParameterTypes/SystemFaction.cs b/ObservatoryFramework/Files/ParameterTypes/SystemFaction.cs
index a06046a..8acb66b 100644
--- a/ObservatoryFramework/Files/ParameterTypes/SystemFaction.cs
+++ b/ObservatoryFramework/Files/ParameterTypes/SystemFaction.cs
@@ -14,11 +14,11 @@ public class SystemFaction : Faction
public double MyReputation { get; init; }
- public ImmutableList PendingStates { get; init; }
+ public IReadOnlyCollection PendingStates { get; init; }
- public ImmutableList RecoveringStates { get; init; }
+ public IReadOnlyCollection RecoveringStates { get; init; }
- public ImmutableList ActiveStates { get; init; }
+ public IReadOnlyCollection ActiveStates { get; init; }
public bool? SquadronFaction { get; init; }
diff --git a/ObservatoryFramework/Files/ShipyardFile.cs b/ObservatoryFramework/Files/ShipyardFile.cs
index 259020c..8bec21f 100644
--- a/ObservatoryFramework/Files/ShipyardFile.cs
+++ b/ObservatoryFramework/Files/ShipyardFile.cs
@@ -34,5 +34,5 @@ public class ShipyardFile : JournalBase
///
/// List of all ships and prices for them at the current shipyard.
///
- public ImmutableList PriceList { get; init; }
+ public IReadOnlyCollection PriceList { get; init; }
}
\ No newline at end of file
diff --git a/Pulsar/Context/Configuration/BackpackCofiguration.cs b/Pulsar/Context/Configuration/BackpackCofiguration.cs
new file mode 100644
index 0000000..3f1754e
--- /dev/null
+++ b/Pulsar/Context/Configuration/BackpackCofiguration.cs
@@ -0,0 +1,17 @@
+using JasperFx.Core;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Observatory.Framework.Files;
+
+namespace Pulsar.Context.Configuration;
+
+public class BackpackCofiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.OwnsMany(b => b.Components, b => b.ToJson());
+ builder.OwnsMany(b => b.Consumables, b => b.ToJson());
+ builder.OwnsMany(b => b.Items, b => b.ToJson());
+ builder.OwnsMany(b => b.Data, b => b.ToJson());
+ }
+}
\ No newline at end of file
diff --git a/Pulsar/Context/Configuration/CargoConfiguration.cs b/Pulsar/Context/Configuration/CargoConfiguration.cs
new file mode 100644
index 0000000..a8d13b0
--- /dev/null
+++ b/Pulsar/Context/Configuration/CargoConfiguration.cs
@@ -0,0 +1,13 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Observatory.Framework.Files.Journal.Startup;
+
+namespace Pulsar.Context.Configuration;
+
+public class CargoConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.OwnsMany(c => c.Inventory, c => c.ToJson());
+ }
+}
\ No newline at end of file
diff --git a/Pulsar/Context/Configuration/LoadoutConfiguration.cs b/Pulsar/Context/Configuration/LoadoutConfiguration.cs
new file mode 100644
index 0000000..c9379fb
--- /dev/null
+++ b/Pulsar/Context/Configuration/LoadoutConfiguration.cs
@@ -0,0 +1,26 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Observatory.Framework.Files.Journal.Startup;
+
+namespace Pulsar.Context.Configuration;
+
+public class LoadoutConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.OwnsMany(l => l.Modules, lb =>
+ {
+ lb.OwnsOne(m => m.Engineering, mb =>
+ {
+ mb.OwnsMany(e => e.Modifiers, eb =>
+ {
+ eb.OwnsOne(em => em.Value, emb => emb.ToJson());
+ eb.ToJson();
+ });
+ mb.ToJson();
+ });
+ lb.ToJson();
+ });
+ builder.OwnsOne(l => l.FuelCapacity, b=>b.ToJson());
+ }
+}
\ No newline at end of file
diff --git a/Pulsar/Context/Configuration/LocationConfiguration.cs b/Pulsar/Context/Configuration/LocationConfiguration.cs
new file mode 100644
index 0000000..b4f0f75
--- /dev/null
+++ b/Pulsar/Context/Configuration/LocationConfiguration.cs
@@ -0,0 +1,34 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Observatory.Framework.Files.Journal.Travel;
+
+namespace Pulsar.Context.Configuration;
+
+public class LocationConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.OwnsOne(l => l.StarPos, b => b.ToJson());
+ builder.OwnsMany(l => l.Conflicts, b =>
+ {
+ b.OwnsOne(c => c.FirstFaction, c => c.ToJson());
+ b.OwnsOne(c => c.SecondFaction, c => c.ToJson());
+ b.ToJson();
+ });
+ builder.OwnsOne(l => l.StationFaction, b => b.ToJson());
+ builder.OwnsOne(l => l.SystemFaction, b =>
+ {
+ b.OwnsMany(s => s.ActiveStates, sb => sb.ToJson());
+ b.OwnsMany(s => s.RecoveringStates, rb => rb.ToJson());
+ b.ToJson();
+ });
+ builder.OwnsMany(l => l.Factions, b =>
+ {
+ b.OwnsMany(f => f.ActiveStates, fb => fb.ToJson());
+ b.OwnsMany(f => f.RecoveringStates, rb => rb.ToJson());
+ b.ToJson();
+ });
+ builder.OwnsMany(l => l.StationEconomies, sb => sb.ToJson());
+ builder.OwnsOne(l => l.ThargoidWar, tb => tb.ToJson());
+ }
+}
diff --git a/Pulsar/Context/Configuration/ShipLockerConfiguration.cs b/Pulsar/Context/Configuration/ShipLockerConfiguration.cs
new file mode 100644
index 0000000..8e21f74
--- /dev/null
+++ b/Pulsar/Context/Configuration/ShipLockerConfiguration.cs
@@ -0,0 +1,16 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Observatory.Framework.Files.Journal.Odyssey;
+
+namespace Pulsar.Context.Configuration;
+
+public class ShipLockerConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.OwnsMany(b => b.Items, b => b.ToJson());
+ builder.OwnsMany(b => b.Components, b => b.ToJson());
+ builder.OwnsMany(b => b.Consumables, b => b.ToJson());
+ builder.OwnsMany(b => b.Data, b => b.ToJson());
+ }
+}
\ No newline at end of file
diff --git a/Pulsar/Context/PulsarContext.cs b/Pulsar/Context/PulsarContext.cs
index 8e228c5..a6456eb 100644
--- a/Pulsar/Context/PulsarContext.cs
+++ b/Pulsar/Context/PulsarContext.cs
@@ -2,8 +2,11 @@ using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Observatory.Framework.Files.Journal;
+using Observatory.Framework.Files.Journal.Odyssey;
using Observatory.Framework.Files.Journal.Startup;
using Observatory.Framework.Files.Journal.StationServices;
+using Observatory.Framework.Files.Journal.Travel;
+using Pulsar.Features.ShipLocker;
///
/// An in-memory database context for Pulsar.
@@ -11,26 +14,23 @@ using Observatory.Framework.Files.Journal.StationServices;
public class PulsarContext : DbContext
{
public SqliteConnection Connection { get; private set; }
+
- // Start of game events:
- /**
- * Materials
- Rank
- Progress
- Reputation
- EngineerProgress
- LoadGame
- --Some time later--
- Statistics
- */
-
+ public DbSet Commander { get; set; }
public DbSet Materials { get; set; }
- public DbSet Ranks { get; set; }
+ public DbSet Rank { get; set; }
public DbSet Progress { get; set; }
- public DbSet Reputations { get; set; }
+ public DbSet Reputation { get; set; }
public DbSet EngineerProgress { get; set; }
public DbSet LoadGames { get; set; }
public DbSet Statistics { get; set; }
+ public DbSet Locations { get; set; }
+ public DbSet PowerPlay { get; set; }
+ public DbSet ShipLocker { get; set; }
+ public DbSet Missions { get; set; }
+ public DbSet Loadout { get; set; }
+ public DbSet Cargo { get; set; }
+
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
diff --git a/Pulsar/Features/EventsHub.cs b/Pulsar/Features/EventsHub.cs
index 18eb0fc..27bb6da 100644
--- a/Pulsar/Features/EventsHub.cs
+++ b/Pulsar/Features/EventsHub.cs
@@ -1,11 +1,19 @@
+using Pulsar.Features.Journal;
+
namespace Pulsar.Features;
using Observatory.Framework.Files;
using Observatory.Framework.Files.Journal;
using Observatory.Framework.Files.Journal.Odyssey;
-public class EventsHub : Hub
+public class EventsHub(IJournalService journalService) : Hub
{
+ public override async Task OnConnectedAsync()
+ {
+ await base.OnConnectedAsync();
+ await Clients.Caller.JournalUpdated(await journalService.GetLastStartupEvents());
+ }
+
public async Task Status([FromServices] IStatusService statusService)
{
var status = await statusService.Get();
diff --git a/Pulsar/Features/FileWatcherService.cs b/Pulsar/Features/FileWatcherService.cs
index 986c933..701b185 100644
--- a/Pulsar/Features/FileWatcherService.cs
+++ b/Pulsar/Features/FileWatcherService.cs
@@ -19,12 +19,7 @@ public class FileWatcherService(IOptions options, IFileHand
Watch(cancellationToken);
// read the journal directory to get the initial files
-#if DEBUG
- Thread.Sleep(TimeSpan.FromSeconds(2));
HandleFileChanged(cancellationToken);
-#else
- HandleFileChanged(cancellationToken);
-#endif
return Task.CompletedTask;
diff --git a/Pulsar/Features/Journal/JournalProcessor.cs b/Pulsar/Features/Journal/JournalProcessor.cs
index 58dd6a0..3583252 100644
--- a/Pulsar/Features/Journal/JournalProcessor.cs
+++ b/Pulsar/Features/Journal/JournalProcessor.cs
@@ -1,18 +1,19 @@
-using Observatory.Framework.Files.Journal.Startup;
+using Observatory.Framework.Files.Journal.StationServices;
namespace Pulsar.Features.Journal;
using Observatory.Framework;
using Observatory.Framework.Files.Journal;
+using Observatory.Framework.Files.Journal.Startup;
public class JournalProcessor(
ILogger logger,
- IJournalService journalService,
+ IJournalStore journalStore,
PulsarContext context,
IEventHubContext hub) : IHostedService, IDisposable
{
private CancellationTokenSource tokenSource = new();
-
+
readonly JsonSerializerOptions options = new()
{
PropertyNameCaseInsensitive = true,
@@ -52,24 +53,74 @@ public class JournalProcessor(
continue;
}
- if (journal is LoadGame loadGame)
+ switch (journal)
{
- // if not existing, add
- if (context.LoadGames.Any(l => l.Timestamp == loadGame.Timestamp))
- {
- //return ValueTask.CompletedTask;
+ case Commander commander when context.Commander.Any(c => c.Timestamp == commander.Timestamp):
continue;
- }
- await context.LoadGames.AddAsync(loadGame, token);
- await context.SaveChangesAsync(token);
+ case Commander commander:
+ await context.Commander.AddAsync(commander, token);
+ await context.SaveChangesAsync(token);
+ break;
+ case Materials materials when context.Materials.Any(m => m.Timestamp == materials.Timestamp):
+ continue;
+ case Materials materials:
+ await context.Materials.AddAsync(materials, token);
+ await context.SaveChangesAsync(token);
+ break;
+ case Rank rank when context.Rank.Any(r => r.Timestamp == rank.Timestamp):
+ continue;
+ case Rank rank:
+ await context.Rank.AddAsync(rank, token);
+ await context.SaveChangesAsync(token);
+ break;
+ case Progress progress when context.Progress.Any(p => p.Timestamp == progress.Timestamp):
+ continue;
+ case Progress progress:
+ await context.Progress.AddAsync(progress, token);
+ await context.SaveChangesAsync(token);
+ break;
+ case Reputation reputation when context.Reputation.Any(r => r.Timestamp == reputation.Timestamp):
+ continue;
+ case Reputation reputation:
+ await context.Reputation.AddAsync(reputation, token);
+ await context.SaveChangesAsync(token);
+ break;
+
+ case EngineerProgress engineerProgress
+ when context.EngineerProgress.Any(e => e.Timestamp == engineerProgress.Timestamp):
+ continue;
+ case EngineerProgress engineerProgress:
+ await context.EngineerProgress.AddAsync(engineerProgress, token);
+ await context.SaveChangesAsync(token);
+ break;
+ case LoadGame loadGame when context.LoadGames.Any(l => l.Timestamp == loadGame.Timestamp):
+ continue;
+ case LoadGame loadGame:
+ await context.LoadGames.AddAsync(loadGame, token);
+ await context.SaveChangesAsync(token);
+ break;
+
+
+ case Statistics statistics when context.Statistics.Any(s => s.Timestamp == statistics.Timestamp):
+ continue;
+ case Statistics statistics:
+ await context.Statistics.AddAsync(statistics, token);
+ await context.SaveChangesAsync(token);
+ break;
+
}
newJournals.Add(journal);
- }
+ }
catch (JsonException ex)
{
logger.LogError(ex, "Error deserializing journal file: '{File}', line: {Line}", filePath, line);
}
+ catch (Exception ex)
+ {
+ logger.LogError(ex, "Error processing journal file: '{File}', line# {LineNumber}, line: {Line}",
+ filePath, index, Encoding.UTF8.GetString(line.ToArray()));
+ }
//return ValueTask.CompletedTask;
}
@@ -95,7 +146,7 @@ public class JournalProcessor(
{
try
{
- if (journalService.TryDequeue(out var file))
+ if (journalStore.TryDequeue(out var file))
{
handled.AddRange(await HandleFileInner(file, tokenSource.Token));
}
@@ -108,6 +159,7 @@ public class JournalProcessor(
{
handled = handled.Where(j => j.Timestamp > lastLoadGame.Timestamp).ToList();
}
+
await hub.Clients.All.JournalUpdated(handled);
handled.Clear();
}
@@ -134,4 +186,4 @@ public class JournalProcessor(
{
tokenSource?.Dispose();
}
-}
+}
\ No newline at end of file
diff --git a/Pulsar/Features/Journal/JournalService.cs b/Pulsar/Features/Journal/JournalService.cs
index 17cab24..a47d924 100644
--- a/Pulsar/Features/Journal/JournalService.cs
+++ b/Pulsar/Features/Journal/JournalService.cs
@@ -1,31 +1,24 @@
+using Microsoft.EntityFrameworkCore;
+using Observatory.Framework.Files.Journal.Startup;
+using Observatory.Framework.Files.Journal.StationServices;
+
namespace Pulsar.Features.Journal;
-using System.Collections.Concurrent;
using Observatory.Framework.Files.Journal;
public interface IJournalService : IJournalHandler>
{
- public bool TryDequeue(out string filePath);
+ Task> GetLastStartupEvents();
}
public class JournalService(
- ILogger logger
+ ILogger logger,
+ IJournalStore store,
+ PulsarContext context
) : IJournalService
{
public string FileName => FileHandlerService.JournalLogFileName;
- private readonly ConcurrentQueue JournalFileQueue = new();
-
- public void EnqueueFile(string filePath)
- {
- JournalFileQueue.Enqueue(filePath);
- }
-
- public bool TryDequeue(out string filePath)
- {
- return JournalFileQueue.TryDequeue(out filePath);
- }
-
public Task HandleFile(string filePath, CancellationToken token = new())
{
if (!FileHelper.ValidateFile(filePath))
@@ -33,10 +26,102 @@ public class JournalService(
return Task.CompletedTask;
}
- EnqueueFile(filePath);
+ store.EnqueueFile(filePath);
return Task.CompletedTask;
}
+
+
+
+ // Start of game events/order:
+ /** Commander
+ * Materials
+ Rank
+ Progress
+ Reputation
+ EngineerProgress
+ LoadGame
+ --Some time later--
+ Statistics
+ -- Game Events (e.g. FSSSignalDiscovered) --
+ Location
+ Powerplay
+ ShipLocker
+ Missions
+ Loadout
+ Cargo
+ */
+
+ // StartupEvents:
+ // Commander
+ // Materials
+ // Rank
+ // Progress
+ // Reputation
+ // EngineerProgress
+ // LoadGame
+
+ // StateEvents:
+ // Location
+ // Powerplay
+ // Music
+ // ShipLocker
+ // Missions
+ // Loadout
+ // Cargo
+ public async Task> GetLastStartupEvents()
+ {
+ //TODO: add other state events
+ var commanderTask = context.Commander.OrderByDescending(x => x.Timestamp).FirstOrDefaultAsync();
+ var materialsTask = context.Materials.OrderByDescending(x => x.Timestamp).FirstOrDefaultAsync();
+ var rankTask = context.Rank.OrderByDescending(x => x.Timestamp).FirstOrDefaultAsync();
+ var progressTask = context.Progress.OrderByDescending(x => x.Timestamp).FirstOrDefaultAsync();
+ var reputationTask = context.Reputation.OrderByDescending(x => x.Timestamp).FirstOrDefaultAsync();
+ var engineerProgressTask = context.EngineerProgress.OrderByDescending(x => x.Timestamp).FirstOrDefaultAsync();
+ var loadGameTask = context.LoadGames.OrderByDescending(x => x.Timestamp).FirstOrDefaultAsync();
+ var statisticsTask = context.Statistics.OrderByDescending(x => x.Timestamp).FirstOrDefaultAsync();
+
+ await Task.WhenAll(
+ commanderTask,
+ materialsTask,
+ rankTask,
+ progressTask,
+ reputationTask,
+ engineerProgressTask,
+ loadGameTask,
+ statisticsTask);
+
+ var commander = await commanderTask;
+ var materials = await materialsTask;
+ var rank = await rankTask;
+ var progress = await progressTask;
+ var reputation = await reputationTask;
+ var engineerProgress = await engineerProgressTask;
+ var loadGame = await loadGameTask;
+ var statistics = await statisticsTask;
+
+ // if any null, return empty list
+ if (materials == null || rank == null || progress == null || reputation == null || engineerProgress == null ||
+ loadGame == null || statistics == null || commander == null)
+ {
+ return [];
+ }
+
+ // dont check the time of statistics as it may occur a few moments after
+ if (commander.Timestamp != materials.Timestamp ||
+ materials.Timestamp != rank.Timestamp ||
+ rank.Timestamp != progress.Timestamp ||
+ progress.Timestamp != reputation.Timestamp ||
+ reputation.Timestamp != engineerProgress.Timestamp ||
+ engineerProgress.Timestamp != loadGame.Timestamp ||
+ statistics.Timestamp < materials.Timestamp)
+ {
+ throw new InvalidOperationException("Timestamps do not match");
+ }
+
+ return [commander, materials, rank, progress, reputation, engineerProgress, loadGame, statistics];
+ }
+
public async Task