Esempio n. 1
0
        public findStorageCapacity()
        {
            string                  cargoGroupName = "Base Cargo";
            string                  LCDName        = "[MCD] Cargo";
            IMyBlockGroup           cargos         = GridTerminalSystem.GetBlockGroupWithName(cargoGroupName);
            List <IMyTerminalBlock> blocks         = new List <IMyTerminalBlock>();

            cargos.GetBlocks(blocks);
            float capacity = 0;
            float usage    = 0;

            foreach (var block in blocks)
            {
                IMyCargoContainer cargo = block as IMyCargoContainer;
                capacity += (float)cargo.GetInventory(0).MaxVolume;
                usage    += (float)cargo.GetInventory(0).CurrentVolume;
            }
            float          pctUsed = 100.0f * usage / capacity;
            IMyTextSurface lcd     = GridTerminalSystem.GetBlockWithName(LCDName) as IMyTextSurface;

            // If we found that LCD, let's write the graph to it.
            if (lcd != null)
            {
                // Start the display text with a title and our space used in %.
                string displayText = String.Format("Capacity\nOverall: {0}%\n", (int)pctUsed);
                // Build the graph from the top down.
                for (int x = 0; x <= 10; x++)
                {
                    if (pctUsed >= 100 - x * 10)
                    {
                        displayText += "    |    -----    |\n";
                    }
                    else
                    {
                        displayText += "    |              |\n";
                    }
                }
                // Show the result on the LCD.
                //lcd.ShowTextureOnScreen();
                lcd.ContentType = ContentType.TEXT_AND_IMAGE;
                lcd.FontSize    = 2;
                lcd.WriteText(displayText, false);
                //lcd.ShowPublicTextOnScreen();
            }

            /*
             * // Now let's find the warning sign.
             * lcd = GridTerminalSystem.GetBlockWithName(warningName) as IMyTextPanel;
             *
             * // If we found the warning sign, decide whether to have it turned on or off.
             * if (lcd != null) {
             *  // If we've used more than 80% of our cargo, have it turn on. Else, have it turn off.
             *  if (pctUsed > 80) {
             *      lcd.ApplyAction("OnOff_On");
             *  } else {
             *      lcd.ApplyAction("OnOff_Off");
             *  }
             * }
             */
        }
        public Program()
        {
            // The constructor, called only once every session and
            // always before any other method is called. Use it to
            // initialize your script.
            //
            // The constructor is optional and can be removed if not
            // needed.
            //
            // It's recommended to set Runtime.UpdateFrequency
            // here, which will allow your script to run itself without a
            // timer block.
            Runtime.UpdateFrequency = UpdateFrequency.Update10;
            MyIniParseResult result;

            if (!ini.TryParse(Me.CustomData, out result))
            {
                throw new Exception(result.ToString());
            }
            string displayName = ini.Get("config", "DisplayName").ToString();

            gravel_group_name = ini.Get("config", "GroupName").ToString();
            gravel_limit      = ini.Get("config", "GravelLimit").ToInt32();

            panel = GridTerminalSystem.GetBlockWithName(displayName) as IMyTextPanel;
            Utilities.setupDisplay(panel as IMyTextPanel);
            panel.WriteText("F*****G SHITTY LCD", false);
            Echo(gravel_group_name);
            gravel_shitter_group = GridTerminalSystem.GetBlockGroupWithName(gravel_group_name);
            gravel_shitter_group.GetBlocks(gravel_shitters);
        }
        public void Init()
        {
            IMyBlockGroup blocks = GridTerminalSystem.GetBlockGroupWithName(ProjectorGroup);

            blocks.GetBlocksOfType <IMyProjector>(_Projectors);
            blocks.GetBlocksOfType <IMyTextPanel>(_LCDPanels);
            _InfoLCD = null;
            _ListLCD = null;
            _DescLCD = null;
            foreach (IMyTextPanel lcd in _LCDPanels)
            {
                if (lcd.ContentType != ContentType.TEXT_AND_IMAGE)
                {
                    lcd.ContentType = ContentType.TEXT_AND_IMAGE;
                }
                if (lcd.DisplayNameText.Contains(InfoLCDFilter))
                {
                    _InfoLCD = lcd;
                }
                else if (lcd.DisplayNameText.Contains(DescriptionLCDFilter))
                {
                    _DescLCD = lcd;
                }
                else if (lcd.DisplayNameText.Contains(ListLCDFilter))
                {
                    _ListLCD = lcd;
                }
            }
        }
Esempio n. 4
0
 public void GetPistons(string name)
 {
     if (GridTerminalSystem.GetBlockWithName(name) as IMyPistonBase != null)
     {
         pistons.Add(GridTerminalSystem.GetBlockWithName(name) as IMyPistonBase);
     }
     else
     {
         if (GridTerminalSystem.GetBlockGroupWithName(name) != null)
         {
             IMyBlockGroup           tempGroup = GridTerminalSystem.GetBlockGroupWithName(name);
             List <IMyTerminalBlock> tempList  = new List <IMyTerminalBlock>();
             tempGroup.GetBlocks(tempList);
             for (int i = 0; i < tempList.Count; i++)
             {
                 pistons.Add(tempList[i] as IMyPistonBase);
             }
             if (pistons.Count == 0)
             {
                 throw new System.InvalidOperationException(name + " not found");
             }
         }
         else
         {
             throw new System.InvalidOperationException(name + " not found");
         }
     }
 }
        public static IEnumerable <IMyTerminalBlock> GetBlocks(this IMyBlockGroup src)
        {
            var output = new List <IMyTerminalBlock>();

            src.GetBlocks(output);
            return(output);
        }
Esempio n. 6
0
            public OxygenControl(LCDClass lcd, Program par)
            {
                lcdHandler = lcd;
                parent     = par;
                try
                {
                    parent.GridTerminalSystem.GetBlocksOfType(ventsHangar, x => x.CustomName.Contains("Hangar"));
                    parent.GridTerminalSystem.GetBlocksOfType(HangarOxyTanks, x => x.CustomName.Contains("Hangar"));
                    parent.GridTerminalSystem.GetBlocksOfType(ShipGasTanks, x => !x.CustomName.Contains("Hangar"));
                    IMyBlockGroup doors = parent.GridTerminalSystem.GetBlockGroupWithName("Hangar Doors");
                    parent.GridTerminalSystem.GetBlocksOfType(oxygenGenerators);
                    doors.GetBlocksOfType(hangarDoors);
                    if (ventsHangar.Count != 0)
                    {
                        hangarState = ventsHangar[0].GetOxygenLevel() == 1 ? AIR_STATE.Full : AIR_STATE.Empty;
                    }
                    else
                    {
                        throw new NullReferenceException();
                    }

                    EnableGasGenerator(false);
                    EnableGasTank(true, ShipGasTanks);
                    EnableGasTank(false, HangarOxyTanks);
                    lcdHandler.logMessage("Oxygen Control operational", Tags.OXY, Labels.BOOT);
                }
                catch (NullReferenceException)
                {
                    lcd.logMessage("Oxygen Control not operational, something is missing", Tags.OXY, Labels.cERR);
                    hangarState = AIR_STATE.Error;
                }
            }
Esempio n. 7
0
        public Program()
        {
            rotor = (IMyMotorBase)GridTerminalSystem.GetBlockWithName("Advanced Rotor");

            pistons = GridTerminalSystem.GetBlockGroupWithName("Crane Pisonts");
            pistons.GetBlocksOfType <IMyPistonBase>(cranePistons);
            horizontal1 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Horizontal 1");
            horizontal2 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Horizontal 2");
            horizontal3 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Horizontal 3");

            vertical1 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Vertical 1");
            vertical2 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Vertical 2");
            vertical3 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Vertical 3");

            Echo("Status");
            Echo("-------------------------------------------");
            Echo("Rotor: " + (rotor == null ? "Not Available" : "Ok"));
            Echo("Crane Pistons: " + (pistons == null ? "Not Available" : "Ok") + " / " + (cranePistons == null ? "Not Available" : "Ok"));
            Echo(" - Horizontal 1: " + (horizontal1 == null ? "Not Available" : "Ok"));
            Echo(" - Horizontal 2: " + (horizontal2 == null ? "Not Available" : "Ok"));
            Echo(" - Horizontal 3: " + (horizontal3 == null ? "Not Available" : "Ok"));
            Echo(" - Vertical 1: " + (vertical1 == null ? "Not Available" : "Ok"));
            Echo(" - Vertical 2: " + (vertical2 == null ? "Not Available" : "Ok"));
            Echo(" - Vertical 3: " + (vertical3 == null ? "Not Available" : "Ok"));
        }
Esempio n. 8
0
        public Program()
        {
            _stateMachine = Init();
            //Get Block Group
            blocks = GridTerminalSystem.GetBlockGroupWithName("Grav Lift");

            //Get Ship Controller as Reference

            List <IMyShipController> controllers = new List <IMyShipController>();

            blocks.GetBlocksOfType(controllers, x => x.CubeGrid == Me.CubeGrid);

            if (controllers.Count == 0)
            {
                Echo("No Remote Control or Cockpit found");
                return;
            }
            reference = controllers[0];

            //Get sensors
            blocks.GetBlocksOfType(sensors, x => x.CubeGrid == Me.CubeGrid);

            //Create a Station for each button Panel
            List <IMyButtonPanel> panels = new List <IMyButtonPanel>();

            blocks.GetBlocksOfType(panels, x => x.CubeGrid == Me.CubeGrid);
            stations = new Station[panels.Count];
            for (int i = 0; i < panels.Count; i++)
            {
                stations[i] = new Station(panels[i]);
            }
            Runtime.UpdateFrequency = UpdateFrequency.Once;
        }
Esempio n. 9
0
        private List <T> getBlocksFromGroup <T>(string tag, IMyCubeGrid CubeGrid = null) where T : IMyTerminalBlock
        {
            List <IMyBlockGroup> Groups = new List <IMyBlockGroup>();
            List <T>             Blocks = new List <T>();

            GridTerminalSystem.GetBlockGroups(Groups);
            for (int i_Groups = 0; i_Groups < Groups.Count; i_Groups++)
            {
                IMyBlockGroup Group = Groups[i_Groups];
                if (Group.Name.Contains(tag))
                {
                    for (int i_Blocks = 0; i_Blocks < Group.Blocks.Count; i_Blocks++)
                    {
                        IMyTerminalBlock Block = Group.Blocks[i_Blocks];
                        if (Block is T && (CubeGrid == null || Block.CubeGrid.Equals(CubeGrid)))
                        {
                            object newBlock = Block;
                            Blocks.Add((T)newBlock);
                        }
                    }
                }
            }

            return(Blocks);
        }
        // Method for finding block groups
        List <IMyTerminalBlock> GetBlocksFromGroup(string group)
        {
            IMyBlockGroup           taggedGroup = GridTerminalSystem.GetBlockGroupWithName(group);
            List <IMyTerminalBlock> listGroup   = new List <IMyTerminalBlock>();
            List <IMyTerminalBlock> finallist   = new List <IMyTerminalBlock>();

            if (taggedGroup != null)
            {
                taggedGroup.GetBlocks(listGroup);
            }

            //check group tagged blocks are of right type
            for (int i = 0; i < listGroup.Count; i++)
            {
                if (listGroup[i] is IMyTextPanel)//Can be made generic
                {
                    finallist.Add(listGroup[i]);
                }
            }
            if (finallist != null)
            {
                return(finallist);
            }
            throw new Exception("GetBlocksFromGroup: Group \"" + group + "\" not found");
        }
Esempio n. 11
0
        public static List <IMyTerminalBlock> GetBlocks(this IMyBlockGroup group)
        {
            var blocks = new List <IMyTerminalBlock>();

            group.GetBlocks(blocks);
            return(blocks);
        }
Esempio n. 12
0
        string AirTightCheck(IMyBlockGroup ventBlocks, IMyTextSurface disp)
        {
            List <IMyAirVent> airVents = new List <IMyAirVent>();

            ventBlocks.GetBlocksOfType <IMyAirVent>(airVents);

            Color         fontColor = new Color(0, 150, 0);
            StringBuilder sb        = new StringBuilder();

            sb.AppendLine("Air Integrity Status");
            sb.AppendLine("--------------------");
            foreach (IMyAirVent av in airVents)
            {
                VentStatus ventStatus = av.Status;

                sb.AppendLine($"{av.CustomName}: {ventStatus.ToString()}");
                if (ventStatus == VentStatus.Depressurized || ventStatus == VentStatus.Depressurizing)
                {
                    disp.FontColor = Color.Red;
                }
                else
                {
                    disp.FontColor = fontColor;
                }
            }
            return(sb.ToString());
        }
Esempio n. 13
0
        public Program()
        {
            switch (tickRate)
            {
            case 1:
                Runtime.UpdateFrequency = UpdateFrequency.Update1;
                break;

            case 10:
                Runtime.UpdateFrequency = UpdateFrequency.Update10;
                break;

            case 100:
                Runtime.UpdateFrequency = UpdateFrequency.Update100;
                break;
            }

            IMyBlockGroup grp = GridTerminalSystem.GetBlockGroupWithName(LIGHT_RUNWAY_GROUP);

            if (grp != null)
            {
                List <IMyLightingBlock> li = new List <IMyLightingBlock>();
                grp.GetBlocksOfType <IMyLightingBlock>(li, b => b.CubeGrid == Me.CubeGrid);
                foreach (IMyLightingBlock b in li)
                {
                    lights.Add(new Light(b, colorList));
                }
            }
        }
Esempio n. 14
0
            public TurningStation(string gridName, Program gridProgram)
            {
                name = gridName;
                grid = gridProgram;

                destinationDict = new Dictionary <int, int>
                {
                    { 1, 0 },
                    { 2, 45 },
                    { 3, 90 },
                    { 4, 135 },
                    { 5, 180 },
                    { 6, 225 },
                    { 7, 270 },
                    { 8, 305 }
                };

                turntableRotor = gridProgram.GridTerminalSystem.GetBlockWithName("Turning Station Rotor") as IMyMotorStator;
                antenna        = gridProgram.GridTerminalSystem.GetBlockWithName("Laser Antenna") as IMyLaserAntenna;

                sensors = new List <IMySensorBlock>();
                gridProgram.GridTerminalSystem.GetBlocksOfType(sensors);
                sensors.Where(item =>
                {
                    return(item.IsSameConstructAs(connector));
                });

                IMyBlockGroup rotatingLightGroup = gridProgram.GridTerminalSystem.GetBlockGroupWithName("Rotating Light");

                rotatingLight = new LargeRotatingLight(rotatingLightGroup);
            }
Esempio n. 15
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (String.IsNullOrEmpty(argument))
            {
                Echo("No argument!");
                return;
            }
            Echo($"Hey! I received {argument}!");

            IMyBlockGroup myGroup = GridTerminalSystem.GetBlockGroupWithName(argument);
            List <IMyAirtightHangarDoor> myDoors = new List <IMyAirtightHangarDoor>();

            myGroup.GetBlocksOfType(myDoors);

            if (myDoors.Count == 0)
            {
                Echo("No doors on group");
                return;
            }

            foreach (IMyAirtightHangarDoor door in myDoors)
            {
                Echo("Toggled doors!");
                door.ToggleDoor();
            }
        }
Esempio n. 16
0
        public Program()
        {
            Runtime.UpdateFrequency = UpdateFrequency.Update100;
            GridTerminalSystem.GetBlocksOfType <IMyAirVent>(externalVents, b => b.CustomName.Contains(EXTERNAL_VENT_TAG) && b.CubeGrid == Me.CubeGrid);
            GridTerminalSystem.GetBlocksOfType <IMyShipController>(seats, b => b.CubeGrid == Me.CubeGrid);
            GridTerminalSystem.GetBlocksOfType <IMyLandingGear>(gear, b => b.CubeGrid == Me.CubeGrid);

            GridTerminalSystem.GetBlocksOfType <IMyGravityGenerator>(gravGens, b => b.CubeGrid == Me.CubeGrid);

            IMyBlockGroup grp = GridTerminalSystem.GetBlockGroupWithName(INTERIOR_LIGHT_GROUP);

            if (grp != null)
            {
                grp.GetBlocksOfType <IMyLightingBlock>(lights, b => b.CubeGrid == Me.CubeGrid);
            }

            grp = GridTerminalSystem.GetBlockGroupWithName(HYDROGEN_THRUSTER_GROUP);
            if (grp != null)
            {
                grp.GetBlocksOfType <IMyThrust>(h2Thrusters, b => b.CubeGrid == Me.CubeGrid);
            }
            grp = GridTerminalSystem.GetBlockGroupWithName(ATMO_THRUSTER_GROUP);
            if (grp != null)
            {
                grp.GetBlocksOfType <IMyThrust>(atmoThrusters, b => b.CubeGrid == Me.CubeGrid);
            }
            grp = GridTerminalSystem.GetBlockGroupWithName(ION_THRUSTER_GROUP);
            if (grp != null)
            {
                grp.GetBlocksOfType <IMyThrust>(ionThrusters, b => b.CubeGrid == Me.CubeGrid);
            }
        }
Esempio n. 17
0
        public Program()
        {
            groupName              = "invManageGroup"; //all blocks from this group will be managed by the script
            automatic_update       = true;             //if you timer block is in the group the script will run every 100 tics
            max_gravel             = 100000.0f;        // here you are free to change how much gravel you want to keep, you need a connector to be able to remove gravel through this script
            addContainerWhenNeeded = true;

            timerDelay = 8.0f; //8.0f is 8 seconds. Can be changed to whatever.

            currentGravel = 0.0f;

            CargoPrefix = new List <string> {
                "Ore", "Ingot", "Component"
            };
            setupRelativeType();

            group = GridTerminalSystem.GetBlockGroupWithName(groupName);
            if (group == null)
            {
                Echo("No group found, returning");
                Echo("Once you've added a group recompile script and run again");
                return;
            }
            updateBlocks();

            if (automatic_update && timer != null)
            {
                Runtime.UpdateFrequency = UpdateFrequency.Update100;
            }
            else
            {
                Runtime.UpdateFrequency = UpdateFrequency.Once;
            }
        }
Esempio n. 18
0
        public void InitLists()
        {
            IMyBlockGroup temp = GridTerminalSystem.GetBlockGroupWithName(solarPanelsGroup);

            if (temp != null)
            {
                temp.GetBlocksOfType(solarPanels);
            }
            else
            {
                solarPanels.Clear();
            }
            temp = GridTerminalSystem.GetBlockGroupWithName(oxygenFarmsGroup);
            if (temp != null)
            {
                temp.GetBlocksOfType(oxygenFarms);
            }
            else
            {
                oxygenFarms.Clear();
            }
            temp = GridTerminalSystem.GetBlockGroupWithName(rotorsGroup);
            if (temp != null)
            {
                temp.GetBlocksOfType(rotors);
            }
            else
            {
                rotors.Clear();
            }
        }
Esempio n. 19
0
            public bool ByDefault <T>(string name, out List <T> block_list) where T : class
            {
                block_list = new List <T>();

                if (name != string.Empty)
                {
                    IMyBlockGroup group = gParent.GridTerminalSystem.GetBlockGroupWithName(name);

                    if (group == null)
                    {
                        T block = gParent.GridTerminalSystem.GetBlockWithName(name) as T;

                        if (block != null && (block as IMyTerminalBlock).IsSameConstructAs(gParent.Me))
                        {
                            block_list.Add(block);
                        }
                    }
                    else
                    {
                        group.GetBlocksOfType(block_list, x => (x as IMyTerminalBlock).IsSameConstructAs(gParent.Me));
                    }
                }
                else
                {
                    gParent.GridTerminalSystem.GetBlocksOfType(block_list, x => (x as IMyTerminalBlock).IsSameConstructAs(gParent.Me));
                }

                return(block_list.Count > 0);
            }
        public Program()
        {
            Load();

            // Grinder Arm Blocks
            _grindArmRotor            = GetBlockOrThrow <IMyMotorStator>("Grinder Rotor");
            _grindArmHinge            = GetBlockOrThrow <IMyMotorStator>("Grinder Hinge");
            _grindArmPistonVert       = GetBlockOrThrow <IMyPistonBase>("Grinder Piston Vert");
            _grindArmPistonHoriz      = GetBlockOrThrow <IMyPistonBase>("Grinder Piston Horiz");
            _grindArmPistonPark       = GetBlockOrThrow <IMyPistonBase>("Grinder Park Piston");
            _grindArmLandingGearGroup = GetGroupOrThrow("Grinder Landing Gear");

            // Drill Blocks
            _drillPistonGroup       = GetGroupOrThrow("Drill Pistons");
            _drillGroup             = GetGroupOrThrow("Drills");
            _drillWelderGroup       = GetGroupOrThrow("Welders");
            _drillMergeBlock        = GetBlockOrThrow <IMyShipMergeBlock>("Drill Merge Block");
            _drillConnector         = GetBlockOrThrow <IMyShipConnector>("Drill Connector");
            _drillSupportMergeBlock = GetBlockOrThrow <IMyShipMergeBlock>("Support Merge Block");
            _drillProjector         = GetBlockOrThrow <IMyProjector>("Drill Projector");

            // LCD setup
            _lcd = GetBlockOrThrow <IMyTextPanel>("Drill Rig LCD");
            if (_lcd != null)
            {
                Echo("Found LCD");
                _lcd.ContentType = ContentType.TEXT_AND_IMAGE;
                _lcd.FontSize    = 0.5f;
                _lcd.FontColor   = new Color(200, 200, 200); // less bright white is also less blurry
                _lcd.Alignment   = TextAlignment.LEFT;
                _lcd.WriteText("Drill Rig Debug Logs");      // Clear all text
            }
        }
Esempio n. 21
0
        private void GetBlocks()
        {
            string        blockGroupName = configReader.Get <string>("blockGroupName");
            IMyBlockGroup blockGroup     = GridTerminalSystem.GetBlockGroupWithName(blockGroupName);

            List <IMyShipController> controllers = new List <IMyShipController>();

            blockGroup.GetBlocksOfType <IMyShipController>(controllers);
            if (controllers.Count == 0)
            {
                throw new Exception("Error: " + blockGroupName + " does not contain a cockpit or remote control block.");
            }
            cockpit = controllers[0];

            List <IMyTextPanel> textPanels = new List <IMyTextPanel>();

            blockGroup.GetBlocksOfType <IMyTextPanel>(textPanels);
            if (textPanels.Count > 0)
            {
                textPanel          = textPanels[0];
                textPanel.Font     = "Monospace";
                textPanel.FontSize = 1.0f;
                textPanel.ShowPublicTextOnScreen();
            }

            blockGroup.GetBlocksOfType <IMyGyro>(gyros);
            if (gyros.Count == 0)
            {
                throw new Exception("Error: " + blockGroupName + " does not contain any gyroscopes.");
            }
        }
Esempio n. 22
0
        private TBlockType GetFirstBlock <TBlockType>(IMyBlockGroup group) where TBlockType : class, IMyTerminalBlock
        {
            var list = new List <IMyTerminalBlock>(1);

            group.GetBlocks(list);
            return(list[0] as TBlockType);
        }
Esempio n. 23
0
        public Program()
        {
            base_prgblk  = GridTerminalSystem.GetBlockWithName(base_prgblk_name) as IMyProgrammableBlock;
            drill_drills = GridTerminalSystem.GetBlockGroupWithName(drill_drills_name);
            drill_rotor  = GridTerminalSystem.GetBlockGroupWithName(drill_rotor_name);
            drill_landing_gears_pistons = GridTerminalSystem.GetBlockGroupWithName(drill_landing_gears_pistons_name);
            drill_landing_gears         = GridTerminalSystem.GetBlockGroupWithName(drill_landing_gears_name);
            drill_pistons     = GridTerminalSystem.GetBlockGroupWithName(drill_pistons_name);
            text_panel_status = GridTerminalSystem.GetBlockWithName(text_panel_status_name) as IMyTextPanel;
            drill_pistons     = GridTerminalSystem.GetBlockGroupWithName(drill_pistons_name);
            drill_connector   = GridTerminalSystem.GetBlockWithName(drill_connector_name) as IMyShipConnector;

            //read stored config
            if (Storage.Length != 0)
            {
                string[] stored_config = Storage.Split('\n');
                {
                    read_stored_settings(stored_config);
                }
            }

            if (drill_status == "")
            {
                drill_status = "stopped";
                write_settings();
            }

            drill_connector_status  = drill_connector.Status.ToString();
            Runtime.UpdateFrequency = UpdateFrequency.Update100;
            verify_availability();
            write_settings();
        }
Esempio n. 24
0
        private AutoDrillArm InitAutoDrillArm(IMyBlockGroup autoDrillArmGroup)
        {
            var pistons     = new List <IMyPistonBase>();
            var mergeBlocks = new List <IMyShipMergeBlock>();
            var connectors  = new List <IMyShipConnector>();

            autoDrillArmGroup.GetBlocksOfType(pistons);
            autoDrillArmGroup.GetBlocksOfType(mergeBlocks);
            autoDrillArmGroup.GetBlocksOfType(connectors);

            if (!pistons.Any())
            {
                throw new Exception($"No pistons for group {autoDrillArmGroup.Name} configured.");
            }
            if (!mergeBlocks.Any())
            {
                throw new Exception($"No merge blocks for group {autoDrillArmGroup.Name} configured.");
            }
            if (!connectors.Any())
            {
                throw new Exception($"No connectors for group {autoDrillArmGroup.Name} configured.");
            }

            return(new AutoDrillArm {
                Pistons = pistons, MergeBlocks = mergeBlocks, Connectors = connectors
            });
        }
            public void ReplaceInGroup(string target, string replacement, IMyBlockGroup blockGroup)
            {
                List <IMyTerminalBlock> blockList = new List <IMyTerminalBlock>();

                blockGroup.GetBlocks(blockList);
                Replace(target, replacement, blockList);
            }
            public void AppendInGroup(string suffix, IMyBlockGroup blockGroup)
            {
                List <IMyTerminalBlock> blockList = new List <IMyTerminalBlock>();

                blockGroup.GetBlocks(blockList);
                Append(suffix, blockList);
            }
Esempio n. 27
0
        public static void GetBlocksOfTypeWithQuery <T>(MatchingType selectionMode, string query, List <T> blocks) where T : class
        {
            switch (selectionMode)
            {
            case MatchingType.Match:
            {
                Program.Current.GridTerminalSystem.GetBlocksOfType(blocks, x => (x as IMyTerminalBlock)?.CustomName?.Equals(query) ?? false);
                return;
            }

            case MatchingType.Contains:
            {
                Program.Current.GridTerminalSystem.GetBlocksOfType(blocks, x => (x as IMyTerminalBlock)?.CustomName?.Contains(query) ?? false);
                return;
            }

            case MatchingType.Head:
            {
                Program.Current.GridTerminalSystem.GetBlocksOfType(blocks, x => (x as IMyTerminalBlock)?.CustomName?.StartsWith(query) ?? false);
                return;
            }

            case MatchingType.Group:
            {
                IMyBlockGroup group = Program.Current.GridTerminalSystem.GetBlockGroupWithName(query);
                blocks.Clear();
                if (group != null)
                {
                    group.GetBlocksOfType <T>(blocks);
                }
                return;
            }

            case MatchingType.Type:
            {
                string[] parts = query.Split("|/:, ".ToCharArray()).Select(x => x.Trim()).ToArray();

                bool   allTypes = parts[0] == "" || parts[0] == "*";
                string type     = "My" + parts[0];

                bool   allSubtypes = true;
                string subtype     = "";

                if (parts.Length > 1)
                {
                    allSubtypes = parts[1] == "*";
                    subtype     = parts[1];
                }

                Program.Current.GridTerminalSystem.GetBlocksOfType(blocks, block =>
                    {
                        return((allTypes || block.GetType().Name == type) &&
                               (allSubtypes || (block as IMyTerminalBlock)?.BlockDefinition.SubtypeName == subtype));
                    });

                return;
            }
            }
        }
            public MissileTurretGroup(GridTerminalSystemUtils GTS, IMyBlockGroup turretGroup, IngameTime ingameTime, DeadzoneProvider deadzoneProvider, string azimuthTag, string elevationTag)
            {
                var rotors = new List <IMyMotorStator>();

                turretGroup.GetBlocksOfType(rotors);

                Setup(GTS, rotors, ingameTime, deadzoneProvider, azimuthTag, elevationTag);
            }
Esempio n. 29
0
        public Program()
        {
            IMyBlockGroup group = GridTerminalSystem.GetBlockGroupWithName(DOCKS_GRP_NAME);

            listDock = new List <IMyShipConnector>();
            group.GetBlocksOfType(listDock);
            Runtime.UpdateFrequency = UpdateFrequency.Update100;
        }
Esempio n. 30
0
 public CustomTurretController(Program p, IMyBlockGroup group)
 {
     _p         = p;
     _group     = group;
     _groupName = group.Name;
     Setup();
     SetBlocks();
 }