Exemplo n.º 1
0
        public Program()
        {
            MyIniParseResult result;

            if (!_ini.TryParse(Me.CustomData, out result))
            {
                Echo("c'è un problema: " + result.Success + " " + result.Error);
            }
            else
            {
                gridPrefix = _ini.Get("airlock", "gridPrefix").ToString();
                Echo(string.Format("Grid prefix: {0}", gridPrefix != "" ? gridPrefix : "<none>"));
                if (gridPrefix != "")
                {
                    gridPrefix = gridPrefix + "_";
                }
                System.Collections.Generic.List <IMyAirVent> vents = new System.Collections.Generic.List <IMyAirVent>();
                GridTerminalSystem.GetBlocksOfType <IMyAirVent>(vents, v => v.CustomName.StartsWith(gridPrefix) && v.CustomName.EndsWith("_Vent"));
                Echo(string.Format("Airlocks found: {0}", vents.Count));
                foreach (IMyAirVent v in vents)
                {
                    string  name    = v.CustomName.Substring(0, v.CustomName.Length - 5);
                    Airlock airlock = new Airlock(GridTerminalSystem, name);
                    airlocks.Add(name, airlock);
                    Echo(string.Format("- {0}", airlock.ToString()));
                }
                Runtime.UpdateFrequency = UpdateFrequency.Update100;
            }
        }
Exemplo n.º 2
0
    private void OnTriggerExit(Collider other)
    {
        var moduleCollider   = other.GetComponent <ModuleInteractCollider>();
        var airlock          = other.GetComponent <Airlock>();
        var validInteraction = false;

        if (moduleCollider != null)
        {
            validInteraction = true;
            nearbyModule     = null;
        }
        else if (airlock != null && airlock == nearbyAirlock)
        {
            validInteraction = true;
            nearbyAirlock    = null;
        }
        else
        {
            var slot = FindModuleSlot(other);
            if (slot == nearbySlot)
            {
                validInteraction = true;
                nearbySlot       = null;
            }
        }
        if (validInteraction)
        {
            var events = other.GetComponent <EventsForToggle>();
            if (events != null)
            {
                events.TriggerNegative();
            }
        }
    }
Exemplo n.º 3
0
        // ***MARKER: State Machine Program
        public IEnumerator <bool> MainState()
        {
            while (true)
            {
                // Re-initialize global vars
                airlocks.Clear();
                foreach (var step in InitializeVars())
                {
                    yield return(step);
                }

                // Look through all the sensors for each airblock group and process airlock cycle if needed
                foreach (var item in airlocks)
                {
                    Airlock iter = item.Value;
                    // Check if there are doors, sensor, and vents for the airlock
                    if (!iter.inDoors.Any() || !iter.outDoors.Any() || !iter.inSensors.Any() || !iter.outSensors.Any() || !iter.airVents.Any())
                    {
                        continue;
                    }
                    foreach (var step in ProcessAirlock(iter))
                    {
                        yield return(step);
                    }
                }
                yield return(true);
            }
        }
Exemplo n.º 4
0
        public void Main(string argument, UpdateType updateSource)
        {
            string[] runParams = argument.Split(' ');
            bool     doIdle    = true;

            if (runParams.Length >= 2)
            {
                string  command = runParams[0];
                string  name    = runParams[1];
                Airlock airlock = findAirlock(name);
                if (airlock != null)
                {
                    if (command == "enter")
                    {
                        airlock.startEnter();
                        doIdle = false;
                    }
                    else if (command == "exit")
                    {
                        airlock.startExit();
                        doIdle = false;
                    }
                }
            }
            if (doIdle)
            {
                foreach (var item in airlocks)
                {
                    item.Value.update(Runtime.TimeSinceLastRun);
                }
            }
            updateAirlockDisplay();
            SpinningBar.Step();
        }
Exemplo n.º 5
0
    private void Start()
    {
        this.globalTemperature = GameObject.FindObjectOfType <GlobalTemperature>();
        this.baseAirlock       = GameObject.FindObjectOfType <Airlock>();

        this.SetIsInside(true);
        this.SetMaxStats();
    }
            public void Init()
            {
                Status = Constants.S_STATUS_INIT;

                GlobalPanels = new List <IMyTextPanel>();
                myProgram.GridTerminalSystem.GetBlocksOfType(GlobalPanels);

                ScriptPanels     = new List <IMyTextPanel>();
                AirlockPanels    = new List <IMyTextPanel>();
                LeakPanels       = new List <IMyTextPanel>();
                ProductionPanels = new List <IMyTextPanel>();
                DoublePanels     = new List <IMyTextPanel>();

                myProgram.Echo("Checking leak and production screens");
                foreach (IMyTextPanel panel in GlobalPanels)
                {
                    if (panel.CustomData.Contains(Constants.T_LSM_AIRVENT_SCREEN) && panel.CustomData.Contains(Constants.T_LSM_PROD_SCREEN))
                    {
                        myProgram.Echo("Production Panel found");
                        panel.ContentType = ContentType.SCRIPT;
                        DoublePanels.Add(panel);
                        ScriptPanels.Add(panel);
                    }
                    else if (panel.CustomData.Contains(Constants.T_LSM_AIRVENT_SCREEN) && !panel.CustomData.Contains(Constants.T_LSM_PROD_SCREEN))
                    {
                        myProgram.Echo("Airvent Panel found");
                        panel.ContentType = ContentType.SCRIPT;
                        LeakPanels.Add(panel);
                        ScriptPanels.Add(panel);
                    }
                    else if (!panel.CustomData.Contains(Constants.T_LSM_AIRVENT_SCREEN) && panel.CustomData.Contains(Constants.T_LSM_PROD_SCREEN))
                    {
                        myProgram.Echo("Production Panel found");
                        panel.ContentType = ContentType.SCRIPT;
                        ProductionPanels.Add(panel);
                        ScriptPanels.Add(panel);
                    }
                }

                myProgram.Echo("Checking airlocks");
                foreach (KeyValuePair <string, Airlock> _al in myProgram.airlockController.Airlocks)
                {
                    myProgram.Echo("Airlocks found");
                    Airlock airlock = _al.Value;
                    foreach (IMyTextPanel panel in airlock.Panels)
                    {
                        panel.ContentType = ContentType.SCRIPT;
                        panel.CustomData  = Constants.T_LSM_AIRLOCK_SCREEN;
                        AirlockPanels.Add(panel);
                        ScriptPanels.Add(panel);
                    }
                }

                splashScreen     = new SplashScreen(this, ScriptPanels);
                airlockScreen    = new AirlockScreen(this, myProgram);
                leakScreen       = new LeakScreen(myProgram, this, LeakPanels, DoublePanels, myProgram.leakController.Airvents);
                productionScreen = new ProductionScreen(myProgram, this, ProductionPanels, DoublePanels);
            }
            private void DrawOxygenInfo(Airlock airlock, List <MySprite> oxygenInfoSpriteList)
            {
                Vector2 orl_pos       = new Vector2(112.5f, 390);
                Vector2 orl_size      = new Vector2(205, 30);
                var     outerRectLeft = MySprite.CreateSprite("SquareSimple", orl_pos, orl_size);

                outerRectLeft.Color = Constants.COLOR_WHITE;

                Vector2 orlm_pos          = new Vector2(112.5f, 390);
                Vector2 orlm_size         = new Vector2(201, 26);
                var     outerRectLeftMask = MySprite.CreateSprite("SquareSimple", orlm_pos, orlm_size);

                outerRectLeftMask.Color = Constants.COLOR_BACKGROUND;

                Vector2 bfl_pos     = new Vector2(112.5f, 390);
                Vector2 bfl_size    = new Vector2((197 * float.Parse(airlock.OxygenLevelDecimals)), 22);
                var     barFillLeft = MySprite.CreateSprite("SquareSimple", bfl_pos, bfl_size);

                barFillLeft.Color = Constants.COLOR_WHITE;

                var oxigenText = MySprite.CreateText("AIRLOCK OXYGEN", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.CENTER);

                oxigenText.Position = new Vector2(112.5f, 410);

                Vector2 orr_pos        = new Vector2(399.5f, 390);
                Vector2 orr_size       = new Vector2(205, 30);
                var     outerRectRight = MySprite.CreateSprite("SquareSimple", orr_pos, orr_size);

                outerRectRight.Color = Constants.COLOR_WHITE;

                Vector2 orrm_pos           = new Vector2(399.5f, 390);
                Vector2 orrm_size          = new Vector2(201, 26);
                var     outerRectRightMask = MySprite.CreateSprite("SquareSimple", orrm_pos, orrm_size);

                outerRectRightMask.Color = Constants.COLOR_BACKGROUND;

                Vector2 bfr_pos      = new Vector2(399.5f, 390);
                Vector2 bfr_size     = new Vector2((197 * float.Parse(airlock.OxygenTankFillDecimals)), 22);
                var     barFillRight = MySprite.CreateSprite("SquareSimple", bfr_pos, bfr_size);

                barFillRight.Color = Constants.COLOR_WHITE;

                var tankText = MySprite.CreateText("02 TANKS STORAGE", "Debug", Constants.COLOR_WHITE, 0.5f, TextAlignment.CENTER);

                tankText.Position = new Vector2(399.5f, 410);

                oxygenInfoSpriteList.Add(outerRectLeft);
                oxygenInfoSpriteList.Add(outerRectLeftMask);
                oxygenInfoSpriteList.Add(barFillLeft);
                oxygenInfoSpriteList.Add(oxigenText);

                oxygenInfoSpriteList.Add(outerRectRight);
                oxygenInfoSpriteList.Add(outerRectRightMask);
                oxygenInfoSpriteList.Add(barFillRight);
                oxygenInfoSpriteList.Add(tankText);
            }
Exemplo n.º 8
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);
                }
            }
Exemplo n.º 9
0
            private Airlock GetAirlock(string airlockTag)
            {
                Airlock airlock;

                if (!airlockDictionary.TryGetValue(airlockTag, out airlock))
                {
                    airlock = new Airlock(this, airlockTag);
                    airlocks.Add(airlock);
                    airlockDictionary.Add(airlockTag, airlock);
                }

                return(airlock);
            }
Exemplo n.º 10
0
        public Program()
        {
            Runtime.UpdateFrequency = UpdateFrequency.Update1;
            mainCockpit             = (IMyCockpit)GridTerminalSystem.GetBlockWithName(MainCockpitName);

            foreach (string name in AirlockDoorNames)
            {
                string[] names   = name.Split(';');
                Airlock  airlock = new Airlock(names[0], names[1], AirlockTimer);
                airlock.D1 = GridTerminalSystem.GetBlockWithName(names[0]) as IMyDoor;
                airlock.D2 = GridTerminalSystem.GetBlockWithName(names[1]) as IMyDoor;
                airlocks.Add(airlock);
            }
        }
Exemplo n.º 11
0
        void InitializeAirLocks()
        {
            // read config
            Config config = new Config();

            configs_.Clear();
            if (!config.parse(Me, out configs_))
            {
                Echo("Error: Invalid configuration!");
                return;
            }

            // find new doors
            airlocks.Clear();
            GridTerminalSystem.GetBlocksOfType <IMyDoor>(null, (door) =>
            {
                // is an airlock door
                if (door.IsSameConstructAs(Me) && door.CustomName.Contains(Program.DefaultAirlockTag))
                {
                    string airlockName = getAirlockName(door.CustomName);

                    if (!findAirlockPair((pair) =>
                    {
                        pair.AddDoor(door);
                        return(true);
                    }, airlockName))
                    {
                        // add new one
                        Airlock airlock = new Airlock(getConfigData(airlockName));
                        airlock.AddDoor(door);

                        //Echo("Find new airlock pair: [" + airlock.Name + "]");
                        airlocks.Add(airlock);
                    }
                }

                return(false);
            });

            // setup display
            surface_                 = Me.GetSurface(0);
            surface_.ContentType     = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            surface_.Alignment       = VRage.Game.GUI.TextPanel.TextAlignment.LEFT;
            surface_.BackgroundColor = new Color(5, 36, 0);

            surface_.TextPadding = 0.0f;
            surface_.FontSize    = 0.7f;
            surface_.FontColor   = new Color(0, 216, 23);
            surface_.Font        = "debug";
        }
Exemplo n.º 12
0
            private void DrawFooter(Airlock airlock, List <MySprite> footerSpriteList)
            {
                Vector2 fb_pos    = new Vector2(256, 457.5f);
                Vector2 fb_size   = new Vector2(492, 5);
                var     footerBar = MySprite.CreateSprite("SquareSimple", fb_pos, fb_size);

                footerBar.Color = Constants.COLOR_ORANGE;

                var airlockNameText = MySprite.CreateText(airlock.Name, "Debug", Constants.COLOR_ORANGE, 1.5f, TextAlignment.CENTER);

                airlockNameText.Position = new Vector2(256, 462f);

                footerSpriteList.Add(footerBar);
                footerSpriteList.Add(airlockNameText);
            }
Exemplo n.º 13
0
            private void InitDoor(IMyDoor door)
            {
                allDoors.Add(door);
                output.Print("Found door " + door.CustomName);

                string[] data = door.CustomData.Split(program.delimiterChars);
                if (data.Length >= 2)
                {
                    string airlockTag = data[0];
                    string inOut      = data[1];

                    Airlock airlock = GetAirlock(airlockTag);
                    airlock.AddDoor(door, inOut);
                }
            }
Exemplo n.º 14
0
    private void OnTriggerEnter(Collider other)
    {
        var  moduleCollider   = other.GetComponent <ModuleInteractCollider>();
        var  airlock          = other.GetComponent <Airlock>();
        bool validInteraction = false;

        if (moduleCollider != null)
        {
            if (nearbyModule == null ||
                (moduleCollider.targetModule.transform.position - transform.position).sqrMagnitude < (nearbyModule.transform.position - transform.position).sqrMagnitude)
            {
                validInteraction = true;
                nearbyModule     = moduleCollider.targetModule;
            }
        }
        else if (airlock != null)
        {
            if (airlock.GetTeam() == GetTeam())
            {
                validInteraction = true;
                nearbyAirlock    = airlock;
            }
        }
        else
        {
            var slot = FindModuleSlot(other);
            if (slot != null)
            {
                if (nearbySlot != null && nearbySlot != slot)
                {
                    allyShip.GetColliderFromModuleSlot(nearbySlot).GetComponent <EventsForToggle>().TriggerNegative();
                }

                validInteraction = true;
                nearbySlot       = slot;
            }
        }

        if (validInteraction)
        {
            var events = other.GetComponent <EventsForToggle>();
            if (events != null)
            {
                events.TriggerPositive();
            }
        }
    }
Exemplo n.º 15
0
            public void Update()
            {
                if (airlocks.Count > 0)
                {
                    if (airlockIndex >= airlocks.Count)
                    {
                        airlockIndex = 0;
                    }

                    Airlock targetAirlock = airlocks[airlockIndex];
                    targetAirlock.Update();
                    airlockIndex++;
                }


                output.Update();
            }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
            private void DrawPressureInfo(Airlock airlock, List <MySprite> pressureInfoSpriteList)
            {
                Color contrastColor = new Color();

                if (airlock.RoomPressure.Equals("High Pressure"))
                {
                    contrastColor = Constants.COLOR_GREEN;
                }
                else if (airlock.RoomPressure.Equals("Low Pressure"))
                {
                    contrastColor = Constants.COLOR_YELLOW;
                }
                else
                {
                    contrastColor = Constants.COLOR_RED;
                }

                Vector2 oc_pos      = new Vector2(256, 150);
                Vector2 oc_size     = new Vector2(240, 240);
                var     outerCircle = MySprite.CreateSprite("Circle", oc_pos, oc_size);

                outerCircle.Color = contrastColor;

                Vector2 ocm_pos         = new Vector2(256, 150);
                Vector2 ocm_size        = new Vector2(230, 230);
                var     outerCircleMask = MySprite.CreateSprite("Circle", ocm_pos, ocm_size);

                outerCircleMask.Color = Constants.COLOR_BACKGROUND_MASK;

                var pressureText = MySprite.CreateText(airlock.OxygenLevel, "Debug", Constants.COLOR_WHITE, 4f, TextAlignment.CENTER);

                pressureText.Position = new Vector2(256, 90);

                var barText = MySprite.CreateText("BAR", "Debug", contrastColor, 1f, TextAlignment.CENTER);

                barText.Position = new Vector2(256, 200);

                pressureInfoSpriteList.Add(outerCircle);
                pressureInfoSpriteList.Add(outerCircleMask);
                pressureInfoSpriteList.Add(pressureText);
                pressureInfoSpriteList.Add(barText);
            }
Exemplo n.º 18
0
            public void GenerateScreen(Dictionary <string, Airlock> airlocks)
            {
                foreach (KeyValuePair <string, Airlock> _al in airlocks)
                {
                    Airlock airlock = _al.Value;

                    foreach (IMyTextPanel panel in airlock.Panels)
                    {
                        using (var frame = panel.DrawFrame()) {
                            List <MySprite> backgroundSpriteList     = new List <MySprite>();
                            List <MySprite> pressureInfoSpriteList   = new List <MySprite>();
                            List <MySprite> oxygenInfoSpriteList     = new List <MySprite>();
                            List <MySprite> pressureButtonSpriteList = new List <MySprite>();
                            List <MySprite> doorButtonSpriteList     = new List <MySprite>();
                            List <MySprite> footerSpriteList         = new List <MySprite>();


                            DrawBackground(airlock, backgroundSpriteList);

                            DrawPressureInfo(airlock, pressureInfoSpriteList);

                            DrawPressureButton(airlock, pressureButtonSpriteList);

                            DrawOxygenInfo(airlock, oxygenInfoSpriteList);

                            DrawDoorButtons(airlock, doorButtonSpriteList);

                            DrawFooter(airlock, footerSpriteList);

                            // SPRITES TO FRAME

                            frame.AddRange(backgroundSpriteList);
                            frame.AddRange(pressureInfoSpriteList);
                            frame.AddRange(pressureButtonSpriteList);
                            frame.AddRange(oxygenInfoSpriteList);
                            frame.AddRange(doorButtonSpriteList);
                            frame.AddRange(footerSpriteList);
                        }
                    }
                }
            }
    void Start()
    {
        // Get the class object instances or the three chambers
        var airlockObject = GameObject.FindGameObjectWithTag("Airlock");

        airlock = airlockObject.GetComponent <Airlock> ();

        var deposition1Object = GameObject.FindGameObjectWithTag("Deposition1");

        deposition1 = deposition1Object.GetComponent <Deposition1> ();

        var deposition2Object = GameObject.FindGameObjectWithTag("Deposition2");

        deposition2 = deposition2Object.GetComponent <Deposition2> ();

        var voiceOversObject = GameObject.FindGameObjectWithTag("VoiceOvers");

        voiceOvers = voiceOversObject.GetComponent <VoiceOvers> ();

        // Get the monitors
        monitors = GameObject.FindGameObjectsWithTag("CloseUpScreen");
    }
Exemplo n.º 20
0
 void GroupFound(GridScanArgs <KeyValuePair <IMyBlockGroup, List <IMyTerminalBlock> > > item)
 {
     if (item.First)
     {
         foreach (var kv in _Airlocks)
         {
             SavedStates[kv.Key.Name] = kv.Value.CurrentState;
         }
         _Airlocks.Clear();
     }
     if (Owner.PolicyCheck(Policy, item.Item.Key) && Airlock.IsAirlock(item.Item.Value))
     {
         var a = new Airlock(item.Item.Value);
         try
         { a.CurrentState = SavedStates[item.Item.Key.Name]; }
         catch (KeyNotFoundException)
         { a.CurrentState = "Idle"; }
         _Airlocks.Add(item.Item.Key, a);
     }
     if (item.Last)
     {
         SavedStates.Clear();
     }
 }
Exemplo n.º 21
0
            private void DrawBackground(Airlock airlock, List <MySprite> backgroundSpriteList)
            {
                Vector2 b_pos      = new Vector2(256, 256);
                Vector2 b_size     = new Vector2(512, 512);
                var     background = MySprite.CreateSprite("SquareSimple", b_pos, b_size);

                background.Color = Constants.COLOR_BACKGROUND_MASK;

                Vector2 bc_pos           = new Vector2(256, 150);
                Vector2 bc_size          = new Vector2(280, 280);
                var     backgroundCircle = MySprite.CreateSprite("Circle", bc_pos, bc_size);

                backgroundCircle.Color = Constants.COLOR_BACKGROUND;

                Vector2 bcr_pos              = new Vector2(256, 150);
                Vector2 bcr_size             = new Vector2(512, 170);
                var     backgroundCircleRect = MySprite.CreateSprite("SquareSimple", bcr_pos, bcr_size);

                backgroundCircleRect.Color = Constants.COLOR_BACKGROUND;

                backgroundSpriteList.Add(background);
                backgroundSpriteList.Add(backgroundCircle);
                backgroundSpriteList.Add(backgroundCircleRect);
            }
Exemplo n.º 22
0
        public void Main(string argument, UpdateType updateType)
        {
            if ((updateType & UpdateType.Trigger) != 0)
            {
                Airlock airlock = new Airlock();
                // Parse Arguments
                if (CommandLine.TryParse(argument))
                {
                    airlock.DoorSide    = CommandLine.Argument(0);
                    airlock.AirlockName = CommandLine.Argument(1);
                }

                // Get a list of all doors for this script
                GridTerminalSystem.GetBlocksOfType <IMyDoor>(airlock.Doors, door => MyIni.HasSection(door.CustomData, "AirlockScript"));
                // Get a list of all airvents for this script
                GridTerminalSystem.GetBlocksOfType <IMyAirVent>(airlock.AirVents, vent => MyIni.HasSection(vent.CustomData, "AirlockScript"));
                // Get a list of all lights for this script
                GridTerminalSystem.GetBlocksOfType <IMyLightingBlock>(airlock.Lights, vent => MyIni.HasSection(vent.CustomData, "AirlockScript"));
                // Get a list of all lights for this script
                GridTerminalSystem.GetBlocksOfType <IMySoundBlock>(airlock.SoundBlocks, vent => MyIni.HasSection(vent.CustomData, "AirlockScript"));

                // Go through each door in the list until the custom data matches with the inputed arguments
                foreach (IMyDoor door in airlock.Doors)
                {
                    MyIniParseResult result;
                    if (!ini.TryParse(door.CustomData, out result))
                    {
                        throw new Exception(result.ToString());
                    }

                    if (ini.Get("AirlockScript", "AirlockName").ToString() == airlock.AirlockName)
                    {
                        // If the airlock was triggered by the sensor, determine which door needs to close
                        // Door side passed in should be the door currently open.
                        if (airlock.DoorSide == "Sensor")
                        {
                            if (door.OpenRatio == 1)
                            {
                                airlock.DoorSide = ini.Get("AirlockScript", "DoorSide").ToString();
                            }
                        }
                        if (ini.Get("AirlockScript", "DoorSide").ToString() == airlock.DoorSide)
                        {
                            airlock.OpenDoors.Add(door);
                        }
                        else
                        {
                            airlock.ClosedDoors.Add(door);
                        }
                    }
                }

                foreach (IMyAirVent vent in airlock.AirVents)
                {
                    MyIniParseResult result;
                    if (!ini.TryParse(vent.CustomData, out result))
                    {
                        throw new Exception(result.ToString());
                    }

                    if (ini.Get("AirlockScript", "AirlockName").ToString() == airlock.AirlockName)
                    {
                        airlock.ThisAirlockAirVents.Add(vent);
                    }
                }

                foreach (IMyLightingBlock light in airlock.Lights)
                {
                    MyIniParseResult result;
                    if (!ini.TryParse(light.CustomData, out result))
                    {
                        throw new Exception(result.ToString());
                    }

                    if (ini.Get("AirlockScript", "AirlockName").ToString() == airlock.AirlockName)
                    {
                        airlock.AirlockLights.Add(light);
                    }
                }

                foreach (IMySoundBlock sb in airlock.SoundBlocks)
                {
                    MyIniParseResult result;
                    if (!ini.TryParse(sb.CustomData, out result))
                    {
                        throw new Exception(result.ToString());
                    }

                    if (ini.Get("AirlockScript", "AirlockName").ToString() == airlock.AirlockName)
                    {
                        airlock.AirlockSoundBlocks.Add(sb);
                    }
                }
                Airlocks.Add(airlock);
            }
            if ((updateType & UpdateType.Update10) != 0 && Airlocks.Count() > 0)
            {
                foreach (Airlock airlock in Airlocks)
                {
                    airlock.AirlockSwitch();
                    if (airlock.Step == 0)
                    {
                        AirlockClearList.Add(airlock);
                    }
                }
                foreach (Airlock airlock in AirlockClearList)
                {
                    Airlocks.Remove(airlock);
                }
                AirlockClearList.Clear();
            }
        }
Exemplo n.º 23
0
        void RunServerRun()
        {
            IP = txtbx_IP.Text;
            TcpListener listener = new TcpListener(IPAddress.Parse(IP), Port);

            try
            {
                listener.Start();

                serverstatus = ServerStatus.starting;
                Thread.Sleep(400);

                while (ServerON)
                {
                    serverstatus = ServerStatus.listening;
                    while (!listener.Pending() && ServerON)
                    {
                        Thread.Sleep(100);
                    }

                    if (!ServerON)
                    {
                        break;
                    }

                    TcpClient client = listener.AcceptTcpClient();
                    serverstatus = ServerStatus.connected;

                    StreamReader reader = new StreamReader(client.GetStream());
                    StreamWriter writer = new StreamWriter(client.GetStream());

                    string s = string.Empty;

                    while (ServerON)
                    {
                        s            = reader.ReadLine();
                        serverstatus = ServerStatus.reading;

                        if (s == "exit")
                        {
                            break;
                        }

                        //clear the airlock
                        while (Airlock.TryTake(out string os))
                        {
                            //do nothing
                        }
                        //Now we can add the datastring
                        Airlock.TryAdd(s);
                    }
                    reader.Close();
                    writer.Close();
                    client.Close();
                }

                listener.Stop();

                serverstatus = ServerStatus.shutting_down;
                Thread.Sleep(1000);

                serverstatus = ServerStatus.offline;
            }
            catch (Exception ex)
            {
                listener.Stop();
                serverstatus = ServerStatus.shutting_down;
                Thread.Sleep(500);
            }
        }
Exemplo n.º 24
0
    void Start()
    {
        airlock = GetComponent<Airlock>();
        animator = GetComponentInChildren<Animator>();

        if (airlock != null) {
            //Opening += airlock.Open;
            //Closed	+= airlock.Close;
        }
    }
Exemplo n.º 25
0
        private IEnumerable <bool> InitializeVars()
        {
            // Does it have the [Airlock 1234 etc] syntax? What is its ID? Does it have an indicator for In or Out?
            // 1st group is the whole thing, 2nd group is its ID, 3rd group is the In/Out
            string pattern = @"^[^\n\[]*(\[Airlock (\d+)(?: ([^\]]+))?\])";
            // Create airlock groups by its ID and add the sub-group blocks to it
            List <IMyTerminalBlock> allBlocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocks(allBlocks);
            foreach (IMyTerminalBlock iter in allBlocks)
            {
                System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match(iter.CustomName, pattern);
                if (!match.Success || match.Groups[2] == null)
                {
                    continue;
                }
                string id = match.Groups[2].Value;
                try {
                    Airlock tmp = new Airlock();
                    airlocks.Add(id, tmp);
                }
                catch (ArgumentException e) {
                    // Key already exists, add this block to the appropriate sub-group
                }


                if (iter is IMyAirVent)
                {
                    airlocks[id].AddVent(iter);
                }
                else if (iter is IMyDoor)
                {
                    // Is it In or Out?
                    if (match.Groups[3] == null)
                    {
                        Echo("Door not specified as 'In' or 'Out': Null");
                    }
                    else if (match.Groups[3].Value == "In")
                    {
                        airlocks[id].AddInDoor(iter);
                    }
                    else if (match.Groups[3].Value == "Out")
                    {
                        airlocks[id].AddOutDoor(iter);
                    }
                    else
                    {
                        Echo("Door not specified as 'In' or 'Out':" + iter.CustomName);
                    }
                }
                else if (iter is IMySensorBlock)
                {
                    // Is it In or Out?
                    if (match.Groups[3] == null)
                    {
                        Echo("Sensor not specified as 'In' or 'Out': null");
                    }
                    else if (match.Groups[3].Value == "In")
                    {
                        airlocks[id].AddInSensor(iter);
                    }
                    else if (match.Groups[3].Value == "Out")
                    {
                        airlocks[id].AddOutSensor(iter);
                    }
                    else
                    {
                        Echo("Sensor not specified as 'In' or 'Out': " + iter.CustomName);
                    }
                }
                else
                {
                    Echo("Block in Airlock group isn't sensor, door, or vent. Type: " + iter.GetType().ToString());
                }
            }
            yield return(true);
        }
Exemplo n.º 26
0
            private void DrawDoorButtons(Airlock airlock, List <MySprite> doorButtonSpriteList)
            {
                Color internalColor = new Color(255, 255, 255);
                Color externalColor = new Color(255, 255, 255);

                if (airlock.OpenDoors.Equals("Both"))
                {
                    internalColor = Constants.COLOR_GREEN;
                    externalColor = Constants.COLOR_GREEN;
                }
                else if (airlock.OpenDoors.Equals("Internal"))
                {
                    internalColor = Constants.COLOR_GREEN;
                    externalColor = Constants.COLOR_RED;
                }
                else if (airlock.OpenDoors.Equals("External"))
                {
                    internalColor = Constants.COLOR_RED;
                    externalColor = Constants.COLOR_GREEN;
                }
                else
                {
                    internalColor = Constants.COLOR_RED;
                    externalColor = Constants.COLOR_RED;
                }

                Vector2 ldr_pos      = new Vector2(70, 150);
                Vector2 ldr_size     = new Vector2(60, 60);
                var     leftDoorRect = MySprite.CreateSprite("SquareSimple", ldr_pos, ldr_size);

                leftDoorRect.Color = Constants.COLOR_WHITE;

                Vector2 ldrm_pos         = new Vector2(70, 150);
                Vector2 ldrm_size        = new Vector2(56, 56);
                var     leftDoorRectMask = MySprite.CreateSprite("SquareSimple", ldrm_pos, ldrm_size);

                leftDoorRectMask.Color = Constants.COLOR_BACKGROUND;

                Vector2 lds_pos        = new Vector2(70, 187);
                Vector2 lds_size       = new Vector2(60, 10);
                var     leftDoorSignal = MySprite.CreateSprite("SquareSimple", lds_pos, lds_size);

                leftDoorSignal.Color = internalColor;

                var innerDoorText = MySprite.CreateText("INNER\nDOOR", "Debug", internalColor, 0.6f, TextAlignment.CENTER);

                innerDoorText.Position = new Vector2(70, 133);

                Vector2 rdr_pos       = new Vector2(437, 150);
                Vector2 rdr_size      = new Vector2(60, 60);
                var     rightDoorRect = MySprite.CreateSprite("SquareSimple", rdr_pos, rdr_size);

                rightDoorRect.Color = Constants.COLOR_WHITE;

                Vector2 rdrm_pos          = new Vector2(437, 150);
                Vector2 rdrm_size         = new Vector2(56, 56);
                var     rightDoorRectMask = MySprite.CreateSprite("SquareSimple", rdrm_pos, rdrm_size);

                rightDoorRectMask.Color = Constants.COLOR_BACKGROUND;

                Vector2 rds_pos         = new Vector2(437, 187);
                Vector2 rds_size        = new Vector2(60, 10);
                var     rightDoorSignal = MySprite.CreateSprite("SquareSimple", rds_pos, rds_size);

                rightDoorSignal.Color = externalColor;

                var outerDoorText = MySprite.CreateText("OUTER\nDOOR", "Debug", externalColor, 0.6f, TextAlignment.CENTER);

                outerDoorText.Position = new Vector2(437, 133);

                doorButtonSpriteList.Add(leftDoorRect);
                doorButtonSpriteList.Add(leftDoorRectMask);
                doorButtonSpriteList.Add(leftDoorSignal);
                doorButtonSpriteList.Add(innerDoorText);
                doorButtonSpriteList.Add(rightDoorRect);
                doorButtonSpriteList.Add(rightDoorRectMask);
                doorButtonSpriteList.Add(rightDoorSignal);
                doorButtonSpriteList.Add(outerDoorText);
            }
Exemplo n.º 27
0
            private void DrawPressureButton(Airlock airlock, List <MySprite> pressureButtonSpriteList)
            {
                Vector2 buttonSize     = new Vector2(130, 50); //136 48
                Vector2 frameSize      = new Vector2(130, 50); //136 48
                Vector2 frameMaskSize  = new Vector2(126, 46); //132 44
                Vector2 frameMaskSizeH = new Vector2(130, 30); // 136 28
                Vector2 frameMaskSizeV = new Vector2(110, 50); // 116 48

                // 130*50

                Vector2 bbl_pos      = new Vector2(75, 330);
                var     buttonBgLeft = MySprite.CreateSprite("SquareSimple", bbl_pos, buttonSize);

                buttonBgLeft.Color = Constants.COLOR_NAVY_BLUE;

                Vector2 bbc_pos        = new Vector2(256, 330);
                var     buttonBgCenter = MySprite.CreateSprite("SquareSimple", bbc_pos, buttonSize);

                buttonBgCenter.Color = Constants.COLOR_NAVY_BLUE;

                Vector2 bbr_pos       = new Vector2(437, 330);
                var     buttonBgRight = MySprite.CreateSprite("SquareSimple", bbr_pos, buttonSize);

                buttonBgRight.Color = Constants.COLOR_NAVY_BLUE;

                var frameButton     = MySprite.CreateSprite("SquareSimple", bbc_pos, frameSize);
                var frameButtonMask = MySprite.CreateSprite("SquareSimple", bbc_pos, frameMaskSize);

                frameButtonMask.Color = Constants.COLOR_NAVY_BLUE;
                var frameButtonMaskH = MySprite.CreateSprite("SquareSimple", bbc_pos, frameMaskSizeH);

                frameButtonMaskH.Color = Constants.COLOR_NAVY_BLUE;
                var frameButtonMaskV = MySprite.CreateSprite("SquareSimple", bbc_pos, frameMaskSizeV);

                frameButtonMaskV.Color = Constants.COLOR_NAVY_BLUE;
                if (airlock.PublicStatus.Equals(Constants.AP_PRESSURIZED))
                {
                    frameButton.Color         = Constants.COLOR_GREEN;
                    frameButtonMask.Color     = Constants.COLOR_GREEN_DARK;
                    frameButtonMaskH.Color    = Constants.COLOR_GREEN_DARK;
                    frameButtonMaskV.Color    = Constants.COLOR_GREEN_DARK;
                    frameButton.Position      = bbl_pos;
                    frameButtonMask.Position  = bbl_pos;
                    frameButtonMaskH.Position = bbl_pos;
                    frameButtonMaskV.Position = bbl_pos;
                }
                else if (airlock.PublicStatus.Equals(Constants.AP_CYCLE))
                {
                    frameButton.Color         = Constants.COLOR_YELLOW;
                    frameButtonMask.Color     = Constants.COLOR_YELLOW_DARK;
                    frameButtonMaskH.Color    = Constants.COLOR_YELLOW_DARK;
                    frameButtonMaskV.Color    = Constants.COLOR_YELLOW_DARK;
                    frameButton.Position      = bbc_pos;
                    frameButtonMask.Position  = bbc_pos;
                    frameButtonMaskH.Position = bbc_pos;
                    frameButtonMaskV.Position = bbc_pos;
                }
                else if (airlock.PublicStatus.Equals(Constants.AP_DEPRESSURIZED))
                {
                    frameButton.Color         = Constants.COLOR_RED;
                    frameButtonMask.Color     = Constants.COLOR_RED_DARK;
                    frameButtonMaskH.Color    = Constants.COLOR_RED_DARK;
                    frameButtonMaskV.Color    = Constants.COLOR_RED_DARK;
                    frameButton.Position      = bbr_pos;
                    frameButtonMask.Position  = bbr_pos;
                    frameButtonMaskH.Position = bbr_pos;
                    frameButtonMaskV.Position = bbr_pos;
                }

                var bblText = MySprite.CreateText("PRESSURIZED", "Debug", Constants.COLOR_WHITE, 0.6f, TextAlignment.CENTER);

                bblText.Position = new Vector2(75, 320);

                var bbcText = MySprite.CreateText("CYCLING", "Debug", Constants.COLOR_WHITE, 0.6f, TextAlignment.CENTER);

                bbcText.Position = new Vector2(256, 320);

                var bbrText = MySprite.CreateText("DEPRESSURIZED", "Debug", Constants.COLOR_WHITE, 0.6f, TextAlignment.CENTER);

                bbrText.Position = new Vector2(437, 320);

                pressureButtonSpriteList.Add(buttonBgCenter);
                pressureButtonSpriteList.Add(buttonBgLeft);
                pressureButtonSpriteList.Add(buttonBgRight);
                pressureButtonSpriteList.Add(frameButton);
                pressureButtonSpriteList.Add(frameButtonMask);
                pressureButtonSpriteList.Add(frameButtonMaskH);
                pressureButtonSpriteList.Add(frameButtonMaskV);
                pressureButtonSpriteList.Add(bbcText);
                pressureButtonSpriteList.Add(bblText);
                pressureButtonSpriteList.Add(bbrText);
            }
            private void DrawAirlocks(List <MySprite> airlocksSpriteList, float screenOffset)
            {
                Vector2 b_pos      = new Vector2(381.5f + screenOffset, 285);
                Vector2 b_size     = new Vector2(241, 434);
                var     background = MySprite.CreateSprite("SquareSimple", b_pos, b_size);

                background.Color = Constants.COLOR_BACKGROUND_MASK;

                Vector2 h_pos  = new Vector2(381.5f + screenOffset, 78);
                Vector2 h_size = new Vector2(241, 20);
                var     header = MySprite.CreateSprite("SquareSimple", h_pos, h_size);

                header.Color = Constants.COLOR_GREEN;

                var headerText = MySprite.CreateText("AIRLOCKS STATUS", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT);

                headerText.Position = new Vector2(271 + screenOffset, 69);

                airlocksSpriteList.Add(background);
                airlocksSpriteList.Add(header);
                airlocksSpriteList.Add(headerText);

                float startY  = 133; // 213
                float offset  = 80;
                int   counter = 0;

                foreach (KeyValuePair <string, Airlock> _al in myProgram.airlockController.Airlocks)
                {
                    Airlock airlock = _al.Value;
                    myProgram.Echo($"Airlock: {airlock.Name}");

                    Color airlockStatusColor = new Color(256, 256, 256);
                    if (airlock.PublicStatus.Equals(Constants.AP_IDLE) || airlock.PublicStatus.Equals(Constants.AP_CYCLE))
                    {
                        airlockStatusColor = Constants.COLOR_YELLOW;
                    }
                    else if (airlock.PublicStatus.Equals(Constants.AP_PRESSURIZED))
                    {
                        airlockStatusColor = Constants.COLOR_GREEN;
                    }
                    else if (airlock.PublicStatus.Equals(Constants.AP_DEPRESSURIZED))
                    {
                        airlockStatusColor = Constants.COLOR_RED;
                    }

                    Vector2 ab_pos            = new Vector2(381.5f + screenOffset, startY + (offset * counter));
                    Vector2 ab_size           = new Vector2(221, 70);
                    var     airlockBackground = MySprite.CreateSprite("SquareSimple", ab_pos, ab_size);
                    airlockBackground.Color = Constants.COLOR_BACKGROUND_LIGHT;

                    Vector2 asi_pos  = new Vector2(276f + screenOffset, startY + (offset * counter));
                    Vector2 asi_size = new Vector2(10, 70);
                    var     airlockStatusIndicator = MySprite.CreateSprite("SquareSimple", asi_pos, asi_size);
                    airlockStatusIndicator.Color = airlockStatusColor;

                    var airlockName = MySprite.CreateText(airlock.Name, "White", Constants.COLOR_WHITE, 1f, TextAlignment.LEFT);
                    airlockName.Position = new Vector2(288f + screenOffset, 100 + (offset * counter));

                    var airlockStatusTitle = MySprite.CreateText("STATUS", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT);
                    airlockStatusTitle.Position = new Vector2(288f + screenOffset, 128 + (offset * counter));

                    var airlockStatus = MySprite.CreateText(airlock.PublicStatus, "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.RIGHT);
                    airlockStatus.Position = new Vector2(480f + screenOffset, 128 + (offset * counter));

                    var airlockDoorStatusTitle = MySprite.CreateText("DOORS", "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.LEFT);
                    airlockDoorStatusTitle.Position = new Vector2(288.5f + screenOffset, 145 + (offset * counter));

                    var airlockDoorStatus = MySprite.CreateText(airlock.OpenDoors, "White", Constants.COLOR_WHITE, 0.6f, TextAlignment.RIGHT);
                    airlockDoorStatus.Position = new Vector2(480f + screenOffset, 145 + (offset * counter));

                    airlocksSpriteList.Add(airlockBackground);
                    airlocksSpriteList.Add(airlockStatusIndicator);
                    airlocksSpriteList.Add(airlockName);
                    airlocksSpriteList.Add(airlockStatusTitle);
                    airlocksSpriteList.Add(airlockStatus);
                    airlocksSpriteList.Add(airlockDoorStatusTitle);
                    airlocksSpriteList.Add(airlockDoorStatus);

                    counter++;
                }
            }
Exemplo n.º 29
0
 void Start()
 {
     this.airlock = FindUtilities
         .TryFind(transform.parent.parent.gameObject, "Airlock")
         .GetComponent<Airlock>();
 }
Exemplo n.º 30
0
 public DebugOutput(BlockHelper blockHelper, Airlock airlock, string debugName)
 {
     this.airlock     = airlock;
     this.blockHelper = blockHelper;
     this.debugName   = debugName;
 }
Exemplo n.º 31
0
        /* collect all inside doorblocks that start with airvent, these should be unique*/
        void initAirlocks()
        {
            List<IMyTerminalBlock> allBlocks = new List<IMyTerminalBlock>();
            GridTerminalSystem.GetBlocks(allBlocks);

            List<IMyTerminalBlock> doorBlocks = new List<IMyTerminalBlock>();
            GridTerminalSystem.GetBlocksOfType<IMyDoor>(doorBlocks);

            airlockCount = 0;
            for (int i = 0; i < doorBlocks.Count; i++)
            {

            string tmpBlockName = doorBlocks[i].CustomName;
            if (tmpBlockName.StartsWith("Airlock") && tmpBlockName.Substring(8) == "insideDoor")
            {
                AirlockObjects airlockObj = new AirlockObjects();

                collectObjectsForAirvent(tmpBlockName, airlockObj);

                Airlock airlock = new Airlock();
                airlock.AirlockInitObject(tmpBlockName, airlockObj);
                airlock.name = tmpBlockName;

                allAirlocks[airlockCount++] = airlock;

            }
            }
        }