本文整理汇总了C#中Chraft.World.Blocks.StructBlock类的典型用法代码示例。如果您正苦于以下问题:C# StructBlock类的具体用法?C# StructBlock怎么用?C# StructBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StructBlock类属于Chraft.World.Blocks命名空间,在下文中一共展示了StructBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
{
// Load the blocks surrounding the position (NSEW) not diagonals
BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
int nsewCount = 0;
block.Chunk.ForNSEW(block.Coords, (uc) =>
{
nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(uc);
nsewBlockPositions[nsewCount] = uc;
nsewCount++;
});
// Count chests in list
if (nsewBlocks.Where((b) => b == BlockData.Blocks.Chest).Count() > 1)
{
// Cannot place next to two chests
return;
}
for (int i = 0; i < 4; i++)
{
UniversalCoords p = nsewBlockPositions[i];
if (nsewBlocks[i] == BlockData.Blocks.Chest && block.Chunk.IsNSEWTo(p, (byte)BlockData.Blocks.Chest))
{
// Cannot place next to a double chest
return;
}
}
base.Place(entity, block, targetBlock, face);
}
开发者ID:Smjert,项目名称:c-raft,代码行数:31,代码来源:BlockChest.cs
示例2: CanGrow
public bool CanGrow(StructBlock block)
{
// Crops grow from 0x0 to 0x7
if (block.MetaData == 0x07)
return false;
return true;
}
开发者ID:Smjert,项目名称:c-raft,代码行数:7,代码来源:BlockCrops.cs
示例3: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
{
Player player = (entity as Player);
if (player == null)
return;
if (face == BlockFace.Down)
return;
switch (face)
{
case BlockFace.Down: return;
case BlockFace.Up: block.MetaData = (byte)MetaData.Torch.Standing;
break;
case BlockFace.West: block.MetaData = (byte)MetaData.Torch.West;
break;
case BlockFace.East: block.MetaData = (byte)MetaData.Torch.East;
break;
case BlockFace.North: block.MetaData = (byte)MetaData.Torch.North;
break;
case BlockFace.South: block.MetaData = (byte)MetaData.Torch.South;
break;
}
base.Place(entity, block, targetBlock, face);
}
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:25,代码来源:BlockRedstoneTorch.cs
示例4: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
{
Player player = entity as Player;
if (player == null)
return;
// TODO: Bugged - should depend on the player's Yaw/Pitch
switch (player.Client.FacingDirection(4))
{
case "N":
block.MetaData = (byte)MetaData.Stairs.South;
break;
case "E":
block.MetaData = (byte)MetaData.Stairs.West;
break;
case "S":
block.MetaData = (byte)MetaData.Stairs.North;
break;
case "W":
block.MetaData = (byte)MetaData.Stairs.East;
break;
default:
return;
}
base.Place(entity, block, targetBlock, targetSide);
}
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:26,代码来源:BlockCobblestoneStairs.cs
示例5: CanBePlacedOn
protected override bool CanBePlacedOn(EntityBase who, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
{
Chunk chunk = GetBlockChunk(block);
if (chunk == null)
return false;
bool isDoubleChestNearby = false;
int chestCount = 0;
chunk.ForNSEW(block.Coords, uc =>
{
byte? nearbyBlockId = block.World.GetBlockId(uc);
if (nearbyBlockId == null)
return;
// Cannot place next to a double chest
if (nearbyBlockId == (byte)BlockData.Blocks.Chest)
{
chestCount++;
if (chunk.IsNSEWTo(uc, (byte)BlockData.Blocks.Chest))
isDoubleChestNearby = true;
}
});
if (isDoubleChestNearby || chestCount > 1)
return false;
return base.CanBePlacedOn(who, block, targetBlock, targetSide);
}
开发者ID:dekema2,项目名称:c-raft,代码行数:28,代码来源:BlockChest.cs
示例6: Grow
public void Grow(StructBlock block)
{
// Too high
/* if (Y > 120)
return;
// Grow a trunk. Replace only the BlockAir
for (int i = Y; i < Y + 5; i++)
{
if (Chunk.World.GetBlockId(X, i, Z) == (byte)BlockData.Blocks.Air)
WorldMgr.GetChunk(X, Z, false, true).ReplaceBlock(this, BlockData.Blocks.Log, BlockMeta);
else
break;
}
// Grow leaves
for (int i = Y + 2; i < Y + 5; i++)
for (int j = X - 2; j <= X + 2; j++)
for (int k = Z - 2; k <= Z + 2; k++)
if (!WorldMgr.ChunkExists(j, k) || !(WorldMgr.GetBlock(j, i, k) is BlockAir))
continue;
else
WorldMgr.GetChunk(j, k, false, true).ReplaceBlock(this, BlockData.Blocks.Leaves, BlockMeta);
for (int i = X - 1; i <= X + 1; i++)
for (int j = Z - 1; j <= Z + 1; j++)
if (!WorldMgr.ChunkExists(i, j) || !(WorldMgr.GetBlock(i, Y + 5, j) is BlockAir))
continue;
else
WorldMgr.GetChunk(i, j, false, true).ReplaceBlock(this, BlockData.Blocks.Leaves, BlockMeta);
foreach (Client c in WorldMgr.Server.GetNearbyPlayers(WorldMgr, X, Y, Z))
c.SendBlockRegion(X - 3, Y, Z - 3, 7, 7, 7);
*/
}
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:35,代码来源:BlockSapling.cs
示例7: StartPhysics
protected void StartPhysics(StructBlock block)
{
Remove(block);
FallingSand fsBlock = new FallingSand(block.World, new Location(block.Coords.WorldX + 0.5, block.Coords.WorldY + 0.5, block.Coords.WorldZ + 0.5));
fsBlock.Start();
block.World.PhysicsBlocks.TryAdd(fsBlock.EntityId, fsBlock);
}
开发者ID:Smjert,项目名称:c-raft,代码行数:7,代码来源:BlockSand.cs
示例8: DropItems
protected override void DropItems(EntityBase entity, StructBlock block)
{
LootTable = new List<ItemStack>();
if (block.World.Server.Rand.Next(5) == 0)
LootTable.Add(new ItemStack((short)BlockData.Blocks.Sapling, 1));
base.DropItems(entity, block);
}
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:7,代码来源:BlockLeaves.cs
示例9: Grow
public void Grow(StructBlock block)
{
if (!CanGrow(block))
return;
for (int i = block.Coords.WorldY; i < block.Coords.WorldY + 4; i++)
{
block.World.SetBlockAndData(block.Coords.WorldX, i, block.Coords.WorldZ, (byte)BlockData.Blocks.Log, block.MetaData);
if (block.World.GetBlockId(block.Coords.WorldX, i + 1, block.Coords.WorldZ) != (byte)BlockData.Blocks.Air)
break;
}
// Grow leaves
for (int i = block.Coords.WorldY + 2; i < block.Coords.WorldY + 5; i++)
for (int j = block.Coords.WorldX - 2; j <= block.Coords.WorldX + 2; j++)
for (int k = block.Coords.WorldZ - 2; k <= block.Coords.WorldZ + 2; k++)
if (!block.World.ChunkExists(j >> 4, k >> 4) || (block.World.GetBlockId(j, i, k) != (byte)BlockData.Blocks.Air))
continue;
else
block.World.SetBlockAndData(j, i, k, (byte)BlockData.Blocks.Leaves,
block.MetaData);
for (int i = block.Coords.WorldX - 1; i <= block.Coords.WorldX + 1; i++)
for (int j = block.Coords.WorldZ - 1; j <= block.Coords.WorldZ + 1; j++)
if (!block.World.ChunkExists(i >> 4, j >> 4) || (block.World.GetBlockId(i, block.Coords.WorldY + 5, j) != (byte)BlockData.Blocks.Air))
continue;
else
block.World.SetBlockAndData(i, block.Coords.WorldY + 5, j, (byte)BlockData.Blocks.Leaves,
block.MetaData);
AbsWorldCoords absCoords = new AbsWorldCoords(block.Coords);
foreach (Net.Client c in block.World.Server.GetNearbyPlayers(block.World, absCoords))
{
c.SendBlockRegion(block.Coords.WorldX - 3, block.Coords.WorldY, block.Coords.WorldZ - 3, 7, 7, 7);
}
}
开发者ID:Smjert,项目名称:c-raft,代码行数:35,代码来源:BlockSapling.cs
示例10: StartPhysics
protected void StartPhysics(StructBlock block)
{
Remove(block);
FallingGravel fgBlock = new FallingGravel(block.World, new AbsWorldCoords(block.Coords.WorldX + 0.5, block.Coords.WorldY + 0.5, block.Coords.WorldZ + 0.5));
fgBlock.Start();
block.World.PhysicsBlocks.TryAdd(fgBlock.EntityId, fgBlock);
}
开发者ID:dekema2,项目名称:c-raft,代码行数:7,代码来源:BlockGravel.cs
示例11: UpdateWorld
protected override void UpdateWorld(StructBlock block, bool isDestroyed = false)
{
base.UpdateWorld(block, isDestroyed);
if (!isDestroyed && block.Coords.WorldY > 1)
if (block.World.GetBlockId(block.Coords.WorldX, block.Coords.WorldY - 1, block.Coords.WorldZ) == (byte)BlockData.Blocks.Air)
StartPhysics(block);
}
开发者ID:dekema2,项目名称:c-raft,代码行数:7,代码来源:BlockGravel.cs
示例12: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
{
LivingEntity living = (entity as LivingEntity);
if (living == null)
return;
block.MetaData = GetDirection(living, block, targetBlock, face);
base.Place(entity, block, targetBlock, face);
}
开发者ID:dekema2,项目名称:c-raft,代码行数:8,代码来源:BlockBaseContainer.cs
示例13: DropItems
protected override void DropItems(EntityBase entity, StructBlock block, List<ItemStack> overridedLoot = null)
{
// SnowBlock requires 9 snowballs to craft and drops 4-6 snowballs upon destruction.
// No tools required.
overridedLoot = new List<ItemStack>();
overridedLoot.Add(new ItemStack((short)BlockData.Items.Snowball, (sbyte)(4 + block.World.Server.Rand.Next(2))));
base.DropItems(entity, block, overridedLoot);
}
开发者ID:dekema2,项目名称:c-raft,代码行数:8,代码来源:BlockSnowBlock.cs
示例14: NotifyDestroy
public override void NotifyDestroy(EntityBase entity, StructBlock sourceBlock, StructBlock targetBlock)
{
if ((targetBlock.Coords.WorldY - sourceBlock.Coords.WorldY) == 1 &&
targetBlock.Coords.WorldX == sourceBlock.Coords.WorldX &&
targetBlock.Coords.WorldZ == sourceBlock.Coords.WorldZ)
Destroy(targetBlock);
base.NotifyDestroy(entity, sourceBlock, targetBlock);
}
开发者ID:IdentErr,项目名称:c-raft,代码行数:8,代码来源:BlockTallGrass.cs
示例15: DropItems
protected override void DropItems(EntityBase entity, StructBlock block, List<ItemStack> overridedLoot = null)
{
overridedLoot = new List<ItemStack>();
int amount = block.World.Server.Rand.Next(10) - 7;
if (amount > 0)
overridedLoot.Add(new ItemStack((short)BlockData.Blocks.Red_Mushroom, (sbyte)amount));
base.DropItems(entity, block, overridedLoot);
}
开发者ID:dekema2,项目名称:c-raft,代码行数:8,代码来源:BlockRedMushroomCap.cs
示例16: DropItems
protected override void DropItems(EntityBase entity, StructBlock block)
{
LootTable = new List<ItemStack>();
int amount = block.World.Server.Rand.Next(10) - 7;
if (amount > 0)
LootTable.Add(new ItemStack((short)BlockData.Blocks.Brown_Mushroom, (sbyte)amount));
base.DropItems(entity, block);
}
开发者ID:IdentErr,项目名称:c-raft,代码行数:8,代码来源:BlockBrownMushroomCap.cs
示例17: Interact
public void Interact(EntityBase entity, StructBlock block)
{
Player player = entity as Player;
if (player == null)
return;
if (player.CurrentInterface != null)
return;
byte? blockId = block.World.GetBlockId(block.Coords);
if (blockId == null || !BlockHelper.Instance((byte)blockId).IsAir)
{
// Cannot open a chest if no space is above it
return;
}
Chunk chunk = GetBlockChunk(block);
// Double chest?
if (chunk.IsNSEWTo(block.Coords, block.Type))
{
// Is this chest the "North or East", or the "South or West"
BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
int nsewCount = 0;
chunk.ForNSEW(block.Coords, (uc) =>
{
nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(uc);
nsewBlockPositions[nsewCount] = uc;
nsewCount++;
});
if ((byte)nsewBlocks[0] == block.Type) // North
{
player.CurrentInterface = new LargeChestInterface(block.World, nsewBlockPositions[0], block.Coords);
}
else if ((byte)nsewBlocks[2] == block.Type) // East
{
player.CurrentInterface = new LargeChestInterface(block.World, nsewBlockPositions[2], block.Coords);
}
else if ((byte)nsewBlocks[1] == block.Type) // South
{
player.CurrentInterface = new LargeChestInterface(block.World, block.Coords, nsewBlockPositions[1]);
}
else if ((byte)nsewBlocks[3] == block.Type) // West
{
player.CurrentInterface = new LargeChestInterface(block.World, block.Coords, nsewBlockPositions[3]);
}
}
else
{
player.CurrentInterface = new SmallChestInterface(block.World, block.Coords);
}
player.CurrentInterface.Associate(player);
player.CurrentInterface.Open();
}
开发者ID:IdentErr,项目名称:c-raft,代码行数:57,代码来源:BlockChest.cs
示例18: Interact
public void Interact(EntityBase entity, StructBlock block)
{
Player player = entity as Player;
if (player == null)
return;
if (player.CurrentInterface != null)
return;
ContainerFactory.Open(player, block.Coords);
}
开发者ID:dekema2,项目名称:c-raft,代码行数:9,代码来源:BlockBaseContainer.cs
示例19: Touch
public override void Touch(EntityBase entity, StructBlock block, BlockFace face)
{
LivingEntity living = entity as LivingEntity;
if (living != null)
{
living.TouchedLava();
}
base.Touch(entity, block, face);
}
开发者ID:dekema2,项目名称:c-raft,代码行数:9,代码来源:BlockLava.cs
示例20: Interact
public void Interact(EntityBase entity, StructBlock block)
{
Player player = entity as Player;
if (player == null)
return;
if (player.CurrentInterface != null)
return;
if (!block.World.BlockHelper.Instance(block.World.GetBlockId(block.X, block.Y, block.Z)).IsAir)
{
// Cannot open a chest if no space is above it
return;
}
Chunk chunk = player.World.GetBlockChunk(block.X, block.Y, block.Z);
// Double chest?
// TODO: simplify chunk API so that no bit shifting is required
if (chunk.IsNSEWTo(block.X & 0xf, block.Y, block.Z & 0xf, block.Type))
{
// Is this chest the "North or East", or the "South or West"
BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
PointI[] nsewBlockPositions = new PointI[4];
int nsewCount = 0;
chunk.ForNSEW(block.X & 0xf, block.Y, block.Z & 0xf, (x1, y1, z1) =>
{
nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(x1, y1, z1);
nsewBlockPositions[nsewCount] = new PointI(x1, y1, z1);
nsewCount++;
});
if ((byte)nsewBlocks[0] == block.Type) // North
{
player.CurrentInterface = new LargeChestInterface(block.World, nsewBlockPositions[0], new PointI(block.X, block.Y, block.Z));
}
else if ((byte)nsewBlocks[2] == block.Type) // East
{
player.CurrentInterface = new LargeChestInterface(block.World, nsewBlockPositions[2], new PointI(block.X, block.Y, block.Z));
}
else if ((byte)nsewBlocks[1] == block.Type) // South
{
player.CurrentInterface = new LargeChestInterface(block.World, new PointI(block.X, block.Y, block.Z), nsewBlockPositions[1]);
}
else if ((byte)nsewBlocks[3] == block.Type) // West
{
player.CurrentInterface = new LargeChestInterface(block.World, new PointI(block.X, block.Y, block.Z), nsewBlockPositions[3]);
}
}
else
{
player.CurrentInterface = new SmallChestInterface(block.World, block.X, block.Y, block.Z);
}
player.CurrentInterface.Associate(player);
player.CurrentInterface.Open();
}
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:56,代码来源:BlockChest.cs
注:本文中的Chraft.World.Blocks.StructBlock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论