public async void Spawn(IWorld world, IGrainFactory grainFactory, IChunkColumnStorage chunk, Random random, BlockWorldPos pos) { int num = random.Next(_groupMaxNum); for (int n = 0; n < num; ++n) { int x = random.Next(16); int z = random.Next(16); int height; for (height = 255; height >= 0; height--) { if (chunk[x, height, z] != BlockStates.Air()) { break; } } BlockWorldPos standPos = new BlockWorldPos(pos.X + x, height + 1, pos.Z + z); if (CanMobStand(world, grainFactory, chunk, random, standPos.ToBlockChunkPos())) { // 添加一个生物 /* * var eid = await world.NewEntityId(); * var entity = grainFactory.GetGrain<IPassiveMob>(world.MakeEntityKey(eid)); * await world.AttachEntity(entity); * * await entity.Spawn(Guid.NewGuid(), new Vector3(pos.X + x + 0.5F, height + 1, pos.Z + z + 0.5F), _mobType); * await entity.OnCreated(); */ IMob entity = grainFactory.GetGrain <IMob>(Guid.NewGuid()); await entity.Tell(new SpawnMob { World = world, EntityId = await world.NewEntityId(), Position = new EntityWorldPos(pos.X + x + 0.5F, height + 1, pos.Z + z + 0.5F), MobType = _mobType, }); } } }