package mapped;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.Reflection;

@ObfuscatedName("fy")
public class class153 extends class144 {
   @ObfuscatedName("at")
   String field1687;
   // $FF: synthetic field
   @ObfuscatedSignature(
      descriptor = "Lfv;"
   )
   final class147 this$0;

   @ObfuscatedSignature(
      descriptor = "(Lfv;)V"
   )
   class153(class147 var1) {
      this.this$0 = var1;
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(Luj;I)V",
      garbageValue = "-734756620"
   )
   void vmethod3510(Buffer var1) {
      this.field1687 = var1.readStringCp1252NullTerminated_base();
      var1.readInt_base();
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(Lfc;I)V",
      garbageValue = "-2111347169"
   )
   void vmethod3506(ClanSettings var1) {
      var1.name = this.field1687;
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(Luj;II)V",
      garbageValue = "-522641810"
   )
   public static void method3310(Buffer var0, int var1) {
      ReflectionCheck var2 = new ReflectionCheck();
      var2.size = var0.readUnsignedByte_base();
      var2.id = var0.readInt_base();
      var2.operations = new int[var2.size];
      var2.creationErrors = new int[var2.size];
      var2.fields = new Field[var2.size];
      var2.intReplaceValues = new int[var2.size];
      var2.methods = new Method[var2.size];
      var2.arguments = new byte[var2.size][][];

      for(int var3 = 0; var3 < var2.size; ++var3) {
         try {
            int var4 = var0.readUnsignedByte_base();
            String var5;
            String var6;
            int var7;
            if(var4 != 0 && var4 != 1 && var4 != 2) {
               if(var4 == 3 || var4 == 4) {
                  var5 = var0.readStringCp1252NullTerminated_base();
                  var6 = var0.readStringCp1252NullTerminated_base();
                  var7 = var0.readUnsignedByte_base();
                  String[] var8 = new String[var7];

                  for(int var9 = 0; var9 < var7; ++var9) {
                     var8[var9] = var0.readStringCp1252NullTerminated_base();
                  }

                  String var20 = var0.readStringCp1252NullTerminated_base();
                  byte[][] var10 = new byte[var7][];
                  int var12;
                  if(var4 == 3) {
                     for(int var11 = 0; var11 < var7; ++var11) {
                        var12 = var0.readInt_base();
                        var10[var11] = new byte[var12];
                        var0.readBytes_base(var10[var11], 0, var12);
                     }
                  }

                  var2.operations[var3] = var4;
                  Class[] var21 = new Class[var7];

                  for(var12 = 0; var12 < var7; ++var12) {
                     var21[var12] = FloorOverlayDefinition.loadClassFromDescriptor_base(var8[var12]);
                  }

                  Class var22 = FloorOverlayDefinition.loadClassFromDescriptor_base(var20);
                  if(FloorOverlayDefinition.loadClassFromDescriptor_base(var5).getClassLoader() == null) {
                     throw new SecurityException();
                  }

                  Method[] var13 = FloorOverlayDefinition.loadClassFromDescriptor_base(var5).getDeclaredMethods();
                  Method[] var14 = var13;

                  for(int var15 = 0; var15 < var14.length; ++var15) {
                     Method var16 = var14[var15];
                     if(Reflection.getMethodName(var16).equals(var6)) {
                        Class[] var17 = Reflection.getParameterTypes(var16);
                        if(var17.length == var21.length) {
                           boolean var18 = true;

                           for(int var19 = 0; var19 < var21.length; ++var19) {
                              if(var17[var19] != var21[var19]) {
                                 var18 = false;
                                 break;
                              }
                           }

                           if(var18 && var22 == var16.getReturnType()) {
                              var2.methods[var3] = var16;
                           }
                        }
                     }
                  }

                  var2.arguments[var3] = var10;
               }
            } else {
               var5 = var0.readStringCp1252NullTerminated_base();
               var6 = var0.readStringCp1252NullTerminated_base();
               var7 = 0;
               if(var4 == 1) {
                  var7 = var0.readInt_base();
               }

               var2.operations[var3] = var4;
               var2.intReplaceValues[var3] = var7;
               if(FloorOverlayDefinition.loadClassFromDescriptor_base(var5).getClassLoader() == null) {
                  throw new SecurityException();
               }

               var2.fields[var3] = Reflection.findField(FloorOverlayDefinition.loadClassFromDescriptor_base(var5), var6);
            }
         } catch (ClassNotFoundException var24) {
            var2.creationErrors[var3] = -1;
         } catch (SecurityException var25) {
            var2.creationErrors[var3] = -2;
         } catch (NullPointerException var26) {
            var2.creationErrors[var3] = -3;
         } catch (Exception var27) {
            var2.creationErrors[var3] = -4;
         } catch (Throwable var28) {
            var2.creationErrors[var3] = -5;
         }
      }

      class36.reflectionChecks.method7287(var2);
   }

   @ObfuscatedName("ib")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "2091716300"
   )
   static final void method3311_base() {
      if(InterfaceParent.field1052) {
         UserComparator9.method2988_base();
         InterfaceParent.field1052 = false;
      }

   }

   @ObfuscatedName("ng")
   @ObfuscatedSignature(
      descriptor = "(IIIILuz;Lme;B)V",
      garbageValue = "4"
   )
   static final void method3309(int var0, int var1, int var2, int var3, SpritePixels var4, SpriteMask var5) {
      int var6 = var3 * var3 + var2 * var2;
      if(var6 > 4225 && var6 < 90000) {
         int var7 = Client.camAngleY & 2047;
         int var8 = Rasterizer3D.Rasterizer3D_sine[var7];
         int var9 = Rasterizer3D.Rasterizer3D_cosine[var7];
         int var10 = var9 * var2 + var3 * var8 >> 16;
         int var11 = var3 * var9 - var8 * var2 >> 16;
         double var12 = Math.atan2((double)var10, (double)var11);
         int var14 = var5.width / 2 - 25;
         int var15 = (int)(Math.sin(var12) * (double)var14);
         int var16 = (int)(Math.cos(var12) * (double)var14);
         byte var17 = 20;
         class11.redHintArrowSprite.method9823_base(var15 + (var0 + var5.width / 2 - var17 / 2), var5.height / 2 + var1 - var17 / 2 - var16 - 10, var17, var17, 15, 15, var12, 256);
      } else {
         class147.method3249(var0, var1, var2, var3, var4, var5);
      }

   }
}
