diff --git a/EliteAPI/Classes/Cargo.cs b/EliteAPI/Classes/Cargo.cs index 9ec995fe..248e6e78 100644 --- a/EliteAPI/Classes/Cargo.cs +++ b/EliteAPI/Classes/Cargo.cs @@ -5,7 +5,7 @@ namespace EliteAPI public class Cargo { public DateTime timestamp { get; set; } - public string _event { get; set; } + public string Vessel { get; set; } public int Count { get; set; } public Inventory[] Inventory { get; set; } diff --git a/EliteAPI/Classes/System.cs b/EliteAPI/Classes/System.cs index 37b44b59..bfcab297 100644 --- a/EliteAPI/Classes/System.cs +++ b/EliteAPI/Classes/System.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace EliteAPI { @@ -16,7 +17,7 @@ public class System public string Government_Localised { get; set; } public string Security { get; set; } public string Security_Localised { get; set; } - public int Population { get; set; } + public ulong Population { get; set; } public string SystemFaction { get; set; } public string FactionState { get; set; } } diff --git a/EliteAPI/EDDB/System.cs b/EliteAPI/EDDB/System.cs index 6e8dad73..dd828059 100644 --- a/EliteAPI/EDDB/System.cs +++ b/EliteAPI/EDDB/System.cs @@ -19,7 +19,7 @@ public class EddbSystem public double x { get; set; } public double y { get; set; } public double z { get; set; } - public UInt64 population { get; set; } + public ulong population { get; set; } public bool is_populated { get; set; } public int? government_id { get; set; } public string government { get; set; } diff --git a/EliteAPI/EliteAPI.csproj b/EliteAPI/EliteAPI.csproj index 26cfb33a..007bfceb 100644 --- a/EliteAPI/EliteAPI.csproj +++ b/EliteAPI/EliteAPI.csproj @@ -84,7 +84,15 @@ + + + + + + + + @@ -94,18 +102,26 @@ + + + + + + + + @@ -114,29 +130,47 @@ + + + + + + + + + + + + + + + + + + @@ -154,6 +188,7 @@ + diff --git a/EliteAPI/EliteDangerousAPI.cs b/EliteAPI/EliteDangerousAPI.cs index b681954a..5a34dc93 100644 --- a/EliteAPI/EliteDangerousAPI.cs +++ b/EliteAPI/EliteDangerousAPI.cs @@ -151,7 +151,7 @@ private void InitProcessLog() /// Process the log file once. /// /// The log file to process. - private void ProcessLog(FileInfo logFile, bool actuallyProcess) + public void ProcessLog(FileInfo logFile, bool actuallyProcess) { //Create a stream from the log file. FileStream fileStream = logFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); @@ -184,7 +184,7 @@ private void Process(string json) { default: OtherEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); - //File.AppendAllText(@"C:\ICT\EliteAPI\NotAddedEvents.txt", json + Environment.NewLine); + File.AppendAllText(@"C:\ICT\EliteAPI\NotAddedEvents.txt", json + Environment.NewLine); break; case "ClearSavedGame": @@ -530,9 +530,219 @@ private void Process(string json) case "FSSDiscoveryScan": FSSDiscoveryScanEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); break; + + case "Powerplay": + PowerplayEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "CommunityGoal": + CommunityGoalEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "FSDTarget": + FSDTargetEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "CodexEntry": + CodexEntryEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "ModuleInfo": + ModuleInfoEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "RedeemVoucher": + RedeemVoucherEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "PowerplaySalary": + PowerplaySalaryEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "SetUserShipName": + SetUserShipNameEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "EngineerCraft": + EngineerCraftEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "ModuleRetrieve": + ModuleRetrieveEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "SellDrones": + SellDronesEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "MultiSellExplorationData": + MultiSellExplorationDataEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "ModuleSwap": + ModuleSwapEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "SAAScanComplete": + SAAScanCompleteEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "LaunchSRV": + LaunchSRVEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "MaterialCollected": + MaterialCollectedEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "DockSRV": + DockSRVEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "MiningRefined": + MiningRefinedEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "FSSAllBodiesFound": + FSSAllBodiesFoundEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "MaterialDiscovered": + MaterialDiscoveredEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "USSDrop": + USSDropEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "MissionRedirected": + MissionRedirectedEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "SendText": + SendTextEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "SelfDestruct": + SelfDestructEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "HeatDamage": + HeatDamageEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "Died": + DiedEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "Resurrect": + ResurrectEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "HullDamage": + HullDamageEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "CrewMemberJoins": + CrewMemberJoinsEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "CrewMemberRoleChange": + CrewMemberRoleChangeEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "CrewLaunchFighter": + CrewLaunchFighterEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "CrimeVictim": + CrimeVictimEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "EndCrewSession": + EndCrewSessionEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "RestockVehicle": + RestockVehicleEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; + + case "CollectCargo": + CollectCargoEvent?.Invoke(this, JsonConvert.DeserializeObject(json)); + break; } } + public EventHandler PowerplayEvent; + + public EventHandler CommunityGoalEvent; + + public EventHandler FSDTargetEvent; + + public EventHandler CodexEntryEvent; + + public EventHandler ModuleInfoEvent; + + public EventHandler RedeemVoucherEvent; + + public EventHandler PowerplaySalaryEvent; + + public EventHandler SetUserShipNameEvent; + + public EventHandler EngineerCraftEvent; + + public EventHandler ModuleRetrieveEvent; + + public EventHandler SellDronesEvent; + + public EventHandler MultiSellExplorationDataEvent; + + public EventHandler ModuleSwapEvent; + + public EventHandler SAAScanCompleteEvent; + + public EventHandler LaunchSRVEvent; + + public EventHandler MaterialCollectedEvent; + + public EventHandler DockSRVEvent; + + public EventHandler MiningRefinedEvent; + + public EventHandler FSSAllBodiesFoundEvent; + + public EventHandler MaterialDiscoveredEvent; + + public EventHandler USSDropEvent; + + public EventHandler MissionRedirectedEvent; + + public EventHandler SendTextEvent; + + public EventHandler SelfDestructEvent; + + public EventHandler HeatDamageEvent; + + public EventHandler DiedEvent; + + public EventHandler ResurrectEvent; + + public EventHandler HullDamageEvent; + + public EventHandler CrewMemberJoinsEvent; + + public EventHandler CrewMemberRoleChangeEvent; + + public EventHandler CrewLaunchFighterEvent; + + public EventHandler CrimeVictimEvent; + + public EventHandler EndCrewSessionEvent; + + public EventHandler RestockVehicleEvent; + + public EventHandler CollectCargoEvent; + /// /// Triggered whenever a discovery scan has been completed. /// diff --git a/EliteAPI/Events/FSDJump.cs b/EliteAPI/Events/FSDJump.cs index 8853e580..34e80564 100644 --- a/EliteAPI/Events/FSDJump.cs +++ b/EliteAPI/Events/FSDJump.cs @@ -18,7 +18,7 @@ public class FSDJumpInfo public string SystemGovernment_Localised { get; set; } public string SystemSecurity { get; set; } public string SystemSecurity_Localised { get; set; } - public int Population { get; set; } + public ulong Population { get; set; } public double JumpDist { get; set; } public double FuelUsed { get; set; } public double FuelLevel { get; set; } diff --git a/EliteAPI/Events/Location.cs b/EliteAPI/Events/Location.cs index fca36f1d..32ed50e1 100644 --- a/EliteAPI/Events/Location.cs +++ b/EliteAPI/Events/Location.cs @@ -38,7 +38,7 @@ public class FactionInfo public string SystemGovernment_Localised { get; set; } public string SystemSecurity { get; set; } public string SystemSecurity_Localised { get; set; } - public int Population { get; set; } + public ulong Population { get; set; } public string Body { get; set; } public int BodyID { get; set; } public string BodyType { get; set; } diff --git a/Test/Program.cs b/Test/Program.cs index fa159f83..69d9154d 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -1,5 +1,6 @@ using EliteAPI; using System; +using System.Collections.Generic; using System.IO; using System.Threading; @@ -7,24 +8,28 @@ namespace Example { class Program { + + private static List unaddedEvents = new List(); + static void Main(string[] args) { - EliteDangerousAPI EliteAPI = new EliteDangerousAPI(new DirectoryInfo($@"C:\Users\{Environment.UserName}\Saved Games\Frontier Developments\Elite Dangerous"), false); - EliteAPI.OtherEvent += EliteAPI_OtherEvent; + DirectoryInfo d = new DirectoryInfo($@"C:\Users\Lucas\Downloads\Elite Dangerous Journals"); - EliteAPI.Start(); + EliteDangerousAPI EliteAPI = new EliteDangerousAPI(d, false); + EliteAPI.OtherEvent += EliteAPI_OtherEvent; - Console.WriteLine(EliteAPI.Status.FireGroup); - Console.WriteLine(EliteAPI.Shipyard.PriceList[0].ShipPrice); - Console.WriteLine(EliteAPI.ModulesInfo.Modules[0].Item); - Console.WriteLine(EliteAPI.Outfitting.Horizons); + foreach (var item in d.GetFiles()) + { + EliteAPI.ProcessLog(item, true); + } Thread.Sleep(-1); } private static void EliteAPI_OtherEvent(object sender, dynamic e) { - Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(e)); + string @event = e.@event; + if (!unaddedEvents.Contains(@event)) { unaddedEvents.Add(@event); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(e)); } } } }