Skip to content

Commit

Permalink
[CL] New entries
Browse files Browse the repository at this point in the history
- Vessel
  - DryMass
  - FuelMass
- Stage
  - StageDryMass
  - StageFuelMass
  - StageEndMass
  - DecoupledMass
 - StageFuelPercentage moved from Vessel to Stage entries (not working currently due to game bug)
  • Loading branch information
Falki-git committed Feb 20, 2024
1 parent 73343b6 commit 9e4b2cd
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 21 deletions.
151 changes: 151 additions & 0 deletions src/MicroEngineer/Entries/StageInfoEntries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,155 @@ public List<Stage> ParseStages(List<DeltaVStageInfo> deltaVStages)

return stages;
}
}

public class StageFuelPercentage : StageInfoEntry
{
public StageFuelPercentage()
{
Name = "Stage Fuel %";
Description = "Stage fuel percentage left.";
Category = MicroEntryCategory.Stage;
IsDefault = false;
BaseUnit = "%";
NumberOfDecimalDigits = 1;
Formatting = "N";
}

public override void RefreshData()
{
EntryValue = Utility.ActiveVessel.StageFuelPercentage;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class StageDryMass : StageInfoEntry
{
public StageDryMass()
{
Name = "Stage Dry Mass";
Description = "Dry mass of the current stage (will be decoupled on staging).";
Category = MicroEntryCategory.Stage;
IsDefault = false;
MiliUnit = "g";
BaseUnit = "kg";
KiloUnit = "T";
MegaUnit = "kT";
GigaUnit = "MT";
NumberOfDecimalDigits = 1;
Formatting = "N";
}

public override void RefreshData()
{
var stageInfo = Utility.ActiveVessel.VesselDeltaV?.StageInfo;
if (stageInfo == null || stageInfo.Count == 0)
{
EntryValue = null;
return;
}

var stageDryMass = stageInfo[0].DryMass;

// if a next stage exists then subtract its drymass from the current drymass to get current stage drymass
if (stageInfo.Count >= 2)
{
stageDryMass -= stageInfo[1].DryMass;
}

// multiply by 100 to convert from tons to kg
EntryValue = stageDryMass * 1000;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class StageFuelMass : StageInfoEntry
{
public StageFuelMass()
{
Name = "Stage Fuel Mass";
Description = "Remaining fuel mass of the current stage.";
Category = MicroEntryCategory.Stage;
IsDefault = false;
MiliUnit = "g";
BaseUnit = "kg";
KiloUnit = "T";
MegaUnit = "kT";
GigaUnit = "MT";
NumberOfDecimalDigits = 1;
Formatting = "N";
}

public override void RefreshData()
{
var stage = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault();
if (stage == null)
{
EntryValue = null;
return;
}

EntryValue = stage.EndMass != 0f ? (stage.StartMass - stage.EndMass) * 1000f : 0f;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class StageEndMass : StageInfoEntry
{
public StageEndMass()
{
Name = "Stage End Mass";
Description = "End mass of the current stage.";
Category = MicroEntryCategory.Stage;
IsDefault = false;
MiliUnit = "g";
BaseUnit = "kg";
KiloUnit = "T";
MegaUnit = "kT";
GigaUnit = "MT";
NumberOfDecimalDigits = 1;
Formatting = "N";
}

public override void RefreshData()
{
var stage = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault();
if (stage == null)
{
EntryValue = null;
return;
}

EntryValue = stage.EndMass == 0 ? stage.StartMass * 1000 : stage.EndMass == stage.StartMass ? null: stage.EndMass * 1000;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class DecoupledMass : StageInfoEntry
{
public DecoupledMass()
{
Name = "Decoupled Mass";
Description = "Decoupled mass of the current stage.";
Category = MicroEntryCategory.Stage;
IsDefault = false;
MiliUnit = "g";
BaseUnit = "kg";
KiloUnit = "T";
MegaUnit = "kT";
GigaUnit = "MT";
NumberOfDecimalDigits = 1;
Formatting = "N";
}

public override void RefreshData()
{
EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.DecoupledMass * 1000;
}

public override string ValueDisplay => base.ValueDisplay;
}
71 changes: 50 additions & 21 deletions src/MicroEngineer/Entries/VesselEntries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,56 @@ public override void RefreshData()
public override string ValueDisplay => base.ValueDisplay;
}

public class DryMass : VesselEntry
{
public DryMass()
{
Name = "Total Dry Mass";
Description = "Total current dry mass.";
Category = MicroEntryCategory.Vessel;
IsDefault = false;
MiliUnit = "g";
BaseUnit = "kg";
KiloUnit = "T";
MegaUnit = "kT";
GigaUnit = "MT";
NumberOfDecimalDigits = 1;
Formatting = "N";
}

public override void RefreshData()
{
EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.DryMass * 1000;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class FuelMass : VesselEntry
{
public FuelMass()
{
Name = "Fuel Mass";
Description = "Total fuel mass remaining on the vessel.";
Category = MicroEntryCategory.Vessel;
IsDefault = false;
MiliUnit = "g";
BaseUnit = "kg";
KiloUnit = "T";
MegaUnit = "kT";
GigaUnit = "MT";
NumberOfDecimalDigits = 1;
Formatting = "N";
}

public override void RefreshData()
{
EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.FuelMass * 1000;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class TotalDeltaVActual : VesselEntry
{
public TotalDeltaVActual()
Expand Down Expand Up @@ -369,27 +419,6 @@ public override void RefreshData()
public override string ValueDisplay => base.ValueDisplay;
}

public class StageFuelPercentage : VesselEntry
{
public StageFuelPercentage()
{
Name = "Stage fuel";
Description = "Stage fuel percentage left.";
Category = MicroEntryCategory.Vessel;
IsDefault = false;
BaseUnit = "%";
NumberOfDecimalDigits = 1;
Formatting = "N";
}

public override void RefreshData()
{
EntryValue = Utility.ActiveVessel.StageFuelPercentage;
}

public override string ValueDisplay => base.ValueDisplay;
}

public class PartsCount : VesselEntry
{
public PartsCount()
Expand Down

0 comments on commit 9e4b2cd

Please sign in to comment.