private JObject ToJsonCoriolisEngineering(ShipModule module) { JObject engineering = new JObject(); engineering["BlueprintID"] = module.Engineering.BlueprintID; engineering["BlueprintName"] = module.Engineering.BlueprintName; engineering["Level"] = module.Engineering.Level; engineering["Quality"] = module.Engineering.Quality; if (module.Engineering.Modifiers != null) // may not have any { JArray modifiers = new JArray(); foreach (ShipModule.EngineeringModifiers modifier in module.Engineering.Modifiers) { JObject jmodifier = new JObject(); jmodifier["Label"] = modifier.Label; jmodifier["Value"] = modifier.Value; jmodifier["OriginalValue"] = modifier.OriginalValue; jmodifier["LessIsGood"] = modifier.LessIsGood; modifiers.Add(jmodifier); } engineering["Modifiers"] = modifiers; } if (module.Engineering.ExperimentalEffect.HasChars()) { engineering["ExperimentalEffect"] = module.Engineering.ExperimentalEffect; } return(engineering); }
public ShipModule(ShipModule other) { Slot = other.Slot; SlotFD = other.SlotFD; Item = other.Item; ItemFD = other.ItemFD; LocalisedItem = other.LocalisedItem; Enabled = other.Enabled; Priority = other.Priority; Health = other.Health; Value = other.Value; AmmoClip = other.AmmoClip; AmmoHopper = other.AmmoHopper; Power = other.Power; Engineering = other.Engineering; }
public bool Same(ShipModule other) // ignore localisased item, it does not occur everywhere.. { bool engsame = Engineering != null?Engineering.Same(other.Engineering) : (other.Engineering == null); // if null, both null, else use the same func return(Slot == other.Slot && Item == other.Item && Enabled == other.Enabled && Priority == other.Priority && AmmoClip == other.AmmoClip && AmmoHopper == other.AmmoHopper && Health == other.Health && Value == other.Value && engsame); }
public bool Same(ShipModule sm) { if (Modules.ContainsKey(sm.Slot)) { return(Modules[sm.Slot].Same(sm)); } else { return(false); } }
public EliteDangerousCalculations.FSDSpec GetFSDSpec() // may be null due to not having the info { ShipModule fsd = GetModule("Frame Shift Drive"); EliteDangerousCalculations.FSDSpec spec = fsd?.GetFSDSpec(); if (spec != null) { foreach (ShipModule sm in Modules.Values) { int classpos; if (sm.Item.Contains("Guardian FSD Booster") && (classpos = sm.Item.IndexOf("Class ")) != -1) { spec.SetFSDBooster(sm.Item[classpos + 6] - '0'); break; } } return(spec); } return(null); }
public void SetModule(ShipModule sm) // changed the module array, so you should have cloned that first.. { if (Modules.ContainsKey(sm.Slot)) { ShipModule oldsm = Modules[sm.Slot]; if (sm.Item.Equals(oldsm.Item) && sm.LocalisedItem == null && oldsm.LocalisedItem != null) // if item the same, old one has a localised name.. { sm.LocalisedItem = oldsm.LocalisedItem; } } Modules[sm.Slot] = sm; if (sm.Item.Contains("Fuel Tank") && sm.Item.IndexOf("Class ") != -1) { FuelCapacity = GetFuelCapacity(); if (FuelLevel > FuelCapacity) { FuelLevel = FuelCapacity; } } }
private void DisplayShip(ShipInformation si) { //System.Diagnostics.Debug.WriteLine("HE " + last_he.Indexno); last_si = si; foreach (string key in si.Modules.Keys) { EliteDangerousCore.ShipModule sm = si.Modules[key]; AddModuleLine(sm); } double hullmass = si.HullMass(); double modulemass = si.ModuleMass(); EliteDangerousCalculations.FSDSpec fsdspec = si.GetFSDSpec(); if (fsdspec != null) { EliteDangerousCalculations.FSDSpec.JumpInfo ji = fsdspec.GetJumpInfo(0, modulemass + hullmass, si.FuelCapacity, si.FuelCapacity / 2); AddInfoLine("FSD Avg Jump".T(EDTx.UserControlModules_FSDAvgJump), ji.avgsinglejumpnocargo.ToString("N2") + "ly", "Half tank, no cargo".T(EDTx.UserControlModules_HT), fsdspec.ToString()); DataGridViewRow rw = dataGridViewModules.Rows[dataGridViewModules.Rows.Count - 1]; AddInfoLine("FSD Max Range".T(EDTx.UserControlModules_FSDMaxRange), ji.maxjumprange.ToString("N2") + "ly", "Full Tank, no cargo".T(EDTx.UserControlModules_FT), fsdspec.ToString()); AddInfoLine("FSD Maximum Fuel per jump".T(EDTx.UserControlModules_FSDMaximumFuelperjump), fsdspec.MaxFuelPerJump.ToString() + "t", "", fsdspec.ToString()); } if (si.HullValue > 0) { AddValueLine("Hull Value".T(EDTx.UserControlModules_HullValue), si.HullValue); } if (si.ModulesValue > 0) { AddValueLine("Modules Value".T(EDTx.UserControlModules_ModulesValue), si.ModulesValue); } if (si.HullValue > 0 && si.ModulesValue > 0) { AddValueLine("Total Cost".T(EDTx.UserControlModules_TotalCost), si.HullValue + si.ModulesValue); } if (si.Rebuy > 0) { AddValueLine("Rebuy Cost".T(EDTx.UserControlModules_RebuyCost), si.Rebuy); } AddMassLine("Mass Hull".T(EDTx.UserControlModules_MassHull), hullmass.ToString("N1") + "t"); AddMassLine("Mass Unladen".T(EDTx.UserControlModules_MassUnladen), (hullmass + modulemass).ToString("N1") + "t"); if (si.UnladenMass > 0) { AddMassLine("Mass FD Unladen".T(EDTx.UserControlModules_MassFDUnladen), si.UnladenMass.ToString("N1") + "t"); } AddMassLine("Mass Modules".T(EDTx.UserControlModules_MassModules), modulemass.ToString("N1") + "t"); AddInfoLine("Manufacturer".T(EDTx.UserControlModules_Manufacturer), si.Manufacturer); if (si.FuelCapacity > 0) { AddInfoLine("Fuel Capacity".T(EDTx.UserControlModules_FuelCapacity), si.FuelCapacity.ToString("N1") + "t"); } if (si.FuelLevel > 0) { AddInfoLine("Fuel Level".T(EDTx.UserControlModules_FuelLevel), si.FuelLevel.ToString("N1") + "t"); } if (si.ReserveFuelCapacity > 0) { AddInfoLine("Fuel Reserve Capacity".T(EDTx.UserControlModules_FuelReserveCapacity), si.ReserveFuelCapacity.ToString("N2") + "t"); } if (si.HullHealthAtLoadout > 0) { AddInfoLine("Hull Health (Loadout)".T(EDTx.UserControlModules_HullHealth), si.HullHealthAtLoadout.ToString("N1") + "%"); } double fuelwarn = si.FuelWarningPercent; AddInfoLine("Fuel Warning %".T(EDTx.UserControlModules_FuelWarning), fuelwarn > 0 ? fuelwarn.ToString("N1") + "%" : "Off".T(EDTx.Off)); AddInfoLine("Pad Size".T(EDTx.UserControlModules_PadSize), si.PadSize); AddInfoLine("Main Thruster Speed".T(EDTx.UserControlModules_MainThrusterSpeed), si.Speed.ToString("0.#")); AddInfoLine("Main Thruster Boost".T(EDTx.UserControlModules_MainThrusterBoost), si.Boost.ToString("0.#")); if (si.InTransit) { AddInfoLine("In Transit to ".T(EDTx.UserControlModules_InTransitto), (si.StoredAtSystem ?? "Unknown".T(EDTx.Unknown)) + ":" + (si.StoredAtStation ?? "Unknown".T(EDTx.Unknown))); } else if (si.StoredAtSystem != null) { AddInfoLine("Stored at".T(EDTx.UserControlModules_Storedat), si.StoredAtSystem + ":" + (si.StoredAtStation ?? "Unknown".T(EDTx.Unknown))); } int cc = si.CargoCapacity(); if (cc > 0) { AddInfoLine("Cargo Capacity".T(EDTx.UserControlModules_CargoCapacity), cc.ToString("N0") + "t"); } labelVehicle.Visible = true; labelVehicle.Text = si.ShipFullInfo(cargo: false, fuel: false); buttonExtConfigure.Visible = true; buttonExtCoriolis.Visible = buttonExtEDShipyard.Visible = si.CheckMinimumJSONModules(); }
public EliteDangerousCalculations.FSDSpec GetFSDSpec() // may be null due to not having the info { ShipModule fsd = GetModule("Frame Shift Drive"); return(fsd?.GetFSDSpec() ?? null); }
private void Display() // allow redisplay of last data { DataGridViewColumn sortcolprev = dataGridViewModules.SortedColumn != null ? dataGridViewModules.SortedColumn : dataGridViewModules.Columns[0]; SortOrder sortorderprev = dataGridViewModules.SortedColumn != null ? dataGridViewModules.SortOrder : SortOrder.Ascending; int firstline = dataGridViewModules.SafeFirstDisplayedScrollingRowIndex(); dataGridViewModules.Rows.Clear(); dataViewScrollerPanel.SuspendLayout(); last_si = null; // no ship info dataGridViewModules.Columns[2].HeaderText = "Slot".T(EDTx.UserControlModules_SlotCol); dataGridViewModules.Columns[3].HeaderText = "Info".T(EDTx.UserControlModules_ItemInfo); dataGridViewModules.Columns[6].HeaderText = "Value".T(EDTx.UserControlModules_Value); if (comboBoxShips.Text == storedmoduletext) { labelVehicle.Visible = buttonExtCoriolis.Visible = buttonExtEDShipyard.Visible = buttonExtConfigure.Visible = false; if (last_he != null && last_he.StoredModules != null) { ModulesInStore mi = last_he.StoredModules; labelVehicle.Text = ""; foreach (ModulesInStore.StoredModule sm in mi.StoredModules) { object[] rowobj = { sm.Name_Localised.Alt(sm.Name), sm.Name, sm.StarSystem.Alt("In Transit".T(EDTx.UserControlModules_InTransit)), sm.TransferTimeString, sm.Mass > 0 ? (sm.Mass.ToString() + "t") : "", sm.EngineerModifications.Alt(""), sm.TransferCost > 0 ? sm.TransferCost.ToString("N0") : "", "" }; dataGridViewModules.Rows.Add(rowobj); } dataGridViewModules.Columns[2].HeaderText = "System".T(EDTx.UserControlModules_System); dataGridViewModules.Columns[3].HeaderText = "Tx Time".T(EDTx.UserControlModules_TxTime); dataGridViewModules.Columns[6].HeaderText = "Cost".T(EDTx.UserControlModules_Cost); } } else if (comboBoxShips.Text == allmodulestext) { labelVehicle.Visible = buttonExtCoriolis.Visible = buttonExtEDShipyard.Visible = buttonExtConfigure.Visible = false; ShipInformationList shm = discoveryform.history.ShipInformationList; var ownedships = (from x1 in shm.Ships where x1.Value.State == ShipInformation.ShipState.Owned && ItemData.IsShip(x1.Value.ShipFD) select x1.Value); foreach (var si in ownedships) { foreach (string key in si.Modules.Keys) { EliteDangerousCore.ShipModule sm = si.Modules[key]; AddModuleLine(sm, si); } } if (last_he != null && last_he.StoredModules != null) { ModulesInStore mi = last_he.StoredModules; labelVehicle.Text = ""; foreach (ModulesInStore.StoredModule sm in mi.StoredModules) { string info = sm.StarSystem.Alt("In Transit".T(EDTx.UserControlModules_InTransit)); info = info.AppendPrePad(sm.TransferTimeString, ":"); object[] rowobj = { sm.Name_Localised.Alt(sm.Name), sm.Name, "Stored".TxID(EDTx.UserControlModules_Stored), info, sm.Mass > 0 ? (sm.Mass.ToString() + "t") : "", sm.EngineerModifications.Alt(""), sm.TransferCost > 0 ? sm.TransferCost.ToString("N0") : "", "" }; dataGridViewModules.Rows.Add(rowobj); } } } else if (comboBoxShips.Text == travelhistorytext || comboBoxShips.Text.Length == 0) // second is due to the order History gets called vs this on start { if (last_he?.ShipInformation != null) { DisplayShip(last_he.ShipInformation); } } else { ShipInformation si = discoveryform.history.ShipInformationList.GetShipByNameIdentType(comboBoxShips.Text); if (si != null) { DisplayShip(si); } } dataViewScrollerPanel.ResumeLayout(); dataGridViewModules.Sort(sortcolprev, (sortorderprev == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending); dataGridViewModules.Columns[sortcolprev.Index].HeaderCell.SortGlyphDirection = sortorderprev; if (firstline >= 0 && firstline < dataGridViewModules.RowCount) { dataGridViewModules.SafeFirstDisplayedScrollingRowIndex(firstline); } }