SwitchResponseCurve class

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

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

extends: ResponseCurve

Поля (1)

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

Исходный код

Показать/скрыть
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 SwitchResponseCurve class="kw">extends ResponseCurve {
   class="kw">public class="kw">static class="kw">final BuilderCodec<SwitchResponseCurve> CODEC = BuilderCodec.builder(SwitchResponseCurve.class, SwitchResponseCurve::new)
      .documentation(
         "A type of 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.range(0.0, 1.0))
      .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 SwitchResponseCurve() {
   }

   @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 "SwitchResponseCurve{initialState="
         + this.initialState
         + ", finalState="
         + this.finalState
         + ", switchPoint="
         + this.switchPoint
         + "}"
         + super.toString();
   }
}