package mapped;

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

@ObfuscatedName("jw")
public class WorldMapSection1 implements WorldMapSection, RSWorldMapSection1 {
   @ObfuscatedName("at")
   @ObfuscatedGetter(
      intValue = 1474955209
   )
   int minPlane;
   @ObfuscatedName("ah")
   @ObfuscatedGetter(
      intValue = -1334747113
   )
   int planes;
   @ObfuscatedName("ar")
   @ObfuscatedGetter(
      intValue = -414159951
   )
   int regionStartX;
   @ObfuscatedName("ao")
   @ObfuscatedGetter(
      intValue = -770703169
   )
   int regionStartY;
   @ObfuscatedName("ab")
   @ObfuscatedGetter(
      intValue = 845610489
   )
   int regionEndX;
   @ObfuscatedName("au")
   @ObfuscatedGetter(
      intValue = -1873789931
   )
   int regionEndY;

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

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

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

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

   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(IIIB)Z",
      garbageValue = "2"
   )
   public boolean containsCoord_base(int var1, int var2, int var3) {
      return var1 >= this.minPlane && var1 < this.planes + this.minPlane?var2 >> 6 == this.regionStartX && var3 >> 6 == this.regionStartY:false;
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(III)Z",
      garbageValue = "904857809"
   )
   public boolean containsPosition_base(int var1, int var2) {
      return var1 >> 6 == this.regionEndX && var2 >> 6 == this.regionEndY;
   }

   @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.regionEndX * 64 - this.regionStartX * 64 + var2, var3 + (this.regionEndY * 64 - this.regionStartY * 64)};
         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.regionStartX * 64 - this.regionEndX * 64 + var1;
         int var4 = this.regionStartY * 64 - this.regionEndY * 64 + var2;
         return new Coord(this.minPlane, var3, var4);
      }
   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(Luj;B)V",
      garbageValue = "-10"
   )
   public void vmethod5019(Buffer var1) {
      this.minPlane = var1.readUnsignedByte_base();
      this.planes = var1.readUnsignedByte_base();
      this.regionStartX = var1.readUnsignedShort_base();
      this.regionStartY = var1.readUnsignedShort_base();
      this.regionEndX = var1.readUnsignedShort_base();
      this.regionEndY = var1.readUnsignedShort_base();
      this.postRead_base();
   }

   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "(B)V",
      garbageValue = "4"
   )
   void postRead_base() {
   }
}
