package mapped;

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

@ObfuscatedName("jh")
public class WorldMapSection0 implements WorldMapSection, RSWorldMapSection0 {
   @ObfuscatedName("fs")
   @ObfuscatedSignature(
      descriptor = "Loh;"
   )
   static Archive archive9;
   @ObfuscatedName("at")
   @ObfuscatedGetter(
      intValue = -83863499
   )
   int oldZ;
   @ObfuscatedName("ah")
   @ObfuscatedGetter(
      intValue = 128970113
   )
   int newZ;
   @ObfuscatedName("ar")
   @ObfuscatedGetter(
      intValue = 1139039491
   )
   int oldX;
   @ObfuscatedName("ao")
   @ObfuscatedGetter(
      intValue = 1599297127
   )
   int oldY;
   @ObfuscatedName("ab")
   @ObfuscatedGetter(
      intValue = -1812273823
   )
   int newX;
   @ObfuscatedName("au")
   @ObfuscatedGetter(
      intValue = -184837991
   )
   int newY;
   @ObfuscatedName("aa")
   @ObfuscatedGetter(
      intValue = -2013058819
   )
   int oldChunkXLow;
   @ObfuscatedName("ac")
   @ObfuscatedGetter(
      intValue = -1476080185
   )
   int oldChunkYLow;
   @ObfuscatedName("al")
   @ObfuscatedGetter(
      intValue = -19462821
   )
   int oldChunkXHigh;
   @ObfuscatedName("az")
   @ObfuscatedGetter(
      intValue = -1537596473
   )
   int oldChunkYHigh;
   @ObfuscatedName("ap")
   @ObfuscatedGetter(
      intValue = -409385469
   )
   int newChunkXLow;
   @ObfuscatedName("av")
   @ObfuscatedGetter(
      intValue = 528474935
   )
   int newChunkYLow;
   @ObfuscatedName("ax")
   @ObfuscatedGetter(
      intValue = -1391652351
   )
   int newChunkXHigh;
   @ObfuscatedName("as")
   @ObfuscatedGetter(
      intValue = -351308513
   )
   int newChunkYHigh;

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Ljv;B)V",
      garbageValue = "16"
   )
   public void vmethod5026(WorldMapArea var1) {
      if(var1.regionLowX > this.newX) {
         var1.regionLowX = this.newX;
      }

      if(var1.regionHighX < this.newX) {
         var1.regionHighX = this.newX;
      }

      if(var1.regionLowY > this.newY) {
         var1.regionLowY = this.newY;
      }

      if(var1.regionHighY < this.newY) {
         var1.regionHighY = this.newY;
      }

   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(IIIB)Z",
      garbageValue = "2"
   )
   public boolean containsCoord_base(int var1, int var2, int var3) {
      return var1 >= this.oldZ && var1 < this.oldZ + this.newZ?var2 >= (this.oldX << 6) + (this.oldChunkXLow << 3) && var2 <= (this.oldX << 6) + (this.oldChunkXHigh << 3) + 7 && var3 >= (this.oldY << 6) + (this.oldChunkYLow << 3) && var3 <= (this.oldY << 6) + (this.oldChunkYHigh << 3) + 7:false;
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(III)Z",
      garbageValue = "904857809"
   )
   public boolean containsPosition_base(int var1, int var2) {
      return var1 >= (this.newX << 6) + (this.newChunkXLow << 3) && var1 <= (this.newX << 6) + (this.newChunkXHigh << 3) + 7 && var2 >= (this.newY << 6) + (this.newChunkYLow << 3) && var2 <= (this.newY << 6) + (this.newChunkYHigh << 3) + 7;
   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(IIIS)[I",
      garbageValue = "12300"
   )
   public int[] getBorderTileLengths_base(int var1, int var2, int var3) {
      if(!this.containsCoord_base(var1, var2, var3)) {
         return null;
      } else {
         int[] var4 = new int[]{this.newX * 64 - this.oldX * 64 + var2 + (this.newChunkXLow * 8 - this.oldChunkXLow * 8), var3 + (this.newY * 64 - this.oldY * 64) + (this.newChunkYLow * 8 - this.oldChunkYLow * 8)};
         return var4;
      }
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(III)Lmh;",
      garbageValue = "-1535299153"
   )
   public Coord vmethod5029(int var1, int var2) {
      if(!this.containsPosition_base(var1, var2)) {
         return null;
      } else {
         int var3 = this.oldX * 64 - this.newX * 64 + (this.oldChunkXLow * 8 - this.newChunkXLow * 8) + var1;
         int var4 = this.oldY * 64 - this.newY * 64 + var2 + (this.oldChunkYLow * 8 - this.newChunkYLow * 8);
         return new Coord(this.oldZ, var3, var4);
      }
   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(Luj;B)V",
      garbageValue = "-10"
   )
   public void vmethod5019(Buffer var1) {
      this.oldZ = var1.readUnsignedByte_base();
      this.newZ = var1.readUnsignedByte_base();
      this.oldX = var1.readUnsignedShort_base();
      this.oldChunkXLow = var1.readUnsignedByte_base();
      this.oldChunkXHigh = var1.readUnsignedByte_base();
      this.oldY = var1.readUnsignedShort_base();
      this.oldChunkYLow = var1.readUnsignedByte_base();
      this.oldChunkYHigh = var1.readUnsignedByte_base();
      this.newX = var1.readUnsignedShort_base();
      this.newChunkXLow = var1.readUnsignedByte_base();
      this.newChunkXHigh = var1.readUnsignedByte_base();
      this.newY = var1.readUnsignedShort_base();
      this.newChunkYLow = var1.readUnsignedByte_base();
      this.newChunkYHigh = var1.readUnsignedByte_base();
      this.postRead_base();
   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "-1662553303"
   )
   void postRead_base() {
   }
}
