package mapped;

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

@ObfuscatedName("hf")
public class NpcOverrides implements RSNpcOverrides {
   @ObfuscatedName("we")
   @ObfuscatedSignature(
      descriptor = "Ltn;"
   )
   static WorldMap worldMap;
   @ObfuscatedName("ck")
   static String otp;
   @ObfuscatedName("jr")
   @ObfuscatedGetter(
      intValue = -1134076095
   )
   static int baseX;
   @ObfuscatedName("at")
   @ObfuscatedGetter(
      longValue = -8617730847920988557L
   )
   public long field1917;
   @ObfuscatedName("ah")
   int[] modelIds;
   @ObfuscatedName("ar")
   short[] recolorTo;
   @ObfuscatedName("ao")
   short[] retextureTo;
   @ObfuscatedName("ab")
   public boolean useLocalPlayer;

   public NpcOverrides(long var1, int[] var3, short[] var4, short[] var5, boolean var6) {
      this.useLocalPlayer = false;
      this.field1917 = var1;
      this.modelIds = var3;
      this.recolorTo = var4;
      this.retextureTo = var5;
      this.useLocalPlayer = var6;
   }

   public int[] getModelIds() {
      return this.modelIds;
   }

   public short[] getColorToReplaceWith() {
      return this.recolorTo;
   }

   public short[] getTextureToReplaceWith() {
      return this.retextureTo;
   }

   public boolean useLocalPlayer() {
      return this.useLocalPlayer;
   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "([BI)Ldt;",
      garbageValue = "-357186857"
   )
   static Script method3690(byte[] var0) {
      Script var1 = new Script();
      Buffer var2 = new Buffer(var0);
      var2.offset = var2.array.length - 2;
      int var3 = var2.readUnsignedShort_base();
      int var4 = var2.array.length - 2 - var3 - 12;
      var2.offset = var4;
      int var5 = var2.readInt_base();
      var1.localIntCount = var2.readUnsignedShort_base();
      var1.localStringCount = var2.readUnsignedShort_base();
      var1.intArgumentCount = var2.readUnsignedShort_base();
      var1.stringArgumentCount = var2.readUnsignedShort_base();
      int var6 = var2.readUnsignedByte_base();
      int var7;
      int var8;
      if(var6 > 0) {
         var1.switches = var1.method2222(var6);

         for(var7 = 0; var7 < var6; ++var7) {
            var8 = var2.readUnsignedShort_base();
            IterableNodeHashTable var9 = new IterableNodeHashTable(var8 > 0?class184.method3680_base(var8):1);
            var1.switches[var7] = var9;

            while(var8-- > 0) {
               int var10 = var2.readInt_base();
               int var11 = var2.readInt_base();
               var9.put(new IntegerNode(var11), (long)var10);
            }
         }
      }

      var2.offset = 0;
      var1.field974 = var2.readStringCp1252NullTerminatedOrNull_base();
      var1.opcodes = new int[var5];
      var1.intOperands = new int[var5];
      var1.stringOperands = new String[var5];

      for(var7 = 0; var2.offset < var4; var1.opcodes[var7++] = var8) {
         var8 = var2.readUnsignedShort_base();
         if(var8 == 3) {
            var1.stringOperands[var7] = var2.readStringCp1252NullTerminated_base();
         } else if(var8 < 100 && var8 != 21 && var8 != 38 && var8 != 39) {
            var1.intOperands[var7] = var2.readInt_base();
         } else {
            var1.intOperands[var7] = var2.readUnsignedByte_base();
         }
      }

      return var1;
   }

   @ObfuscatedName("au")
   @ObfuscatedSignature(
      descriptor = "(Ljava/lang/CharSequence;II[BIB)I",
      garbageValue = "48"
   )
   public static int encodeStringCp1252_base(CharSequence var0, int var1, int var2, byte[] var3, int var4) {
      int var5 = var2 - var1;

      for(int var6 = 0; var6 < var5; ++var6) {
         char var7 = var0.charAt(var6 + var1);
         if(var7 > 0 && var7 < 128 || var7 >= 160 && var7 <= 255) {
            var3[var6 + var4] = (byte)var7;
         } else if(var7 == 8364) {
            var3[var6 + var4] = -128;
         } else if(var7 == 8218) {
            var3[var6 + var4] = -126;
         } else if(var7 == 402) {
            var3[var6 + var4] = -125;
         } else if(var7 == 8222) {
            var3[var6 + var4] = -124;
         } else if(var7 == 8230) {
            var3[var6 + var4] = -123;
         } else if(var7 == 8224) {
            var3[var6 + var4] = -122;
         } else if(var7 == 8225) {
            var3[var6 + var4] = -121;
         } else if(var7 == 710) {
            var3[var6 + var4] = -120;
         } else if(var7 == 8240) {
            var3[var6 + var4] = -119;
         } else if(var7 == 352) {
            var3[var6 + var4] = -118;
         } else if(var7 == 8249) {
            var3[var6 + var4] = -117;
         } else if(var7 == 338) {
            var3[var6 + var4] = -116;
         } else if(var7 == 381) {
            var3[var6 + var4] = -114;
         } else if(var7 == 8216) {
            var3[var6 + var4] = -111;
         } else if(var7 == 8217) {
            var3[var6 + var4] = -110;
         } else if(var7 == 8220) {
            var3[var6 + var4] = -109;
         } else if(var7 == 8221) {
            var3[var6 + var4] = -108;
         } else if(var7 == 8226) {
            var3[var6 + var4] = -107;
         } else if(var7 == 8211) {
            var3[var6 + var4] = -106;
         } else if(var7 == 8212) {
            var3[var6 + var4] = -105;
         } else if(var7 == 732) {
            var3[var6 + var4] = -104;
         } else if(var7 == 8482) {
            var3[var6 + var4] = -103;
         } else if(var7 == 353) {
            var3[var6 + var4] = -102;
         } else if(var7 == 8250) {
            var3[var6 + var4] = -101;
         } else if(var7 == 339) {
            var3[var6 + var4] = -100;
         } else if(var7 == 382) {
            var3[var6 + var4] = -98;
         } else if(var7 == 376) {
            var3[var6 + var4] = -97;
         } else {
            var3[var6 + var4] = 63;
         }
      }

      return var5;
   }

   @ObfuscatedName("nr")
   @ObfuscatedSignature(
      descriptor = "([BII)V",
      garbageValue = "2008735118"
   )
   static void method3688_base(byte[] var0, int var1) {
      if(Client.randomDatData == null) {
         Client.randomDatData = new byte[24];
      }

      class421.writeRandomDat_base(var0, var1, Client.randomDatData, 0, 24);
   }
}
