ScaledSwitchResponseCurve class

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

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

extends: ScaledResponseCurve

Поля (1)

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

Исходный код

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

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 ScaledSwitchResponseCurve class="kw">extends ScaledResponseCurve {
   class="kw">public class="kw">static class="kw">final BuilderCodec<ScaledSwitchResponseCurve> CODEC = BuilderCodec.builder(ScaledSwitchResponseCurve.class, ScaledSwitchResponseCurve::new)
      .documentation(
         "A special type of scaled response curve which returns the initial state value before the defined class="kw">switch point and the class="kw">final state value after reaching it."
      )
      .<Double>append(new KeyedCodec<>("InitialState", Codec.DOUBLE), (var0, var1) -> var0.initialState = var1, var0 -> var0.initialState)
      .addValidator(Validators.range(0.0, 1.0))
      .documentation("The y value to class="kw">return before the class="kw">switch point.")
      .add()
      .<Double>append(new KeyedCodec<>("FinalState", Codec.DOUBLE), (var0, var1) -> var0.finalState = var1, var0 -> var0.finalState)
      .addValidator(Validators.range(0.0, 1.0))
      .documentation("The y value to class="kw">return at and beyond the class="kw">switch point.")
      .add()
      .<Double>append(new KeyedCodec<>("SwitchPoint", Codec.DOUBLE), (var0, var1) -> var0.switchPoint = var1, var0 -> var0.switchPoint)
      .addValidator(Validators.nonNull())
      .documentation("The value at which to class="kw">switch from the initial state to the class="kw">final state.")
      .add()
      .build();
   class="kw">protected double initialState = 0.0;
   class="kw">protected double finalState = 1.0;
   class="kw">protected double switchPoint;

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

   @Override
   class="kw">public double computeY(double var1) {
      class="kw">return var1 < this.switchPoint ? this.initialState : this.finalState;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "ScaledSwitchResponseCurve{initialState="
         + this.initialState
         + ", finalState="
         + this.finalState
         + ", switchPoint="
         + this.switchPoint
         + "}"
         + super.toString();
   }
}