package mapped;

import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSAnimation;
import net.runelite.rs.api.RSFrames;

@ObfuscatedName("ko")
public class Frames extends DualNode implements RSFrames {
   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "[Lkr;"
   )
   Animation[] frames;

   @ObfuscatedSignature(
      descriptor = "(Lol;Lol;IZ)V"
   )
   Frames(AbstractArchive var1, AbstractArchive var2, int var3, boolean var4) {
      NodeDeque var5 = new NodeDeque();
      int var6 = var1.getGroupFileCount_base(var3);
      this.frames = new Animation[var6];
      int[] var7 = var1.getGroupFileIds_base(var3);

      for(int var8 = 0; var8 < var7.length; ++var8) {
         byte[] var9 = var1.takeFile_base(var3, var7[var8]);
         Skeleton var10 = null;
         int var11 = (var9[0] & 255) << 8 | var9[1] & 255;

         for(Skeleton var12 = (Skeleton)var5.method7265(); var12 != null; var12 = (Skeleton)var5.method7235()) {
            if(var11 == var12.id) {
               var10 = var12;
               break;
            }
         }

         if(var10 == null) {
            byte[] var13;
            if(var4) {
               var13 = var2.getFile_base(0, var11);
            } else {
               var13 = var2.getFile_base(var11, 0);
            }

            var10 = new Skeleton(var11, var13);
            var5.method7233(var10);
         }

         this.frames[var7[var8]] = new Animation(var9, var10);
      }

   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(IB)Z",
      garbageValue = "-58"
   )
   public boolean hasAlphaTransform_base(int var1) {
      return this.frames[var1].hasAlphaTransform;
   }

   public RSAnimation[] getFrames() {
      return this.frames;
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(II)Lhr;",
      garbageValue = "-1830265159"
   )
   public static ParamComposition method5518(int var0) {
      ParamComposition var1 = (ParamComposition)ParamComposition.ParamDefinition_cached.get((long)var0);
      if(var1 != null) {
         return var1;
      } else {
         byte[] var2 = ParamComposition.ParamDefinition_archive.takeFile_base(11, var0);
         var1 = new ParamComposition();
         if(var2 != null) {
            var1.method3814(new Buffer(var2));
         }

         var1.postDecode_base();
         ParamComposition.ParamDefinition_cached.put(var1, (long)var0);
         return var1;
      }
   }

   @ObfuscatedName("ao")
   @ObfuscatedSignature(
      descriptor = "(B)V",
      garbageValue = "-34"
   )
   static void method5517_base() {
      if(Login.Login_username == null || Login.Login_username.length() <= 0) {
         if(WorldMapIcon_1.clientPreferences.method2593_base() != null) {
            Login.Login_username = WorldMapIcon_1.clientPreferences.method2593_base();
            Client.onUsernameChanged(-1);
            Client.Login_isUsernameRemembered = true;
         } else {
            Client.Login_isUsernameRemembered = false;
         }

      }
   }
}
