package mapped;

import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSModel;
import net.runelite.rs.api.RSRenderable;

@ObfuscatedName("kt")
public abstract class Renderable extends DualNode implements RSRenderable {
   @ObfuscatedName("ek")
   @ObfuscatedGetter(
      intValue = -2146691913
   )
   public int height;
   public boolean hidden;

   protected Renderable() {
      this.height = 1000;
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(B)Lka;",
      garbageValue = "1"
   )
   protected Model vmethod5504() {
      return null;
   }

   @ObfuscatedName("dw")
   void draw_base(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, long var9) {
      Model var11 = this.vmethod5504();
      if(var11 != null) {
         this.height = var11.height;
         var11.draw_base(var1, var2, var3, var4, var5, var6, var7, var8, var9);
      }

   }

   public RSModel getModel() {
      return this.vmethod5504();
   }

   public void setHidden(boolean var1) {
      this.hidden = var1;
   }

   public boolean isHidden() {
      return this.hidden;
   }

   public int getModelHeight() {
      return this.height;
   }

   public void setModelHeight(int var1) {
      this.height = var1;
   }

   public void draw(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, long var9) {
      this.draw_base(var1, var2, var3, var4, var5, var6, var7, var8, var9);
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(I)V",
      garbageValue = "1945159516"
   )
   static void method5509_base() {
      ByteArrayPool.field4590.clear();
      ByteArrayPool.field4590.add(Integer.valueOf(100));
      ByteArrayPool.field4590.add(Integer.valueOf(5000));
      ByteArrayPool.field4590.add(Integer.valueOf(10000));
      ByteArrayPool.field4590.add(Integer.valueOf(30000));
   }

   @ObfuscatedName("ld")
   @ObfuscatedSignature(
      descriptor = "(Lnn;IIZB)V",
      garbageValue = "-74"
   )
   static void method5510(Widget var0, int var1, int var2, boolean var3) {
      int var4 = var0.width;
      int var5 = var0.height;
      if(var0.widthAlignment == 0) {
         var0.width = var0.rawWidth;
      } else if(var0.widthAlignment == 1) {
         var0.width = var1 - var0.rawWidth;
      } else if(var0.widthAlignment == 2) {
         var0.width = var0.rawWidth * var1 >> 14;
      }

      if(var0.heightAlignment == 0) {
         var0.height = var0.rawHeight;
      } else if(var0.heightAlignment == 1) {
         var0.height = var2 - var0.rawHeight;
      } else if(var0.heightAlignment == 2) {
         var0.height = var2 * var0.rawHeight >> 14;
      }

      if(var0.widthAlignment == 4) {
         var0.width = var0.field3770 * var0.height / var0.field3677;
      }

      if(var0.heightAlignment == 4) {
         var0.height = var0.width * var0.field3677 / var0.field3770;
      }

      if(var0.contentType == 1337) {
         Client.viewportWidget = var0;
      }

      if(var0.type == 12) {
         var0.method6688_base().method6366_base(var0.width, var0.height);
      }

      if(var3 && var0.onResize != null && (var4 != var0.width || var5 != var0.height)) {
         ScriptEvent var6 = new ScriptEvent();
         var6.widget = var0;
         var6.args = var0.onResize;
         Client.scriptEvents.method7233(var6);
      }

   }
}
