public RemoveAttachedParts ( HashSet |
||
partSims | HashSet |
|
Résultat | void |
// This function activates the next stage // currentStage must be updated before calling this function private void ActivateStage() { // Build a set of all the parts that will be decoupled decoupledParts.Clear(); for (int i = 0; i < this.allParts.Count; i++) { PartSim partSim = this.allParts[i]; if (partSim.decoupledInStage >= this.currentStage) { decoupledParts.Add(partSim); } } foreach (PartSim partSim in decoupledParts) { // Remove it from the all parts list this.allParts.Remove(partSim); partSim.Release(); if (partSim.isEngine) { // If it is an engine then loop through all the engine modules and remove all the ones from this engine part for (int i = this.allEngines.Count - 1; i >= 0; i--) { EngineSim engine = this.allEngines[i]; if (engine.partSim == partSim) { this.allEngines.RemoveAt(i); engine.Release(); } } } // If it is a fuel line then remove it from the list of all fuel lines if (partSim.isFuelLine) { this.allFuelLines.Remove(partSim); } } // Loop through all the (remaining) parts for (int i = 0; i < this.allParts.Count; i++) { PartSim partSim = this.allParts[i]; // Ask the part to remove all the parts that are decoupled partSim.RemoveAttachedParts(decoupledParts); } // Now we loop through all the engines and activate those that are ignited in this stage for (int i = 0; i < this.allEngines.Count; i++) { EngineSim engine = this.allEngines[i]; if (engine.partSim.inverseStage == this.currentStage) { engine.isActive = true; } } }