/// <summary> /// Gets all objects encountered at the given position, in order from the highest existing layer in the layer mask downward. Layer mask defaults /// to all layers. /// </summary> /// <param name="x">X-value of the position to get objects for.</param> /// <param name="y">Y-value of the position to get objects for.</param> /// <param name="layerMask">Layer mask for which layers can return an object. Defaults to all layers.</param> /// <returns>All objects encountered at the given position, in order from the highest existing layer in the mask downward.</returns> public IEnumerable <IGameObject> GetObjects(int x, int y, uint layerMask = uint.MaxValue) { foreach (var entity in _entities.GetItems(x, y, layerMask)) { yield return(entity); } if (LayerMasker.HasLayer(layerMask, 0) && _terrain[x, y] != null) { yield return(_terrain[x, y]); } }