static public void ShipBasicInformation(ConditionVariables vars, EliteDangerous.ShipInformation si, string prefix) { string ship = "Unknown", id = "0", name = "Unknown", ident = "Unknown", sv = "None", fullinfo = "Unknown", shortname = "Unknown", fuel = "0", cargo = "0", fuellevel = "0"; if (si != null) { ship = si.ShipType; id = si.ID.ToString(System.Globalization.CultureInfo.InvariantCulture); name = si.ShipUserName; ident = si.ShipUserIdent; sv = si.SubVehicle.ToString(); fullinfo = si.ShipFullInfo; shortname = si.ShipShortName; fuel = si.FuelCapacity.ToString("0.0"); fuellevel = si.FuelLevel.ToString("0.0"); cargo = si.CargoCapacity().ToStringInvariant(); } vars[prefix + "Ship"] = ship; // need to be backwards compatible with older entries.. vars[prefix + "Ship_ID"] = id; vars[prefix + "Ship_Name"] = name; vars[prefix + "Ship_Ident"] = ident; vars[prefix + "Ship_SubVehicle"] = sv; vars[prefix + "Ship_FullInfo"] = fullinfo; vars[prefix + "Ship_ShortName"] = shortname; vars[prefix + "Ship_FuelLevel"] = fuellevel; vars[prefix + "Ship_FuelCapacity"] = fuel; vars[prefix + "Ship_CargoCapacity"] = cargo; }
static public void ShipInformation(ConditionVariables vars, EliteDangerous.ShipInformation si, string prefix, bool modlist) { string ship = "Unknown", id = "0", name = "Unknown", ident = "Unknown", sv = "None", fullinfo = "Unknown", shortname = "Unknown", fuel = "0", cargo = "0"; if (si != null) { ship = si.ShipType; id = si.ID.ToString(System.Globalization.CultureInfo.InvariantCulture); name = si.ShipUserName; ident = si.ShipUserIdent; sv = si.SubVehicle.ToString(); fullinfo = si.ShipFullInfo; shortname = si.ShipShortName; fuel = si.FuelCapacity.ToString(System.Globalization.CultureInfo.InvariantCulture); cargo = si.CargoCapacity().ToString(System.Globalization.CultureInfo.InvariantCulture); } vars[prefix + "Ship"] = ship; // need to be backwards compatible with older entries.. vars[prefix + "Ship_ID"] = id; vars[prefix + "Ship_Name"] = name; vars[prefix + "Ship_Ident"] = ident; vars[prefix + "Ship_SubVehicle"] = sv; vars[prefix + "Ship_FullInfo"] = fullinfo; vars[prefix + "Ship_ShortName"] = shortname; vars[prefix + "Ship_FuelCapacity"] = fuel; vars[prefix + "Ship_CargoCapacity"] = cargo; if (modlist && si != null && si.Modules != null) { vars[prefix + "Ship_Module_Count"] = si.Modules.Count.ToString(System.Globalization.CultureInfo.InvariantCulture); int ind = 0; foreach (EliteDangerous.JournalEvents.JournalLoadout.ShipModule m in si.Modules.Values) { string mi = prefix + "Ship_Module[" + ind.ToString() + "]_"; vars[mi + "Slot"] = m.Slot; vars[mi + "Item"] = m.Item; vars[mi + "ItemLocalised"] = m.LocalisedItem.Alt(m.Item); vars[mi + "Enabled"] = m.Enabled.ToStringInvariant(); vars[mi + "AmmoClip"] = m.AmmoClip.ToStringInvariant(); vars[mi + "AmmoHopper"] = m.AmmoHopper.ToStringInvariant(); vars[mi + "Blueprint"] = m.Blueprint.ToNullSafeString(); vars[mi + "Health"] = m.Health.ToStringInvariant(); vars[mi + "Value"] = m.Value.ToStringInvariant(); ind++; } } }
static public void ShipModuleInformation(ActionLanguage.ActionProgramRun vars, EliteDangerous.ShipInformation si, string prefix) { if (si != null && si.Modules != null) { vars[prefix + "Ship_Module_Count"] = si.Modules.Count.ToString(System.Globalization.CultureInfo.InvariantCulture); int ind = 0; foreach (EliteDangerous.JournalEvents.JournalLoadout.ShipModule m in si.Modules.Values) { string mi = prefix + "Ship_Module[" + ind.ToString() + "]_"; vars[mi + "Slot"] = m.Slot; vars[mi + "Item"] = m.Item; vars[mi + "ItemLocalised"] = m.LocalisedItem.Alt(m.Item); vars[mi + "Enabled"] = m.Enabled.ToStringInvariant(); vars[mi + "AmmoClip"] = m.AmmoClip.ToStringInvariant(); vars[mi + "AmmoHopper"] = m.AmmoHopper.ToStringInvariant(); vars[mi + "Blueprint"] = m.Blueprint.ToNullSafeString(); vars[mi + "Health"] = m.Health.ToStringInvariant(); vars[mi + "Value"] = m.Value.ToStringInvariant(); ind++; } } }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != ConditionFunctions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "SH_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Ship"); return(true); } cmdname = sp.NextQuotedWord(); } if (cmdname != null) { EliteDangerous.ShipInformationList lst = ap.actioncontroller.HistoryList.shipinformationlist; ConditionVariables values = new ConditionVariables(); if (cmdname.Length > 0) { EliteDangerous.ShipInformation si = lst.GetShipByFullInfoMatch(cmdname); if (si != null) { ActionVars.ShipInformation(values, si, prefix, true); } values[prefix + "Found"] = (si != null) ? "1" : "0"; } values[prefix + "Ships"] = lst.Ships.Count.ToString(System.Globalization.CultureInfo.InvariantCulture); int ind = 0; foreach (EliteDangerous.ShipInformation si in lst.Ships.Values) { string p = prefix + "Ships[" + ind.ToString() + "]_"; ActionVars.ShipInformation(values, si, p, false); ind++; } ap.Add(values); } else { ap.ReportError("Missing ship name in Ship"); } } else { ap.ReportError(res); } return(true); }