package mapped;

import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSCollisionMap;

@ObfuscatedName("iw")
public class CollisionMap implements RSCollisionMap {
   @ObfuscatedName("vj")
   @ObfuscatedGetter(
      intValue = 703712075
   )
   static int field2370;
   @ObfuscatedName("ba")
   @ObfuscatedGetter(
      intValue = -356375381
   )
   int xInset;
   @ObfuscatedName("bm")
   @ObfuscatedGetter(
      intValue = 1562012705
   )
   int yInset;
   @ObfuscatedName("bp")
   @ObfuscatedGetter(
      intValue = -562831735
   )
   int xSize;
   @ObfuscatedName("bw")
   @ObfuscatedGetter(
      intValue = 702872543
   )
   int ySize;
   @ObfuscatedName("bj")
   public int[][] flags;

   public CollisionMap(int var1, int var2) {
      this.xInset = 0;
      this.yInset = 0;
      this.xSize = var1;
      this.ySize = var2;
      this.flags = new int[this.xSize][this.ySize];
      this.clear_base();
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "1649069799"
   )
   public void clear_base() {
      for(int var1 = 0; var1 < this.xSize; ++var1) {
         for(int var2 = 0; var2 < this.ySize; ++var2) {
            if(var1 != 0 && var2 != 0 && var1 < this.xSize - 5 && var2 < this.ySize - 5) {
               this.flags[var1][var2] = 16777216;
            } else {
               this.flags[var1][var2] = 16777215;
            }
         }
      }

   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(IIIIZI)V",
      garbageValue = "854998385"
   )
   public void method4349_base(int var1, int var2, int var3, int var4, boolean var5) {
      var1 -= this.xInset;
      var2 -= this.yInset;
      if(var3 == 0) {
         if(var4 == 0) {
            this.setFlag_base(var1, var2, 128);
            this.setFlag_base(var1 - 1, var2, 8);
         }

         if(var4 == 1) {
            this.setFlag_base(var1, var2, 2);
            this.setFlag_base(var1, var2 + 1, 32);
         }

         if(var4 == 2) {
            this.setFlag_base(var1, var2, 8);
            this.setFlag_base(var1 + 1, var2, 128);
         }

         if(var4 == 3) {
            this.setFlag_base(var1, var2, 32);
            this.setFlag_base(var1, var2 - 1, 2);
         }
      }

      if(var3 == 1 || var3 == 3) {
         if(var4 == 0) {
            this.setFlag_base(var1, var2, 1);
            this.setFlag_base(var1 - 1, var2 + 1, 16);
         }

         if(var4 == 1) {
            this.setFlag_base(var1, var2, 4);
            this.setFlag_base(var1 + 1, var2 + 1, 64);
         }

         if(var4 == 2) {
            this.setFlag_base(var1, var2, 16);
            this.setFlag_base(var1 + 1, var2 - 1, 1);
         }

         if(var4 == 3) {
            this.setFlag_base(var1, var2, 64);
            this.setFlag_base(var1 - 1, var2 - 1, 4);
         }
      }

      if(var3 == 2) {
         if(var4 == 0) {
            this.setFlag_base(var1, var2, 130);
            this.setFlag_base(var1 - 1, var2, 8);
            this.setFlag_base(var1, var2 + 1, 32);
         }

         if(var4 == 1) {
            this.setFlag_base(var1, var2, 10);
            this.setFlag_base(var1, var2 + 1, 32);
            this.setFlag_base(var1 + 1, var2, 128);
         }

         if(var4 == 2) {
            this.setFlag_base(var1, var2, 40);
            this.setFlag_base(var1 + 1, var2, 128);
            this.setFlag_base(var1, var2 - 1, 2);
         }

         if(var4 == 3) {
            this.setFlag_base(var1, var2, 160);
            this.setFlag_base(var1, var2 - 1, 2);
            this.setFlag_base(var1 - 1, var2, 8);
         }
      }

      if(var5) {
         if(var3 == 0) {
            if(var4 == 0) {
               this.setFlag_base(var1, var2, 65536);
               this.setFlag_base(var1 - 1, var2, 4096);
            }

            if(var4 == 1) {
               this.setFlag_base(var1, var2, 1024);
               this.setFlag_base(var1, var2 + 1, 16384);
            }

            if(var4 == 2) {
               this.setFlag_base(var1, var2, 4096);
               this.setFlag_base(var1 + 1, var2, 65536);
            }

            if(var4 == 3) {
               this.setFlag_base(var1, var2, 16384);
               this.setFlag_base(var1, var2 - 1, 1024);
            }
         }

         if(var3 == 1 || var3 == 3) {
            if(var4 == 0) {
               this.setFlag_base(var1, var2, 512);
               this.setFlag_base(var1 - 1, var2 + 1, 8192);
            }

            if(var4 == 1) {
               this.setFlag_base(var1, var2, 2048);
               this.setFlag_base(var1 + 1, var2 + 1, 32768);
            }

            if(var4 == 2) {
               this.setFlag_base(var1, var2, 8192);
               this.setFlag_base(var1 + 1, var2 - 1, 512);
            }

            if(var4 == 3) {
               this.setFlag_base(var1, var2, 32768);
               this.setFlag_base(var1 - 1, var2 - 1, 2048);
            }
         }

         if(var3 == 2) {
            if(var4 == 0) {
               this.setFlag_base(var1, var2, 66560);
               this.setFlag_base(var1 - 1, var2, 4096);
               this.setFlag_base(var1, var2 + 1, 16384);
            }

            if(var4 == 1) {
               this.setFlag_base(var1, var2, 5120);
               this.setFlag_base(var1, var2 + 1, 16384);
               this.setFlag_base(var1 + 1, var2, 65536);
            }

            if(var4 == 2) {
               this.setFlag_base(var1, var2, 20480);
               this.setFlag_base(var1 + 1, var2, 65536);
               this.setFlag_base(var1, var2 - 1, 1024);
            }

            if(var4 == 3) {
               this.setFlag_base(var1, var2, 81920);
               this.setFlag_base(var1, var2 - 1, 1024);
               this.setFlag_base(var1 - 1, var2, 4096);
            }
         }
      }

   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(IIIIZB)V",
      garbageValue = "114"
   )
   public void addGameObject_base(int var1, int var2, int var3, int var4, boolean var5) {
      int var6 = 256;
      if(var5) {
         var6 += 131072;
      }

      var1 -= this.xInset;
      var2 -= this.yInset;

      for(int var7 = var1; var7 < var3 + var1; ++var7) {
         if(var7 >= 0 && var7 < this.xSize) {
            for(int var8 = var2; var8 < var2 + var4; ++var8) {
               if(var8 >= 0 && var8 < this.ySize) {
                  this.setFlag_base(var7, var8, var6);
               }
            }
         }
      }

   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(III)V",
      garbageValue = "-1907019996"
   )
   public void setBlockedByFloor_base(int var1, int var2) {
      var1 -= this.xInset;
      var2 -= this.yInset;
      this.flags[var1][var2] |= 2097152;
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(III)V",
      garbageValue = "-744902483"
   )
   public void setBlockedByFloorDec_base(int var1, int var2) {
      var1 -= this.xInset;
      var2 -= this.yInset;
      this.flags[var1][var2] |= 262144;
   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(IIIB)V",
      garbageValue = "1"
   )
   void setFlag_base(int var1, int var2, int var3) {
      this.flags[var1][var2] |= var3;
   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(IIIIZI)V",
      garbageValue = "1877141157"
   )
   public void method4382_base(int var1, int var2, int var3, int var4, boolean var5) {
      var1 -= this.xInset;
      var2 -= this.yInset;
      if(var3 == 0) {
         if(var4 == 0) {
            this.setFlagOff_base(var1, var2, 128);
            this.setFlagOff_base(var1 - 1, var2, 8);
         }

         if(var4 == 1) {
            this.setFlagOff_base(var1, var2, 2);
            this.setFlagOff_base(var1, var2 + 1, 32);
         }

         if(var4 == 2) {
            this.setFlagOff_base(var1, var2, 8);
            this.setFlagOff_base(var1 + 1, var2, 128);
         }

         if(var4 == 3) {
            this.setFlagOff_base(var1, var2, 32);
            this.setFlagOff_base(var1, var2 - 1, 2);
         }
      }

      if(var3 == 1 || var3 == 3) {
         if(var4 == 0) {
            this.setFlagOff_base(var1, var2, 1);
            this.setFlagOff_base(var1 - 1, var2 + 1, 16);
         }

         if(var4 == 1) {
            this.setFlagOff_base(var1, var2, 4);
            this.setFlagOff_base(var1 + 1, var2 + 1, 64);
         }

         if(var4 == 2) {
            this.setFlagOff_base(var1, var2, 16);
            this.setFlagOff_base(var1 + 1, var2 - 1, 1);
         }

         if(var4 == 3) {
            this.setFlagOff_base(var1, var2, 64);
            this.setFlagOff_base(var1 - 1, var2 - 1, 4);
         }
      }

      if(var3 == 2) {
         if(var4 == 0) {
            this.setFlagOff_base(var1, var2, 130);
            this.setFlagOff_base(var1 - 1, var2, 8);
            this.setFlagOff_base(var1, var2 + 1, 32);
         }

         if(var4 == 1) {
            this.setFlagOff_base(var1, var2, 10);
            this.setFlagOff_base(var1, var2 + 1, 32);
            this.setFlagOff_base(var1 + 1, var2, 128);
         }

         if(var4 == 2) {
            this.setFlagOff_base(var1, var2, 40);
            this.setFlagOff_base(var1 + 1, var2, 128);
            this.setFlagOff_base(var1, var2 - 1, 2);
         }

         if(var4 == 3) {
            this.setFlagOff_base(var1, var2, 160);
            this.setFlagOff_base(var1, var2 - 1, 2);
            this.setFlagOff_base(var1 - 1, var2, 8);
         }
      }

      if(var5) {
         if(var3 == 0) {
            if(var4 == 0) {
               this.setFlagOff_base(var1, var2, 65536);
               this.setFlagOff_base(var1 - 1, var2, 4096);
            }

            if(var4 == 1) {
               this.setFlagOff_base(var1, var2, 1024);
               this.setFlagOff_base(var1, var2 + 1, 16384);
            }

            if(var4 == 2) {
               this.setFlagOff_base(var1, var2, 4096);
               this.setFlagOff_base(var1 + 1, var2, 65536);
            }

            if(var4 == 3) {
               this.setFlagOff_base(var1, var2, 16384);
               this.setFlagOff_base(var1, var2 - 1, 1024);
            }
         }

         if(var3 == 1 || var3 == 3) {
            if(var4 == 0) {
               this.setFlagOff_base(var1, var2, 512);
               this.setFlagOff_base(var1 - 1, var2 + 1, 8192);
            }

            if(var4 == 1) {
               this.setFlagOff_base(var1, var2, 2048);
               this.setFlagOff_base(var1 + 1, var2 + 1, 32768);
            }

            if(var4 == 2) {
               this.setFlagOff_base(var1, var2, 8192);
               this.setFlagOff_base(var1 + 1, var2 - 1, 512);
            }

            if(var4 == 3) {
               this.setFlagOff_base(var1, var2, 32768);
               this.setFlagOff_base(var1 - 1, var2 - 1, 2048);
            }
         }

         if(var3 == 2) {
            if(var4 == 0) {
               this.setFlagOff_base(var1, var2, 66560);
               this.setFlagOff_base(var1 - 1, var2, 4096);
               this.setFlagOff_base(var1, var2 + 1, 16384);
            }

            if(var4 == 1) {
               this.setFlagOff_base(var1, var2, 5120);
               this.setFlagOff_base(var1, var2 + 1, 16384);
               this.setFlagOff_base(var1 + 1, var2, 65536);
            }

            if(var4 == 2) {
               this.setFlagOff_base(var1, var2, 20480);
               this.setFlagOff_base(var1 + 1, var2, 65536);
               this.setFlagOff_base(var1, var2 - 1, 1024);
            }

            if(var4 == 3) {
               this.setFlagOff_base(var1, var2, 81920);
               this.setFlagOff_base(var1, var2 - 1, 1024);
               this.setFlagOff_base(var1 - 1, var2, 4096);
            }
         }
      }

   }

   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "(IIIIIZI)V",
      garbageValue = "-1490436324"
   )
   public void setFlagOffNonSquare_base(int var1, int var2, int var3, int var4, int var5, boolean var6) {
      int var7 = 256;
      if(var6) {
         var7 += 131072;
      }

      var1 -= this.xInset;
      var2 -= this.yInset;
      int var8;
      if(var5 == 1 || var5 == 3) {
         var8 = var3;
         var3 = var4;
         var4 = var8;
      }

      for(var8 = var1; var8 < var3 + var1; ++var8) {
         if(var8 >= 0 && var8 < this.xSize) {
            for(int var9 = var2; var9 < var2 + var4; ++var9) {
               if(var9 >= 0 && var9 < this.ySize) {
                  this.setFlagOff_base(var8, var9, var7);
               }
            }
         }
      }

   }

   @ObfuscatedName("al")
   @ObfuscatedSignature(
      descriptor = "(IIII)V",
      garbageValue = "1035067169"
   )
   void setFlagOff_base(int var1, int var2, int var3) {
      this.flags[var1][var2] &= ~var3;
   }

   @ObfuscatedName("az")
   @ObfuscatedSignature(
      descriptor = "(IIB)V",
      garbageValue = "-95"
   )
   public void method4362_base(int var1, int var2) {
      var1 -= this.xInset;
      var2 -= this.yInset;
      this.flags[var1][var2] &= -262145;
   }

   public int[][] getFlags() {
      return this.flags;
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(I[BLrg;I)V",
      garbageValue = "412809840"
   )
   static void method4381(int var0, byte[] var1, ArchiveDisk var2) {
      ArchiveDiskAction var3 = new ArchiveDiskAction();
      var3.type = 0;
      var3.key = (long)var0;
      var3.data = var1;
      var3.archiveDisk = var2;
      NodeDeque var4 = ArchiveDiskActionHandler.ArchiveDiskActionHandler_requestQueue;
      synchronized(ArchiveDiskActionHandler.ArchiveDiskActionHandler_requestQueue) {
         ArchiveDiskActionHandler.ArchiveDiskActionHandler_requestQueue.method7233(var3);
      }

      Object var9 = ArchiveDiskActionHandler.field4272;
      synchronized(ArchiveDiskActionHandler.field4272) {
         if(ArchiveDiskActionHandler.field4271 == 0) {
            ArchiveDiskActionHandler.ArchiveDiskActionHandler_thread = new Thread(new ArchiveDiskActionHandler());
            ArchiveDiskActionHandler.ArchiveDiskActionHandler_thread.setDaemon(true);
            ArchiveDiskActionHandler.ArchiveDiskActionHandler_thread.start();
            ArchiveDiskActionHandler.ArchiveDiskActionHandler_thread.setPriority(5);
         }

         ArchiveDiskActionHandler.field4271 = 600;
         ArchiveDiskActionHandler.field4274 = false;
      }

   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/Throwable;Ljava/lang/String;)Lvf;"
   )
   public static RunException method4371(Throwable var0, String var1) {
      RunException var2;
      if(var0 instanceof RunException) {
         var2 = (RunException)var0;
         var2.message = var2.message + ' ' + var1;
      } else {
         var2 = new RunException(var0, var1);
      }

      return var2;
   }

   @ObfuscatedName("ae")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "2056075058"
   )
   static void method4354_base() {
      UserComparator7.method2966_base(24);
      class139.setLoginResponseString_base("The game servers are currently being updated.", "Please wait a few minutes and try again.", "");
   }
}
