| 836 | | |
|---|
| 837 | | uint startX = mapPos.x > radius - 1 ? mapPos.x - radius : 0; |
|---|
| 838 | | uint startY = mapPos.y > radius - 1 ? mapPos.y - radius : 0; |
|---|
| 839 | | |
|---|
| 840 | | uint endX = mapPos.x + typeInfo.dimension.x + radius < map.size.x ? |
|---|
| 841 | | mapPos.x + typeInfo.dimension.x + radius : |
|---|
| 842 | | mapPos.x + typeInfo.dimension.x; |
|---|
| 843 | | |
|---|
| 844 | | uint endY = mapPos.y + typeInfo.dimension.y + radius < map.size.y ? |
|---|
| 845 | | mapPos.y + typeInfo.dimension.y + radius : |
|---|
| 846 | | mapPos.y + typeInfo.dimension.y; |
|---|
| 847 | | |
|---|
| 848 | | for(uint y = startY; y < endY; y++) |
|---|
| 849 | | { |
|---|
| 850 | | for(uint x = startX; x < endX; x++) |
|---|
| 851 | | { |
|---|
| 852 | | if(map.getTile(x, y).free) |
|---|
| 853 | | return MapPos(x, y); |
|---|
| 854 | | } |
|---|
| | 836 | |
|---|
| | 837 | foreach(x, y; mapRectangle(1)) |
|---|
| | 838 | { |
|---|
| | 839 | if(map.getTile(x, y).free) |
|---|
| | 840 | return MapPos(x, y); |
|---|
| 864 | | |
|---|
| 865 | | uint startX = mapPos.x > radius - 1 ? mapPos.x - radius : 0; |
|---|
| 866 | | uint startY = mapPos.y > radius - 1 ? mapPos.y - radius : 0; |
|---|
| 867 | | |
|---|
| 868 | | uint endX = mapPos.x + typeInfo.dimension.x + radius < map.size.x ? |
|---|
| 869 | | mapPos.x + typeInfo.dimension.x + radius : |
|---|
| 870 | | mapPos.x + typeInfo.dimension.x; |
|---|
| 871 | | |
|---|
| 872 | | uint endY = mapPos.y + typeInfo.dimension.y + radius < map.size.y ? |
|---|
| 873 | | mapPos.y + typeInfo.dimension.y + radius : |
|---|
| 874 | | mapPos.y + typeInfo.dimension.y; |
|---|
| 880 | | for(uint y = startY; y < endY; y++) |
|---|
| 881 | | { |
|---|
| 882 | | for(uint x = startX; x < endX; x++) |
|---|
| 883 | | { |
|---|
| 884 | | if(!map.getTile(x, y).free) |
|---|
| 885 | | continue; |
|---|
| 886 | | |
|---|
| 887 | | MapPos pos = MapPos(x, y); |
|---|
| 888 | | |
|---|
| 889 | | auto distance = pos.distance(from); |
|---|
| 890 | | |
|---|
| 891 | | if(!hasResult || distance < minDistance) |
|---|
| 892 | | { |
|---|
| 893 | | minDistance = distance; |
|---|
| 894 | | result = pos; |
|---|
| 895 | | hasResult = true; |
|---|
| 896 | | } |
|---|
| | 855 | foreach(x, y; mapRectangle(1)) |
|---|
| | 856 | { |
|---|
| | 857 | if(!map.getTile(x, y).free) |
|---|
| | 858 | continue; |
|---|
| | 859 | |
|---|
| | 860 | MapPos pos = MapPos(x, y); |
|---|
| | 861 | |
|---|
| | 862 | auto distance = pos.distance(from); |
|---|
| | 863 | |
|---|
| | 864 | if(!hasResult || distance < minDistance) |
|---|
| | 865 | { |
|---|
| | 866 | minDistance = distance; |
|---|
| | 867 | result = pos; |
|---|
| | 868 | hasResult = true; |
|---|