Copy stage activeness after config clone/copy
This commit is contained in:
parent
b12c4f02f4
commit
e994dc7230
@ -136,6 +136,21 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
updateMotors();
|
updateMotors();
|
||||||
updateActiveInstances();
|
updateActiveInstances();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy only the stage activeness from another configuration.
|
||||||
|
* @param other the configuration to copy the stage active flags from.
|
||||||
|
*/
|
||||||
|
public void copyStageActiveness(FlightConfiguration other) {
|
||||||
|
for (StageFlags flags : this.stages.values()) {
|
||||||
|
StageFlags otherFlags = other.stages.get(flags.stageNumber);
|
||||||
|
if (otherFlags != null) {
|
||||||
|
flags.active = otherFlags.active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateMotors();
|
||||||
|
updateActiveInstances();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method flags a stage inactive. Other stages are unaffected.
|
* This method flags a stage inactive. Other stages are unaffected.
|
||||||
@ -831,6 +846,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
// Note the stages are updated in the constructor call.
|
// Note the stages are updated in the constructor call.
|
||||||
FlightConfiguration clone = new FlightConfiguration( this.rocket, this.fcid );
|
FlightConfiguration clone = new FlightConfiguration( this.rocket, this.fcid );
|
||||||
clone.setName(configurationName);
|
clone.setName(configurationName);
|
||||||
|
clone.copyStageActiveness(this);
|
||||||
clone.preloadStageActiveness = this.preloadStageActiveness == null ? null : new HashMap<>(this.preloadStageActiveness);
|
clone.preloadStageActiveness = this.preloadStageActiveness == null ? null : new HashMap<>(this.preloadStageActiveness);
|
||||||
|
|
||||||
clone.cachedBoundsAerodynamic = this.cachedBoundsAerodynamic.clone();
|
clone.cachedBoundsAerodynamic = this.cachedBoundsAerodynamic.clone();
|
||||||
@ -851,7 +867,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
@Override
|
@Override
|
||||||
public FlightConfiguration copy( final FlightConfigurationId newId ) {
|
public FlightConfiguration copy( final FlightConfigurationId newId ) {
|
||||||
// Note the stages are updated in the constructor call.
|
// Note the stages are updated in the constructor call.
|
||||||
FlightConfiguration copy= new FlightConfiguration( this.rocket, newId );
|
FlightConfiguration copy = new FlightConfiguration( this.rocket, newId );
|
||||||
final FlightConfigurationId copyId = copy.getId();
|
final FlightConfigurationId copyId = copy.getId();
|
||||||
|
|
||||||
// copy motor instances.
|
// copy motor instances.
|
||||||
@ -861,6 +877,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
cloneMotor.getMount().setMotorConfig(cloneMotor, copyId);
|
cloneMotor.getMount().setMotorConfig(cloneMotor, copyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copy.copyStages(this);
|
||||||
copy.preloadStageActiveness = this.preloadStageActiveness == null ? null : new HashMap<>(this.preloadStageActiveness);
|
copy.preloadStageActiveness = this.preloadStageActiveness == null ? null : new HashMap<>(this.preloadStageActiveness);
|
||||||
copy.cachedBoundsAerodynamic = this.cachedBoundsAerodynamic.clone();
|
copy.cachedBoundsAerodynamic = this.cachedBoundsAerodynamic.clone();
|
||||||
copy.cachedBounds = this.cachedBounds.clone();
|
copy.cachedBounds = this.cachedBounds.clone();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user