Add Startup Events to Database
Now emit startup events on conneciton Some events still to add
This commit is contained in:
parent
579b2b115d
commit
68eff73dbd
65 changed files with 586 additions and 229 deletions
|
|
@ -13,17 +13,17 @@ public class BackpackFile : JournalBase
|
|||
/// <summary>
|
||||
/// List of all items carried.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Items { get; init; }
|
||||
public IReadOnlyCollection<BackpackItem> Items { get; init; }
|
||||
/// <summary>
|
||||
/// List of all components carried.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Components { get; init; }
|
||||
public IReadOnlyCollection<BackpackItem> Components { get; init; }
|
||||
/// <summary>
|
||||
/// List of player consumable items carried.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Consumables { get; init; }
|
||||
public IReadOnlyCollection<BackpackItem> Consumables { get; init; }
|
||||
/// <summary>
|
||||
/// List of all data currently stored by the player.
|
||||
/// </summary>
|
||||
public ImmutableList<BackpackItem> Data { get; init; }
|
||||
public IReadOnlyCollection<BackpackItem> Data { get; init; }
|
||||
}
|
||||
|
|
@ -21,5 +21,5 @@ public class CargoFile : JournalBase
|
|||
/// <summary>
|
||||
/// List of full cargo details.
|
||||
/// </summary>
|
||||
public ImmutableList<CargoType> Inventory { get; init; }
|
||||
public IReadOnlyCollection<CargoType> Inventory { get; init; }
|
||||
}
|
||||
|
|
@ -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.
|
||||
/// </summary>
|
||||
public class MaterialCompositionConverter : JsonConverter<ImmutableList<MaterialComposition>>
|
||||
public class MaterialCompositionConverter : JsonConverter<IReadOnlyCollection<MaterialComposition>>
|
||||
{
|
||||
public override ImmutableList<MaterialComposition> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
public override IReadOnlyCollection<MaterialComposition> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.StartObject)
|
||||
{
|
||||
|
|
@ -38,13 +38,14 @@ public class MaterialCompositionConverter : JsonConverter<ImmutableList<Material
|
|||
break;
|
||||
}
|
||||
}
|
||||
return materialComposition.ToImmutableList();
|
||||
|
||||
return materialComposition;
|
||||
}
|
||||
|
||||
return JsonSerializer.Deserialize<ImmutableList<MaterialComposition>>(ref reader, options)!;
|
||||
return JsonSerializer.Deserialize<IReadOnlyCollection<MaterialComposition>>(ref reader, options)!;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, ImmutableList<MaterialComposition> value,
|
||||
public override void Write(Utf8JsonWriter writer, IReadOnlyCollection<MaterialComposition> value,
|
||||
JsonSerializerOptions options)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, value, options);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
/// </summary>
|
||||
public class MaterialConverter : JsonConverter<ImmutableList<Material>>
|
||||
public class MaterialConverter : JsonConverter<IReadOnlyCollection<Material>>
|
||||
{
|
||||
public override ImmutableList<Material> Read(ref Utf8JsonReader reader, Type typeToConvert,
|
||||
public override IReadOnlyCollection<Material> Read(ref Utf8JsonReader reader, Type typeToConvert,
|
||||
JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.StartObject)
|
||||
|
|
@ -41,13 +41,13 @@ public class MaterialConverter : JsonConverter<ImmutableList<Material>>
|
|||
}
|
||||
}
|
||||
|
||||
return materialComposition.ToImmutableList();
|
||||
return materialComposition;
|
||||
}
|
||||
|
||||
return JsonSerializer.Deserialize<ImmutableList<Material>>(ref reader, options)!;
|
||||
return JsonSerializer.Deserialize<IReadOnlyCollection<Material>>(ref reader, options)!;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, ImmutableList<Material> value, JsonSerializerOptions options)
|
||||
public override void Write(Utf8JsonWriter writer, IReadOnlyCollection<Material> value, JsonSerializerOptions options)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, value, options);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
class MutableStringDoubleConverter : JsonConverter<object>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<NumberOrString>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,22 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Observatory.Framework.Files.Journal.Travel;
|
||||
|
||||
namespace Observatory.Framework.Files.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// Converting the ordered array of coordinates from the journal to a named tuple for clarity.
|
||||
/// </summary>
|
||||
public class StarPosConverter : JsonConverter<(double x, double y, double z)>
|
||||
public class StarPosConverter : JsonConverter<StarPos>
|
||||
{
|
||||
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<double[]>(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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@ public class FCMaterialsFile : JournalBase
|
|||
/// <summary>
|
||||
/// List of items in stock and in demand from the carrier bartender.
|
||||
/// </summary>
|
||||
public ImmutableList<FCMaterial> Items { get; init; }
|
||||
public IReadOnlyCollection<FCMaterial> Items { get; init; }
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ namespace Observatory.Framework.Files.Journal.Combat;
|
|||
public class Bounty : JournalBase
|
||||
{
|
||||
public override string Event => "Bounty";
|
||||
public ImmutableList<Rewards> Rewards { get; init; }
|
||||
public IReadOnlyCollection<Rewards> Rewards { get; init; }
|
||||
public string PilotName { get; set; }
|
||||
public string PilotName_Localised { get; set; }
|
||||
public string Target { get; init; }
|
||||
|
|
|
|||
|
|
@ -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<Killer> Killers { get; init; }
|
||||
public IReadOnlyCollection<Killer> Killers { get; init; }
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ public class CodexEntry : JournalBase
|
|||
/// <summary>
|
||||
/// List of trais of the scanned item.
|
||||
/// </summary>
|
||||
public ImmutableList<string> Traits { get; init; }
|
||||
public ICollection<string> Traits { get; init; }
|
||||
/// <summary>
|
||||
/// Value of the codex entry when sold to Universal Cartographics.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class MultiSellExplorationData : JournalBase
|
|||
/// <summary>
|
||||
/// List of all sold first discoveries.
|
||||
/// </summary>
|
||||
public ImmutableList<Discovered> Discovered { get; init; }
|
||||
public IReadOnlyCollection<Discovered> Discovered { get; init; }
|
||||
/// <summary>
|
||||
/// Base value of total sold data.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ public class SAAScanComplete : JournalBase
|
|||
/// <summary>
|
||||
/// This property is indicated with strikethrough in Frontier's documentation and is likely unused.
|
||||
/// </summary>
|
||||
public ImmutableList<string> Discoverers { get; init; }
|
||||
public ICollection<string> Discoverers { get; init; }
|
||||
/// <summary>
|
||||
/// This property is indicated with strikethrough in Frontier's documentation and is likely unused.
|
||||
/// </summary>
|
||||
public ImmutableList<string> Mappers { get; init; }
|
||||
public ICollection<string> Mappers { get; init; }
|
||||
/// <summary>
|
||||
/// Number of probes fired to complete the surface scan.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ public class SAASignalsFound : JournalBase
|
|||
/// <summary>
|
||||
/// List of signals found.
|
||||
/// </summary>
|
||||
public ImmutableList<Signal> Signals { get; init; }
|
||||
public IReadOnlyCollection<Signal> Signals { get; init; }
|
||||
/// <summary>
|
||||
/// List of genuses present.
|
||||
/// </summary>
|
||||
public ImmutableList<GenusType> Genuses { get; init; }
|
||||
public IReadOnlyCollection<GenusType> Genuses { get; init; }
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ public class Scan : ScanBaryCentre
|
|||
/// <summary>
|
||||
/// List which reflects Frontier's JSON structure for the "Parents" object. Use of Parent property is recommended instead.
|
||||
/// </summary>
|
||||
public ImmutableList<Parent> Parents {
|
||||
public IReadOnlyCollection<Parent> 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;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// "Parents" object rearranged into more intuitive structure for ease of use.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public ImmutableList<(ParentType ParentType, int Body)> Parent { get; init; }
|
||||
private ImmutableList<Parent> _Parents;
|
||||
public IReadOnlyCollection<(ParentType ParentType, int Body)> Parent { get; init; }
|
||||
private IReadOnlyCollection<Parent> _Parents;
|
||||
/// <summary>
|
||||
/// Body distance from system arrival point in light-seconds.
|
||||
/// </summary>
|
||||
|
|
@ -79,7 +80,7 @@ public class Scan : ScanBaryCentre
|
|||
/// <summary>
|
||||
/// List containing full breakdown of atmospheric components and their relative percentages.
|
||||
/// </summary>
|
||||
public ImmutableList<MaterialComposition> AtmosphereComposition { get; init; }
|
||||
public IReadOnlyCollection<MaterialComposition> AtmosphereComposition { get; init; }
|
||||
/// <summary>
|
||||
/// Descriptive string for type of volcanism present, or an empty string for none, e.g. "major silicate vapour geysers volcanism".
|
||||
/// </summary>
|
||||
|
|
@ -112,7 +113,7 @@ public class Scan : ScanBaryCentre
|
|||
/// List containing full breakdown of prospectable surface materials and their relative percentages.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(MaterialCompositionConverter))]
|
||||
public ImmutableList<MaterialComposition> Materials { get; init; }
|
||||
public IReadOnlyCollection<MaterialComposition> Materials { get; init; }
|
||||
/// <summary>
|
||||
/// Overall composition of body, expressed as percentages of ice, rock, and metal.
|
||||
/// </summary>
|
||||
|
|
@ -129,7 +130,7 @@ public class Scan : ScanBaryCentre
|
|||
/// <summary>
|
||||
/// List of all planetary or stellar ring systems around the body.
|
||||
/// </summary>
|
||||
public ImmutableList<Ring> Rings { get; init; }
|
||||
public IReadOnlyCollection<Ring> Rings { get; init; }
|
||||
/// <summary>
|
||||
/// Description of the minable material abundance.<br/>Possible values inclue "PristineResources", "MajorResources", "CommonResources", "LowResources", and "DepletedResources".
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ public class SellExplorationData : JournalBase
|
|||
/// <summary>
|
||||
/// List of systems for which data was sold.
|
||||
/// </summary>
|
||||
public ImmutableList<string> Systems { get; init; }
|
||||
public ICollection<string> Systems { get; init; }
|
||||
/// <summary>
|
||||
/// List of first discovered bodies.
|
||||
/// </summary>
|
||||
public ImmutableList<string> Discovered { get; init; }
|
||||
public ICollection<string> Discovered { get; init; }
|
||||
/// <summary>
|
||||
/// Base value of sold data.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -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<StationEconomy> StationEconomies { get; init; }
|
||||
public IReadOnlyCollection<StationEconomy> StationEconomies { get; init; }
|
||||
}
|
||||
|
|
@ -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<CarrierCrew> Crew { get; init; }
|
||||
public ImmutableList<CarrierPack> ShipPacks { get; init; }
|
||||
public ImmutableList<CarrierPack> ModulePacks { get; init; }
|
||||
public IReadOnlyCollection<CarrierCrew> Crew { get; init; }
|
||||
public IReadOnlyCollection<CarrierPack> ShipPacks { get; init; }
|
||||
public IReadOnlyCollection<CarrierPack> ModulePacks { get; init; }
|
||||
}
|
||||
|
|
@ -6,6 +6,6 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
|
|||
public class BackpackChange : JournalBase
|
||||
{
|
||||
public override string Event => "BackpackChange";
|
||||
public ImmutableList<BackpackItemChange> Added { get; init; }
|
||||
public ImmutableList<BackpackItemChange> Removed { get; init; }
|
||||
public IReadOnlyCollection<BackpackItemChange> Added { get; init; }
|
||||
public IReadOnlyCollection<BackpackItemChange> Removed { get; init; }
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@ namespace Observatory.Framework.Files.Journal.Odyssey;
|
|||
public class BackpackMaterials : JournalBase
|
||||
{
|
||||
public override string Event => "BackpackMaterials";
|
||||
public ImmutableList<BackpackItem> Items { get; init; }
|
||||
public ImmutableList<BackpackItem> Components { get; init; }
|
||||
public ImmutableList<BackpackItem> Consumables { get; init; }
|
||||
public ImmutableList<BackpackItem> Data { get; init; }
|
||||
public IReadOnlyCollection<BackpackItem> Items { get; init; }
|
||||
public IReadOnlyCollection<BackpackItem> Components { get; init; }
|
||||
public IReadOnlyCollection<BackpackItem> Consumables { get; init; }
|
||||
public IReadOnlyCollection<BackpackItem> Data { get; init; }
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue