From 06014de43f7bfe9eaf774f4982440f2ba752cb64 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 26 Aug 2017 17:17:15 +1000 Subject: [PATCH] simplify a few comparisons --- MCGalaxy/Blocks/Physics/HunterPhysics.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/MCGalaxy/Blocks/Physics/HunterPhysics.cs b/MCGalaxy/Blocks/Physics/HunterPhysics.cs index 850a4152c..da5892330 100644 --- a/MCGalaxy/Blocks/Physics/HunterPhysics.cs +++ b/MCGalaxy/Blocks/Physics/HunterPhysics.cs @@ -34,30 +34,33 @@ namespace MCGalaxy.Blocks.Physics { case 1: case 2: case 3: - if (closest.Pos.BlockX - x != 0) { + if (closest.Pos.BlockX != x) { index = lvl.PosToInt((ushort)(x + Math.Sign(closest.Pos.BlockX - x)), y, z); if (MoveFish(lvl, C.b, index, target)) return; - } + } + dirsVisited++; if (dirsVisited >= 3) break; goto case 4; case 4: case 5: case 6: - if (closest.Pos.BlockY - y != 0) { + if (closest.Pos.BlockY != y) { index = lvl.PosToInt(x, (ushort)(y + Math.Sign(closest.Pos.BlockY - y)), z); if (MoveFish(lvl, C.b, index, target)) return; } + dirsVisited++; if (dirsVisited >= 3) break; goto case 7; case 7: case 8: case 9: - if (closest.Pos.BlockZ - z != 0) { + if (closest.Pos.BlockZ != z) { index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign(closest.Pos.BlockZ - z))); if (MoveFish(lvl, C.b, index, target)) return; } + dirsVisited++; if (dirsVisited >= 3) break; goto case 1; @@ -79,30 +82,33 @@ namespace MCGalaxy.Blocks.Physics { case 1: case 2: case 3: - if (closest.Pos.BlockX - x != 0) { + if (closest.Pos.BlockX != x) { index = lvl.PosToInt((ushort)(x - Math.Sign(closest.Pos.BlockX - x)), y, z); if (MoveFish(lvl, C.b, index, target)) return; - } + } + dirsVisited++; if (dirsVisited >= 3) break; goto case 4; case 4: case 5: case 6: - if (closest.Pos.BlockY - y != 0) { + if (closest.Pos.BlockY != y) { index = lvl.PosToInt(x, (ushort)(y - Math.Sign(closest.Pos.BlockY - y)), z); if (MoveFish(lvl, C.b, index, target)) return; } + dirsVisited++; if (dirsVisited >= 3) break; goto case 7; case 7: case 8: case 9: - if (closest.Pos.BlockZ - z != 0) { + if (closest.Pos.BlockZ != z) { index = lvl.PosToInt(x, y, (ushort)(z - Math.Sign(closest.Pos.BlockZ - z))); if (MoveFish(lvl, C.b, index, target)) return; } + dirsVisited++; if (dirsVisited >= 3) break; goto case 1;