ExponentialResponseCurve class

Пакет: com.hypixel.hytale.server.core.asset.type.responsecurve.config

Файл: com/hypixel/hytale/server/core/asset/type/responsecurve/config/ExponentialResponseCurve.java

extends: ResponseCurve

Поля (1)

МодификаторыТипИмя
final BuilderCodec<ExponentialResponseCurve> CODEC

Методы (6)

МодификаторыВозвратСигнатура
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("X must be between 0.0 and 1.0")
public double getExponentdouble getExponent()
public double getHorizontalShiftdouble getHorizontalShift()
public double getSlopedouble getSlope()
public double getVerticalShiftdouble getVerticalShift()
abstract super super(var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.responsecurve.config;

class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import javax.annotation.Nonnull;

class="kw">public class ExponentialResponseCurve class="kw">extends ResponseCurve {
   class="kw">public class="kw">static class="kw">final BuilderCodec<ExponentialResponseCurve> CODEC = BuilderCodec.<ResponseCurve>builder(
         ExponentialResponseCurve.class, ExponentialResponseCurve::new, BASE_CODEC
      )
      .documentation("An response curve which changes at an exponential rate.")
      .<Double>appendInherited(
         new KeyedCodec<>("Slope", Codec.DOUBLE), (var0, var1) -> var0.slope = var1, var0 -> var0.slope, (var0, var1) -> var0.slope = var1.slope
      )
      .documentation("The slope of the curve.")
      .add()
      .<Double>appendInherited(
         new KeyedCodec<>("Exponent", Codec.DOUBLE), (var0, var1) -> var0.exponent = var1, var0 -> var0.exponent, (var0, var1) -> var0.exponent = var1.exponent
      )
      .documentation("The exponent used to generate this curve. 1 is linear, 2 results in a quadratic parabola, and 3 in a cubic curve, etc.")
      .add()
      .<Double>appendInherited(
         new KeyedCodec<>("HorizontalShift", Codec.DOUBLE),
         (var0, var1) -> var0.horizontalShift = var1,
         var0 -> var0.horizontalShift,
         (var0, var1) -> var0.horizontalShift = var1.horizontalShift
      )
      .documentation("The horizontal shift to apply to the curve. This decides how far the curve is shifted left or right along the x axis.")
      .addValidator(Validators.range(-1.0, 1.0))
      .add()
      .<Double>appendInherited(
         new KeyedCodec<>("VerticalShift", Codec.DOUBLE),
         (var0, var1) -> var0.verticalShift = var1,
         var0 -> var0.verticalShift,
         (var0, var1) -> var0.verticalShift = var1.verticalShift
      )
      .documentation("The vertical shift to apply to the curve. This decides how far the curve is shifted up or down along the y axis.")
      .addValidator(Validators.range(-1.0, 1.0))
      .add()
      .build();
   class="kw">protected double slope = 1.0;
   class="kw">protected double exponent = 1.0;
   class="kw">protected double horizontalShift;
   class="kw">protected double verticalShift;

   class="kw">public ExponentialResponseCurve(double var1, double var3, double var5, double var7) {
      this.slope = var1;
      this.exponent = var3;
      this.horizontalShift = var5;
      this.verticalShift = var7;
   }

   class="kw">public ExponentialResponseCurve(String var1) {
      super(var1);
   }

   class="kw">protected ExponentialResponseCurve() {
   }

   @Override
   class="kw">public double computeY(double var1) {
      if (!(var1 < 0.0) && !(var1 > 1.0)) {
         class="kw">return this.slope * Math.pow(var1 - this.horizontalShift, this.exponent) + this.verticalShift;
      } else {
         throw new IllegalArgumentException("X must be between 0.0 and 1.0");
      }
   }

   class="kw">public double getSlope() {
      class="kw">return this.slope;
   }

   class="kw">public double getExponent() {
      class="kw">return this.exponent;
   }

   class="kw">public double getHorizontalShift() {
      class="kw">return this.horizontalShift;
   }

   class="kw">public double getVerticalShift() {
      class="kw">return this.verticalShift;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "ExponentialResponseCurve{slope="
         + this.slope
         + ", exponent="
         + this.exponent
         + ", horizontalShift="
         + this.horizontalShift
         + ", verticalShift="
         + this.verticalShift
         + "} "
         + super.toString();
   }
}