Advertisement
RandomGuy32

Die Monstrosität

Sep 23rd, 2020
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.26 KB | None | 0 0
  1. private int getSpriteSheetIndex(int x, int y) {
  2.     boolean top = this.borderingTileTypes.contains(Game.activeRegion.getTile(x, y - 1));
  3.     boolean topRight = this.borderingTileTypes.contains(Game.activeRegion.getTile(x + 1, y - 1));
  4.     boolean right = this.borderingTileTypes.contains(Game.activeRegion.getTile(x + 1, y));
  5.     boolean bottomRight = this.borderingTileTypes.contains(Game.activeRegion.getTile(x + 1, y + 1));
  6.     boolean bottom = this.borderingTileTypes.contains(Game.activeRegion.getTile(x, y + 1));
  7.     boolean bottomLeft = this.borderingTileTypes.contains(Game.activeRegion.getTile(x - 1, y + 1));
  8.     boolean left = this.borderingTileTypes.contains(Game.activeRegion.getTile(x - 1, y));
  9.     boolean topLeft = this.borderingTileTypes.contains(Game.activeRegion.getTile(x - 1, y - 1));
  10.  
  11.     String s;
  12.  
  13.     /* ==================== AT LEAST ONE SIDE ==================== */
  14.     if (top) {
  15.         if (right) {
  16.             if (bottom) {
  17.                 if (left) {
  18.                     s = "TRBL";
  19.                 }
  20.                 else {
  21.                     s = "TRB";
  22.                 }
  23.             }
  24.             else if (left) {
  25.                 s = "TRL";
  26.             }
  27.             else if (bottomLeft) {
  28.                 s = "TR3";
  29.             }
  30.             else {
  31.                 s = "TR";
  32.             }
  33.         }
  34.         else if (bottom) {
  35.             if (left) {
  36.                 s = "TBL";
  37.             }
  38.             else {
  39.                 s = "TB";
  40.             }
  41.         }
  42.         else if (left) {
  43.             if (bottomRight) {
  44.                 s = "TL2";
  45.             }
  46.             else {
  47.                 s = "TL";
  48.             }
  49.         }
  50.         else {
  51.             if (bottomRight) {
  52.                 if (bottomLeft) {
  53.                     s = "T23";
  54.                 }
  55.                 else {
  56.                     s = "T2";
  57.                 }
  58.             }
  59.             else if (bottomLeft) {
  60.                 s = "T3";
  61.             }
  62.             else {
  63.                 s = "T";
  64.             }
  65.         }
  66.     }
  67.     else if (right) {
  68.         if (bottom) {
  69.             if (left) {
  70.                 s = "RBL";
  71.             }
  72.             else if (topLeft) {
  73.                 s = "RB4";
  74.             }
  75.             else {
  76.                 s = "RB";
  77.             }
  78.         }
  79.         else if (left) {
  80.             s = "RL";
  81.         }
  82.         else if (bottomLeft) {
  83.             if (topLeft) {
  84.                 s = "R34";
  85.             }
  86.             else {
  87.                 s = "R3";
  88.             }
  89.         }
  90.         else if (topLeft) {
  91.             s = "R4";
  92.         }
  93.         else {
  94.             s = "R";
  95.         }
  96.     }
  97.     else if (bottom) {
  98.         if (left) {
  99.             if (topRight) {
  100.                 s = "BL1";
  101.             }
  102.             else {
  103.                 s = "BL";
  104.             }
  105.         }
  106.         else if (topRight) {
  107.             if (topLeft) {
  108.                 s = "B14";
  109.             }
  110.             else {
  111.                 s = "B1";
  112.             }
  113.         }
  114.         else if (topLeft) {
  115.             s = "B4";
  116.         }
  117.         else {
  118.             s = "B";
  119.         }
  120.     }
  121.     else if (left) {
  122.         if (topRight) {
  123.             if (bottomRight) {
  124.                 s = "L12";
  125.             }
  126.             else {
  127.                 s = "L1";
  128.             }
  129.         }
  130.         else if (bottomRight) {
  131.             s = "L2";
  132.         }
  133.         else {
  134.             s = "L";
  135.         }
  136.     }
  137.  
  138.     /* ==================== CORNERS ONLY ==================== */
  139.     else if (topRight) {
  140.         if (bottomRight) {
  141.             if (bottomLeft) {
  142.                 if (topLeft) {
  143.                     s = "1234";
  144.                 }
  145.                 else {
  146.                     s = "123";
  147.                 }
  148.             }
  149.             else if (topLeft) {
  150.                 s = "124";
  151.             }
  152.             else {
  153.                 s = "12";
  154.             }
  155.         }
  156.         else if (bottomLeft) {
  157.             if (topLeft) {
  158.                 s = "134";
  159.             }
  160.             else {
  161.                 s = "13";
  162.             }
  163.         }
  164.         else if (topLeft) {
  165.             s = "14";
  166.         }
  167.         else {
  168.             s = "1";
  169.         }
  170.     }
  171.     else if (bottomRight) {
  172.         if (bottomLeft) {
  173.             if (topLeft) {
  174.                 s = "234";
  175.             }
  176.             else {
  177.                 s = "23";
  178.             }
  179.         }
  180.         else if (topLeft) {
  181.             s = "24";
  182.         }
  183.         else {
  184.             s = "2";
  185.         }
  186.     }
  187.     else if (bottomLeft) {
  188.         if (topLeft) {
  189.             s = "34";
  190.         }
  191.         else {
  192.             s = "3";
  193.         }
  194.     }
  195.     else if (topLeft) {
  196.         s = "4";
  197.     }
  198.  
  199.     /* ==================== NOTHING AT ALL ==================== */
  200.     else {
  201.         s = "_";
  202.     }
  203.  
  204.     return INDICES.indexOf(s);
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement