package mapped;

import net.runelite.api.Perspective;
import net.runelite.api.coords.LocalPoint;
import net.runelite.mapping.Export;
import net.runelite.mapping.ObfuscatedSignature;
import net.runelite.rs.api.RSModel;
import net.runelite.rs.api.RSRuneLiteObject;
import net.runelite.rs.api.RSSequenceDefinition;

public class RuneLiteObject extends GraphicsObject implements RSRuneLiteObject {
   @Export("model")
   @ObfuscatedSignature(
      descriptor = "Lka;"
   )
   public Model model;
   @Export("orientation")
   private int orientation;
   @Export("drawFrontTilesFirst")
   private boolean drawFrontTilesFirst;
   @Export("loop")
   public boolean loop;
   @Export("radius")
   private int radius;

   public RuneLiteObject() {
      this.radius = 60;
      super.isFinished = true;
   }

   @Export("isLooping")
   public boolean isLooping() {
      return this.loop;
   }

   @Export("isActive")
   public boolean isActive() {
      return !super.isFinished;
   }

   @Export("setActive")
   public void setActive(boolean var1) {
      if(super.isFinished == var1) {
         super.isFinished = !var1;
         if(var1) {
            super.frame = 0;
            super.frameCycle = 0;
            Client.graphicsObjects.method7233(this);
         } else {
            this.remove_base();
         }
      }

   }

   @Export("setShouldLoop")
   public void setShouldLoop(boolean var1) {
      this.loop = var1;
   }

   @Export("setModel")
   @ObfuscatedSignature(
      descriptor = "(Lka;)V"
   )
   public void setModel(Model var1) {
      this.model = var1;
   }

   @Export("setOrientation")
   public void setOrientation(int var1) {
      this.orientation = var1;
   }

   @Export("getOrientation")
   public int getOrientation() {
      return this.orientation;
   }

   @Export("setRadius")
   public void setRadius(int var1) {
      this.radius = var1;
   }

   @Export("getRadius")
   public int getRadius() {
      return this.radius;
   }

   @Export("setDrawFrontTilesFirst")
   public void setDrawFrontTilesFirst(boolean var1) {
      this.drawFrontTilesFirst = var1;
   }

   @Export("drawFrontTilesFirst")
   public boolean drawFrontTilesFirst() {
      return this.drawFrontTilesFirst;
   }

   public void setLocation(LocalPoint var1, int var2) {
      this.setX(var1.getX());
      this.setY(var1.getY());
      this.setLevel(var2);
      this.setZ(Perspective.getTileHeight(SpriteMask.client, var1, var2));
   }

   public void setAnimation(net.runelite.api.Animation var1) {
      this.setFrame(0);
      this.setFrameCycle(0);
      this.setSequenceDefinition((RSSequenceDefinition)var1);
   }

   public void advanceRL(int var1) {
      if(this.getSequenceDefinition() != null && this.isLooping() && this.finished()) {
         this.setFinished(false);
         this.setFrame(0);
         this.setFrameCycle(0);
      }

   }

   public void setModel(net.runelite.api.Model var1) {
      model = (Model) var1;
   }

   public RSModel getModelRl() {
      RSModel var1 = model;
      if(this.getSequenceDefinition() != null) {
         var1 = this.getSequenceDefinition().transformSpotAnimationModel(var1, this.getFrame());
      } else {
         var1 = var1.toSharedModel(true);
      }

      return var1;
   }
}
