public void SpawnMovers(int moverId, Vector3 position, float radius, int count) { for (var i = 0; i < count; i++) { var spawnedMover = new SpawnedMover { Id = Guid.NewGuid(), Position = position, MoverId = moverId, World = WorldManager.Worlds[1] }; SpawnedMovers[CurrentMaxSpawnedMover] = spawnedMover; CurrentMaxSpawnedMover++; } }
public SpawnedMover[] GetNearbyMovers(Player player, float distance, out int moverCount) { moverCount = 0; var spawnedMovers = new SpawnedMover[20480]; for (var i = 0; i < CurrentMaxSpawnedMover; i++) { var spawnedMover = SpawnedMovers[i]; if (player.WorldId == spawnedMover.World.Id && Vector3.Distance(player.Position, spawnedMover.Position) <= distance) { spawnedMovers[moverCount] = spawnedMover; moverCount++; } } return(spawnedMovers); }