package mapped;

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

@ObfuscatedName("js")
public class WorldMapDecoration implements RSWorldMapDecoration {
   @ObfuscatedName("at")
   @ObfuscatedGetter(
      intValue = -1757511385
   )
   final int objectDefinitionId;
   @ObfuscatedName("ah")
   @ObfuscatedGetter(
      intValue = -982756641
   )
   final int decoration;
   @ObfuscatedName("ar")
   @ObfuscatedGetter(
      intValue = 805230653
   )
   final int rotation;

   WorldMapDecoration(int var1, int var2, int var3) {
      this.objectDefinitionId = var1;
      this.decoration = var2;
      this.rotation = var3;
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(B)Lrz;",
      garbageValue = "26"
   )
   public static class462 method4928_base() {
      class462[] var0 = class462.field4770;
      class462 var10000;
      synchronized(class462.field4770) {
         if(DirectByteArrayCopier.field3822 == 0) {
            var10000 = new class462();
            return var10000;
         }

         class462.field4770[--DirectByteArrayCopier.field3822].method8457_base();
         var10000 = class462.field4770[DirectByteArrayCopier.field3822];
      }

      return var10000;
   }

   @ObfuscatedName("jz")
   @ObfuscatedSignature(
      descriptor = "(II)V",
      garbageValue = "750324904"
   )
   static final void method4929_base(int var0) {
      int[] var1 = class102.sceneMinimapSprite.pixels;
      int var2 = var1.length;

      int var3;
      for(var3 = 0; var3 < var2; ++var3) {
         var1[var3] = 0;
      }

      int var4;
      int var5;
      for(var3 = 1; var3 < 103; ++var3) {
         var4 = (103 - var3) * 2048 + 24628;

         for(var5 = 1; var5 < 103; ++var5) {
            if((Tiles.Tiles_renderFlags[var0][var5][var3] & 24) == 0) {
               class36.scene.drawTileMinimap_base(var1, var4, 512, var0, var5, var3);
            }

            if(var0 < 3 && (Tiles.Tiles_renderFlags[var0 + 1][var5][var3] & 8) != 0) {
               class36.scene.drawTileMinimap_base(var1, var4, 512, var0 + 1, var5, var3);
            }

            var4 += 4;
         }
      }

      var3 = (238 + (int)(Math.random() * 20.0D) - 10 << 16) + (238 + (int)(Math.random() * 20.0D) - 10 << 8) + (238 + (int)(Math.random() * 20.0D) - 10);
      var4 = 238 + (int)(Math.random() * 20.0D) - 10 << 16;
      class102.sceneMinimapSprite.setRaster_base();

      int var6;
      for(var5 = 1; var5 < 103; ++var5) {
         for(var6 = 1; var6 < 103; ++var6) {
            if((Tiles.Tiles_renderFlags[var0][var6][var5] & 24) == 0) {
               class511.drawObject_base(var0, var6, var5, var3, var4);
            }

            if(var0 < 3 && (Tiles.Tiles_renderFlags[var0 + 1][var6][var5] & 8) != 0) {
               class511.drawObject_base(var0 + 1, var6, var5, var3, var4);
            }
         }
      }

      Client.mapIconCount = 0;

      for(var5 = 0; var5 < 104; ++var5) {
         for(var6 = 0; var6 < 104; ++var6) {
            long var7 = class36.scene.getFloorDecorationTag_base(ItemLayer.Client_plane, var5, var6);
            if(0L != var7) {
               int var9 = class232.Entity_unpackID_base(var7);
               int var10 = WorldMapSection2.method4515(var9).mapIconId;
               if(var10 >= 0 && class141.method3209(var10).field1824) {
                  Client.mapIcons[Client.mapIconCount] = class141.method3209(var10).method3564(false);
                  Client.mapIconXs[Client.mapIconCount] = var5;
                  Client.mapIconYs[Client.mapIconCount] = var6;
                  ++Client.mapIconCount;
               }
            }
         }
      }

      class338.rasterProvider.apply_base();
   }
}
