| 1 | package net.encode.wurmesp.util; |
| 2 | |
| 3 | import net.encode.wurmesp.WurmEspMod; |
| 4 | |
| 5 | public class TerrainUtils { |
| 6 | public static boolean isFlat(float[] tile) { |
| 7 | return tile[1] == tile[4] && tile[4] == tile[7] && tile[7] == tile[10]; |
| 8 | } |
| 9 | |
| 10 | public static boolean isNotRideable(float[] tile) { |
| 11 | return TerrainUtils.getTileSteepness(tile)[1] >= WurmEspMod.tilenotrideable; |
| 12 | } |
| 13 | |
| 14 | public static short[] getTileSteepness(float[] tile) { |
| 15 | short highest = -100; |
| 16 | short lowest = 32000; |
| 17 | for (int i = 1; i <= 10; i += 3) { |
| 18 | short height = 0; |
| 19 | height = (short)(tile[i] * 10.0f); |
| 20 | if (height > highest) { |
| 21 | highest = height; |
| 22 | } |
| 23 | if (height >= lowest) continue; |
| 24 | lowest = height; |
| 25 | } |
| 26 | int med = (highest + lowest) / 2; |
| 27 | return new short[]{(short)med, (short)(highest - lowest)}; |
| 28 | } |
| 29 | } |
| 30 | |