Skip to content

Commit 956a8c4

Browse files
committed
Make intermediate methods virtual so they can be redefined
1 parent 2674f8f commit 956a8c4

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/PersistentEngine.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void UpdatePersistentParameters () {
9898
}
9999

100100
// Calculate demands of each resource
101-
public double [] CalculateDemands (double demandMass) {
101+
public virtual double [] CalculateDemands (double demandMass) {
102102
var demands = new double[pplist.Count];
103103
if (demandMass > 0) {
104104
// Per propellant demand
@@ -111,7 +111,7 @@ public double [] CalculateDemands (double demandMass) {
111111

112112
// Apply demanded resources & return results
113113
// Updated depleted boolean flag if resource request failed
114-
public double [] ApplyDemands (double [] demands, ref bool depleted) {
114+
public virtual double [] ApplyDemands (double [] demands, ref bool depleted) {
115115
var demandsOut = new double [pplist.Count];
116116
for (var i = 0; i < pplist.Count; i++) {
117117
var pp = pplist[i];
@@ -138,7 +138,7 @@ public double [] ApplyDemands (double [] demands, ref bool depleted) {
138138
}
139139

140140
// Calculate DeltaV vector and update resource demand from mass (demandMass)
141-
public Vector3d CalculateDeltaVV (double m0, double dT, float thrust, float isp, Vector3d thrustUV, out double demandMass) {
141+
public virtual Vector3d CalculateDeltaVV (double m0, double dT, float thrust, float isp, Vector3d thrustUV, out double demandMass) {
142142
// Mass flow rate
143143
var mdot = thrust / (isp * 9.81f);
144144
// Change in mass over time interval dT
@@ -153,11 +153,6 @@ public Vector3d CalculateDeltaVV (double m0, double dT, float thrust, float isp,
153153
return deltaV * thrustUV;
154154
}
155155

156-
// Apply the deltaV vector at UT and dT to
157-
public static void ApplyDeltaVV (Vector3d deltaVV, double UT, Orbit orbit) {
158-
orbit.Perturb(deltaVV, UT);
159-
}
160-
161156
// Physics update
162157
public override void OnFixedUpdate() {
163158
if (FlightGlobals.fetch != null && isEnabled) {
@@ -188,7 +183,7 @@ public override void OnFixedUpdate() {
188183
var demandsOut = ApplyDemands(demands, ref depleted);
189184
// Apply deltaV vector at UT & dT to orbit if resources not depleted
190185
if (!depleted) {
191-
ApplyDeltaVV(deltaVV, UT, this.vessel.orbit);
186+
vessel.orbit.Perturb(deltaVV, UT);
192187
}
193188
// Otherwise log warning and drop out of timewarp if throttle on & depleted
194189
else if (ThrottlePersistent > 0) {

0 commit comments

Comments
 (0)