当前位置: 首页>>代码示例>>C#>>正文


C# TagData.Error方法代码示例

本文整理汇总了C#中TagData.Error方法的典型用法代码示例。如果您正苦于以下问题:C# TagData.Error方法的具体用法?C# TagData.Error怎么用?C# TagData.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TagData的用法示例。


在下文中一共展示了TagData.Error方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Handle

 public override TemplateObject Handle(TagData data)
 {
     long eid;
     string input = data.GetModifier(0).ToLowerFast();
     if (long.TryParse(input, out eid))
     {
         Entity e = TheServer.GetEntity(eid);
         if (e != null && e is LivingEntity)
         {
             return new LivingEntityTag((LivingEntity)e).Handle(data.Shrink());
         }
     }
     else
     {
         foreach (PlayerEntity p in TheServer.Players)
         {
             if (p.Name.ToLowerFast() == input)
             {
                 return new LivingEntityTag(p).Handle(data.Shrink());
             }
         }
     }
     data.Error("Invalid living entity '" + TagParser.Escape(input) + "'!");
     return new NullTag();
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:25,代码来源:LivingEntityTagBase.cs

示例2: Handle

 public override TemplateObject Handle(TagData data)
 {
     string rname = data.GetModifier(0);
     World w = TheServer.GetWorld(rname);
     if (w != null)
     {
         return new WorldTag(w);
     }
     data.Error("Invalid world '" + TagParser.Escape(rname) + "'!");
     return new NullTag();
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:11,代码来源:WorldTagBase.cs

示例3: Handle

 public override TemplateObject Handle(TagData data)
 {
     TemplateObject pname = data.GetModifierObject(0);
     ItemTag ptag = ItemTag.For(TheServer, pname);
     if (ptag == null)
     {
         data.Error("Invalid player '" + TagParser.Escape(pname.ToString()) + "'!");
         return new NullTag();
     }
     return ptag.Handle(data.Shrink());
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:11,代码来源:PlayerTagBase.cs

示例4: Handle

 public override TemplateObject Handle(TagData data)
 {
     string lname = data.GetModifier(0);
     LocationTag ltag = LocationTag.For(TheServer, data, lname);
     if (ltag == null)
     {
         data.Error("Invalid location '" + TagParser.Escape(lname) + "'!");
         return new NullTag();
     }
     return ltag.Handle(data.Shrink());
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:11,代码来源:LocationTagBase.cs

示例5: Handle

 public override TemplateObject Handle(TagData data)
 {
     TemplateObject rdata = data.GetModifierObject(0);
     RecipeTag rtag = RecipeTag.For(TheServer, data, rdata);
     if (rtag == null)
     {
         data.Error("Invalid recipe '" + TagParser.Escape(rdata.ToString()) + "'!");
         return new NullTag();
     }
     return rtag.Handle(data.Shrink());
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:11,代码来源:RecipeTagBase.cs

示例6: Handle

 public override TemplateObject Handle(TagData data)
 {
     string cname = data.GetModifier(0);
     ColorTag ctag = ColorTag.For(cname);
     if (ctag == null)
     {
         data.Error("Invalid color '" + TagParser.Escape(cname) + "'!");
         return new NullTag();
     }
     return ctag.Handle(data.Shrink());
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:11,代码来源:ColorTagBase.cs

示例7: Handle

 public override TemplateObject Handle(TagData data)
 {
     string modif = data.GetModifier(0);
     EntityTag itag = EntityTag.For(modif);
     if (itag == null)
     {
         data.Error("Invalid entity!");
         return new NullTag().Handle(data.Shrink());
     }
     return itag.Handle(data.Shrink());
 }
开发者ID:FreneticXYZ,项目名称:UnturnedFrenetic,代码行数:11,代码来源:EntityTagBase.cs

示例8: For

 public static RecipeTag For(Server tserver, TagData data, TemplateObject input)
 {
     if (input is RecipeTag)
     {
         return (RecipeTag)input;
     }
     int ind = (int)IntegerTag.For(data, input).Internal;
     if (ind < 0 || ind >= tserver.Recipes.Recipes.Count)
     {
         data.Error("Invalid recipe input!");
         return null;
     }
     return new RecipeTag(tserver.Recipes.Recipes[ind]);
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:14,代码来源:RecipeTag.cs

示例9: Handle

 public override TemplateObject Handle(TagData data)
 {
     long eid;
     string input = data.GetModifier(0).ToLowerFast();
     if (long.TryParse(input, out eid))
     {
         Entity e = TheServer.GetEntity(eid);
         if (e != null && e is ModelEntity)
         {
             return new ModelEntityTag((ModelEntity)e).Handle(data.Shrink());
         }
     }
     data.Error("Invalid model entity '" + TagParser.Escape(input) + "'!");
     return new NullTag();
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:15,代码来源:ModelEntityTagBase.cs

示例10: Handle

 public override TemplateObject Handle(TagData data)
 {
     string input = data.GetModifier(0).ToLowerFast();
     try
     {
         Material mat = MaterialHelpers.FromNameOrNumber(input);
         return new MaterialTag(mat).Handle(data.Shrink());
     }
     catch (Exception ex)
     {
         Utilities.CheckException(ex);
         data.Error("Invalid material '" + TagParser.Escape(input) + "'!");
         return new NullTag();
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:15,代码来源:MaterialTagBase.cs

示例11: For

 public static LocationTag For(Server tserver, TagData dat, string input)
 {
     string[] spl = input.Split(',');
     Location coord;
     if (spl.Length < 3)
     {
         dat.Error("Invalid LocationTag input!");
     }
     coord.X = NumberTag.For(dat, spl[0]).Internal;
     coord.Y = NumberTag.For(dat, spl[1]).Internal;
     coord.Z = NumberTag.For(dat, spl[2]).Internal;
     World w = null;
     if (spl.Length >= 4)
     {
         w = tserver.GetWorld(spl[3]);
         if (w == null)
         {
             dat.Error("Invalid world for LocationTag input!");
         }
     }
     return new LocationTag(coord, w);
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:22,代码来源:LocationTag.cs

示例12: Handle

 public override TemplateObject Handle(TagData data)
 {
     if (data.Remaining == 0)
     {
         return this;
     }
     switch (data[0])
     {
         // <--[tag]
         // @Name BarricadeTag.asset
         // @Group General Information
         // @ReturnType ItemAssetTag
         // @Returns the item asset that this barricade is based off.
         // @Example "2" .asset returns "Bush_Jade".
         // -->
         case "asset":
             return ItemAssetTag.For(InternalData.barricade.id.ToString()).Handle(data.Shrink());
         // <--[tag]
         // @Name BarricadeTag.health
         // @Group General Information
         // @ReturnType NumberTag
         // @Returns the barricade's current health.
         // @Example "2" .health returns "96".
         // -->
         case "health":
             return new NumberTag(InternalData.barricade.health).Handle(data.Shrink());
         // <--[tag]
         // @Name BarricadeTag.powered
         // @Group General Information
         // @ReturnType BooleanTag
         // @Returns whether the barricade is currently powered, open, or lit, etc.
         // @Example "2" .powered returns "true".
         // -->
         case "powered":
             Interactable power = Internal.gameObject.GetComponent<Interactable>();
             if (power != null)
             {
                 if (power is InteractableDoor)
                 {
                     return new BooleanTag(InternalData.barricade.state[16] == 1).Handle(data.Shrink());
                 }
                 else if (power is InteractableFire || power is InteractableGenerator
                     || power is InteractableSafezone || power is InteractableSpot)
                 {
                     return new BooleanTag(InternalData.barricade.state[0] == 1).Handle(data.Shrink());
                 }
             }
             data.Error("Read 'powered' tag on non-powerable object!");
             return new NullTag();
         default:
             return new EntityTag(Internal.gameObject).Handle(data);
     }
 }
开发者ID:FreneticXYZ,项目名称:UnturnedFrenetic,代码行数:53,代码来源:BarricadeTag.cs

示例13: Handle

 public override TemplateObject Handle(TagData data)
 {
     data.Shrink();
     if (data.Remaining == 0)
     {
         return new TextTag(ToString());
     }
     switch (data[0])
     {
         // <--[tagbase]
         // @Name ServerTag.online_players
         // @Group Entities
         // @ReturnType ListTag
         // @Returns a list of all online players.
         // @Example .online_players could return "Fortifier|mcmonkey".
         // -->
         case "online_players":
             {
                 ListTag players = new ListTag();
                 foreach (PlayerEntity p in TheServer.Players)
                 {
                     players.ListEntries.Add(new PlayerTag(p));
                 }
                 return players.Handle(data.Shrink());
             }
         // <--[tagbase]
         // @Name ServerTag.loaded_worlds
         // @Group World
         // @ReturnType ListTag
         // @Returns a list of all loaded worlds.
         // @Example .loaded_worlds could return "default|bob".
         // -->
         case "loaded_worlds":
             {
                 ListTag worlds = new ListTag();
                 foreach (World w in TheServer.LoadedWorlds)
                 {
                     worlds.ListEntries.Add(new WorldTag(w));
                 }
                 return worlds.Handle(data.Shrink());
             }
         // <--[tagbase]
         // @Name ServerTag.loaded_recipes
         // @Group Items
         // @ReturnType ListTag
         // @Returns a list of all loaded recipes.
         // -->
         case "loaded_recipes":
             {
                 ListTag recipes = new ListTag();
                 foreach (ItemRecipe r in TheServer.Recipes.Recipes)
                 {
                     recipes.ListEntries.Add(new RecipeTag(r));
                 }
                 return recipes.Handle(data.Shrink());
             }
         // <--[tagbase]
         // @Name ServerTag.can_craft_from[<ListTag>]
         // @Group Items
         // @ReturnType ListTag
         // @Returns a list of all loaded recipes that can be crafted from the given input.
         // @Example .can_craft_from[blocks/grass_forest] could return "1&pipeblocks/grass_forest|".
         // -->
         case "can_craft_from":
             {
                 // TODO: Handle errors neatly!
                 List<ItemStack> items = new List<ItemStack>();
                 ListTag list = ListTag.For(data.GetModifierObject(0));
                 foreach (TemplateObject obj in list.ListEntries)
                 {
                     items.Add(ItemTag.For(TheServer, obj).Internal);
                 }
                 ListTag recipes = new ListTag();
                 foreach (RecipeResult r in TheServer.Recipes.CanCraftFrom(items.ToArray()))
                 {
                     recipes.ListEntries.Add(new RecipeResultTag(r));
                 }
                 return recipes.Handle(data.Shrink());
             }
         // <--[tagbase]
         // @Name ServerTag.match_player[<TextTag>]
         // @Group Entities
         // @ReturnType PlayerTag
         // @Returns the player whose name best matches the input.
         // @Example .match_player[Fort] out of a group of "Fortifier", "Fort", and "Forty" would return "Fort".
         // @Example .match_player[monk] out of a group of "mcmonkey", "morph", and "Fort" would return "mcmonkey".
         // -->
         case "match_player":
             {
                 string pname = data.GetModifier(0);
                 PlayerEntity player = TheServer.GetPlayerFor(pname);
                 if (player == null)
                 {
                     data.Error("Invalid player '" + TagParser.Escape(pname) + "'!");
                     return new NullTag();
                 }
                 return new PlayerTag(player).Handle(data.Shrink());
             }
         default:
             return new TextTag(ToString()).Handle(data);
//.........这里部分代码省略.........
开发者ID:Morphan1,项目名称:Voxalia,代码行数:101,代码来源:ServerTagBase.cs


注:本文中的TagData.Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。