Esempio n. 1
0
        public Program()

        {
            // It's recommended to set RuntimeInfo.UpdateFrequency
            // Replace the Echo
            Echo = this.EchoToLCD;

            // Fetch a log text panel
            this._logOutput = GridTerminalSystem.GetBlockWithName("Airlock LCD") as IMyTextPanel;

            this.innerDoors = new List <IMyTerminalBlock>();
            this.outerDoors = new List <IMyTerminalBlock>();

            this.innerDoorLights = new List <IMyTerminalBlock>();
            this.outerDoorLights = new List <IMyTerminalBlock>();

            //this.mainVent = GridTerminalSystem.GetBlockWithName("Airlock Air Vent Main") as IMyAirVent;
            this.purgeVent = GridTerminalSystem.GetBlockWithName("Airlock Air Vent Purge") as IMyAirVent;

            GridTerminalSystem.SearchBlocksOfName("Airlock Inner Door", this.innerDoors, door => door is IMyDoor);
            GridTerminalSystem.SearchBlocksOfName("Airlock Outer Door", this.outerDoors, door => door is IMyAirtightHangarDoor);

            GridTerminalSystem.SearchBlocksOfName("Airlock Inner Door Light", this.innerDoorLights, door => door is IMyInteriorLight);
            GridTerminalSystem.SearchBlocksOfName("Airlock Outer Door Light", this.outerDoorLights, door => door is IMyInteriorLight);

            this.airlockState  = AirlockState.Unknown;
            this.buttonPressed = ButtonPressed.Unknown;
            //Echo(innerDoors.Count.ToString());

            var x = this.purgeVent.CanPressurize;
        }
            internal void setAirlockState(AirlockState state, bool setOpenState = true)
            {
                switch (state)
                {
                case AirlockState.OPEN:
                    setInnerDoorStates(true, true, setOpenState);
                    setOuterDoorStates(true, true, setOpenState);
                    setVents(false);
                    break;

                case AirlockState.CLOSED:
                    setInnerDoorStates(true, false, setOpenState);
                    setOuterDoorStates(true, false, setOpenState);
                    setVents(true);
                    break;

                case AirlockState.INNER:
                    setInnerDoorStates(true, true, setOpenState);
                    setOuterDoorStates(true, false, setOpenState);
                    setVents(false);
                    break;

                case AirlockState.OUTER:
                    setInnerDoorStates(true, false, setOpenState);
                    setOuterDoorStates(true, true, setOpenState);
                    setVents(true);
                    break;
                }
            }
Esempio n. 3
0
    private IEnumerator OpenDoorOut(float start)
    {
        yield return(new WaitForSeconds(start));

        state = AirlockState.Decompressed;
        doorOut.GetComponent <SettlementDoor>().Animate("open");
        environment.GetComponent <EnvironmentSound>().PlayAmbientSound();
    }
Esempio n. 4
0
        void DepresurizeAirlock()
        {
            this.airlockState = AirlockState.Emptying;

            this.ControlInnerDoors(false);
            this.ControlOuterDoors(false);

            //this.mainVent.ApplyAction("OnOff_Off");
            this.purgeVent.ApplyAction("Depressurize_On");
            this.purgeVent.ApplyAction("OnOff_On");
        }
            internal void tick(float atmo, double tankFill)
            {
                foreach (IMyTextPanel scr in displays)
                {
                    scr.WritePublicText("");                     //clear
                }

                if (atmo < MAX_ATMOSPHERE)
                {
                    show("No external atmosphere present.");

                    if (atmoLastTick > atmo)                       //accidentally left outside doors open? But only want to fire this once, not continuously, or it keeps closing airlocks
                    {
                        setAirlockState(AirlockState.CLOSED);
                    }

                    if (isDepressurized())
                    {
                        show("Airlock '" + airlockID + "' is depressurized.");
                    }
                    else if (isBreached())
                    {
                        show("Airlock '" + airlockID + "' is breached!");
                        setAirlockState(AirlockState.CLOSED);
                    }
                    else
                    {
                        show("Airlock '" + airlockID + "' is pressurized.");
                    }

                    AirlockState s = getCurrentAirlockState();
                    setAirlockState(s, false);
                    if (s != AirlockState.CLOSED && s != AirlockState.OPEN)
                    {
                        preventAccidentalOpen(s);
                    }

                    if (atmo < MAX_ATMOSPHERE && getAtmo() > 0.02 && !(allowOpenIfNoO2Space && isDepressurized() && tankFill > 0.99))
                    {
                        setOuterDoorStates(false, false);
                    }

                    show("Airlock '" + airlockID + "' is " + s + ".");
                }
                else
                {
                    show("Usable external atmosphere present.");
                    setAirlockState(AirlockState.OPEN);                     //fresh air
                    show("All airlocks fully open.");
                }

                atmoLastTick = atmo;
            }
Esempio n. 6
0
            internal AirlockState tick(float atmo, double tankFill)
            {
                AirlockState?ret = null;

                if (atmo < MAX_ATMOSPHERE)
                {
                    float air = getAtmo();

                    if (atmoLastTick > atmo)                       //accidentally left outside doors open? But only want to fire this once, not continuously, or it keeps closing airlocks
                    {
                        setAirlockState(AirlockState.CLOSED, false, air);
                    }

                    if (isDepressurized())
                    {
                        //show("Airlock '"+airlockID+"' is depressurized.");
                    }
                    else if (isBreached())
                    {
                        caller.Echo("Airlock '" + airlockID + "' is breached!");
                        setAirlockState(AirlockState.CLOSED, false, air);
                    }
                    else
                    {
                        //show("Airlock '"+airlockID+"' is pressurized.");
                    }

                    AirlockState s = getCurrentAirlockState();
                    setAirlockState(s, false, air, false);
                    if (s != AirlockState.CLOSED && s != AirlockState.OPEN)
                    {
                        preventAccidentalOpen(s);
                    }

                    if (atmo < MAX_ATMOSPHERE && air > 0.02 && !(allowOpenIfNoO2Space && isDepressurized() && tankFill > 0.99))
                    {
                        setDoorStates(outerDoors, false, false);
                    }

                    caller.Echo("Airlock '" + airlockID + "' is " + s + ".");

                    ret = s;
                }
                else
                {
                    setAirlockState(AirlockState.OPEN, true, atmo);                     //fresh air
                    ret = AirlockState.OPEN;
                }

                atmoLastTick = atmo;
                return(ret.Value);
            }
Esempio n. 7
0
 internal void preventAccidentalOpen(AirlockState s)
 {
     if (s == AirlockState.INNER)
     {
         setDoorStates(outerDoors, false, false);
         //setInnerDoorStates(true, true);
     }
     else if (s == AirlockState.OUTER)
     {
         setDoorStates(innerDoors, false, false);
         //setOuterDoorStates(true, true);
     }
 }
Esempio n. 8
0
        public void Main()           //called each cycle
        {
            float  f  = getExternalAtmo();
            double f2 = getTankFill();
            List <MySpriteDrawFrame> li = new List <MySpriteDrawFrame>();

            foreach (IMyTextPanel scr in displays)
            {
                li.Add(prepareScreen(scr));
            }
            float dy = 0;

            foreach (Airlock a in airlocks.Values)
            {
                AirlockState s    = a.tick(f, f2);
                string       name = s.ToString().ToUpperInvariant()[0] + s.ToString().Substring(1).ToLowerInvariant();
                Color?       c    = null;
                switch (s)
                {
                case AirlockState.CLOSED:
                    c = BLUE;
                    break;

                case AirlockState.INNER:
                    c = YELLOW;
                    break;

                case AirlockState.OUTER:
                    c = YELLOW;
                    break;

                case AirlockState.OPEN:
                    c = GREEN;
                    break;
                }
                if (s != AirlockState.OPEN && s != AirlockState.OUTER && a.isBreached())
                {
                    name = "breached!";
                    c    = RED;
                }
                string sg = "Airlock " + a.airlockID + " is " + name;
                drawText(li, edgePadding, dy, sg, c);
                dy += lineSize;
            }

            foreach (MySpriteDrawFrame frame in li)
            {
                frame.Dispose();
            }
        }
Esempio n. 9
0
    public bool AssignMembersFromAirVent(IMyAirVent newVent, ShipSystems shipSystems)
    {
        this.airVent = newVent;

        string desiredStateString = GetKeyValue(newVent.CustomData, "AirlockController.DesiredState");

        if (desiredStateString == null)
        {
            return(false);  // State string wasn't found.
        }
        this.desiredState = getStateFromString(desiredStateString);

        string airSideDoorName = GetKeyValue(newVent.CustomData, "AirlockController.AirSideDoorName");

        if (airSideDoorName == null)
        {
            return(false);
        }
        for (int i = 0; i < shipSystems.doors.Count; ++i)
        {
            if (shipSystems.doors[i].CustomName == airSideDoorName)
            {
                this.airSideDoor = shipSystems.doors[i];
            }
        }
        if (this.airSideDoor == null)
        {
            return(false);  // Specified door wasn't found.
        }
        string spaceSideDoorName = GetKeyValue(newVent.CustomData, "AirlockController.SpaceSideDoorName");

        if (spaceSideDoorName == null)
        {
            return(false);
        }
        for (int i = 0; i < shipSystems.doors.Count; ++i)
        {
            if (shipSystems.doors[i].CustomName == spaceSideDoorName)
            {
                this.spaceSideDoor = shipSystems.doors[i];
            }
        }
        if (this.spaceSideDoor == null)
        {
            return(false);  // Specified door wasn't found.
        }
        return(true);
    }
Esempio n. 10
0
    private IEnumerator DecompressAirlock()
    {
        float start;

        if (!doorIn.GetComponent <SettlementDoor>().isOpened)
        {
            start = 0;
        }
        else
        {
            start = 2.5f;
        }
        yield return(new WaitForSeconds(start));

        state = AirlockState.Decompressing;
        StartCoroutine(PlaySound(soundStartTime));
        StartCoroutine(LightDecompressing(greenLightStartTime));
        StartCoroutine(ActivateSmoke(smokeStartTime));
        StartCoroutine(LightDecompressed(redLightStartTime));
        StartCoroutine(OpenDoorOut(openDoorStartTime));
    }
Esempio n. 11
0
            internal void setAirlockState(AirlockState state, bool externalAtmo, float airLevel, bool setOpenState = true)
            {
                switch (state)
                {
                case AirlockState.OPEN:
                    setDoorStates(innerDoors, true, true, setOpenState);
                    setDoorStates(outerDoors, true, true, setOpenState);
                    setVents(externalAtmo);
                    if (externalAtmo)
                    {
                        setLightState(false);
                    }
                    else
                    {
                        setLightState(true, RED, 1);
                    }
                    break;

                case AirlockState.CLOSED:
                    setDoorStates(innerDoors, true, false, setOpenState);
                    setDoorStates(outerDoors, true, false, setOpenState);
                    setVents(true);
                    setLightState(true, Color.Lerp(YELLOW, GREEN, 1 - airLevel));
                    break;

                case AirlockState.INNER:
                    setDoorStates(innerDoors, true, true, setOpenState);
                    setDoorStates(outerDoors, true, false, setOpenState);
                    setVents(false);
                    setLightState(true, RED);
                    break;

                case AirlockState.OUTER:
                    setDoorStates(innerDoors, true, false, setOpenState);
                    setDoorStates(outerDoors, true, true, setOpenState);
                    setVents(true);
                    setLightState(true, RED);
                    break;
                }
            }
Esempio n. 12
0
        public void Main(string argument, UpdateType updateSource)

        {
            // The main entry point of the script, invoked every time
            // one of the programmable block's Run actions are invoked,
            // or the script updates itself. The updateSource argument
            // describes where the update came from.
            //
            // The method itself is required, but the arguments above
            // can be removed if not needed.

            if (argument == string.Empty)
            {
                return;
            }

            switch (argument)
            {
            case "InnerIn":
            {
                this.buttonPressed = ButtonPressed.InnerIn;
                if (this.airlockState == AirlockState.Full)
                {
                    this.ControlInnerDoors(true);
                }
                else
                {
                    this.PresurizeAirlock();
                }

                break;
            }

            case "InnerOut":
            {
                this.buttonPressed = ButtonPressed.InnerOut;
                if (this.airlockState == AirlockState.Full)
                {
                    this.ControlInnerDoors(true);
                }
                else
                {
                    this.PresurizeAirlock();
                }

                break;
            }

            case "OuterIn":
            {
                this.buttonPressed = ButtonPressed.OuterIn;
                Echo($"OuterIn: {this.airlockState}");

                if (this.airlockState == AirlockState.Empty)
                {
                    this.ControlOuterDoors(true);
                }
                else
                {
                    this.DepresurizeAirlock();
                }

                break;
            }

            case "OuterOut":
            {
                Echo("OuterOut");

                this.buttonPressed = ButtonPressed.OuterOut;
                if (this.airlockState == AirlockState.Empty)
                {
                    this.ControlOuterDoors(true);
                }
                else
                {
                    this.DepresurizeAirlock();
                }

                break;
            }

            case "AirPurgeFull":
            {
                this.airlockState = AirlockState.Full;
                if (this.buttonPressed == ButtonPressed.InnerOut || this.buttonPressed == ButtonPressed.InnerIn)
                {
                    this.ControlInnerDoors(true);
                }

                break;
            }

            case "AirPurgeEmpty":
            {
                this.airlockState = AirlockState.Empty;
                if (this.buttonPressed == ButtonPressed.OuterOut || this.buttonPressed == ButtonPressed.OuterIn)
                {
                    Echo("Open-1");
                    this.ControlOuterDoors(true);
                }

                break;
            }

            default:
            {
                Echo($"Unknown command: {argument}");
                break;
            }
            }
        }
Esempio n. 13
0
 void Start()
 {
     audioSource = GetComponent <AudioSource>();
     state       = AirlockState.Ambient;
 }