package mapped;

import net.runelite.api.coords.WorldPoint;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSAbstractWorldMapIcon;
import net.runelite.rs.api.RSCoord;

@ObfuscatedName("jc")
public abstract class AbstractWorldMapIcon implements RSAbstractWorldMapIcon {
   @ObfuscatedName("aa")
   @ObfuscatedSignature(
      descriptor = "Lmh;"
   )
   public final Coord coord2;
   @ObfuscatedName("ac")
   @ObfuscatedSignature(
      descriptor = "Lmh;"
   )
   public final Coord coord1;
   @ObfuscatedName("al")
   @ObfuscatedGetter(
      intValue = -1015538881
   )
   int screenX;
   @ObfuscatedName("az")
   @ObfuscatedGetter(
      intValue = 1546943709
   )
   int screenY;

   @ObfuscatedSignature(
      descriptor = "(Lmh;Lmh;)V"
   )
   AbstractWorldMapIcon(Coord var1, Coord var2) {
      this.coord1 = var1;
      this.coord2 = var2;
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(I)I",
      garbageValue = "574784276"
   )
   public abstract int getElement_base();

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(B)Ljk;",
      garbageValue = "34"
   )
   abstract WorldMapLabel vmethod4977();

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(I)I",
      garbageValue = "472460923"
   )
   abstract int getSubWidth_base();

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(I)I",
      garbageValue = "-653051141"
   )
   abstract int getSubHeight_base();

   @ObfuscatedName("aw")
   @ObfuscatedSignature(
      descriptor = "(IIB)Z",
      garbageValue = "-1"
   )
   boolean fitsScreen_base(int var1, int var2) {
      return this.elementFitsScreen_base(var1, var2)?true:this.labelFitsScreen_base(var1, var2);
   }

   @ObfuscatedName("ae")
   @ObfuscatedSignature(
      descriptor = "(S)Z",
      garbageValue = "497"
   )
   boolean hasValidElement_base() {
      return this.getElement_base() >= 0;
   }

   @ObfuscatedName("an")
   @ObfuscatedSignature(
      descriptor = "(III)Z",
      garbageValue = "384970426"
   )
   boolean elementFitsScreen_base(int var1, int var2) {
      if(!this.hasValidElement_base()) {
         return false;
      } else {
         WorldMapElement var3 = class141.method3209(this.getElement_base());
         int var4 = this.getSubWidth_base();
         int var5 = this.getSubHeight_base();
         switch(var3.horizontalAlignment.value) {
         case 0:
            if(var1 > this.screenX - var4 && var1 <= this.screenX) {
               break;
            }

            return false;
         case 1:
            if(var1 >= this.screenX && var1 < var4 + this.screenX) {
               break;
            }

            return false;
         case 2:
            if(var1 < this.screenX - var4 / 2 || var1 > var4 / 2 + this.screenX) {
               return false;
            }
         }

         switch(var3.verticalAlignment.value) {
         case 0:
            if(var2 < this.screenY - var5 / 2 || var2 > var5 / 2 + this.screenY) {
               return false;
            }
            break;
         case 1:
            if(var2 < this.screenY || var2 >= var5 + this.screenY) {
               return false;
            }
            break;
         case 2:
            if(var2 <= this.screenY - var5 || var2 > this.screenY) {
               return false;
            }
         }

         return true;
      }
   }

   @ObfuscatedName("ag")
   @ObfuscatedSignature(
      descriptor = "(III)Z",
      garbageValue = "870406805"
   )
   boolean labelFitsScreen_base(int var1, int var2) {
      WorldMapLabel var3 = this.vmethod4977();
      return var3 == null?false:(var1 >= this.screenX - var3.width / 2 && var1 <= var3.width / 2 + this.screenX?var2 >= this.screenY && var2 <= this.screenY + var3.height:false);
   }

   public RSCoord getRSCoordinate() {
      return this.coord1;
   }

   public WorldPoint getCoordinate() {
      return new WorldPoint(this.getRSCoordinate().getX(), this.getRSCoordinate().getY(), this.getRSCoordinate().getPlane());
   }

   public int getType() {
      return this.getElement_base();
   }
}
