public Func <bool> waitForPressure(IMyAirVent vent, bool pressurizing)
    {
        Func <bool> maxWait = waitForTicks(pressurizing ? MAX_WAIT_PRESSURIZING : MAX_WAIT_DEPRESSURIZING);

        return(() =>
        {
            double ox = vent.GetOxygenLevel();
            if (maxWait())
            {
                c_log((pressurizing ? "" : "de") + "pressurization_wait_timout (" + (ox * 100) + "% oxygen lost)");
                return true;
            }
            if (pressurizing)
            {
                if (ox >= 0.95)
                {
                    return true;
                }
            }
            else
            {
                if (ox <= 0.0001)
                {
                    return true;
                }
            }
            return false;
        });
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: Davidj361/airlocksystem
        private IEnumerable <bool> ExternalOpenAirlock(List <IMyTerminalBlock> vents, List <IMyTerminalBlock> inDoors, List <IMyTerminalBlock> outDoors)
        {
            IMyAirVent firstVent = vents.First() as IMyAirVent;

            if (firstVent.Enabled)
            {
                foreach (var step in CloseDoors(inDoors))
                {
                    yield return(step);
                }
                foreach (var step in MyWait(0.5))
                {
                    yield return(step);
                }
                foreach (IMyAirVent vent in vents)
                {
                    vent.Enabled = false;
                }
                foreach (var step in MyWait(0.5))
                {
                    yield return(step);
                }
                foreach (var step in OpenDoors(outDoors))
                {
                    yield return(step);
                }
            }
        }
コード例 #3
0
        public void Update()
        {
            if (status == Status.DRAW) // if the path to air leak is shown then decrease the countdown timer or clear it directly if the grid suddenly vanishes.
            {
                if (--drawTicks <= 0 || selectedGrid.Closed)
                {
                    ClearStatus();
                }
            }

            if (status == Status.RUNNING) // notify the player that a background task is running.
            {
                NotifyHUD("Computing path...", 100, MyFontEnum.Blue);
            }

            if (++skipUpdates > 30) // every half a second, update the custom detail info on the currently selected air vent in the terminal.
            {
                skipUpdates = 0;

                if (viewedVentControlPanel != null)
                {
                    if (viewedVentControlPanel.Closed || MyAPIGateway.Gui.ActiveGamePlayScreen == null)
                    {
                        viewedVentControlPanel = null;
                    }
                    else
                    {
                        viewedVentControlPanel.RefreshCustomInfo();
                    }
                }
            }
        }
コード例 #4
0
        bool isPressurizationOn()
        {
            if (!bAVInit)
            {
                airventInit();
            }
            if (airventList.Count < 1) // no air vents to check
            {
                return(false);
            }
            IMyAirVent av = airventList[0] as IMyAirVent;

            if (av == null)
            {
                return(false);
            }
            return(av.PressurizationEnabled);

            /*
             * pre 1.185
             * if (airventList[0].DetailedInfo.Contains("Oxygen disabled in world settings"))
             * {
             *  return false;
             * }
             * return true;
             */
        }
コード例 #5
0
ファイル: Airlock.cs プロジェクト: VMSBigot/SEScripts
        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;
        }
コード例 #6
0
            /// <summary>
            /// Returns the average oxygen level reported by all enabled vents.
            /// </summary>
            public float AreaOxygenLevel()
            {
                float o2LevelSum = 0;
                float ventCount  = 0;

                if (area == null)
                {
                    ReportItem("Area is null. Ensure controller has a valid area and recompile.", StatusReport.Type.ERROR);
                    return(-1f);
                }

                for (int i = 0; i < area.SourceAirVentCount; i++)
                {
                    IMyAirVent sourceAirVent = area.SourceAirVent(i);

                    if (ValidateO2Level(sourceAirVent))
                    {
                        o2LevelSum += sourceAirVent.GetOxygenLevel();
                        ventCount  += 1;
                    }
                }

                for (int i = 0; i < area.StorageAirVentCount; i++)
                {
                    IMyAirVent storageAirVent = area.StorageAirVent(i);

                    if (ValidateO2Level(storageAirVent))
                    {
                        o2LevelSum += storageAirVent.GetOxygenLevel();
                        ventCount  += 1;
                    }
                }

                return(o2LevelSum / ventCount);
            }
コード例 #7
0
    protected void LoadAirlock(string baseName)
    {
        string ventName    = String.Format("Air Vent ({0} Airlock)", baseName);
        string intDoorName = String.Format("Airlock Door: Int. ({0})", baseName);
        string extDoorName = String.Format("Airlock Door: Ext. ({0})", baseName);

        vent    = (IMyAirVent)GridTerminalSystem.GetBlockWithName(ventName);
        intDoor = (IMyDoor)GridTerminalSystem.GetBlockWithName(intDoorName);
        extDoor = (IMyDoor)GridTerminalSystem.GetBlockWithName(extDoorName);

        if (vent == null)
        {
            throw new Exception("Missing airvent: " + ventName);
        }
        if (intDoor == null)
        {
            throw new Exception("Missing int. door: " + intDoorName);
        }
        if (extDoor == null)
        {
            throw new Exception("Missing ext. door: " + extDoorName);
        }

        intClosed = intDoor.OpenRatio == 0f;
        intOpened = intDoor.OpenRatio == 1f;
        extClosed = extDoor.OpenRatio == 0f;
        extOpened = extDoor.OpenRatio == 1f;

        ventLevel = vent.GetOxygenLevel();
        evacDone  = ventLevel < 0.00001;
        presDone  = ventLevel > 0.99;
    }
コード例 #8
0
 public override void Init(MyObjectBuilder_EntityBase objectBuilder)
 {
     if (MyAPIGateway.Session.IsServer)
     {
         vent        = Entity as IMyAirVent;
         NeedsUpdate = MyEntityUpdateEnum.EACH_100TH_FRAME;
     }
 }
コード例 #9
0
ファイル: Airlock.cs プロジェクト: fishykins/CAM
 public void AddVent(IMyAirVent vent)
 {
     airVents.Add(vent);
     if (primaryVent == null)
     {
         primaryVent = vent;
     }
 }
コード例 #10
0
            public AirLock(IMyBlockGroup airLockGroup)
            {
                if (airLockGroup == null)
                {
                    throw new ArgumentNullException("airLockGroup cannot be null");
                }

                _InsideDoor  = ParseFromGroup <IMyDoor>(airLockGroup, "In");
                _OutsideDoor = ParseFromGroup <IMyDoor>(airLockGroup, "Out");
                _AirVent     = ParseFromGroup <IMyAirVent>(airLockGroup, "Vent");
            }
コード例 #11
0
            public VentInfo(IMyAirVent airVent, string description = "") : base(description)
            {
                Current = airVent.GetOxygenLevel();
                Max     = 1.0f;

                CanPressurize         = airVent.CanPressurize;
                Depressurize          = airVent.Depressurize;
                VentStatus            = airVent.Status;
                Pressurized           = (airVent.Status == VentStatus.Pressurized);
                Depressurized         = (airVent.Status == VentStatus.Depressurized);
                PressurizationEnabled = airVent.PressurizationEnabled;
            }
コード例 #12
0
 public AirlockConstruct(ISelector <IMyDoor> innerDoor, ISelector <IMyDoor> outerDoor, ISelector <IMyAirVent> vent)
 {
     _innerDoor         = innerDoor.GetBlock();
     _outerDoor         = outerDoor.GetBlock();
     _vent              = vent.GetBlock();
     _status            = _vent.Status;
     _enabled           = _vent.Enabled;
     CycleAction        = new ScriptableAction(() => Cycle());
     PressurizeAction   = new ScriptableAction(() => Cycle(true));
     DepressurizeAction = new ScriptableAction(() => Cycle(false));
     _triggers.Add(new IntervalTrigger(300).Then(new ScriptableAction(Update)));
 }
コード例 #13
0
            private void InitVent(IMyAirVent vent)
            {
                output.Print("Found airlock " + vent.CustomName);
                string[] data = vent.CustomData.Split(program.delimiterChars);
                if (data.Length >= 1)
                {
                    string airlockTag = data[0];

                    Airlock airlock = GetAirlock(airlockTag);
                    airlock.AddVent(vent);
                }
            }
コード例 #14
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);
    }
コード例 #15
0
        private VentStatus GetVentStatus(IMyAirVent vent)
        {
            if (vent.Status != VentStatus.Depressurizing) // don't trust depressurizing. It could be depressurized
            {
                return(vent.Status);
            }

            if (vent.GetOxygenLevel() < 0.01)
            {
                return(VentStatus.Depressurized);
            }
            else
            {
                return(VentStatus.Depressurizing);
            }
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: Davidj361/airlocksystem
        private IEnumerable <bool> ProcessAirlock(Airlock iter)
        {
            IMyAirVent firstVent = iter.airVents.First() as IMyAirVent;

            if (firstVent.Status == VentStatus.Depressurizing || firstVent.Status == VentStatus.Pressurizing)
            {
                yield return(true);
            }
            // Compare which side has the most people standing in
            int inCount  = 0;
            int outCount = 0;

            foreach (IMySensorBlock s in iter.inSensors)
            {
                List <MyDetectedEntityInfo> entities = new List <MyDetectedEntityInfo>();
                s.DetectedEntities(entities);
                inCount = entities.Count;
            }
            foreach (IMySensorBlock s in iter.outSensors)
            {
                List <MyDetectedEntityInfo> entities = new List <MyDetectedEntityInfo>();
                s.DetectedEntities(entities);
                outCount = entities.Count;
            }

            if (outCount == 0 && inCount == 0)
            {
                yield return(true);
            }
            else if (outCount > inCount)
            {
                foreach (var step in ExternalOpenAirlock(iter.airVents, iter.inDoors, iter.outDoors))
                {
                    yield return(step);
                }
            }
            else
            {
                foreach (var step in InternalOpenAirlock(iter.airVents, iter.inDoors, iter.outDoors))
                {
                    yield return(step);
                }
            }

            yield return(true);
        }
コード例 #17
0
        /// <summary>
        /// Clears the lines, various status data and gracefully stops the processing thread if running.
        /// </summary>
        public void ClearStatus()
        {
            if (status == Status.RUNNING) // gracefully cancel the task by telling it to stop doing stuff and then wait for it to finish so we can clear its data.
            {
                cancelTask = true;
                task.Wait();
            }

            status = Status.IDLE;
            lines.Clear();
            particles.Clear();
            stopSpawning = false;
            drawTicks    = 0;
            crumb        = null;
            selectedGrid = null;
            usedFromVent = null;
        }
コード例 #18
0
        public List <IMyAirVent> searchVents(string[] values)
        {
            List <IMyAirVent> vents = new List <IMyAirVent>();

            for (int i = 0; i < values.Length; i++)
            {
                IMyTerminalBlock block = this.gridTerminal.GetBlockWithName(values[i].Trim());
                if (block != null && block as IMyAirVent != null)
                {
                    IMyAirVent vent = block as IMyAirVent;
                    if (!vents.Contains(vent))
                    {
                        vents.Add(vent);
                    }
                }
            }
            return(vents);
        }
コード例 #19
0
 public Airlock(IMyGridTerminalSystem system, string name)
 {
     _name      = name;
     inDoor     = system.GetBlockWithName(name + "_Door_In") as IMyDoor;
     outDoor    = system.GetBlockWithName(name + "_Door_Out") as IMyDoor;
     light      = system.GetBlockWithName(name + "_Light") as IMyLightingBlock;
     vent       = system.GetBlockWithName(name + "_Vent") as IMyAirVent;
     inDisplay  = system.GetBlockWithName(name + "_Display_In") as IMyTextPanel;
     outDisplay = system.GetBlockWithName(name + "_Display_Out") as IMyTextPanel;
     if (inDoor == null || outDoor == null)
     {
         setStatus(S_ERR);
     }
     else
     {
         setStatus(S_SETUP);
         enabled = true;
     }
 }
コード例 #20
0
    private List <IMyAirVent> GetAirVents(IMyGridTerminalSystem gts, IMyCubeGrid desiredGrid)
    {
        List <IMyAirVent> ventList = new List <IMyAirVent>();

        List <IMyTerminalBlock> ventBlocks = new List <IMyTerminalBlock> {
        };

        gts.GetBlocksOfType <IMyAirVent>(ventBlocks);

        for (int i = 0; i < ventBlocks.Count; i++)
        {
            IMyAirVent currentVent = (IMyAirVent)ventBlocks[i];
            if (currentVent.CubeGrid != desiredGrid)
            {
                continue;  // Ignore doors not on this grid
            }
            ventList.Add(currentVent);
        }
        return(ventList);
    }
コード例 #21
0
            public void topOffBay(IMyAirVent vent)
            {
                if (!vent.CanPressurize)
                {
                    Echo("Hangar is not airtight");
                    return;
                }

                ITerminalAction action;

                if (vent.GetOxygenLevel() <= topOffThreshold)
                {
                    action            = vent.GetActionWithName("OnOff_On");
                    vent.Depressurize = false;
                }
                else
                {
                    action = vent.GetActionWithName("OnOff_Off");
                }
                action.Apply(vent);
            }
コード例 #22
0
        public Program()
        {
            LightList  = new List <IMyInteriorLight>();
            DoorList   = new List <IMyDoor>();
            SensorList = new List <IMySensorBlock>();

            IMyBlockGroup Lights = GridTerminalSystem.GetBlockGroupWithName("Airlock Lights");

            if (Lights == null)
            {
                Echo("Cannot find light group");
            }
            IMyBlockGroup Doors = GridTerminalSystem.GetBlockGroupWithName("Airlock Doors");

            if (Doors == null)
            {
                Echo("Cannot find door group");
            }
            IMyBlockGroup Sensors = GridTerminalSystem.GetBlockGroupWithName("Airlock Sensors");

            if (Sensors == null)
            {
                Echo("Cannot find sensor group");
            }

            Lights.GetBlocksOfType(LightList);
            Doors.GetBlocksOfType(DoorList);
            Sensors.GetBlocksOfType(SensorList);

            SpinningLight = GridTerminalSystem.GetBlockWithName("Airlock Rotating Light") as IMyReflectorLight;
            if (SpinningLight == null)
            {
                Echo("Cannot find spinning light");
            }
            Vent = GridTerminalSystem.GetBlockWithName("Airlock Vent") as IMyAirVent;
            if (Vent == null)
            {
                Echo("Cannot find air vent");
            }
        }
コード例 #23
0
            public AirManage()
            {
                hangarVents = GridTerminalSystem.GetBlockGroupWithName(hangarVentGroupName);
                topOffVent  = GridTerminalSystem.GetBlockWithName(hangarTopOffVentName) as IMyAirVent;
                hangarTanks = GridTerminalSystem.GetBlockGroupWithName(hangarTankGroupName);

                if (hangarVents == null)
                {
                    Echo("Hangar Vents group not found");
                    throw new ArgumentException("Cannot find Vent group: " + hangarVentGroupName);
                }
                if (topOffVent == null)
                {
                    Echo("Top off vent could not be found");
                    throw new ArgumentException("Cannot find Top Off Vent: " + hangarTopOffVentName);
                }
                if (hangarTanks == null)
                {
                    Echo("Hangar Oxygen Tank group could not be found");
                    throw new ArgumentException("Cannot find Tank group: " + hangarTankGroupName);
                }
            }
コード例 #24
0
 protected bool ValidateO2Level(IMyAirVent airVent)
 {
     if (airVent == null)
     {
         ReportItem("Source air vent is null. Can not report oxygen level.", StatusReport.Type.ERROR);
         return(false);
     }
     else if (!airVent.IsFunctional)
     {
         ReportItem("Source air vent nonfunctional. Can not report oxygen level.", StatusReport.Type.ERROR);
         return(false);
     }
     else if (!airVent.Enabled)
     {
         ReportItem("Source air vent disabled. Can not report oxygen level.", StatusReport.Type.ERROR);
         return(false);
     }
     else
     {
         return(true);
     }
 }
コード例 #25
0
        /// <summary>
        /// Check if the room is pressurized
        /// </summary>
        /// <param name="_data">The data for the airlock to look for</param>
        /// <returns></returns>
        private string Is_Under_Pressure(string _data)
        {
            IMyAirVent vent = null;

            string [] info = null;
            for (int i = 0; i < vents.Count; i++)
            {
                //  If a vent custom data matches passed data
                if (vents [i].CustomData == _data)
                {
                    vent = vents [i];
                    break;
                }
            }

            if (vent != null)
            {
                errorFLAG = 0;
                info      = vent.DetailedInfo.Split(':'); //  Detailed info sperated by ':'
            }

            return((info == null) ? ("Error") : (info [3]));             //  Return pressure data
        }
コード例 #26
0
ファイル: Program.cs プロジェクト: Davidj361/airlocksystem
        private IEnumerable <bool> InternalOpenAirlock(List <IMyTerminalBlock> vents, List <IMyTerminalBlock> inDoors, List <IMyTerminalBlock> outDoors)
        {
            IMyAirVent firstVent = vents.First() as IMyAirVent;

            if (!firstVent.Enabled)
            {
                foreach (var step in CloseDoors(outDoors))
                {
                    yield return(step);
                }
                foreach (var step in MyWait(0.5))
                {
                    yield return(step);
                }
                foreach (IMyAirVent vent in vents)
                {
                    vent.Enabled = true;
                }
                foreach (var step in MyWait(0.5))
                {
                    yield return(step);
                }
                while (firstVent.Status != VentStatus.Pressurized)
                {
                    yield return(true);
                }
                foreach (var step in MyWait(0.5))
                {
                    yield return(step);
                }
                foreach (var step in OpenDoors(inDoors))
                {
                    yield return(step);
                }
            }
        }
コード例 #27
0
            private void DrawAirventInfos(float posX, float posY, Color stateColor, bool isWorking, IMyAirVent airvent, out MySprite airventText, out MySprite divider, out MySprite statusTitle, out MySprite statusInfo, out MySprite oxygenTitle, out MySprite oxygenInfo, out MySprite pressurizeTitle, out MySprite pressurizeInfo)
            {
                string name = airvent.CustomName;

                if (name.Length > 17)
                {
                    name  = name.Substring(0, 14);
                    name += "...";
                }

                airventText          = MySprite.CreateText(name, "Debug", Constants.COLOR_WHITE, 0.8f, TextAlignment.LEFT);
                airventText.Position = new Vector2(posX - 83, posY - 25);

                Vector2 d_pos  = new Vector2(posX + 17, posY);
                Vector2 d_size = new Vector2(199, 2);

                divider       = MySprite.CreateSprite("SquareSimple", d_pos, d_size);
                divider.Color = Constants.COLOR_GREEN;

                statusTitle          = MySprite.CreateText("Status", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.LEFT);
                statusTitle.Position = new Vector2(posX - 116, posY + 2);

                string airventStatus = "";
                Color  textColor     = Constants.COLOR_WHITE;

                if (!airvent.IsFunctional)
                {
                    airventStatus = "BROKEN";
                    textColor     = Constants.COLOR_RED;
                }
                else if (!airvent.IsWorking)
                {
                    airventStatus = "NOT WORKING";
                    textColor     = Constants.COLOR_RED;
                }
                else if (!airvent.CanPressurize)
                {
                    airventStatus = "LEAK";
                    textColor     = Constants.COLOR_RED;
                }
                else
                {
                    airventStatus = "OPTIMAL";
                }

                statusInfo          = MySprite.CreateText(airventStatus, "Debug", textColor, 0.5f, TextAlignment.LEFT);
                statusInfo.Position = new Vector2(posX - 116, posY + 16);

                oxygenTitle          = MySprite.CreateText("Oxygen", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.CENTER);
                oxygenTitle.Position = new Vector2(posX, posY + 2);

                oxygenInfo          = MySprite.CreateText((airvent.GetOxygenLevel() * 100).ToString("0.0"), "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.CENTER);
                oxygenInfo.Position = new Vector2(posX, posY + 16);

                pressurizeTitle          = MySprite.CreateText("Action", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.RIGHT);
                pressurizeTitle.Position = new Vector2(posX + 116, posY + 2);

                string action = "";

                if (airvent.Depressurize)
                {
                    action = "Depressurizing";
                }
                else
                {
                    action = "Pressurizing";
                }
                pressurizeInfo          = MySprite.CreateText(action, "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.RIGHT);
                pressurizeInfo.Position = new Vector2(posX + 116, posY + 16);
            }
コード例 #28
0
        public void Main(string argument, UpdateType updateSource)
        {
            Runtime.UpdateFrequency = UpdateFrequency.Update10;
            IMyTextPanel display = GridTerminalSystem.GetBlockWithName("LCD Panel [Status]") as IMyTextPanel;

            IMyBlockGroup hangarLights = GridTerminalSystem.GetBlockGroupWithName("Hangar Lights");

            IMyBlockGroup hangarDoors = GridTerminalSystem.GetBlockGroupWithName("Hangar Doors");

            List <IMyTerminalBlock> doors = new List <IMyTerminalBlock>();

            hangarDoors.GetBlocksOfType <IMyAirtightHangarDoor>(doors);

            bool missing = false;

            if (hangarDoors == null) //Returns if doors not found
            {
                Echo("Doors not found");
                missing = true;
            }

            List <IMyTerminalBlock> lights = new List <IMyTerminalBlock>();

            hangarLights.GetBlocksOfType <IMyInteriorLight>(lights);

            if (hangarLights == null) //Returns if lights not found
            {
                Echo("Lights not found");
                missing = true;
            }

            IMyTimerBlock timer = GridTerminalSystem.GetBlockWithName("[Hangar] Timer Block") as IMyTimerBlock;

            if (timer == null) //Returns if timer not found
            {
                Echo("Timer not found");
                missing = true;
            }

            IMyAirVent vent = GridTerminalSystem.GetBlockWithName("[Hangar] Air Vent") as IMyAirVent;

            if (vent == null) //Returns if vent not found
            {
                Echo("Vent not found");
                missing = true;
            }

            IMySoundBlock speaker = GridTerminalSystem.GetBlockWithName("[Hangar] Sound Block") as IMySoundBlock;

            if (speaker == null) //Returns if speaker not found
            {
                Echo("Speaker not found");
                missing = true;
            }

            if (missing == true)
            {
                return;
            }

            UnifyLights(lights);               //Turns all lights on

            speaker.SelectedSound = "Alert 1"; //Set speaker sound

            if (!timer.IsCountingDown)         //Program will skip over if the timer is counting down
            {
                if (timer.TriggerDelay == 10)  //Program will disable timer if the timer is set to 10 (end of hanagar door stage).
                {
                    NormalLights(lights);
                    display.FontSize = 4.4F;
                    Echo("All is well");
                    display.WritePublicTitle("All is well");
                    timer.Enabled      = true;
                    timer.TriggerDelay = 15;
                    speaker.LoopPeriod = 10;
                    speaker.Stop();
                    Runtime.UpdateFrequency = UpdateFrequency.None;
                }
                else //Program will start hangar toggle process else wise
                {
                    if (vent.CanPressurize && !vent.Depressurize) //If the vent needs to depressurize, start depressurize sequence
                    {
                        vent.Depressurize  = true;
                        timer.Enabled      = true;
                        timer.TriggerDelay = 15;
                        timer.StartCountdown();
                        speaker.LoopPeriod = 25;
                        speaker.Play();
                        WarningLights(lights);
                        return;
                    }
                    WarningLights(lights);
                    ToggleDoors(doors);
                    display.FontSize = 3;
                    Echo("!!!CAUTION!!!");
                    display.WritePublicTitle("!!!CAUTION!!!");
                    timer.TriggerDelay = 10;
                    timer.StartCountdown();
                    vent.Depressurize = false;
                    if (speaker.LoopPeriod != 25)
                    {
                        speaker.LoopPeriod = 10;
                        speaker.Play();
                    }
                }
            }
        }
コード例 #29
0
        private void ControlDoors()
        {
            IMyAirtightSlideDoor insideDoor  = GridTerminalSystem.GetBlockWithName("AirLock SlidingDoor In") as IMyAirtightSlideDoor;
            IMyAirtightSlideDoor outsideDoor = GridTerminalSystem.GetBlockWithName("AirLock SlidingDoor Out") as IMyAirtightSlideDoor;
            IMyAirVent           airVent     = GridTerminalSystem.GetBlockWithName("AirLock Vent") as IMyAirVent;

            if (insideDoor == null || outsideDoor == null || airVent == null)
            {
                return;
            }

            _PanelTextSurface.WriteText(String.Format(
                                            "Inside door ticks: {0}\nOutside door ticks: {1}\nPressure: {2}",
                                            _InsideDoorTicks,
                                            _OutsideDoorTicks,
                                            airVent.GetOxygenLevel()
                                            ));



            if (_InsideDoorTicks != -1)
            {
                --_InsideDoorTicks;
            }

            if (_OutsideDoorTicks != -1)
            {
                --_OutsideDoorTicks;
            }

            if (_InsideDoorTicks == 0)
            {
                insideDoor.CloseDoor();
                _InsideDoorTicks  = -1;
                _DoorNeedsClosing = false;
            }

            if (_OutsideDoorTicks == 0)
            {
                outsideDoor.CloseDoor();
                _OutsideDoorTicks = -1;
                _DoorNeedsClosing = false;
            }

            if (insideDoor.Status == DoorStatus.Closed &&
                outsideDoor.Status == DoorStatus.Closed &&
                airVent.GetOxygenLevel() == 0.0f)
            {
                insideDoor.Enabled  = true;
                outsideDoor.Enabled = true;
                _InsideDoorTicks    = -1;
                _OutsideDoorTicks   = -1;
                _DoorNeedsClosing   = false;
            }

            if (outsideDoor.Status == DoorStatus.Open || outsideDoor.Status == DoorStatus.Opening)
            {
                insideDoor.CloseDoor();
                insideDoor.Enabled = false;

                if (!_DoorNeedsClosing)
                {
                    _OutsideDoorTicks = DOOR_DELAY;
                    _DoorNeedsClosing = true;
                }
            }

            if (insideDoor.Status == DoorStatus.Open || insideDoor.Status == DoorStatus.Opening)
            {
                outsideDoor.CloseDoor();
                outsideDoor.Enabled = false;
                if (!_DoorNeedsClosing)
                {
                    _InsideDoorTicks  = DOOR_DELAY;
                    _DoorNeedsClosing = true;
                }
            }
        }
コード例 #30
0
ファイル: EDI.cs プロジェクト: cccdemon/space-engineers-sios
        //////////////////////////////////////////////////////////////////////////////////////////////////////////
        /*                                                                       INITIALIZATION                                                                           */
        //////////////////////////////////////////////////////////////////////////////////////////////////////////



        void GetBlocks()
        {
            List <IMyTerminalBlock> _blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(_blocks);
            for (int i = 0; i < _blocks.Count; i++)
            {
                if (_blocks[i].CustomName.Contains(platformID))
                {
                    ///////////////////////// CHECK FOR HACKED BLOCKs
                    if (IsBeingHacked(_blocks[i]))
                    {
                        Debug("->" + _blocks[i].CustomName + " is being hacked!");

                        hackDetected = true;
                    }
                    ///////////////////////// CHECK FOR DAMAGED BLOCKs
                    if (IsBeingAttacked(_blocks[i]))
                    {
                        Debug("->" + _blocks[i].CustomName + " is damaged!");
                        attackDetected = true;
                    }
                    /////////////////////// GETTING GRAV GENs //////////////////////
                    if (_blocks[i].CustomName.Contains(gravID) && _blocks[i].CustomName.Contains(securityID))
                    {
                        gravs.Add((IMyGravityGenerator)_blocks[i]);
                    }
                    /////////////////////// GETTING AIRVENTS //////////////////////
                    if (_blocks[i].CustomName.Contains(airVentID))
                    {
                        IMyAirVent _vent = (IMyAirVent)_blocks[i];
                        airvents.Add(_vent);
                    }
                    ////////////////// GETTING ALERT SPEAKERS ////////////////////
                    if (_blocks[i].CustomName.Contains(speakerID) && _blocks[i].CustomName.Contains(securityID))
                    {
                        alerts.Add((IMySoundBlock)_blocks[i]);
                    }
                    /////////////////// GETTING INTERIOR LIGHTS ////////////////////
                    if (_blocks[i].CustomName.Contains(lightID) && _blocks[i].CustomName.Contains(securityID))
                    {
                        lights.Add((IMyInteriorLight)_blocks[i]);
                    }
                    /////////////////////// GETTING DOORS //////////////////////////
                    if (_blocks[i].CustomName.Contains(doorID))
                    {
                        doors.Add((IMyDoor)_blocks[i]);
                        if (_blocks[i].CustomName.Contains(securityID))
                        {
                            securityDoors.Add((IMyDoor)_blocks[i]);
                        }
                    }
                    ///////////////////// GETTING TEXT PANELS /////////////////////
                    if (_blocks[i].CustomName.Contains(panelID))
                    {
                        IMyTextPanel _panel = (IMyTextPanel)_blocks[i];
                        if (_panel.GetPublicTitle().Contains(debugID))
                        {
                            //debugger.Add(_panel);
                            //debugEnabled = true;
                        }
                        else
                        {
                            if (!_panel.CustomName.Contains(configID) && _panel.GetPublicTitle() == infoID)
                            {
                                _panel.ShowPublicTextOnScreen();
                                _panel.SetValue("FontSize", 0.8f);
                                panels.Add(_panel);
                            }
                        }
                    }

                    ////////////////////// GETTING PROGRAMS //////////////////////
                    if (_blocks[i].CustomName.Contains(programID))
                    {
                        IMyProgrammableBlock _program = (IMyProgrammableBlock)_blocks[i];
                        if (!_program.CustomName.Contains(coreID))
                        {
                            programs.Add(_program);
                        }
                    }
                    ///////////////////// GETTING TIMERBLOCKS ////////////////////
                    if (_blocks[i].CustomName.Contains(timerID) && _blocks[i].CustomName.Contains(securityID))
                    {
                        timers.Add((IMyTimerBlock)_blocks[i]);
                    }
                    /////////////////// GETTING GATLING TURRETS /////////////////
                    if (_blocks[i].CustomName.Contains(gatlingID))
                    {
                        gatlings.Add((IMyLargeGatlingTurret)_blocks[i]);
                    }
                    if (_blocks[i].CustomName.Contains(missileID))
                    {
                        missiles.Add((IMyLargeMissileTurret)_blocks[i]);
                    }
                    if (_blocks[i].CustomName.Contains(turretID))
                    {
                        turrets.Add((IMyLargeInteriorTurret)_blocks[i]);
                    }
                }
            }
            booted = true;
        }