本文整理汇总了C#中CommandReader类的典型用法代码示例。如果您正苦于以下问题:C# CommandReader类的具体用法?C# CommandReader怎么用?C# CommandReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandReader类属于命名空间,在下文中一共展示了CommandReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
List<Block> blocks = new List<Block>();
List<int> blockRatios = new List<int>();
while( cmd.HasNext ) {
int ratio;
Block block;
if( !cmd.NextBlockWithParam( player, true, out block, out ratio ) ) return null;
if( ratio < 1 || ratio > RandomBrush.MaxRatio ) {
player.Message( "Random brush: Invalid block ratio ({0}). Must be between 1 and {1}.",
ratio, RandomBrush.MaxRatio );
return null;
}
blocks.Add( block );
blockRatios.Add( ratio );
}
if( blocks.Count == 0 ) {
return new RandomBrush();
} else if( blocks.Count == 1 ) {
return new RandomBrush( blocks[0], blockRatios[0] );
} else {
return new RandomBrush( blocks.ToArray(), blockRatios.ToArray() );
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:27,代码来源:RandomBrush.cs
示例2: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
if( !cmd.HasNext ) {
player.Message( "ReplaceBrush usage: &H/Brush rb <Block> <BrushName>" );
return null;
}
Block block;
if( !cmd.NextBlock( player, false, out block ) ) return null;
string brushName = cmd.Next();
if( brushName == null || !CommandManager.IsValidCommandName( brushName ) ) {
player.Message( "ReplaceBrush usage: &H/Brush rb <Block> <BrushName>" );
return null;
}
IBrushFactory brushFactory = BrushManager.GetBrushFactory( brushName );
if( brushFactory == null ) {
player.Message( "Unrecognized brush \"{0}\"", brushName );
return null;
}
IBrush newBrush = brushFactory.MakeBrush( player, cmd );
if( newBrush == null ) {
return null;
}
return new ReplaceBrushBrush( block, newBrush );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:31,代码来源:ReplaceBrushBrush.cs
示例3: MakeBrush
public IBrush MakeBrush(Player player, CommandReader cmd) {
if (player == null) throw new ArgumentNullException("player");
if (cmd == null) throw new ArgumentNullException("cmd");
// read the block filter list
HashSet<Block> blocks = new HashSet<Block>();
while (cmd.HasNext) {
Block block;
if (!cmd.NextBlock(player, false, out block)) {
return null;
}
if (!blocks.Add(block)) {
// just a warning -- don't abort
player.Message("{0}: {1} was specified twice!", Name, block);
}
}
// create a brush
if (blocks.Count > 0) {
return new PasteBrush(blocks.ToArray(), Not);
} else if (Not) {
player.Message("PasteNot brush requires at least 1 block.");
return null;
} else {
return new PasteBrush();
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:27,代码来源:PasteBrush.cs
示例4: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
List<Block> blocks = new List<Block>();
List<int> blockRatios = new List<int>();
while( cmd.HasNext ) {
int ratio;
Block block;
if( !cmd.NextBlockWithParam( player, true, out block, out ratio ) ) return null;
if( block == Block.None ) return null;
if( ratio < 0 || ratio > 1000 ) {
player.Message( "{0} brush: Invalid block ratio ({1}). Must be between 1 and 1000.",
Name, ratio );
return null;
}
blocks.Add( block );
blockRatios.Add( ratio );
}
switch( blocks.Count ) {
case 0:
return new RandomBrush();
case 1:
return new RandomBrush( blocks[0], blockRatios[0] );
default:
return new RandomBrush( blocks.ToArray(), blockRatios.ToArray() );
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:29,代码来源:RandomBrush.cs
示例5:
IBrushInstance IBrush.MakeInstance( Player player, CommandReader cmd, DrawOperation op ) {
if( ReadParams( cmd ) ) {
return this;
} else {
return null;
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:7,代码来源:DrawOpWithBrush.cs
示例6: MakeBrush
public IBrush MakeBrush(Player player, CommandReader cmd) {
if (player == null)
throw new ArgumentNullException("player");
if (cmd == null)
throw new ArgumentNullException("cmd");
Stack<Block> blocks = new Stack<Block>();
while (cmd.HasNext) {
Block block;
if (!cmd.NextBlock(player, false, out block))
return null;
blocks.Push(block);
}
switch (blocks.Count) {
case 0:
player.Message("{0} brush: Please specify the replacement block type.", Name);
return null;
case 1:
return new ReplaceNotBrush(blocks.ToArray(), Block.None);
default: {
Block replacement = blocks.Pop();
return new ReplaceNotBrush(blocks.ToArray(), replacement);
}
}
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:25,代码来源:ReplaceNotBrush.cs
示例7: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
Block block, altBlock;
cmd.NextBlock( player, true, out block );
cmd.NextBlock( player, true, out altBlock );
return new CheckeredBrush( block, altBlock );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:8,代码来源:CheckeredBrush.cs
示例8: ReadParams
public override bool ReadParams(CommandReader cmd) {
// get image URL
string urlString = cmd.Next();
if (string.IsNullOrWhiteSpace(urlString)) {
return false;
}
if (urlString.StartsWith("http://imgur.com/")) {
urlString = "http://i.imgur.com/" + urlString.Substring("http://imgur.com/".Length) + ".png";
}
// if string starts with "++", load image from imgur
if (urlString.StartsWith("++")) {
urlString = "http://i.imgur.com/" + urlString.Substring(2) + ".png";
}
// prepend the protocol, if needed (assume http)
if (!urlString.ToLower().StartsWith("http://") && !urlString.ToLower().StartsWith("https://")) {
urlString = "http://" + urlString;
}
if (!urlString.ToLower().StartsWith("http://i.imgur.com")) {
Player.Message("For safety reasons we only accept images uploaded to &9http://imgur.com/ &sSorry for this inconvenience.");
return false;
}
if (!urlString.ToLower().EndsWith(".png") && !urlString.ToLower().EndsWith(".jpg") && !urlString.ToLower().EndsWith(".gif")) {
Player.Message("URL must be a link to an image");
return false;
}
// validate the image URL
Uri url;
if (!Uri.TryCreate(urlString, UriKind.Absolute, out url)) {
Player.Message("DrawImage: Invalid URL given.");
return false;
} else if (!url.Scheme.Equals(Uri.UriSchemeHttp) && !url.Scheme.Equals(Uri.UriSchemeHttps)) {
Player.Message("DrawImage: Invalid URL given. Only HTTP and HTTPS links are allowed.");
return false;
}
ImageUrl = url;
// Check if player gave optional second argument (palette name)
string paletteName = cmd.Next();
if (paletteName != null) {
StandardBlockPalette paletteType;
if (EnumUtil.TryParse(paletteName, out paletteType, true)) {
Palette = BlockPalette.GetPalette(paletteType);
} else {
Player.Message("DrawImage: Unrecognized palette \"{0}\". Available palettes are: \"{1}\"",
paletteName,
Enum.GetNames(typeof(StandardBlockPalette)).JoinToString());
return false;
}
} else {
// default to "Light" (lit single-layer) palette
Palette = BlockPalette.Light;
}
// All set
return true;
}
开发者ID:Magi1053,项目名称:ProCraft,代码行数:58,代码来源:DrawImageOperation.cs
示例9: ReadParams
public override bool ReadParams( CommandReader cmd ) {
if( cmd.HasNext ) {
Block replacement;
if( cmd.NextBlock( Player, false, out replacement ) ) {
ReplacementBlock = replacement;
} else {
return false;
}
}
Brush = this;
return true;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:12,代码来源:Fill2DDrawOperation.cs
示例10: Execute
public void Execute( string text )
{
CommandReader reader = new CommandReader( text );
if( reader.TotalArgs == 0 ) {
game.Chat.Add( "&e/client: No command name specified. See /client commands for a list of commands." );
return;
}
string commandName = reader.Next();
Command cmd = GetMatchingCommand( commandName );
if( cmd != null ) {
cmd.Execute( reader );
}
}
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:13,代码来源:CommandManager.cs
示例11: CreateParameters
public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
string themeName = cmd.Next();
MapGeneratorParameters newParams;
if( themeName != null ) {
newParams = CreateParameters( themeName );
if( newParams == null ) {
player.Message( "SetGen: \"{0}\" is not a recognized flat theme name. Available themes are: {1}",
themeName, Presets.JoinToString() );
return null;
}
} else {
newParams = CreateDefaultParameters();
}
return newParams;
}
开发者ID:fragmer,项目名称:fCraft,代码行数:15,代码来源:FlatMapGen.cs
示例12: Execute
public void Execute( string text )
{
CommandReader reader = new CommandReader( text );
if( reader.TotalArgs == 0 ) {
game.Chat.Add( "&eList of client commands:" );
PrintDefinedCommands( game );
game.Chat.Add( "&eTo see a particular command's help, type /client help [cmd name]" );
return;
}
string commandName = reader.Next();
Command cmd = GetMatchingCommand( commandName );
if( cmd != null ) {
cmd.Execute( reader );
}
}
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:15,代码来源:CommandManager.cs
示例13: Execute
public override void Execute( CommandReader reader )
{
string cmdName = reader.Next();
if( cmdName == null ) {
game.Chat.Add( "&e/client help: No command name specified. See /client commands for a list of commands." );
} else {
Command cmd = game.CommandManager.GetMatchingCommand( cmdName );
if( cmd != null ) {
string[] help = cmd.Help;
for( int i = 0; i < help.Length; i++ ) {
game.Chat.Add( help[i] );
}
}
}
}
开发者ID:Cheesse,项目名称:ClassicalSharp,代码行数:15,代码来源:DefaultCommands.cs
示例14: MakeBrush
public IBrush MakeBrush(Player player, CommandReader cmd) {
if (player == null) throw new ArgumentNullException("player");
if (cmd == null) throw new ArgumentNullException("cmd");
List<Block> blocks = new List<Block>();
while (cmd.HasNext) {
Block block;
if (!cmd.NextBlock(player, true, out block)) {
return null;
}
blocks.Add(block);
}
return new NormalBrush(blocks.ToArray());
}
开发者ID:fragmer,项目名称:fCraft,代码行数:16,代码来源:NormalBrush.cs
示例15: Execute
public override void Execute( CommandReader reader )
{
game.UserEvents.BlockChanged -= BlockChanged;
block = 0xFF;
mark1 = new Vector3I( int.MaxValue );
mark2 = new Vector3I( int.MaxValue );
persist = false;
if( !ParseBlock( reader ) ) return;
string arg = reader.Next();
if( arg != null && Utils.CaselessEquals( arg, "yes" ) )
persist = true;
game.Chat.Add( "&eCuboid: &fPlace or delete a block.", MessageType.ClientStatus3 );
game.UserEvents.BlockChanged += BlockChanged;
}
开发者ID:Retatta,项目名称:ClassicalSharp,代码行数:16,代码来源:SinglePlayerCommands.cs
示例16: BrushHandler
static void BrushHandler( Player player, CommandReader cmd ) {
string brushName = cmd.Next();
if( brushName == null ) {
player.Message( player.Brush.Description );
} else {
IBrushFactory brushFactory = GetBrushFactory( brushName );
if( brushFactory == null ) {
player.Message( "Unrecognized brush \"{0}\"", brushName );
} else {
IBrush newBrush = brushFactory.MakeBrush( player, cmd );
if( newBrush != null ) {
player.Brush = newBrush;
player.Message( "Brush set to {0}", player.Brush.Description );
}
}
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:17,代码来源:BrushManager.cs
示例17: MakeBrush
public IBrush MakeBrush( Player player, CommandReader cmd ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
Stack<Block> blocks = new Stack<Block>();
while( cmd.HasNext ) {
Block block;
if( !cmd.NextBlock( player, false, out block ) ) return null;
blocks.Push( block );
}
if( blocks.Count == 0 ) {
return new ReplaceNotBrush();
} else if( blocks.Count == 1 ) {
return new ReplaceNotBrush( blocks.ToArray(), Block.None );
} else {
Block replacement = blocks.Pop();
return new ReplaceNotBrush( blocks.ToArray(), replacement );
}
}
开发者ID:fragmer,项目名称:fCraft,代码行数:19,代码来源:ReplaceNotBrush.cs
示例18: CreateParameters
public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
string themeName = cmd.Next();
if( themeName == null ) {
return CreateDefaultParameters();
}
MapGenTheme theme;
RealisticMapGenTerrainType terrainType;
string templateName = cmd.Next();
if( templateName == null ) {
player.Message( "SetGen: Realistic MapGen requires both a theme and a terrainType. " +
"See &H/Help SetGen Realistic&S or check wiki.fCraft.net for details" );
return null;
}
// parse theme
bool swapThemeAndTemplate;
if( EnumUtil.TryParse( themeName, out theme, true ) ) {
swapThemeAndTemplate = false;
} else if( EnumUtil.TryParse( templateName, out theme, true ) ) {
swapThemeAndTemplate = true;
} else {
player.Message( "SetGen: Unrecognized theme \"{0}\". Available themes are: {1}",
themeName,
Enum.GetNames( typeof( MapGenTheme ) ).JoinToString() );
return null;
}
// parse terrainType
if( swapThemeAndTemplate && !EnumUtil.TryParse( themeName, out terrainType, true ) ) {
MessageTemplateList( themeName, player );
return null;
} else if( !EnumUtil.TryParse( templateName, out terrainType, true ) ) {
MessageTemplateList( templateName, player );
return null;
}
// TODO: optional parameters for preset customization
return CreateParameters( terrainType, theme );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:43,代码来源:RealisticMapGen.cs
示例19: MakeBrush
public IBrush MakeBrush(Player player, CommandReader cmd) {
if (player == null) throw new ArgumentNullException("player");
if (cmd == null) throw new ArgumentNullException("cmd");
Block block, altBlock;
// first block type is required
if (!cmd.NextBlock(player, true, out block)) {
player.Message("{0}: Please specify at least one block type.", Name);
return null;
}
// second block type is optional
if (cmd.HasNext) {
if (!cmd.NextBlock(player, true, out altBlock)) return null;
} else {
altBlock = Block.None;
}
return new CheckeredBrush(block, altBlock);
}
开发者ID:fragmer,项目名称:fCraft,代码行数:21,代码来源:CheckeredBrush.cs
示例20: MakeInstance
public IBrushInstance MakeInstance( Player player, CommandReader cmd, DrawOperation op ) {
if( player == null ) throw new ArgumentNullException( "player" );
if( cmd == null ) throw new ArgumentNullException( "cmd" );
if( op == null ) throw new ArgumentNullException( "op" );
if( cmd.HasNext ) {
Block block, altBlock;
if( !cmd.NextBlock( player, true, out block ) ) return null;
if( cmd.HasNext ) {
if( !cmd.NextBlock( player, true, out altBlock ) ) return null;
} else {
altBlock = Block.None;
}
Block1 = block;
Block2 = altBlock;
} else if( Block1 == Block.None ) {
player.Message( "{0}: Please specify one or two blocks.", Factory.Name );
return null;
}
return new CheckeredBrush( this );
}
开发者ID:fragmer,项目名称:fCraft,代码行数:23,代码来源:CheckeredBrush.cs
注:本文中的CommandReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论