本文整理汇总了C#中IWorld.FindBlockPosition方法的典型用法代码示例。如果您正苦于以下问题:C# IWorld.FindBlockPosition方法的具体用法?C# IWorld.FindBlockPosition怎么用?C# IWorld.FindBlockPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorld
的用法示例。
在下文中一共展示了IWorld.FindBlockPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
var _candidate = world.FindBlockPosition(candidate, out chunk);
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;
}
}
if (grow)
{
world.SetBlockID(candidate, GrassBlock.BlockID);
server.Scheduler.ScheduleEvent("grass", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
s => TrySpread(candidate, world, server));
}
break;
}
}
}