Ejemplo n.º 1
0
            private void Staging(ActionMachine action)
            {
                bool state = true;

                switch (action)
                {
                case ActionMachine.Open:
                    state = true;
                    doors.ForEach(delegate(IMyDoor block) {
                        block.OpenDoor();
                        if (block.OpenRatio < 1 - Epsilon)
                        {
                            state = false;
                        }
                    });
                    if (state)
                    {
                        Stage++;
                        openned = true;
                    }
                    break;

                case ActionMachine.OpenInt:
                    state = true;
                    doors.ForEach(delegate(IMyDoor block) {
                        if (block.CustomName.ToLower().Contains("int"))
                        {
                            block.OpenDoor();
                            if (block.OpenRatio < 1 - Epsilon)
                            {
                                state = false;
                            }
                        }
                    });
                    if (state)
                    {
                        Stage++;
                        openned = true;
                    }
                    break;

                case ActionMachine.OpenExt:
                    state = true;
                    doors.ForEach(delegate(IMyDoor block) {
                        if (block.CustomName.ToLower().Contains("ext"))
                        {
                            block.OpenDoor();
                            if (block.OpenRatio < 1 - Epsilon)
                            {
                                state = false;
                            }
                        }
                    });
                    if (state)
                    {
                        Stage++;
                        openned = true;
                    }
                    break;

                case ActionMachine.Close:
                    state = true;
                    doors.ForEach(delegate(IMyDoor block) {
                        block.CloseDoor();
                        if (block.OpenRatio > 0 + Epsilon)
                        {
                            state = false;
                        }
                    });
                    if (state)
                    {
                        Stage++;
                        openned = false;
                    }
                    break;

                case ActionMachine.CloseInt:
                    state = true;
                    doors.ForEach(delegate(IMyDoor block) {
                        if (block.CustomName.ToLower().Contains("int"))
                        {
                            block.CloseDoor();
                            if (block.OpenRatio > 0 + Epsilon)
                            {
                                state = false;
                            }
                        }
                    });
                    if (state)
                    {
                        Stage++;
                        openned = false;
                    }
                    break;

                case ActionMachine.CloseExt:
                    state = true;
                    doors.ForEach(delegate(IMyDoor block) {
                        if (block.CustomName.ToLower().Contains("ext"))
                        {
                            block.CloseDoor();
                            if (block.OpenRatio > 0 + Epsilon)
                            {
                                state = false;
                            }
                        }
                    });
                    if (state)
                    {
                        Stage++;
                        openned = false;
                    }
                    break;

                case ActionMachine.Lock:
                    doors.ForEach(delegate(IMyDoor block) {
                        block.ApplyAction("OnOff_Off");
                    });
                    Stage++;
                    break;

                case ActionMachine.LockInt:
                    doors.ForEach(delegate(IMyDoor block) {
                        if (block.CustomName.ToLower().Contains("int"))
                        {
                            block.ApplyAction("OnOff_Off");
                        }
                    });
                    Stage++;
                    break;

                case ActionMachine.LockExt:
                    doors.ForEach(delegate(IMyDoor block) {
                        if (block.CustomName.ToLower().Contains("ext"))
                        {
                            block.ApplyAction("OnOff_Off");
                        }
                    });
                    Stage++;
                    break;

                case ActionMachine.Unlock:
                    doors.ForEach(delegate(IMyDoor block) {
                        block.ApplyAction("OnOff_On");
                    });
                    Stage++;
                    break;

                case ActionMachine.UnlockInt:
                    doors.ForEach(delegate(IMyDoor block) {
                        if (block.CustomName.ToLower().Contains("int"))
                        {
                            block.ApplyAction("OnOff_On");
                        }
                    });
                    Stage++;
                    break;

                case ActionMachine.UnlockExt:
                    doors.ForEach(delegate(IMyDoor block) {
                        if (block.CustomName.ToLower().Contains("ext"))
                        {
                            block.ApplyAction("OnOff_On");
                        }
                    });
                    Stage++;
                    break;

                case ActionMachine.Pressure:
                    airvent.ApplyAction("Depressurize_Off");
                    state = true;
                    airvent.ForEach(delegate(IMyAirVent block) {
                        VentStatus status = block.Status;
                        if (block.GetOxygenLevel() < 1 - Epsilon)
                        {
                            state = false;
                        }
                        WriteText($"Status:{status}", true);
                        WriteText($"Pressure:{block.GetOxygenLevel() * 100}", true);
                    });
                    if (state)
                    {
                        Stage++;
                    }
                    break;

                case ActionMachine.Depressure:
                    airvent.ApplyAction("Depressurize_On");
                    state = true;
                    airvent.ForEach(delegate(IMyAirVent block) {
                        VentStatus status = block.Status;
                        if (block.GetOxygenLevel() > 0 + Epsilon)
                        {
                            state = false;
                        }
                        WriteText($"Status:{status}", true);
                        WriteText($"Pressure:{block.GetOxygenLevel() * 100}", true);
                    });
                    if (state)
                    {
                        Stage++;
                    }
                    break;

                case ActionMachine.Sleep:
                    Sleep--;
                    WriteText($"Sleep:{Sleep}", true);
                    if (Sleep <= 0)
                    {
                        Stage++;
                    }
                    break;

                case ActionMachine.SleepInit:
                    Sleep = program.MyProperty.timer;
                    Stage++;
                    break;

                case ActionMachine.Start:
                    State = StateMachine.Running;
                    Stage++;
                    break;

                case ActionMachine.Stop:
                    State = StateMachine.Stop;
                    Sleep = 0;
                    Stage++;
                    break;

                case ActionMachine.Terminated:
                    Stage++;
                    break;

                case ActionMachine.TerminatedInt:
                    Stage++;
                    break;

                case ActionMachine.TerminatedExt:
                    Stage++;
                    break;
                }
            }