예제 #1
0
            private IEnumerator <bool> DetectCurrentState()
            {
                var cycleModifiers = default(CycleModifiers);

                cycleModifiers.SkipWaitTime = true;
                if (!PrimaryVent.CanPressurize || PrimaryVent.GetOxygenLevel() == 0)
                {
                    State = AirlockStates.Depressurized;
                    return(ProcedureMonitor());
                }
                if (PrimaryVent.GetOxygenLevel() > 0 && PrimaryVent.Depressurize)
                {
                    return(ProcedureDepressurize(cycleModifiers));
                }
                if (PrimaryVent.GetOxygenLevel() < 1F && !PrimaryVent.Depressurize)
                {
                    return(ProcedurePressurize(cycleModifiers));
                }
                if (PrimaryVent.GetOxygenLevel() == 1F && !PrimaryVent.Depressurize)
                {
                    State = AirlockStates.Pressurized;
                    return(ProcedureMonitor());
                }
                return(ProcedureMonitor());
            }
예제 #2
0
            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);
            }
예제 #3
0
 private void Initialize()
 {
     State             = AirlockStates.Initializing;
     BlockGroup        = TheProgram.GridTerminalSystem.GetBlockGroupWithName(AirlockId);
     CurrentBlockCount = CountTheBlocks();
     if (BlockGroup == null)
     {
         State = AirlockStates.BlockGroupNotFound;
         return;
     }
     _lazy_cache.Clear();
     foreach (var panel in AllTextPanels)
     {
         panel.ShowPublicTextOnScreen();
         panel.FontSize = 2.5F;
     }
     CurrentConfig    = PrimaryVent.CustomData;
     CurrentProcedure = DetectCurrentState();
 }