Disable stage when parent stage is inactive
This commit is contained in:
parent
88e343a30c
commit
4d1e6165a8
@ -193,6 +193,10 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
public void _setStageActive(final int stageNumber, final boolean _active ) {
|
||||
if ((0 <= stageNumber) && (stages.containsKey(stageNumber))) {
|
||||
stages.get(stageNumber).active = _active;
|
||||
// Set the active state of all the sub-stages as well.
|
||||
for (AxialStage stage : rocket.getStage(stageNumber).getSubStages()) {
|
||||
stages.get(stage.getStageNumber()).active = _active;
|
||||
}
|
||||
fireChangeEvent();
|
||||
return;
|
||||
}
|
||||
@ -204,6 +208,10 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
if ((0 <= stageNumber) && (stages.containsKey(stageNumber))) {
|
||||
StageFlags flags = stages.get(stageNumber);
|
||||
flags.active = !flags.active;
|
||||
// Set the active state of all the sub-stages as well.
|
||||
for (AxialStage stage : rocket.getStage(stageNumber).getSubStages()) {
|
||||
stages.get(stage.getStageNumber()).active = flags.active;
|
||||
}
|
||||
updateMotors();
|
||||
updateActiveInstances();
|
||||
|
||||
|
@ -1749,6 +1749,21 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
}
|
||||
throw new IllegalStateException("getStage() called on hierarchy without an AxialStage.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the stages that are a child or sub-child of this component.
|
||||
* @return all the stages that are a child or sub-child of this component.
|
||||
*/
|
||||
public final List<AxialStage> getSubStages() {
|
||||
List<AxialStage> result = new LinkedList<>();
|
||||
Iterator<RocketComponent> it = iterator(false);
|
||||
while (it.hasNext()) {
|
||||
RocketComponent c = it.next();
|
||||
if (c instanceof AxialStage)
|
||||
result.add((AxialStage) c);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the first component assembly component that this component belongs to.
|
||||
|
Loading…
x
Reference in New Issue
Block a user