コード例 #1
0
ファイル: RangeExt.cs プロジェクト: AllanNisbet/runuo
        /// <summary>
        ///     Gets a LandTile collection representing all LandTiles that are within 'range' of 'center' on the given 'map'
        /// </summary>
        public static List <LandTile> GetLandTilesInRange(this IPoint3D center, Map map, int range)
        {
            if (center == null || map == null)
            {
                return(new List <LandTile>());
            }

            range = Math.Abs(range);

            var tiles = new List <LandTile>((int)Math.Ceiling(Math.PI * Math.Sqrt(range)));

            ScanRange(
                center,
                map,
                range,
                r =>
            {
                if (!r.Excluded)
                {
                    tiles.Add(map.GetLandTile(r.Current));
                }

                return(false);
            },
                false);

            tiles.Free(false);

            return(tiles);
        }