package mapped;

import net.runelite.api.Ignore;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSIgnoreList;
import net.runelite.rs.api.RSSpritePixels;

@ObfuscatedName("qs")
public class IgnoreList extends UserList<Ignore> implements RSIgnoreList {
   @ObfuscatedName("ar")
   @ObfuscatedGetter(
      intValue = 131186403
   )
   static int field4663;
   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "Ltt;"
   )
   final LoginType field4661;

   @ObfuscatedSignature(
      descriptor = "(Ltt;)V"
   )
   public IgnoreList(LoginType var1) {
      super(400);
      this.field4661 = var1;
   }

   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "(I)Lrf;",
      garbageValue = "794695059"
   )
   User vmethod8212() {
      return new Ignored();
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(II)[Lrf;",
      garbageValue = "-190310061"
   )
   User[] vmethod8221(int var1) {
      return new Ignored[var1];
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(Luj;IB)V",
      garbageValue = "-24"
   )
   public void method8056(Buffer var1, int var2) {
      while(var1.offset < var2) {
         int var3 = var1.readUnsignedByte_base();
         if(var3 == 4) {
            Username var4 = new Username(var1.readStringCp1252NullTerminated_base(), this.field4661);
            if(!var4.hasCleanName_base()) {
               throw new IllegalStateException();
            }

            boolean var10 = false;
            class12.friendSystem.removeIgnore_base(var4.getName_base(), var10);
         } else {
            boolean var9 = (var3 & 1) != 0;
            Username var5 = new Username(var1.readStringCp1252NullTerminated_base(), this.field4661);
            Username var6 = new Username(var1.readStringCp1252NullTerminated_base(), this.field4661);
            var1.readStringCp1252NullTerminated_base();
            if(!var5.hasCleanName_base()) {
               throw new IllegalStateException();
            }

            Ignored var7 = (Ignored)this.method8222(var5);
            if(var9) {
               Ignored var8 = (Ignored)this.method8222(var6);
               if(var8 != null && var7 != var8) {
                  if(var7 != null) {
                     this.method8189(var8);
                  } else {
                     var7 = var8;
                  }
               }
            }

            if(var7 != null) {
               this.method8194(var7, var5, var6);
            } else if(this.getSize_base() < 400) {
               int var11 = this.getSize_base();
               var7 = (Ignored)this.method8191(var5, var6);
               var7.id = var11;
            }
         }
      }

   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(Lol;IIB)Luz;",
      garbageValue = "-108"
   )
   public static SpritePixels method8066(AbstractArchive var0, int var1, int var2) {
      net.runelite.api.SpritePixels var3 = (net.runelite.api.SpritePixels)Client.spriteOverrides.get(Integer.valueOf(var1));
      return var3 != null?(SpritePixels)((RSSpritePixels)var3):(SpritePixels)Client.copy$SpriteBuffer_getSprite(var0, var1, var2, (byte)-123);
   }

   @ObfuscatedName("ab")
   @ObfuscatedSignature(
      descriptor = "(IIIIB)V",
      garbageValue = "35"
   )
   static void method8061_base(int var0, int var1, int var2, int var3) {
      for(ObjectSound var4 = (ObjectSound)ObjectSound.objectSounds.method7265(); var4 != null; var4 = (ObjectSound)ObjectSound.objectSounds.method7235()) {
         if(var4.soundEffectId != -1 || var4.soundEffectIds != null) {
            int var5 = 0;
            if(var1 > var4.maxX) {
               var5 += var1 - var4.maxX;
            } else if(var1 < var4.x) {
               var5 += var4.x - var1;
            }

            if(var2 > var4.maxY) {
               var5 += var2 - var4.maxY;
            } else if(var2 < var4.y) {
               var5 += var4.y - var2;
            }

            if(var5 - 64 <= var4.field824 && WorldMapIcon_1.clientPreferences.method2605_base() != 0 && var0 == var4.plane) {
               var5 -= 64;
               if(var5 < 0) {
                  var5 = 0;
               }

               int var6 = (var4.field824 - var5) * WorldMapIcon_1.clientPreferences.method2605_base() / var4.field824;
               if(var4.stream1 == null) {
                  if(var4.soundEffectId >= 0) {
                     SoundEffect var7 = SoundEffect.method761(Language.field4412, var4.soundEffectId, 0);
                     if(var7 != null) {
                        RawSound var8 = var7.method767().method772(class521.decimator);
                        RawPcmStream var9 = RawPcmStream.method949(var8, 100, var6);
                        var9.setNumLoops_base(-1);
                        LoginScreenAnimation.pcmStreamMixer.method713(var9);
                        var4.stream1 = var9;
                     }
                  }
               } else {
                  var4.stream1.method1000_base(var6);
               }

               if(var4.stream2 == null) {
                  if(var4.soundEffectIds != null && (var4.field832 -= var3) <= 0) {
                     int var11 = (int)(Math.random() * (double)var4.soundEffectIds.length);

                     if (var11 < var4.soundEffectIds.length) {
                        SoundEffect var12 = SoundEffect.method761(Language.field4412, var4.soundEffectIds[var11], 0);
                        if(var12 != null) {
                           RawSound var13 = var12.method767().method772(class521.decimator);
                           RawPcmStream var10 = RawPcmStream.method949(var13, 100, var6);
                           var10.setNumLoops_base(0);
                           LoginScreenAnimation.pcmStreamMixer.method713(var10);
                           var4.stream2 = var10;
                           var4.field832 = var4.field827 + (int)(Math.random() * (double)(var4.field828 - var4.field827));
                        }
                     }
                  }
               } else {
                  var4.stream2.method1000_base(var6);
                  if(!var4.stream2.hasNext_base()) {
                     var4.stream2 = null;
                  }
               }
            } else {
               if(var4.stream1 != null) {
                  LoginScreenAnimation.pcmStreamMixer.method745(var4.stream1);
                  var4.stream1 = null;
               }

               if(var4.stream2 != null) {
                  LoginScreenAnimation.pcmStreamMixer.method745(var4.stream2);
                  var4.stream2 = null;
               }
            }
         }
      }

   }

   @ObfuscatedName("my")
   @ObfuscatedSignature(
      descriptor = "(ZB)V",
      garbageValue = "-24"
   )
   static void setTapToDrop_base(boolean var0) {
      Client.tapToDrop = var0;
   }
}
