LogisticResponseCurve class
Пакет: com.hypixel.hytale.server.core.asset.type.responsecurve.config
Файл: com/hypixel/hytale/server/core/asset/type/responsecurve/config/LogisticResponseCurve.java
extends: ResponseCurve
Поля (1)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<LogisticResponseCurve> |
CODEC |
Методы (5)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("X must be between 0.0 and 1.0") |
public |
double |
getCeilingdouble getCeiling() |
public |
double |
getHorizontalShiftdouble getHorizontalShift() |
public |
double |
getRateOfChangedouble getRateOfChange() |
public |
double |
getVerticalShiftdouble getVerticalShift() |
Исходный код
Показать/скрыть
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 javax.annotation.Nonnull;
class="kw">public class LogisticResponseCurve class="kw">extends ResponseCurve {
class="kw">public class="kw">static class="kw">final BuilderCodec<LogisticResponseCurve> CODEC = BuilderCodec.<ResponseCurve>builder(
LogisticResponseCurve.class, LogisticResponseCurve::new, BASE_CODEC
)
.documentation("A response curve with a logistic rate of change.")
.<Double>appendInherited(
new KeyedCodec<>("RateOfChange", Codec.DOUBLE),
(var0, var1) -> var0.rateOfChange = var1,
var0 -> var0.rateOfChange,
(var0, var1) -> var0.rateOfChange = var1.rateOfChange
)
.documentation("The rate of change of the curve - similar to **Slope** in the exponential curve.")
.add()
.<Double>appendInherited(
new KeyedCodec<>("Ceiling", Codec.DOUBLE), (var0, var1) -> var0.ceiling = var1, var0 -> var0.ceiling, (var0, var1) -> var0.ceiling = var1.ceiling
)
.documentation(
"The total height of the curve between its two plateaus. Using a negative value with vertical offsets allows the curve to act as a diminishing factor"
)
.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.")
.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.")
.add()
.build();
class="kw">protected double rateOfChange = 1.0;
class="kw">protected double ceiling = 1.0;
class="kw">protected double horizontalShift = 0.5;
class="kw">protected double verticalShift = 0.0;
class="kw">public LogisticResponseCurve(double var1, double var3, double var5, double var7) {
this.rateOfChange = var1;
this.ceiling = var3;
this.horizontalShift = var5;
this.verticalShift = var7;
}
class="kw">protected LogisticResponseCurve() {
}
@Override
class="kw">public double computeY(double var1) {
if (!(var1 < 0.0) && !(var1 > 1.0)) {
class="kw">return this.ceiling / (1.0 + Math.pow(100.0, 2.0 * this.rateOfChange * (this.horizontalShift - var1))) + this.verticalShift;
} else {
throw new IllegalArgumentException("X must be between 0.0 and 1.0");
}
}
class="kw">public double getRateOfChange() {
class="kw">return this.rateOfChange;
}
class="kw">public double getCeiling() {
class="kw">return this.ceiling;
}
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 "LogisticResponseCurve{rateOfChange="
+ this.rateOfChange
+ ", ceiling="
+ this.ceiling
+ ", horizontalShift="
+ this.horizontalShift
+ ", verticalShift="
+ this.verticalShift
+ "} "
+ super.toString();
}
}