Beispiel #1
0
        public static List <IMyShipController> GetGridControllers(IMyCubeGrid cubeGrid)
        {
            var resultList = new List <IMyShipController>();

            var blockList = TargetHelper.GetAllBlocks(cubeGrid);

            foreach (var block in blockList.Where(x => x.FatBlock != null))
            {
                var controller = block.FatBlock as IMyShipController;

                if (controller != null)
                {
                    resultList.Add(controller);
                }
            }

            return(resultList);
        }
Beispiel #2
0
        public static List <IMyRadioAntenna> GetGridAntennas(IMyCubeGrid cubeGrid)
        {
            var resultList = new List <IMyRadioAntenna>();

            var blockList = TargetHelper.GetAllBlocks(cubeGrid);

            foreach (var block in blockList.Where(x => x.FatBlock != null))
            {
                var antenna = block.FatBlock as IMyRadioAntenna;

                if (antenna != null)
                {
                    resultList.Add(antenna);
                }
            }

            return(resultList);
        }
Beispiel #3
0
        public static List <IMyTerminalBlock> GetBlocksOfType <T>(IMyCubeGrid cubeGrid) where T : class
        {
            var blockList  = TargetHelper.GetAllBlocks(cubeGrid);
            var resultList = new List <IMyTerminalBlock>();

            foreach (IMySlimBlock block in blockList.Where(x => x.FatBlock != null))
            {
                IMyTerminalBlock terminalBlock = block.FatBlock as IMyTerminalBlock;

                if (terminalBlock == null || terminalBlock as T == null)
                {
                    continue;
                }

                resultList.Add(terminalBlock);
            }

            return(resultList);
        }
Beispiel #4
0
        public static List <IMyTerminalBlock> GetBlocksWithNames(IMyCubeGrid cubeGrid, List <string> names)
        {
            var resultList = new List <IMyTerminalBlock>();
            var blockList  = TargetHelper.GetAllBlocks(cubeGrid);

            foreach (var block in blockList.Where(x => x.FatBlock != null))
            {
                var tBlock = block.FatBlock as IMyTerminalBlock;

                if (tBlock == null)
                {
                    continue;
                }

                if (names.Contains(tBlock.CustomName))
                {
                    resultList.Add(tBlock);
                }
            }

            return(resultList);
        }
Beispiel #5
0
        public static IMyTerminalBlock GetBlockWithName(IMyCubeGrid cubeGrid, string name)
        {
            if (string.IsNullOrWhiteSpace(name) == true)
            {
                return(null);
            }

            var blockList = TargetHelper.GetAllBlocks(cubeGrid);

            foreach (var block in blockList.Where(x => x.FatBlock != null))
            {
                if ((block.FatBlock as IMyTerminalBlock) == null)
                {
                    continue;
                }

                if ((block.FatBlock as IMyTerminalBlock).CustomName == name)
                {
                    return(block as IMyTerminalBlock);
                }
            }

            return(null);
        }