Constant interface
Пакет: com.hypixel.hytale.procedurallib.json
Файл: com/hypixel/hytale/procedurallib/json/BranchNoiseJsonLoader.java
Поля (28)
| Модификаторы | Тип | Имя |
|---|---|---|
|
double |
DEFAULT_JITTER |
|
CellType |
DEFAULT_LINE_CELL_TYPE |
|
BranchEvaluator.Direction |
DEFAULT_LINE_DIRECTION |
|
double |
DEFAULT_LINE_SCALE |
|
double |
DEFAULT_LINE_THICKNESS |
|
CellType |
DEFAULT_PARENT_CELL_TYPE |
|
DistanceCalculationMode |
DEFAULT_PARENT_DISTANCE_CAL_MODE |
|
DistanceNoise.Distance2Mode |
DEFAULT_PARENT_DISTANCE_TYPE |
|
double |
DEFAULT_PARENT_FADE |
|
NoiseFormulaProperty.NoiseFormula |
DEFAULT_PARENT_FORMULA |
|
double |
DEFAULT_PARENT_VALUE |
|
String |
KEY_LINE_DIRECTION_MODE |
|
String |
KEY_LINE_JITTER |
|
String |
KEY_LINE_JITTER_X |
|
String |
KEY_LINE_JITTER_Y |
|
String |
KEY_LINE_SCALE |
|
String |
KEY_LINE_THICKNESS |
|
String |
KEY_LINE_TYPE |
|
String |
KEY_PARENT_DENSITY |
|
String |
KEY_PARENT_DISTANCE_CALCULATION_MODE |
|
String |
KEY_PARENT_DISTANCE_TYPE |
|
String |
KEY_PARENT_FADE |
|
String |
KEY_PARENT_FORMULA |
|
String |
KEY_PARENT_JITTER |
|
String |
KEY_PARENT_JITTER_X |
|
String |
KEY_PARENT_JITTER_Y |
|
String |
KEY_PARENT_TYPE |
|
String |
KEY_PARENT_VALUE |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.procedurallib.json;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.procedurallib.condition.ConstantIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.IDoubleCondition;
class="kw">import com.hypixel.hytale.procedurallib.condition.IIntCondition;
class="kw">import com.hypixel.hytale.procedurallib.logic.BranchNoise;
class="kw">import com.hypixel.hytale.procedurallib.logic.DistanceNoise;
class="kw">import com.hypixel.hytale.procedurallib.logic.ResultBuffer;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.CellDistanceFunction;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.CellPointFunction;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.CellType;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.DistanceCalculationMode;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.GridCellDistanceFunction;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.HexCellDistanceFunction;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.evaluator.BranchEvaluator;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.evaluator.DensityPointEvaluator;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.evaluator.PointEvaluator;
class="kw">import com.hypixel.hytale.procedurallib.logic.cell.jitter.CellJitter;
class="kw">import com.hypixel.hytale.procedurallib.property.NoiseFormulaProperty;
class="kw">import com.hypixel.hytale.procedurallib.supplier.DoubleRange;
class="kw">import com.hypixel.hytale.procedurallib.supplier.IDoubleRange;
class="kw">import java.nio.file.Path;
class="kw">import java.util.function.Function;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class BranchNoiseJsonLoader<T class="kw">extends SeedResource> class="kw">extends AbstractCellJitterJsonLoader<T, BranchNoise> {
class="kw">public BranchNoiseJsonLoader(SeedString<T> var1, Path var2, JsonElement var3) {
super(var1, var2, var3);
}
@Nonnull
class="kw">public BranchNoise load() {
SeedResource var1 = this.seed.get();
CellType var2 = this.loadParentCellType();
CellDistanceFunction var3 = getCellDistanceFunction(var2);
PointEvaluator var4 = this.loadParentEvaluator();
double var5 = this.loadDouble("ParentValue", 0.0);
IDoubleRange var7 = this.loadRange("ParentFade", 0.0);
IIntCondition var8 = this.loadParentDensity();
DistanceNoise.Distance2Function var9 = this.loadParentDistance2Function();
NoiseFormulaProperty.NoiseFormula.Formula var10 = this.loadParentFormula();
CellType var11 = this.loadLineCellType();
CellPointFunction var12 = getCellPointFunction(var11);
double var13 = this.loadDouble("LineScale", 0.1);
IDoubleRange var15 = this.loadRange("LineThickness", 0.1);
CellDistanceFunction var16 = getCellDistanceFunction(var11);
PointEvaluator var17 = this.loadLineEvaluator(var3, var12, var13);
class="kw">return new BranchNoiseJsonLoader.LoadedBranchNoise(var3, var4, var5, var7, var8, var9, var10, var16, var17, var13, var15, var1);
}
class="kw">protected CellType loadParentCellType() {
class="kw">return this.loadEnum("ParentType", CellType::valueOf, BranchNoiseJsonLoader.Constant.DEFAULT_PARENT_CELL_TYPE);
}
class="kw">protected CellType loadLineCellType() {
class="kw">return this.loadEnum("LineType", CellType::valueOf, BranchNoiseJsonLoader.Constant.DEFAULT_LINE_CELL_TYPE);
}
class="kw">protected PointEvaluator loadParentEvaluator() {
double var1 = this.loadDouble("ParentJitter", 1.0);
double var3 = this.loadDouble("ParentJitterX", var1);
double var5 = this.loadDouble("ParentJitterY", var1);
CellJitter var7 = CellJitter.of(var3, var5, 1.0);
DistanceCalculationMode var8 = this.loadEnum(
"ParentDistanceMode", DistanceCalculationMode::valueOf, BranchNoiseJsonLoader.Constant.DEFAULT_PARENT_DISTANCE_CAL_MODE
);
class="kw">return PointEvaluator.of(var8.getFunction(), null, null, var7);
}
@Nonnull
class="kw">protected IIntCondition loadParentDensity() {
IIntCondition var1 = ConstantIntCondition.DEFAULT_TRUE;
if (this.has("ParentDensity")) {
IDoubleCondition var2 = new DoubleConditionJsonLoader<>(this.seed, this.dataFolder, this.get("ParentDensity")).load();
var1 = DensityPointEvaluator.getDensityCondition(var2);
}
class="kw">return var1;
}
class="kw">protected DistanceNoise.Distance2Function loadParentDistance2Function() {
class="kw">return this.loadEnum("ParentDistanceType", DistanceNoise.Distance2Mode::valueOf, BranchNoiseJsonLoader.Constant.DEFAULT_PARENT_DISTANCE_TYPE)
.getFunction();
}
class="kw">protected NoiseFormulaProperty.NoiseFormula.Formula loadParentFormula() {
class="kw">return this.loadEnum("ParentFormula", NoiseFormulaProperty.NoiseFormula::valueOf, BranchNoiseJsonLoader.Constant.DEFAULT_PARENT_FORMULA).getFormula();
}
@Nonnull
class="kw">protected PointEvaluator loadLineEvaluator(@Nonnull CellDistanceFunction var1, @Nonnull CellPointFunction var2, double var3) {
double var5 = this.loadDouble("LineJitter", 1.0);
double var7 = this.loadDouble("LineJitterX", var5);
double var9 = this.loadDouble("LineJitterY", var5);
CellJitter var11 = CellJitter.of(var7, var9, 1.0);
BranchEvaluator.Direction var12 = this.loadEnum(
"LineDirection", BranchEvaluator.Direction::valueOf, BranchNoiseJsonLoader.Constant.DEFAULT_LINE_DIRECTION
);
class="kw">return new BranchEvaluator(var1, var2, var12, var11, var3);
}
class="kw">protected double loadDouble(String var1, double var2) {
class="kw">return !this.has(var1) ? var2 : this.get(var1).getAsDouble();
}
@Nullable
class="kw">protected IDoubleRange loadRange(String var1, double var2) {
class="kw">return !this.has(var1) ? new DoubleRange.Constant(var2) : new DoubleRangeJsonLoader<>(this.seed, this.dataFolder, this.get(var1)).load();
}
class="kw">protected <E class="kw">extends Enum<E>> E loadEnum(String var1, @Nonnull Function<String, E> var2, E var3) {
class="kw">return !this.has(var1) ? var3 : var2.apply(this.get(var1).getAsString());
}
@Nonnull
class="kw">protected class="kw">static CellDistanceFunction getCellDistanceFunction(@Nonnull CellType var0) {
class="kw">return class="kw">switch (var0) {
case SQUARE -> GridCellDistanceFunction.DISTANCE_FUNCTION;
case HEX -> HexCellDistanceFunction.DISTANCE_FUNCTION;
};
}
@Nonnull
class="kw">protected class="kw">static CellPointFunction getCellPointFunction(@Nonnull CellType var0) {
class="kw">return class="kw">switch (var0) {
case SQUARE -> GridCellDistanceFunction.POINT_FUNCTION;
case HEX -> HexCellDistanceFunction.POINT_FUNCTION;
};
}
class="kw">public class="kw">interface Constant {
String KEY_PARENT_TYPE = "ParentType";
String KEY_PARENT_DISTANCE_CALCULATION_MODE = "ParentDistanceMode";
String KEY_PARENT_DISTANCE_TYPE = "ParentDistanceType";
String KEY_PARENT_FORMULA = "ParentFormula";
String KEY_PARENT_JITTER = "ParentJitter";
String KEY_PARENT_JITTER_X = "ParentJitterX";
String KEY_PARENT_JITTER_Y = "ParentJitterY";
String KEY_PARENT_VALUE = "ParentValue";
String KEY_PARENT_FADE = "ParentFade";
String KEY_PARENT_DENSITY = "ParentDensity";
String KEY_LINE_TYPE = "LineType";
String KEY_LINE_DIRECTION_MODE = "LineDirection";
String KEY_LINE_SCALE = "LineScale";
String KEY_LINE_JITTER = "LineJitter";
String KEY_LINE_JITTER_X = "LineJitterX";
String KEY_LINE_JITTER_Y = "LineJitterY";
String KEY_LINE_THICKNESS = "LineThickness";
double DEFAULT_JITTER = 1.0;
double DEFAULT_PARENT_VALUE = 0.0;
double DEFAULT_PARENT_FADE = 0.0;
double DEFAULT_LINE_SCALE = 0.1;
double DEFAULT_LINE_THICKNESS = 0.1;
CellType DEFAULT_PARENT_CELL_TYPE = CellType.SQUARE;
CellType DEFAULT_LINE_CELL_TYPE = CellType.SQUARE;
BranchEvaluator.Direction DEFAULT_LINE_DIRECTION = BranchEvaluator.Direction.OUTWARD;
DistanceCalculationMode DEFAULT_PARENT_DISTANCE_CAL_MODE = DistanceCalculationMode.EUCLIDEAN;
DistanceNoise.Distance2Mode DEFAULT_PARENT_DISTANCE_TYPE = DistanceNoise.Distance2Mode.DIV;
NoiseFormulaProperty.NoiseFormula DEFAULT_PARENT_FORMULA = NoiseFormulaProperty.NoiseFormula.SQRT;
}
class="kw">protected class="kw">static class LoadedBranchNoise class="kw">extends BranchNoise {
class="kw">protected class="kw">final SeedResource seedResource;
class="kw">public LoadedBranchNoise(
CellDistanceFunction var1,
PointEvaluator var2,
double var3,
IDoubleRange var5,
IIntCondition var6,
DistanceNoise.Distance2Function var7,
NoiseFormulaProperty.NoiseFormula.Formula var8,
CellDistanceFunction var9,
PointEvaluator var10,
double var11,
IDoubleRange var13,
SeedResource var14
) {
super(var1, var2, var3, var5, var6, var7, var8, var9, var10, var11, var13);
this.seedResource = var14;
}
@Nonnull
@Override
class="kw">protected ResultBuffer.ResultBuffer2d localBuffer2d() {
class="kw">return this.seedResource.localBuffer2d();
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "LoadedBranchNoise{seedResource="
+ this.seedResource
+ ", parentFunction="
+ this.parentFunction
+ ", parentEvaluator="
+ this.parentEvaluator
+ ", parentValue="
+ this.parentValue
+ ", parentFade="
+ this.parentFade
+ ", distance2Function="
+ this.distance2Function
+ ", noiseFormula="
+ this.noiseFormula
+ ", lineFunction="
+ this.lineFunction
+ ", lineEvaluator="
+ this.lineEvaluator
+ ", lineScale="
+ this.lineScale
+ ", lineThickness="
+ this.lineThickness
+ "}";
}
}
}