本文整理汇总了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;
}
示例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;
}
示例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));
}
示例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));
}
示例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;
}
示例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));
}
示例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));
}
}
示例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);
}
}
}
示例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);
}
示例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));
}
示例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));
}
}
}
示例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;
}
示例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));
}
}
}
示例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));
}
}
示例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;
}
}