package dev.crucifixbeta.mod.modules.impl.render;

import dev.crucifixbeta.mod.modules.Module;
import dev.crucifixbeta.mod.modules.settings.impl.BooleanSetting;
import dev.crucifixbeta.mod.modules.settings.impl.SliderSetting;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public class SwingModule extends Module {
   public static SwingModule INSTANCE;
   public final BooleanSetting swingSpeed = this.add(new BooleanSetting("SwingSpeed", false, this::swingSettingsVisible));
   public final SliderSetting swingFactor = this.add(
      new SliderSetting("SwingFactor", 6, 1, 20, () -> this.swingSettingsVisible() && this.swingSpeed.getValue())
   );
   public final BooleanSetting selfOnly = this.add(
      new BooleanSetting("SelfOnly", true, () -> this.swingSettingsVisible() && this.swingSpeed.getValue())
   );
   public final BooleanSetting eatTransform = this.add(new BooleanSetting("EatTransform", false, this::swingSettingsVisible));
   public final SliderSetting eatTransformFactor = this.add(
      new SliderSetting("EatTransformFactor", 1.0, 0.0, 1.0, 0.01, () -> this.swingSettingsVisible() && this.eatTransform.getValue())
   );

   public SwingModule() {
      this("Swing", Module.Category.Render);
      this.setChinese("\u6325\u624b\u52a8\u753b");
      INSTANCE = this;
   }

   protected SwingModule(String name, Module.Category category) {
      super(name, category);
      INSTANCE = this;
   }

   public boolean shouldModifySwingSpeed() {
      return this.isOn() && this.swingSpeed.getValue();
   }

   public boolean shouldTransformEat() {
      return this.isOn() && this.eatTransform.getValue();
   }

   public int getSwingSpeed() {
      return this.swingFactor.getValueInt();
   }

   public float getEatTransformFactor() {
      return this.eatTransformFactor.getValueFloat();
   }

   public boolean isSelfOnly() {
      return this.selfOnly.getValue();
   }

   protected boolean swingSettingsVisible() {
      return true;
   }
}
