本文整理汇总了C#中IWorld.IsValidPosition方法的典型用法代码示例。如果您正苦于以下问题:C# IWorld.IsValidPosition方法的具体用法?C# IWorld.IsValidPosition怎么用?C# IWorld.IsValidPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorld
的用法示例。
在下文中一共展示了IWorld.IsValidPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScheduledUpdate
private void ScheduledUpdate(IWorld world, Coordinates3D coords)
{
if (world.IsValidPosition(coords + Coordinates3D.Up))
{
var id = world.GetBlockID(coords + Coordinates3D.Up);
var provider = world.BlockRepository.GetBlockProvider(id);
if (provider.Opaque)
world.SetBlockID(coords, DirtBlock.BlockID);
}
}
示例2: DoUpdate
public void DoUpdate(IMultiplayerServer server, IWorld world, BlockDescriptor descriptor)
{
var down = descriptor.Coordinates + Coordinates3D.Down;
var current = world.GetBlockID(descriptor.Coordinates);
if (current != FireBlock.BlockID && current != LavaBlock.BlockID && current != StationaryLavaBlock.BlockID)
return;
// Decay
var meta = world.GetMetadata(descriptor.Coordinates);
meta++;
if (meta == 0xE)
{
if (!world.IsValidPosition(down) || world.GetBlockID(down) != NetherrackBlock.BlockID)
{
world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
return;
}
}
world.SetMetadata(descriptor.Coordinates, meta);
if (meta > 9)
{
var pick = AdjacentBlocks[meta % AdjacentBlocks.Length];
var provider = BlockRepository
.GetBlockProvider(world.GetBlockID(pick + descriptor.Coordinates));
if (provider.Flammable)
world.SetBlockID(pick + descriptor.Coordinates, AirBlock.BlockID);
}
// Spread
DoSpread(server, world, descriptor);
// Schedule next event
ScheduleUpdate(server, world, descriptor);
}
示例3: TrySpread
public void TrySpread(Coordinates3D coords, IWorld world, IMultiplayerServer server)
{
if (!world.IsValidPosition(coords + Coordinates3D.Up))
return;
var sky = world.GetSkyLight(coords + Coordinates3D.Up);
var block = world.GetBlockLight(coords + Coordinates3D.Up);
if (sky < 9 && block < 9)
return;
for (int i = 0, j = MathHelper.Random.Next(GrowthCandidates.Length); i < GrowthCandidates.Length; i++, j++)
{
var candidate = GrowthCandidates[j % GrowthCandidates.Length] + coords;
if (!world.IsValidPosition(candidate) || !world.IsValidPosition(candidate + Coordinates3D.Up))
continue;
var id = world.GetBlockID(candidate);
if (id == DirtBlock.BlockID)
{
var _sky = world.GetSkyLight(candidate + Coordinates3D.Up);
var _block = world.GetBlockLight(candidate + Coordinates3D.Up);
if (_sky < 4 && _block < 4)
continue;
// TODO: Check for blocks above this one with light modifier >= 2 (and if so skip this block)
world.SetBlockID(candidate, GrassBlock.BlockID);
var chunk = world.FindChunk(candidate);
server.Scheduler.ScheduleEvent(chunk,
DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
s => TrySpread(candidate, world, server));
break;
}
}
}
示例4: BlockLeftClicked
public virtual void BlockLeftClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
var coords = descriptor.Coordinates + MathHelper.BlockFaceToCoordinates(face);
if (world.IsValidPosition(coords) && world.GetBlockID(coords) == FireBlock.BlockID)
world.SetBlockID(coords, 0);
}
示例5: TrySpread
public void TrySpread(Coordinates3D coords, IWorld world, IMultiplayerServer server)
{
if (!world.IsValidPosition(coords + Coordinates3D.Up))
return;
var sky = world.GetSkyLight(coords + Coordinates3D.Up);
var block = world.GetBlockLight(coords + Coordinates3D.Up);
if (sky < 9 && block < 9)
return;
for (int i = 0, j = MathHelper.Random.Next(GrowthCandidates.Length); i < GrowthCandidates.Length; i++, j++)
{
var candidate = GrowthCandidates[j % GrowthCandidates.Length] + coords;
if (!world.IsValidPosition(candidate) || !world.IsValidPosition(candidate + Coordinates3D.Up))
continue;
var id = world.GetBlockID(candidate);
if (id == DirtBlock.BlockID)
{
var _sky = world.GetSkyLight(candidate + Coordinates3D.Up);
var _block = world.GetBlockLight(candidate + Coordinates3D.Up);
if (_sky < 4 && _block < 4)
continue;
IChunk chunk = world.FindChunk(candidate);
bool grow = true;
for (int y = candidate.Y; y < chunk.GetHeight((byte)candidate.X, (byte)candidate.Z); y++)
{
var b = world.GetBlockID(new Coordinates3D(candidate.X, y, candidate.Z));
var p = world.BlockRepository.GetBlockProvider(b);
if (p.LightOpacity >= 2)
{
grow = false;
break;
}
}
world.SetBlockID(candidate, GrassBlock.BlockID);
server.Scheduler.ScheduleEvent(chunk,
DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
s => TrySpread(candidate, world, server));
break;
}
}
}