本文整理匯總了C#中Chunk.SetLocation方法的典型用法代碼示例。如果您正苦於以下問題:C# Chunk.SetLocation方法的具體用法?C# Chunk.SetLocation怎麽用?C# Chunk.SetLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Chunk
的用法示例。
在下文中一共展示了Chunk.SetLocation方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SetChunk
/// <summary>
/// Saves an existing <see cref="Chunk"/> to the region at the given local coordinates.
/// </summary>
/// <param name="lcx">The local X-coordinate of a chunk relative to this region.</param>
/// <param name="lcz">The local Z-coordinate of a chunk relative to this region.</param>
/// <param name="chunk">A <see cref="Chunk"/> to save to the given location.</param>
/// <returns>A <see cref="ChunkRef"/> represneting the <see cref="Chunk"/> at its new location.</returns>
/// <remarks>If the local coordinates are out of bounds for this region, the action will be forwarded to the correct region
/// transparently. The <see cref="Chunk"/>'s internal global coordinates will be updated to reflect the new location.</remarks>
public ChunkRef SetChunk(int lcx, int lcz, Chunk chunk)
{
if (!LocalBoundsCheck(lcx, lcz)) {
Region alt = GetForeignRegion(lcx, lcz);
return (alt == null) ? null : alt.CreateChunk(ForeignX(lcx), ForeignZ(lcz));
}
DeleteChunk(lcx, lcz);
int cx = lcx + _rx * XDIM;
int cz = lcz + _rz * ZDIM;
chunk.SetLocation(cx, cz);
chunk.Save(GetChunkOutStream(lcx, lcz));
ChunkRef cr = ChunkRef.Create(this, lcx, lcz);
_cache.Insert(cr);
return cr;
}
示例2: SetChunkRef
/// <summary>
/// Replaces the underlying physical chunk with a different one, updating its physical location to reflect the ChunkRef.
/// </summary>
/// <remarks>
/// Use this function to save chunks that have been created or manipulated independently of a container, or to
/// move a physical chunk between locations within a container (by taking the reference from another ChunkRef).
/// </remarks>
/// <param name="chunk">Physical Chunk to store into the location represented by this ChunkRef.</param>
public void SetChunkRef(Chunk chunk)
{
_chunk = chunk;
_chunk.SetLocation(X, Z);
_dirty = true;
}