fix location not updating on carrier jumps
This commit is contained in:
parent
d6e2280a00
commit
9994a45d06
30
EDPlayerJournal/BGS/Parsers/CarrierJumpParser.cs
Normal file
30
EDPlayerJournal/BGS/Parsers/CarrierJumpParser.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -665,6 +665,7 @@ public class TransactionParser {
|
||||
{
|
||||
{ Events.ApproachSettlement, new ApproachSettlementParser() },
|
||||
{ Events.CapShipBond, new CapShipBondParser() },
|
||||
{ Events.CarrierJump, new CarrierJumpParser() },
|
||||
{ Events.Commander, new CommanderParser() },
|
||||
{ Events.CommitCrime, new CommitCrimeParser() },
|
||||
{ Events.Died, new DiedParser() },
|
||||
|
44
EDPlayerJournal/Entries/CarrierJump.cs
Normal file
44
EDPlayerJournal/Entries/CarrierJump.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ public class Entry {
|
||||
{ Events.ApproachSettlement, typeof(ApproachSettlementEntry) },
|
||||
{ Events.Bounty, typeof(BountyEntry) },
|
||||
{ Events.CapShipBond, typeof(CapShipBondEntry) },
|
||||
{ Events.CarrierJump, typeof(CarrierJump) },
|
||||
{ Events.Commander, typeof(CommanderEntry) },
|
||||
{ Events.CommitCrime, typeof(CommitCrimeEntry) },
|
||||
{ Events.Died, typeof(DiedEntry) },
|
||||
|
@ -4,6 +4,7 @@ public class Events {
|
||||
public static readonly string ApproachSettlement = "ApproachSettlement";
|
||||
public static readonly string Bounty = "Bounty";
|
||||
public static readonly string CapShipBond = "CapShipBond";
|
||||
public static readonly string CarrierJump = "CarrierJump";
|
||||
public static readonly string Commander = "Commander";
|
||||
public static readonly string CommitCrime = "CommitCrime";
|
||||
public static readonly string Died = "Died";
|
||||
|
Loading…
Reference in New Issue
Block a user