本文整理汇总了C#中IWorld.GetBlockLight方法的典型用法代码示例。如果您正苦于以下问题:C# IWorld.GetBlockLight方法的具体用法?C# IWorld.GetBlockLight怎么用?C# IWorld.GetBlockLight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorld
的用法示例。
在下文中一共展示了IWorld.GetBlockLight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
// 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;
}
}
}
示例2: 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;
}
}
}