本文整理汇总了C#中IWorld.FindChunk方法的典型用法代码示例。如果您正苦于以下问题:C# IWorld.FindChunk方法的具体用法?C# IWorld.FindChunk怎么用?C# IWorld.FindChunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorld
的用法示例。
在下文中一共展示了IWorld.FindChunk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlockLoadedFromChunk
public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
{
var chunk = world.FindChunk(coords);
server.Scheduler.ScheduleEvent("farmland", chunk,
TimeSpan.FromSeconds(UpdateIntervalSeconds),
s => HydrationCheckEvent(s, coords, world));
}
示例2: BlockPlaced
public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
var chunk = world.FindChunk(descriptor.Coordinates);
user.Server.Scheduler.ScheduleEvent(chunk,
DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
s => TrySpread(descriptor.Coordinates, world, user.Server));
}
示例3: BlockPlaced
public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
var chunk = world.FindChunk(descriptor.Coordinates);
user.Server.Scheduler.ScheduleEvent("crops", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(30, 60)),
(server) => GrowBlock(server, world, descriptor.Coordinates + MathHelper.BlockFaceToCoordinates(face)));
}
示例4: BlockLoadedFromChunk
public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
{
var chunk = world.FindChunk(coords);
server.Scheduler.ScheduleEvent("cactus", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
s => TryGrowth(s, coords, world));
}
示例5: BlockLoadedFromChunk
public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
{
var chunk = world.FindChunk(coords);
server.Scheduler.ScheduleEvent(chunk,
DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
s => TrySpread(coords, world, server));
}
示例6: BlockLoadedFromChunk
public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
{
var chunk = world.FindChunk(coords);
server.Scheduler.ScheduleEvent("crops", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(30, 60)),
(s) => GrowBlock(s, world, coords));
}
示例7: ScheduleNextEvent
public void ScheduleNextEvent(Coordinates3D coords, IWorld world, IMultiplayerServer server)
{
if (world.GetBlockID(coords) == StillID)
return;
var chunk = world.FindChunk(coords);
server.Scheduler.ScheduleEvent("fluid", chunk,
TimeSpan.FromSeconds(SecondsBetweenUpdates), (_server) =>
AutomataUpdate(_server, world, coords));
}
示例8: BlockPlaced
public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
if (IsHydrated(descriptor.Coordinates, world))
{
world.SetMetadata(descriptor.Coordinates, 1);
}
var chunk = world.FindChunk(descriptor.Coordinates);
user.Server.Scheduler.ScheduleEvent(chunk,
DateTime.UtcNow.AddSeconds(UpdateIntervalSeconds),
server => HydrationCheckEvent(server, descriptor.Coordinates, world));
}
示例9: GrowBlock
private void GrowBlock(IMultiplayerServer server, IWorld world, Coordinates3D coords)
{
if (world.GetBlockID(coords) != BlockID)
return;
var meta = world.GetMetadata(coords);
meta++;
world.SetMetadata(coords, meta);
if (meta < 7)
{
var chunk = world.FindChunk(coords);
server.Scheduler.ScheduleEvent("crops",
chunk, TimeSpan.FromSeconds(MathHelper.Random.Next(30, 60)),
(_server) => GrowBlock(_server, world, coords));
}
}
示例10: BlockUpdate
public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
{
if (source.Coordinates == descriptor.Coordinates + Coordinates3D.Up)
{
var provider = world.BlockRepository.GetBlockProvider(source.ID);
if (provider.Opaque)
{
var chunk = world.FindChunk(descriptor.Coordinates, generate: false);
server.Scheduler.ScheduleEvent("grass", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(MinDecayTime, MaxDecayTime)), s =>
{
ScheduledUpdate(world, descriptor.Coordinates);
});
}
}
}
示例11: BlockPlaced
public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
if (ValidCactusPosition(descriptor, user.Server.BlockRepository, world))
base.BlockPlaced(descriptor, face, world, user);
else
{
world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
var manager = user.Server.GetEntityManagerForWorld(world);
manager.SpawnEntity(
new ItemEntity(descriptor.Coordinates + Coordinates3D.Up,
new ItemStack(CactusBlock.BlockID, (sbyte)1)));
// user.Inventory.PickUpStack() wasn't working?
}
var chunk = world.FindChunk(descriptor.Coordinates);
user.Server.Scheduler.ScheduleEvent("cactus", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
(server) => TryGrowth(server, descriptor.Coordinates, world));
}
示例12: ScheduleUpdate
public void ScheduleUpdate(IMultiplayerServer server, IWorld world, BlockDescriptor descriptor)
{
var chunk = world.FindChunk(descriptor.Coordinates);
server.Scheduler.ScheduleEvent("fire.spread", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(MinSpreadTime, MaxSpreadTime)),
s => DoUpdate(s, world, descriptor));
}
示例13: HydrationCheckEvent
void HydrationCheckEvent(IMultiplayerServer server, Coordinates3D coords, IWorld world)
{
if (world.GetBlockID(coords) != BlockID)
return;
if (MathHelper.Random.Next(3) == 0)
{
var meta = world.GetMetadata(coords);
if (IsHydrated(coords, world) && meta != 15)
meta++;
else
{
meta--;
if (meta == 0)
{
world.SetBlockID(coords, BlockID);
return;
}
}
world.SetMetadata(coords, meta);
}
var chunk = world.FindChunk(coords);
server.Scheduler.ScheduleEvent(chunk,
DateTime.UtcNow.AddSeconds(UpdateIntervalSeconds),
_server => HydrationCheckEvent(_server, coords, world));
}
示例14: 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;
}
}
}
示例15: TryGrowth
private void TryGrowth(IMultiplayerServer server, Coordinates3D coords, IWorld world)
{
if (world.GetBlockID(coords) != BlockID)
return;
// Find current height of stalk
int height = 0;
for (int y = -MaxGrowHeight; y <= MaxGrowHeight; y++)
{
if (world.GetBlockID(coords + (Coordinates3D.Down * y)) == BlockID)
height++;
}
if (height < MaxGrowHeight)
{
var meta = world.GetMetadata(coords);
meta++;
world.SetMetadata(coords, meta);
var chunk = world.FindChunk(coords);
if (meta == 15)
{
if (world.GetBlockID(coords + Coordinates3D.Up) == 0)
{
world.SetBlockID(coords + Coordinates3D.Up, BlockID);
server.Scheduler.ScheduleEvent("cactus", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
(_server) => TryGrowth(_server, coords + Coordinates3D.Up, world));
}
}
else
{
server.Scheduler.ScheduleEvent("cactus", chunk,
TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
(_server) => TryGrowth(_server, coords, world));
}
}
}