fix location not updating on carrier jumps

This commit is contained in:
Florian Stinglmayr 2024-01-29 18:23:19 +01:00
parent d6e2280a00
commit 9994a45d06
5 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,30 @@
using EDPlayerJournal.Entries;
namespace EDPlayerJournal.BGS.Parsers;
internal class CarrierJumpParser : ITransactionParserPart {
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
CarrierJump? jump = entry as CarrierJump;
if (jump == null) {
return;
}
if (!jump.Docked) {
return;
}
context.CurrentSystem = jump.StarSystem;
context.CurrentSystemAddress = jump.SystemAddress;
context.SystemsByID.TryAdd(jump.SystemAddress, jump.StarSystem);
if (!string.IsNullOrEmpty(jump.SystemFaction)) {
context.ControllingFaction = jump.SystemFaction;
}
if (jump.SystemFactions != null && jump.SystemFactions.Count > 0) {
context.SystemFactions[jump.StarSystem] = jump.SystemFactions;
}
}
}

View File

@ -665,6 +665,7 @@ public class TransactionParser {
{ {
{ Events.ApproachSettlement, new ApproachSettlementParser() }, { Events.ApproachSettlement, new ApproachSettlementParser() },
{ Events.CapShipBond, new CapShipBondParser() }, { Events.CapShipBond, new CapShipBondParser() },
{ Events.CarrierJump, new CarrierJumpParser() },
{ Events.Commander, new CommanderParser() }, { Events.Commander, new CommanderParser() },
{ Events.CommitCrime, new CommitCrimeParser() }, { Events.CommitCrime, new CommitCrimeParser() },
{ Events.Died, new DiedParser() }, { Events.Died, new DiedParser() },

View File

@ -0,0 +1,44 @@
using Newtonsoft.Json.Linq;
namespace EDPlayerJournal.Entries;
public class CarrierJump : Entry {
public bool Docked { get; set; } = false;
public string? StationName { get; set; } = null;
public string? StationType { get; set; } = null;
public string? StarSystem { get; set; } = null;
public ulong SystemAddress { get; set; } = 0;
public string? SystemFaction { get; set; } = null;
public List<Faction> SystemFactions { get; set; } = new List<Faction>();
protected override void Initialise() {
Docked = JSON.Value<bool?>("Docked") ?? false;
StarSystem = JSON.Value<string>("StarSystem");
SystemAddress = JSON.Value<ulong?>("SystemAddress") ?? 0;
StationName = JSON.Value<string?>("StationName");
StationType = JSON.Value<string?>("StationType");
var faction = JSON.Value<JObject>("SystemFaction");
if (faction != null) {
SystemFaction = faction.Value<string>("Name");
}
var factions = JSON.Value<JArray>("Factions");
if (factions != null) {
foreach (JObject system_faction in factions) {
Faction? f = Faction.FromJSON(system_faction);
if (f != null) {
SystemFactions.Add(f);
}
}
}
}
}

View File

@ -15,6 +15,7 @@ public class Entry {
{ Events.ApproachSettlement, typeof(ApproachSettlementEntry) }, { Events.ApproachSettlement, typeof(ApproachSettlementEntry) },
{ Events.Bounty, typeof(BountyEntry) }, { Events.Bounty, typeof(BountyEntry) },
{ Events.CapShipBond, typeof(CapShipBondEntry) }, { Events.CapShipBond, typeof(CapShipBondEntry) },
{ Events.CarrierJump, typeof(CarrierJump) },
{ Events.Commander, typeof(CommanderEntry) }, { Events.Commander, typeof(CommanderEntry) },
{ Events.CommitCrime, typeof(CommitCrimeEntry) }, { Events.CommitCrime, typeof(CommitCrimeEntry) },
{ Events.Died, typeof(DiedEntry) }, { Events.Died, typeof(DiedEntry) },

View File

@ -4,6 +4,7 @@ public class Events {
public static readonly string ApproachSettlement = "ApproachSettlement"; public static readonly string ApproachSettlement = "ApproachSettlement";
public static readonly string Bounty = "Bounty"; public static readonly string Bounty = "Bounty";
public static readonly string CapShipBond = "CapShipBond"; public static readonly string CapShipBond = "CapShipBond";
public static readonly string CarrierJump = "CarrierJump";
public static readonly string Commander = "Commander"; public static readonly string Commander = "Commander";
public static readonly string CommitCrime = "CommitCrime"; public static readonly string CommitCrime = "CommitCrime";
public static readonly string Died = "Died"; public static readonly string Died = "Died";