public Block NextBlockWithParam( [NotNull] Player player, ref int param )
{
if ( player == null )
throw new ArgumentNullException( "player" );
string jointString = Next();
if ( jointString == null ) {
return Block.Undefined;
}
Block targetBlock;
int slashIndex = jointString.IndexOf( '/' );
if ( slashIndex != -1 ) {
string blockName = jointString.Substring( 0, slashIndex );
string paramString = jointString.Substring( slashIndex + 1 );
targetBlock = Map.GetBlockByName( blockName );
if ( targetBlock == Block.Undefined ) {
player.Message( "Unrecognized blocktype \"{0}\"", blockName );
}
int tempParam;
if ( Int32.TryParse( paramString, out tempParam ) ) {
param = tempParam;
} else {
player.Message( "Could not parse \"{0}\" as an integer.", paramString );
}
} else {
targetBlock = Map.GetBlockByName( jointString );
if ( targetBlock == Block.Undefined ) {
player.Message( "Unrecognized blocktype \"{0}\"", jointString );
}
}
return targetBlock;
}