本文整理汇总了C#中Chraft.World.WorldManager.GetEntities方法的典型用法代码示例。如果您正苦于以下问题:C# WorldManager.GetEntities方法的具体用法?C# WorldManager.GetEntities怎么用?C# WorldManager.GetEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chraft.World.WorldManager
的用法示例。
在下文中一共展示了WorldManager.GetEntities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpawnMobs
public static void SpawnMobs(WorldManager world, bool spawnHostileMobs, bool spawnPeacefulMobs)
{
Client[] authClients = world.Server.GetAuthenticatedClients() as Client[];
var players = authClients.Where(c => c.Owner.World == world).Select(c => c.Owner).ToArray();
HashSet<int> chunksToSpawnIn = new HashSet<int>();
#region Get a list of all chunks within 8 chunks of any players
foreach (var player in players)
{
UniversalCoords coord = UniversalCoords.FromAbsWorld(player.Position);
for (int x = -MaxSpawnDistance; x <= MaxSpawnDistance; x++)
{
for (int z = -MaxSpawnDistance; z <= MaxSpawnDistance; z++)
{
chunksToSpawnIn.Add(UniversalCoords.FromChunkToPackedChunk(coord.ChunkX + x, coord.ChunkZ + z));
}
}
}
#endregion
// Get a list of Mob entities outside of the loop so we only get it once
Mob[] mobEntities = world.GetEntities().Where(e => e is Mob).Select((e) => e as Mob).ToArray();
// TODO: need to use Biome to get the list of mob types available for each category
// TODO: make the maximum count of mobs per category configurable
if (spawnHostileMobs)
{
DoSpawn(world, chunksToSpawnIn, mobEntities, Monsters, MaxMonsters);
}
if (spawnPeacefulMobs)
{
DoSpawn(world, chunksToSpawnIn, mobEntities, Creatures, MaxCreatures);
DoSpawn(world, chunksToSpawnIn, mobEntities, WaterCreatures, MaxWaterCreatures, true);
}
}