private void UnlockDoors(CycleModifiers modifiers, IEnumerable <IMyDoor> Doors) { var doorsToOpen = new HashSet <IMyDoor>(); if (modifiers.AutoOpen != null) { foreach (var tag in modifiers.AutoOpen) { foreach (var door in Doors.Where(x => x.CustomName.Contains(tag))) { doorsToOpen.Add(door); } } } foreach (var door in Doors) { door.Enabled = true; if (modifiers.AutoOpenAll && doorsToOpen.Count < 1) { door.OpenDoor(); } } foreach (var door in doorsToOpen) { door.OpenDoor(); } }
public void CycleOut(CycleModifiers modifiers) { if (State == AirlockStates.Depressurized || State == AirlockStates.Depressurizing) { return; } SwitchProcedure(ProcedureDepressurize(modifiers)); }
private IEnumerator <bool> ProcedurePressurize(CycleModifiers modifiers) { State = AirlockStates.Pressurizing; // Signal Warning UpdateLights(); // Wait for Presserize Warning Time if (!modifiers.SkipWaitTime) { var startTime = DateTime.Now; int timeRemaining; while ((timeRemaining = PressurizeWarningTime - (DateTime.Now - startTime).Seconds) > 0) { lcdOutput.AppendLine("Warning\nAirlock Will\nPressurize"); lcdOutput.Append(timeRemaining.ToString()).AppendLine(" seconds"); if (timeRemaining <= 5) { lcdOutput.AppendLine("Stand Clear\nof Doors"); } yield return(true); } } // Close and Lock all doors foreach (var door in AllDoors) { door.CloseDoor(); } yield return(true); while (AllDoors.Any(door => door.Status != DoorStatus.Closed)) { lcdOutput.AppendLine("Warning\nClosing Doors\nStand Clear"); yield return(true); } foreach (var door in AllDoors) { door.Enabled = false; } yield return(true); // Pressurize Airlock foreach (var vent in MainVents) { vent.Depressurize = false; } while (MainVents.Any(vent => vent.GetOxygenLevel() < 1F)) { lcdOutput.AppendLine("Warning\nPressurizing"); lcdOutput.AppendLine($"{(int)(PrimaryVent.GetOxygenLevel() * 100)}%"); yield return(true); } State = AirlockStates.Pressurized; // Turn Alarms Off UpdateLights(); // Update Lights and Displays UnlockDoors(modifiers, InternalDoors); // TODO: Finish Implementing PresserizeProcedure yield return(false); }
public void CycleToggle(CycleModifiers modifiers = default(CycleModifiers)) { switch (State) { case AirlockStates.Pressurized: case AirlockStates.Pressurizing: CycleOut(modifiers); break; default: CycleIn(modifiers); break; } }