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


C# TagData.GetModifierObject方法代码示例

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


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

示例1: Handle

 public override TemplateObject Handle(TagData data)
 {
     ColorTag ctag = ColorTag.For(data.GetModifierObject(0));
     if (ctag == null)
     {
         return new TextTag("&{NULL}");
     }
     return ctag.Handle(data.Shrink());
 }
开发者ID:FreneticXYZ,项目名称:UnturnedFrenetic,代码行数:9,代码来源:ColorTagBase.cs

示例2: 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

示例3: 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

示例4: Handle

 public override TemplateObject Handle(TagData data)
 {
     if (data.Remaining == 0)
     {
         return this;
     }
     switch (data[0])
     {
         case "items":
             {
                 List<TemplateObject> list = new List<TemplateObject>();
                 foreach (Items items in Internal) {
                     for (byte i = 0; i < items.getItemCount(); i++)
                     {
                         ItemJar item = items.getItem(i);
                         list.Add(new ItemTag(item));
                     }
                 }
                 return new ListTag(list).Handle(data);
             }
         case "item":
             {
                 long index = IntegerTag.For(data, data.GetModifierObject(0)).Internal;
                 int curr = 0;
                 byte size;
                 while (index >= (size = Internal[curr].getItemCount()))
                 {
                     curr++;
                     if (curr == Internal.Length)
                     {
                         curr--;
                         index = Internal[curr].getItemCount() - 1;
                         break;
                     }
                     else
                     {
                         index -= size;
                     }
                 }
                 return new ItemTag(Internal[curr].getItem((byte)index));
             }
         default:
             return new TextTag(ToString()).Handle(data);
     }
 }
开发者ID:FreneticXYZ,项目名称:UnturnedFrenetic,代码行数:45,代码来源:InventoryTag.cs

示例5: Handle


//.........这里部分代码省略.........
         // @Example "blocks/dirt" .model_name returns "block".
         // -->
         case "model_name":
             return new TextTag(Internal.GetModelName()).Handle(data.Shrink());
         // <--[tag]
         // @Name ItemTag.shared_attributes
         // @Group General Information
         // @ReturnType MapTag
         // @Returns a full map of all this items shared attributes.
         // @Example "blocks/dirt" .shared_attributes returns an empty map.
         // -->
         case "shared_attributes":
             return new MapTag(Internal.SharedAttributes).Handle(data.Shrink());
         // <--[tag]
         // @Name ItemTag.local_attributes
         // @Group General Information
         // @ReturnType MapTag
         // @Returns a full map of all this items local attributes.
         // @Example "blocks/dirt" .local_attributes returns an empty map.
         // -->
         case "local_attributes":
             return new MapTag(Internal.Attributes).Handle(data.Shrink());
         // TODO: All other item properties!
         // <--[tag]
         // @Name ItemTag.with_count[<IntegerTag>]
         // @Group Modification
         // @ReturnType ItemTag
         // @Returns a copy of this item with the specified count of items. An input of 0 or less will result in an air item being returned.
         // @Example "blocks/dirt" .with_count[5] returns 5x "blocks/dirt".
         // -->
         case "with_count":
             {
                 ItemStack items = Internal.Duplicate();
                 items.Count = (int)IntegerTag.For(data, data.GetModifierObject(0)).Internal;
                 if (items.Count <= 0)
                 {
                     items = Internal.TheServer.Items.Air;
                 }
                 return new ItemTag(items).Handle(data.Shrink());
             }
         // <--[tag]
         // @Name ItemTag.with_bound_status[<BooleanTag>]
         // @Group Modification
         // @ReturnType ItemTag
         // @Returns a copy of this item with the specified 'bound' status.
         // @Example "blocks/dirt" .with_bound_status[true] returns a dirt block that can't be moved.
         // -->
         case "with_bound_status":
             {
                 ItemStack items = Internal.Duplicate();
                 items.IsBound = BooleanTag.For(data, data.GetModifierObject(0)).Internal;
                 return new ItemTag(items).Handle(data.Shrink());
             }
         // <--[tag]
         // @Name ItemTag.with_datum[<IntegerTag>]
         // @Group Modification
         // @ReturnType ItemTag
         // @Returns a copy of this item with the specified item datum value.
         // @Example "blocks/dirt" .with_datum[1] returns a dirt block that is secretly made of stone.
         // -->
         case "with_datum":
             {
                 ItemStack items = Internal.Duplicate();
                 items.Datum = (int)IntegerTag.For(data, data.GetModifierObject(0)).Internal;
                 return new ItemTag(items).Handle(data.Shrink());
             }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:67,代码来源:ItemTag.cs

示例6: Handle

 public override TemplateObject Handle(TagData data)
 {
     if (data.Remaining == 0)
     {
         return this;
     }
     switch (data[0])
     {
         // <--[tag]
         // @Name LocationTag.x
         // @Group General Information
         // @ReturnType NumberTag
         // @Returns the X coordinate of this location.
         // @Example "0,1,2" .x returns "0".
         // -->
         case "x":
             return new NumberTag(X).Handle(data.Shrink());
         // <--[tag]
         // @Name LocationTag.y
         // @Group General Information
         // @ReturnType NumberTag
         // @Returns the Y coordinate of this location.
         // @Example "0,1,2" .y returns "1".
         // -->
         case "y":
             return new NumberTag(Y).Handle(data.Shrink());
         // <--[tag]
         // @Name LocationTag.z
         // @Group General Information
         // @ReturnType NumberTag
         // @Returns the Z coordinate of this location.
         // @Example "0,1,2" .z returns "2".
         // -->
         case "z":
             return new NumberTag(Z).Handle(data.Shrink());
         // <--[tag]
         // @Name LocationTag.add[<LocationTag>]
         // @Group Mathematics
         // @ReturnType LocationTag
         // @Returns the result of adding the specified location to this location.
         // @Example "0,1,2" .add[2,1,0] returns "2,2,2".
         // -->
         case "add":
             {
                 LocationTag modif = LocationTag.For(data.GetModifier(0));
                 return new LocationTag(X + modif.X, Y + modif.Y, Z + modif.Z).Handle(data.Shrink());
             }
         // <--[tag]
         // @Name LocationTag.subtract[<LocationTag>]
         // @Group Mathematics
         // @ReturnType LocationTag
         // @Returns the result of subtracting the specified location from this location.
         // @Example "0,1,2" .subtract[0,1,2] returns "0,0,0".
         // -->
         case "subtract":
             {
                 LocationTag modif = LocationTag.For(data.GetModifier(0));
                 return new LocationTag(X - modif.X, Y - modif.Y, Z - modif.Z).Handle(data.Shrink());
             }
         // <--[tag]
         // @Name LocationTag.length
         // @Group Mathematics
         // @ReturnType NumberTag
         // @Returns the length from this location to the origin.
         // @Warning this tag requires a square root operation, which is a tiny bit slow internally. Consider using <@link tag LocationTag.length_squared>.
         // @Example "0,2,0" .length returns "2".
         // -->
         case "length":
             return new NumberTag(ToVector3().magnitude).Handle(data.Shrink());
         // <--[tag]
         // @Name LocationTag.length_squared
         // @Group Mathematics
         // @ReturnType NumberTag
         // @Returns the square of the length from this location to the origin.
         // @Example "0,2,0" .length_squared returns "4".
         // -->
         case "length_squared":
             return new NumberTag(ToVector3().sqrMagnitude).Handle(data.Shrink());
         // <--[tag]
         // @Name LocationTag.find_animals_within[<NumberTag>]
         // @Group World
         // @ReturnType ListTag<AnimalTag>
         // @Returns a list of all animals within the specified range (spherical).
         // @Example "0,1,2" .find_animals_within[10] returns "2|3|17".
         // -->
         case "find_animals_within":
             {
                 List<TemplateObject> animals = new List<TemplateObject>();
                 Vector3 vec3 = ToVector3();
                 float range = (float)NumberTag.For(data, data.GetModifierObject(0)).Internal;
                 foreach (Animal animal in AnimalManager.animals)
                 {
                     if ((animal.transform.position - vec3).sqrMagnitude <= range * range)
                     {
                         animals.Add(new AnimalTag(animal));
                     }
                 }
                 return new ListTag(animals).Handle(data.Shrink());
             }
         // <--[tag]
//.........这里部分代码省略.........
开发者ID:FreneticXYZ,项目名称:UnturnedFrenetic,代码行数:101,代码来源:LocationTag.cs

示例7: 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

示例8: Handle

 public override TemplateObject Handle(TagData data)
 {
     if (data.Remaining == 0)
     {
         return this;
     }
     switch (data[0])
     {
         // <--[tag]
         // @Name ColorTag.red
         // @Group General Information
         // @ReturnType NumberTag
         // @Returns the red value of this color.
         // @Example "0.1,0.2,0.3,1" .red returns "0.1".
         // -->
         case "red":
             return new NumberTag(Internal.r).Handle(data.Shrink());
         // <--[tag]
         // @Name ColorTag.green
         // @Group General Information
         // @ReturnType NumberTag
         // @Returns the green value of this color.
         // @Example "0.1,0.2,0.3,1" .green returns "0.2".
         // -->
         case "green":
             return new NumberTag(Internal.g).Handle(data.Shrink());
         // <--[tag]
         // @Name ColorTag.blue
         // @Group General Information
         // @ReturnType NumberTag
         // @Returns the blue value of this color.
         // @Example "0.1,0.2,0.3,1" .red returns "0.3".
         // -->
         case "blue":
             return new NumberTag(Internal.b).Handle(data.Shrink());
         // <--[tag]
         // @Name ColorTag.alpha
         // @Group General Information
         // @ReturnType NumberTag
         // @Returns the alpha value of this color.
         // @Example "0.1,0.2,0.3,1" .red returns "1".
         // -->
         case "alpha":
             return new NumberTag(Internal.a).Handle(data.Shrink());
         // <--[tag]
         // @Name ColorTag.mix[<ColorTag>|...]
         // @Group Mathematics
         // @ReturnType ColorTag
         // @Returns the result of mixing the specified color(s) with this one.
         // @Example "blue" .mix[red] returns "0.5,0,0.5,1"
         // -->
         case "mix":
             {
                 ListTag list = ListTag.For(data.GetModifierObject(0));
                 Color mixedColor = Internal;
                 foreach (TemplateObject tcolor in list.ListEntries)
                 {
                     ColorTag color = ColorTag.For(tcolor);
                     if (color == null)
                     {
                         SysConsole.Output(OutputType.ERROR, "Invalid color: " + TagParser.Escape(tcolor.ToString()));
                         continue;
                     }
                     mixedColor += color.Internal;
                 }
                 return new ColorTag(mixedColor / list.ListEntries.Count).Handle(data.Shrink());
             }
         default:
             return new TextTag(ToString()).Handle(data);
     }
 }
开发者ID:FreneticXYZ,项目名称:UnturnedFrenetic,代码行数:71,代码来源:ColorTag.cs


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