Skip to content

Commit

Permalink
Add engineMode.propellant field (addresses #130)
Browse files Browse the repository at this point in the history
  • Loading branch information
untoldwind committed Mar 5, 2024
1 parent f0c6041 commit 90b7272
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changes

## 0.5.4.1 ->

* Add `engineMode.propellant` field


## 0.5.4.0 -> 0.5.4.1

Hotfix:
Expand Down
16 changes: 15 additions & 1 deletion KSP2Runtime/KSPVessel/KSPVesselModule.EngineMode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using KontrolSystem.TO2.Binding;
using KontrolSystem.KSP.Runtime.KSPResource;
using KontrolSystem.TO2.Binding;
using KSP.Modules;

namespace KontrolSystem.KSP.Runtime.KSPVessel;
Expand All @@ -25,5 +26,18 @@ public EngineModeAdapter(Data_Engine.EngineMode engineMode) {
[KSField] public double MaxThrust => engineMode.maxThrust;

[KSField] public EngineType EngineType => engineMode.engineType;

[KSField]
public KSPResourceModule.ResourceDefinitionAdapter Propellant {
get {
var context = KSPContext.CurrentContext;
var resourceId =
context.Game.ResourceDefinitionDatabase.GetResourceIDFromName(engineMode.propellant.mixtureName);
var resourceDefinitionData =
context.Game.ResourceDefinitionDatabase.GetDefinitionData(resourceId);

return new KSPResourceModule.ResourceDefinitionAdapter(resourceDefinitionData);
}
}
}
}
3 changes: 1 addition & 2 deletions TO2/AST/VariableDeclaration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using KontrolSystem.Parsing;
using KontrolSystem.Parsing;
using KontrolSystem.TO2.Generator;
using KontrolSystem.TO2.Runtime;

Expand Down

0 comments on commit 90b7272

Please sign in to comment.