本文整理汇总了C#中Chraft.World.UniversalCoords类的典型用法代码示例。如果您正苦于以下问题:C# UniversalCoords类的具体用法?C# UniversalCoords怎么用?C# UniversalCoords使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UniversalCoords类属于Chraft.World命名空间,在下文中一共展示了UniversalCoords类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SingleContainerInterface
internal SingleContainerInterface(World.WorldManager world, InterfaceType interfaceType, UniversalCoords coords, sbyte slotCount)
: base(world, interfaceType, slotCount)
{
Coords = coords;
Load();
}
示例2: ForNSEW
public void ForNSEW(UniversalCoords coords, ForEachBlock predicate)
{
predicate(UniversalCoords.FromWorld(coords.WorldX - 1, coords.WorldY, coords.WorldZ));
predicate(UniversalCoords.FromWorld(coords.WorldX + 1, coords.WorldY, coords.WorldZ));
predicate(UniversalCoords.FromWorld(coords.WorldX, coords.WorldY, coords.WorldZ - 1));
predicate(UniversalCoords.FromWorld(coords.WorldX, coords.WorldY, coords.WorldZ + 1));
}
示例3: Open
/// <summary>
/// Opens the Workbench and specifies where items should be dropped if exiting the workbench with items still in it.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="z"></param>
public virtual void Open(UniversalCoords coords)
{
_useProvidedDropCoordinates = true;
_DropCoords = coords;
this.Open();
}
示例4: LargeChestInterface
/// <summary>
/// Creates a Large Chest interface for the two chests specified (North or East chest, and South or West chest)
/// </summary>
/// <param name="world"></param>
/// <param name="neChest">The North or East chest coordinates</param>
/// <param name="swChest">The South or West chest coordinates</param>
public LargeChestInterface(World.WorldManager world, UniversalCoords neChest, UniversalCoords swChest)
: base(world, InterfaceType.Chest, 54)
{
NEChest = neChest;
SWChest = swChest;
Load();
}
示例5: StopBurning
public static void StopBurning(WorldManager world, UniversalCoords coords)
{
string id = String.Format("{0}-{1},{2},{3}", world.Name, coords.WorldX, coords.WorldY, coords.WorldZ);
lock (_staticLock)
{
if (_furnaceInstances.ContainsKey(id))
_furnaceInstances[id].StopBurning();
}
}
示例6: ForAdjacent
public void ForAdjacent(UniversalCoords coords, ForEachBlock predicate)
{
predicate(UniversalCoords.FromWorld(coords.WorldX - 1, coords.WorldY, coords.WorldZ));
predicate(UniversalCoords.FromWorld(coords.WorldX + 1, coords.WorldY, coords.WorldZ));
predicate(UniversalCoords.FromWorld(coords.WorldX, coords.WorldY, coords.WorldZ - 1));
predicate(UniversalCoords.FromWorld(coords.WorldX, coords.WorldY, coords.WorldZ + 1));
if (coords.BlockY > 0)
predicate(UniversalCoords.FromWorld(coords.WorldX, coords.WorldY - 1, coords.WorldZ));
if (coords.BlockY < 127)
predicate(UniversalCoords.FromWorld(coords.WorldX, coords.WorldY + 1, coords.WorldZ));
}
示例7: BlockPathWeight
protected override double BlockPathWeight(UniversalCoords coords)
{
if (this.World.GetBlockId(coords.WorldX, coords.WorldY - 1, coords.WorldZ) == (byte)BlockData.Blocks.Grass)
{
return 10.0;
}
else
{
return this.World.GetBlockLightBrightness(coords) - 0.5; // stay out of lower half of brightness spectrum
}
}
示例8: fixed
public unsafe byte this[UniversalCoords coords]
{
get
{
fixed (byte* types = Types)
return types[coords.BlockPackedCoords];
}
set
{
fixed (byte* types = Types)
types[coords.BlockPackedCoords] = value;
}
}
示例9:
public Chunk this[UniversalCoords coords]
{
get
{
Chunk chunk;
Chunks.TryGetValue(coords.ChunkPackedCoords, out chunk);
return chunk;
}
private set
{
Chunks.AddOrUpdate(coords.ChunkPackedCoords, value, (key, oldValue) => value);
}
}
示例10: Destroy
public static void Destroy(WorldManager world, UniversalCoords coords)
{
PersistentContainer container = Instance(world, coords);
if (container == null)
return;
Chunk chunk = world.GetChunk(coords);
if (chunk == null)
return;
PersistentContainer unused;
container.Destroy();
chunk.Containers.TryRemove(container.Coords.BlockPackedCoords, out unused);
if (container is LargeChestContainer)
chunk.Containers.TryRemove((container as LargeChestContainer).SecondCoords.BlockPackedCoords, out unused);
}
示例11: Close
public static void Close(PersistentContainerInterface containerInterface, UniversalCoords coords)
{
PersistentContainer container = Instance(containerInterface.World, coords);
if (container == null)
return;
container.RemoveInterface(containerInterface);
Chunk chunk = container.World.GetChunk(coords);
if (chunk == null)
return;
PersistentContainer unused;
if (container is LargeChestContainer && container.IsUnused())
{
chunk.Containers.TryRemove(container.Coords.BlockPackedCoords, out unused);
chunk.Containers.TryRemove((container as LargeChestContainer).SecondCoords.BlockPackedCoords, out unused);
} else if (container is SmallChestContainer && container.IsUnused())
chunk.Containers.TryRemove(container.Coords.BlockPackedCoords, out unused);
}
示例12: GetDoubleChestCoords
public static UniversalCoords[] GetDoubleChestCoords(WorldManager world, UniversalCoords coords)
{
Chunk chunk = world.GetChunk(coords);
if (chunk == null || !IsDoubleChest(chunk, coords))
return null;
// 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;
byte? blockId;
chunk.ForNSEW(coords, uc =>
{
blockId = world.GetBlockId(uc) ?? 0;
nsewBlocks[nsewCount] = (BlockData.Blocks)blockId;
nsewBlockPositions[nsewCount] = uc;
nsewCount++;
});
UniversalCoords firstCoords;
UniversalCoords secondCoords;
if ((byte)nsewBlocks[0] == (byte)BlockData.Blocks.Chest) // North
{
firstCoords = nsewBlockPositions[0];
secondCoords = coords;
}
else if ((byte)nsewBlocks[2] == (byte)BlockData.Blocks.Chest) // East
{
firstCoords = nsewBlockPositions[2];
secondCoords = coords;
}
else if ((byte)nsewBlocks[1] == (byte)BlockData.Blocks.Chest) // South
{
firstCoords = coords;
secondCoords = nsewBlockPositions[1];
}
else// if ((byte)nsewBlocks[3] == (byte)BlockData.Blocks.Chest) // West
{
firstCoords = coords;
secondCoords = nsewBlockPositions[3];
}
return new UniversalCoords[] { firstCoords, secondCoords };
}
示例13: GrowCactus
public void GrowCactus(UniversalCoords coords)
{
if (GetType(coords) == BlockData.Blocks.Cactus)
return;
if (GetType(UniversalCoords.FromWorld(coords.WorldX, coords.WorldY - 3, coords.WorldZ)) == BlockData.Blocks.Cactus)
return;
if (!IsNSEWTo(coords, (byte)BlockData.Blocks.Air))
return;
if (World.Server.Rand.Next(60) == 0)
{
SetType(coords, BlockData.Blocks.Cactus);
}
}
示例14: Load
public static Chunk Load(UniversalCoords coords, WorldManager world)
{
string path = world.Folder + "/x" + coords.ChunkX + "_z" + coords.ChunkZ + ".gz";
if (!CanLoad(path))
return null;
Stream zip = null;
Chunk chunk = new Chunk(world, coords);
try
{
zip = new DeflateStream(File.Open(path, FileMode.Open), CompressionMode.Decompress);
int version = zip.ReadByte();
switch(version)
{
/* When there's a new mod you do:
case 1:
{
* dosomething
* goto case 0;
}*/
case 0:
{
chunk.LightToRecalculate = Convert.ToBoolean(zip.ReadByte());
chunk.HeightMap = new byte[16,16];
int height;
chunk.MaxHeight = 0;
for (int x = 0; x < 16; ++x)
{
for (int z = 0; z < 16; ++z)
{
height = chunk.HeightMap[x, z] = (byte) zip.ReadByte();
if (chunk.MaxHeight < height)
chunk.MaxHeight = height;
}
}
chunk.LoadAllBlocks(zip);
break;
}
}
}
catch (Exception ex)
{
world.Logger.Log(ex);
return null;
}
if (zip != null)
zip.Dispose();
(BlockHelper.Instance((byte) BlockData.Blocks.Sign_Post) as BlockSignBase).LoadSignsFromDisk(chunk, world.SignsFolder);
return chunk;
}
示例15: FurnaceInterface
public FurnaceInterface(World.WorldManager world, UniversalCoords coords)
: base(world, InterfaceType.Furnace, coords, 3)
{
}