package mapped;

import net.runelite.api.coords.LocalPoint;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSObjectSound;

@ObfuscatedName("ca")
public final class ObjectSound extends Node implements RSObjectSound {
   @ObfuscatedName("at")
   @ObfuscatedSignature(
      descriptor = "Lon;"
   )
   static NodeDeque objectSounds;
   @ObfuscatedName("ah")
   @ObfuscatedGetter(
      intValue = -69802151
   )
   int plane;
   @ObfuscatedName("ar")
   @ObfuscatedGetter(
      intValue = -621731961
   )
   int x;
   @ObfuscatedName("ao")
   @ObfuscatedGetter(
      intValue = -1280498257
   )
   int y;
   @ObfuscatedName("ab")
   @ObfuscatedGetter(
      intValue = 471303989
   )
   int maxX;
   @ObfuscatedName("au")
   @ObfuscatedGetter(
      intValue = 1049389789
   )
   int maxY;
   @ObfuscatedName("aa")
   @ObfuscatedGetter(
      intValue = -1736475093
   )
   int field824;
   @ObfuscatedName("ac")
   @ObfuscatedGetter(
      intValue = 4042297
   )
   int soundEffectId;
   @ObfuscatedName("al")
   @ObfuscatedSignature(
      descriptor = "Lbb;"
   )
   RawPcmStream stream1;
   @ObfuscatedName("az")
   @ObfuscatedGetter(
      intValue = 2032217193
   )
   int field827;
   @ObfuscatedName("ap")
   @ObfuscatedGetter(
      intValue = -1837221441
   )
   int field828;
   @ObfuscatedName("av")
   int[] soundEffectIds;
   @ObfuscatedName("ax")
   @ObfuscatedGetter(
      intValue = 1799658609
   )
   int field832;
   @ObfuscatedName("as")
   @ObfuscatedSignature(
      descriptor = "Lbb;"
   )
   RawPcmStream stream2;
   @ObfuscatedName("ay")
   @ObfuscatedSignature(
      descriptor = "Lhs;"
   )
   ObjectComposition obj;

   static {
      objectSounds = new NodeDeque();
   }

   @ObfuscatedName("ar")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "249118325"
   )
   void set_base() {
      int var1 = this.soundEffectId;
      ObjectComposition var2 = this.obj.method3907();
      if(var2 != null) {
         this.soundEffectId = var2.ambientSoundId;
         this.field824 = var2.int7 * 128;
         this.field827 = var2.int5;
         this.field828 = var2.int6;
         this.soundEffectIds = var2.soundEffectIds;
      } else {
         this.soundEffectId = -1;
         this.field824 = 0;
         this.field827 = 0;
         this.field828 = 0;
         this.soundEffectIds = null;
      }

      if(var1 != this.soundEffectId && this.stream1 != null) {
         LoginScreenAnimation.pcmStreamMixer.method745(this.stream1);
         this.stream1 = null;
      }

   }

   public int getX() {
      return this.x;
   }

   public int getMaxX() {
      return this.maxX * 128;
   }

   public int getY() {
      return this.y * 128;
   }

   public int getMaxY() {
      return this.maxY * 128;
   }

   public LocalPoint getMinPosition() {
      return new LocalPoint(this.getX(), this.getY());
   }

   public LocalPoint getMaxPosition() {
      return new LocalPoint(this.getMaxX(), this.getMaxY());
   }

   public int getPlane() {
      return this.plane;
   }

   public int getSoundEffectId() {
      return this.soundEffectId;
   }

   public int[] getBackgroundSoundEffectIds() {
      return this.soundEffectIds;
   }

   @ObfuscatedName("ax")
   @ObfuscatedSignature(
      descriptor = "(III)I",
      garbageValue = "-737174701"
   )
   static int method1978_base(int var0, int var1) {
      for(int var2 = 0; var2 < 8; ++var2) {
         if(var1 <= var0 + 30) {
            return var2;
         }

         var0 += 30;
         var0 += var2 != 1 && var2 != 3?5:20;
      }

      return 0;
   }

   @ObfuscatedName("bp")
   @ObfuscatedSignature(
      descriptor = "(ILdt;ZB)I",
      garbageValue = "2"
   )
   static int method1973(int var0, Script var1, boolean var2) {
      int var3;
      if(var0 == 4200) {
         var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
         Interpreter.Interpreter_stringStack[++class127.Interpreter_stringStackSize - 1] = class214.method4226(var3).name;
         return 1;
      } else {
         int var4;
         ItemComposition var5;
         if(var0 == 4201) {
            DbTableType.Interpreter_intStackSize -= 2;
            var3 = Interpreter.Interpreter_intStack[DbTableType.Interpreter_intStackSize];
            var4 = Interpreter.Interpreter_intStack[DbTableType.Interpreter_intStackSize + 1];
            var5 = class214.method4226(var3);
            if(var4 >= 1 && var4 <= 5 && var5.groundActions[var4 - 1] != null) {
               Interpreter.Interpreter_stringStack[++class127.Interpreter_stringStackSize - 1] = var5.groundActions[var4 - 1];
            } else {
               Interpreter.Interpreter_stringStack[++class127.Interpreter_stringStackSize - 1] = "";
            }

            return 1;
         } else if(var0 == 4202) {
            DbTableType.Interpreter_intStackSize -= 2;
            var3 = Interpreter.Interpreter_intStack[DbTableType.Interpreter_intStackSize];
            var4 = Interpreter.Interpreter_intStack[DbTableType.Interpreter_intStackSize + 1];
            var5 = class214.method4226(var3);
            if(var4 >= 1 && var4 <= 5 && var5.inventoryActions[var4 - 1] != null) {
               Interpreter.Interpreter_stringStack[++class127.Interpreter_stringStackSize - 1] = var5.inventoryActions[var4 - 1];
            } else {
               Interpreter.Interpreter_stringStack[++class127.Interpreter_stringStackSize - 1] = "";
            }

            return 1;
         } else if(var0 == 4203) {
            var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
            Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = class214.method4226(var3).price;
            return 1;
         } else if(var0 == 4204) {
            var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
            Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = class214.method4226(var3).isStackable == 1?1:0;
            return 1;
         } else {
            ItemComposition var6;
            if(var0 == 4205) {
               var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
               var6 = class214.method4226(var3);
               if(var6.noteTemplate == -1 && var6.note >= 0) {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var6.note;
               } else {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var3;
               }

               return 1;
            } else if(var0 == 4206) {
               var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
               var6 = class214.method4226(var3);
               if(var6.noteTemplate >= 0 && var6.note >= 0) {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var6.note;
               } else {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var3;
               }

               return 1;
            } else if(var0 == 4207) {
               var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
               Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = class214.method4226(var3).isMembersOnly?1:0;
               return 1;
            } else if(var0 == 4208) {
               var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
               var6 = class214.method4226(var3);
               if(var6.placeholderTemplate == -1 && var6.placeholder >= 0) {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var6.placeholder;
               } else {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var3;
               }

               return 1;
            } else if(var0 == 4209) {
               var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
               var6 = class214.method4226(var3);
               if(var6.placeholderTemplate >= 0 && var6.placeholder >= 0) {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var6.placeholder;
               } else {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var3;
               }

               return 1;
            } else if(var0 == 4210) {
               String var7 = Interpreter.Interpreter_stringStack[--class127.Interpreter_stringStackSize];
               var4 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
               UrlRequest.findItemDefinitions_base(var7, var4 == 1);
               Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = BuddyRankComparator.foundItemIdCount;
               return 1;
            } else if(var0 != 4211) {
               if(var0 == 4212) {
                  ApproximateRouteStrategy.foundItemIndex = 0;
                  return 1;
               } else if(var0 == 4213) {
                  var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
                  var4 = class214.method4226(var3).getShiftClickIndex_base();
                  if(var4 == -1) {
                     Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var4;
                  } else {
                     Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var4 + 1;
                  }

                  return 1;
               } else if(var0 == 4214) {
                  var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = class214.method4226(var3).maleModel;
                  return 1;
               } else if(var0 == 4215) {
                  var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = class214.method4226(var3).maleModel1;
                  return 1;
               } else if(var0 == 4216) {
                  var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = class214.method4226(var3).maleModel2;
                  return 1;
               } else if(var0 == 4217) {
                  var3 = Interpreter.Interpreter_intStack[--DbTableType.Interpreter_intStackSize];
                  var6 = class214.method4226(var3);
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = var6.field2181;
                  return 1;
               } else {
                  return 2;
               }
            } else {
               if(MusicPatchNode.foundItemIds != null && ApproximateRouteStrategy.foundItemIndex < BuddyRankComparator.foundItemIdCount) {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = MusicPatchNode.foundItemIds[++ApproximateRouteStrategy.foundItemIndex - 1] & '\uffff';
               } else {
                  Interpreter.Interpreter_intStack[++DbTableType.Interpreter_intStackSize - 1] = -1;
               }

               return 1;
            }
         }
      }
   }

   @ObfuscatedName("hv")
   @ObfuscatedSignature(
      descriptor = "(S)V",
      garbageValue = "-6436"
   )
   static final void method1980_base() {
      class72.method2136_base();
      class184.field2023.clear_base();
      InvDefinition.method3530_base();
      KitDefinition.method3631_base();
      DbTableType.DBTableType_cache.clear_base();
      EnumComposition.EnumDefinition_cached.clear_base();
      class138.method3158_base();
      class172.method3534_base();
      AttackOption.method2751_base();
      Client.method1848_base();
      class145.method3247_base();
      HitSplatDefinition.method3858_base();
      InvDefinition.InvDefinition_cached.clear_base();
      class267.method5275_base();
      WorldMapElement.HitSplatDefinition_cached.clear_base();
      class185.field2026.clear_base();
      InterfaceParent.method2352_base();
      ItemComposition.ItemDefinition_cached.clear_base();
      ItemComposition.ItemDefinition_cachedModels.clear_base();
      ItemComposition.ItemDefinition_cachedSprites.clear_base();
      ModeWhere.method7211_base();
      SequenceDefinition.SequenceDefinition_cached.clear_base();
      SequenceDefinition.SequenceDefinition_cachedFrames.clear_base();
      SequenceDefinition.SequenceDefinition_cachedModel.clear_base();
      SpotAnimationDefinition.SpotAnimationDefinition_cached.clear_base();
      SpotAnimationDefinition.SpotAnimationDefinition_cachedModels.clear_base();
      WorldMapElement.method3589_base();
      class252.method4944_base();
      class399.Widget_cachedModels.method9078_base();
      Players.Widget_cachedFonts.method9078_base();
      class189.Widget_cachedSpriteMasks.clear_base();
      class191.field2100.clear_base();
      VarcInt.VarcInt_cached.clear_base();
      VarcInt.method3601_base();
      class171.field1909.clear_base();
      class208.method4152_base();
      class197.archive4.clear_base();
      LoginPacket.method5936_base();
      class195.field2136.clear_base();
      Client.DBTableIndex_cache.clear_base();
      Client.archive11.clear_base();
      RouteStrategy.method4389_base();
      HealthBarDefinition.widgetDefinition.method6288_base();
      ((TextureProvider)Rasterizer3D.clips.Rasterizer3D_textureLoader).clear_base();
      Canvas.method329_base();
      Client.field779.clearFiles_base();
      UserComparator7.field1441.clearFiles_base();
      class145.field1643.clearFiles_base();
      WorldMapDecorationType.archive10.clearFiles_base();
      class47.archive12.clearFiles_base();
      class344.archive2.clearFiles_base();
      class267.field2778.clearFiles_base();
      SoundSystem.field298.clearFiles_base();
      VarbitComposition.archive13.clearFiles_base();
      class313.archive4.clearFiles_base();
      WorldMapAreaData.field2641.clearFiles_base();
      Language.field4412.clearFiles_base();
      PcmPlayer.field281.clearFiles_base();
      WorldMapSection0.archive9.clearFiles_base();
      class514.archive6.clearFiles_base();
      class19.field92.clearFiles_base();
      class7.field25.clearFiles_base();
      GrandExchangeOfferOwnWorldComparator.archive8.clearFiles_base();
      Canvas.field114.clearFiles_base();
      StructComposition.field2041.clearFiles_base();
      WorldMapData_0.field2426.clearFiles_base();
      BuddyRankComparator.field1460.clearFiles_base();
      SpotAnimationDefinition.field2007.clearFiles_base();
   }
}
