public Entity[] GetEntitiesAt(Vector3Int Blockpos, float Radius) { List <Entity> toReturn = new List <Entity>(); for (int i = 0; i < Entities.Count; i++) { if (Vector3Int.DistanceSquared(Entities[i].blockPosition, Blockpos) <= Radius * Radius) { toReturn.Add(Entities[i]); } } return(toReturn.ToArray()); }
/// <summary> /// Sorts the Vector3Ints by distance /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> private int DistanceSorter(Vector3Int a, Vector3Int b) { float da = Vector3Int.DistanceSquared(a, playerChunk); float db = Vector3Int.DistanceSquared(b, playerChunk); if (da < db) { return(-1); } else if (da > db) { return(1); } return(0); }
/// <summary> /// Sorts the Chunks by distance /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> private int ChunkDistanceSorter(Chunk a, Chunk b) { float da = Vector3Int.DistanceSquared(new Vector3Int(a.posX, a.posY, a.posZ), playerChunk); float db = Vector3Int.DistanceSquared(new Vector3Int(b.posX, b.posY, b.posZ), playerChunk); if (da < db) { return(-1); } else if (da > db) { return(1); } return(0); }