Quantcast
Channel: Programming (In-game)
Viewing all articles
Browse latest Browse all 903

How to use GetBlocksOfType with condition?

$
0
0
I'm trying to get block using GetBlocksOfType<T>

Code:
T GetBlockOfTypeNamed<T>(string Name) where T : IMyTerminalBlock
{
	List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
	BlockNameCondition_Name = Name;
	GridTerminalSystem.GetBlocksOfType<T>(blocks, BlockNameCondition);
   
	if (blocks.Count > 0)
	{
		return (T)blocks[0];
	}
	else
	{
		return default(T);
	}
}
 
 
string BlockNameCondition_Name; // Keeeeeen!!!
bool BlockNameCondition(IMyTerminalBlock block) { return...
How to use GetBlocksOfType with condition?

Viewing all articles
Browse latest Browse all 903

Trending Articles