
using Sandbox.ModAPI.Ingame;

using System.Collections.Generic;
using System.Linq;

using VRage.Game.ModAPI.Ingame;

namespace IngameScript
{
    static class Utils
    {
        public static T GetBlock<T>(this IMyGridTerminalSystem gridTerminal, string name, IMyCubeGrid grid)
            where T: class, IMyTerminalBlock
        {
            var l = new List<T>();
            gridTerminal.GetBlocksOfType<T>(l, (T block) => block.CustomName == name && block.CubeGrid == grid);
            if (l.Count > 0)
                return l.First();
            else
                return null;
        }
    }
}