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


C# IWorld.SetMetadata方法代码示例

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


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

示例1: BlockRightClicked

 public override bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     bool upper = ((DoorItem.DoorFlags)descriptor.Metadata & DoorItem.DoorFlags.Upper) == DoorItem.DoorFlags.Upper;
     var other = upper ? Coordinates3D.Down : Coordinates3D.Up;
     var otherMeta = world.GetMetadata(descriptor.Coordinates + other);
     world.SetMetadata(descriptor.Coordinates, (byte)(descriptor.Metadata ^ (byte)DoorItem.DoorFlags.Open));
     world.SetMetadata(descriptor.Coordinates + other, (byte)(otherMeta ^ (byte)DoorItem.DoorFlags.Open));
     return false;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:9,代码来源:DoorBlock.cs

示例2: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     var bottom = coordinates + MathHelper.BlockFaceToCoordinates(face);
     var top = bottom + Coordinates3D.Up;
     if (world.GetBlockID(top) != 0 || world.GetBlockID(bottom) != 0)
         return;
     DoorFlags direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = DoorFlags.Northwest;
             break;
         case Direction.South:
             direction = DoorFlags.Southeast;
             break;
         case Direction.East:
             direction = DoorFlags.Northeast;
             break;
         default: // Direction.West:
             direction = DoorFlags.Southwest;
             break;
     }
     user.Server.BlockUpdatesEnabled = false;
     world.SetBlockID(bottom, BlockID);
     world.SetMetadata(bottom, (byte)direction);
     world.SetBlockID(top, BlockID);
     world.SetMetadata(top, (byte)(direction | DoorFlags.Upper));
     user.Server.BlockUpdatesEnabled = true;
     item.Count--;
     user.Inventory[user.SelectedSlot] = item;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:31,代码来源:DoorItem.cs

示例3: BlockPlaced

 public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     if (IsHydrated(descriptor.Coordinates, world))
     {
         world.SetMetadata(descriptor.Coordinates, 1);
     }
     user.Server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(UpdateIntervalSeconds), (server) => HydrationCheckEvent(server, descriptor.Coordinates, world));
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:8,代码来源:FarmlandBlock.cs

示例4: BlockPlaced

        public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
        {
            double rotation = user.Entity.Yaw + 180 % 360;
            if (rotation < 0)
                rotation += 360;

            world.SetMetadata(descriptor.Coordinates, (byte)(rotation / 22.5));
        }
开发者ID:Gbear605,项目名称:TrueCraft,代码行数:8,代码来源:UprightSignBlock.cs

示例5: BlockRightClicked

 public override bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     if (descriptor.Metadata == 5)
         world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
     else
         world.SetMetadata(descriptor.Coordinates, (byte)(descriptor.Metadata + 1));
     return false;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:8,代码来源:CakeBlock.cs

示例6: BlockPlaced

 public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     if (IsHydrated(descriptor.Coordinates, world))
     {
         world.SetMetadata(descriptor.Coordinates, 1);
     }
     var chunk = world.FindChunk(descriptor.Coordinates);
     user.Server.Scheduler.ScheduleEvent("farmland", chunk,
         TimeSpan.FromSeconds(UpdateIntervalSeconds),
         server => HydrationCheckEvent(server, descriptor.Coordinates, world));
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:11,代码来源:FarmlandBlock.cs

示例7: GrowBlock

 private void GrowBlock(IMultiplayerServer server, IWorld world, Coordinates3D coords)
 {
     if (world.GetBlockID(coords) != BlockID)
         return;
     var meta = world.GetMetadata(coords);
     meta++;
     world.SetMetadata(coords, meta);
     if (meta < 7)
     {
         var chunk = world.FindChunk(coords);
         server.Scheduler.ScheduleEvent("crops",
             chunk, TimeSpan.FromSeconds(MathHelper.Random.Next(30, 60)),
            (_server) => GrowBlock(_server, world, coords));
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:15,代码来源:CropsBlock.cs

示例8: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     if (item.ID == ItemID) // Empty bucket
     {
         var block = world.GetBlockID(coordinates);
         if (block == WaterBlock.BlockID || block == StationaryWaterBlock.BlockID)
         {
             var meta = world.GetMetadata(coordinates);
             if (meta == 0) // Is source block?
             {
                 user.Inventory[user.SelectedSlot] = new ItemStack(WaterBucketItem.ItemID);
                 world.SetBlockID(coordinates, 0);
             }
         }
         else if (block == LavaBlock.BlockID || block == StationaryLavaBlock.BlockID)
         {
             var meta = world.GetMetadata(coordinates);
             if (meta == 0) // Is source block?
             {
                 user.Inventory[user.SelectedSlot] = new ItemStack(LavaBucketItem.ItemID);
                 world.SetBlockID(coordinates, 0);
             }
         }
     }
     else
     {
         var provider = user.Server.BlockRepository.GetBlockProvider(world.GetBlockID(coordinates));
         if (!provider.Opaque)
         {
             if (RelevantBlockType != null)
             {
                 var blockType = RelevantBlockType.Value;
                 user.Server.BlockUpdatesEnabled = false;
                 world.SetBlockID(coordinates, blockType);
                 world.SetMetadata(coordinates, 0); // Source block
                 user.Server.BlockUpdatesEnabled = true;
                 var liquidProvider = world.BlockRepository.GetBlockProvider(blockType);
                 liquidProvider.BlockPlaced(new BlockDescriptor { Coordinates = coordinates }, face, world, user);
             }
             user.Inventory[user.SelectedSlot] = new ItemStack(BucketItem.ItemID);
         }
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:44,代码来源:BucketItem.cs

示例9: BlockPlaced

 public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     byte meta = 0;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.East:
             meta = (byte)StairDirection.East;
             break;
         case Direction.West:
             meta = (byte)StairDirection.West;
             break;
         case Direction.North:
             meta = (byte)StairDirection.North;
             break;
         case Direction.South:
             meta = (byte)StairDirection.South;
             break;
         default:
             meta = 0; // Should never happen
             break;
     }
     world.SetMetadata(descriptor.Coordinates, meta);
 }
开发者ID:Gbear605,项目名称:TrueCraft,代码行数:23,代码来源:StairsBlock.cs

示例10: BlockPlaced

 public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     world.SetMetadata(descriptor.Coordinates, (byte)MathHelper.DirectionByRotationFlat(user.Entity.Yaw, true));
 }
开发者ID:Gbear605,项目名称:TrueCraft,代码行数:4,代码来源:PumpkinBlock.cs

示例11: TryGrowth

 private void TryGrowth(IMultiplayerServer server, Coordinates3D coords, IWorld world)
 {
     if (world.GetBlockID(coords) != BlockID)
         return;
     // Find current height of stalk
     int height = 0;
     for (int y = -3; y <= 3; y++)
     {
         if (world.GetBlockID(coords + (Coordinates3D.Down * y)) == BlockID)
             height++;
     }
     if (height < 3)
     {
         var meta = world.GetMetadata(coords);
         meta++;
         world.SetMetadata(coords, meta);
         if (meta == 15)
         {
             world.SetBlockID(coords + Coordinates3D.Up, BlockID);
             server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
                 (_server) => TryGrowth(_server, coords + Coordinates3D.Up, world));
         }
         else
         {
             server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
                 (_server) => TryGrowth(_server, coords, world));
         }
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:29,代码来源:SugarcaneBlock.cs

示例12: BlockRightClicked

 public override bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     // Flip bit back and forth between Open and Closed
     world.SetMetadata(descriptor.Coordinates, (byte)(descriptor.Metadata ^ (byte)TrapdoorFlags.Open));
     return false;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:6,代码来源:TrapdoorBlock.cs

示例13: TryGrowth

 private void TryGrowth(IMultiplayerServer server, Coordinates3D coords, IWorld world)
 {
     if (world.GetBlockID(coords) != BlockID)
         return;
     // Find current height of stalk
     int height = 0;
     for (int y = -MaxGrowHeight; y <= MaxGrowHeight; y++)
     {
         if (world.GetBlockID(coords + (Coordinates3D.Down * y)) == BlockID)
             height++;
     }
     if (height < MaxGrowHeight)
     {
         var meta = world.GetMetadata(coords);
         meta++;
         world.SetMetadata(coords, meta);
         var chunk = world.FindChunk(coords);
         if (meta == 15)
         {
             if (world.GetBlockID(coords + Coordinates3D.Up) == 0)
             {
                 world.SetBlockID(coords + Coordinates3D.Up, BlockID);
                 server.Scheduler.ScheduleEvent("cactus", chunk,
                     TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
                     (_server) => TryGrowth(_server, coords + Coordinates3D.Up, world));
             }
         }
         else
         {
             server.Scheduler.ScheduleEvent("cactus", chunk,
                 TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
                 (_server) => TryGrowth(_server, coords, world));
         }
     }
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:35,代码来源:CactusBlock.cs

示例14: GrowBlock

 private void GrowBlock(IMultiplayerServer server, IWorld world, Coordinates3D coords)
 {
     if (world.GetBlockID(coords) != BlockID)
         return;
     var meta = world.GetMetadata(coords);
     meta++;
     world.SetMetadata(coords, meta);
     if (meta < 7)
     {
         server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(MathHelper.Random.Next(30, 60)),
            (_server) => GrowBlock(_server, world, coords));
     }
 }
开发者ID:Luigifan,项目名称:TrueCraft,代码行数:13,代码来源:CropsBlock.cs

示例15: ItemUsedOnBlock

        public virtual void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            var old = world.GetBlockData(coordinates);
            if (!Overwritable.Any(b => b == old.ID))
            {
                coordinates += MathHelper.BlockFaceToCoordinates(face);
                old = world.GetBlockData(coordinates);
                if (!Overwritable.Any(b => b == old.ID))
                    return;
            }

            // Test for entities
            if (BoundingBox.HasValue)
            {
                var em = user.Server.GetEntityManagerForWorld(world);
                var entities = em.EntitiesInRange(coordinates, 3);
                var box = new BoundingBox(BoundingBox.Value.Min + (Vector3)coordinates,
                    BoundingBox.Value.Max + (Vector3)coordinates);
                foreach (var entity in entities)
                {
                    var aabb = entity as IAABBEntity;
                    if (aabb != null && !(entity is ItemEntity))
                    {
                        if (aabb.BoundingBox.Intersects(box))
                            return;
                    }
                    var player = entity as PlayerEntity; // Players do not implement IAABBEntity
                    if (player != null)
                    {
                        if (new BoundingBox(player.Position, player.Position + player.Size)
                            .Intersects(box))
                            return;
                    }
                }
            }

            // Place block
            world.SetBlockID(coordinates, ID);
            world.SetMetadata(coordinates, (byte)item.Metadata);

            BlockPlaced(world.GetBlockData(coordinates), face, world, user);

            if (!IsSupported(world.GetBlockData(coordinates), user.Server, world))
                world.SetBlockData(coordinates, old);
            else
            {
                item.Count--;
                user.Inventory[user.SelectedSlot] = item;
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:50,代码来源:BlockProvider.cs


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