BuilderMotionControllerDive class
Пакет: com.hypixel.hytale.server.npc.movement.controllers.builders
Файл: com/hypixel/hytale/server/npc/movement/controllers/builders/BuilderMotionControllerDive.java
extends: BuilderMotionControllerBase
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
private |
double |
minHorizontalSpeed |
|
Model |
var2 |
Методы (20)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
return new |
MotionControllerDivereturn new MotionControllerDive(var1, this) |
public |
double |
getAccelerationdouble getAcceleration() |
public |
double |
getDesiredDepthWeightdouble getDesiredDepthWeight() |
public |
double |
getFastDiveThresholddouble getFastDiveThreshold() |
public |
double |
getGravitydouble getGravity() |
public |
double |
getMaxDiveDepthdouble getMaxDiveDepth() |
public |
double |
getMaxFallSpeeddouble getMaxFallSpeed() |
public |
float |
getMaxMoveTurnAnglefloat getMaxMoveTurnAngle() |
public |
double |
getMaxRotationSpeeddouble getMaxRotationSpeed() |
public |
double |
getMaxSinkSpeeddouble getMaxSinkSpeed() |
public |
double |
getMaxVerticalSpeeddouble getMaxVerticalSpeed() |
public |
double |
getMaxWaterDepthdouble getMaxWaterDepth() |
public |
double |
getMinDepthAboveGrounddouble getMinDepthAboveGround() |
public |
double |
getMinDepthBelowSurfacedouble getMinDepthBelowSurface() |
public |
double |
getMinDiveDepthdouble getMinDiveDepth() |
public |
double |
getMinHorizontalSpeeddouble getMinHorizontalSpeed() |
public |
double |
getMinWaterDepthdouble getMinWaterDepth() |
public |
double |
getSinkRatiodouble getSinkRatio() |
public |
double |
getSwimDepthdouble getSwimDepth() |
|
|
if if(var1.breathesInWater) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.movement.controllers.builders;
class="kw">import com.google.gson.JsonElement;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.Model;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleRangeValidator;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSingleValidator;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.validators.RelationalOperator;
class="kw">import com.hypixel.hytale.server.npc.movement.MovementMode;
class="kw">import com.hypixel.hytale.server.npc.movement.controllers.MotionController;
class="kw">import com.hypixel.hytale.server.npc.movement.controllers.MotionControllerDive;
class="kw">import com.hypixel.hytale.server.spawning.SpawnTestResult;
class="kw">import com.hypixel.hytale.server.spawning.SpawningContext;
class="kw">import java.util.Set;
class="kw">import javax.annotation.Nonnull;
class="kw">public class BuilderMotionControllerDive class="kw">extends BuilderMotionControllerBase {
class="kw">private double minHorizontalSpeed;
class="kw">private double maxVerticalSpeed;
class="kw">private double acceleration;
class="kw">private double gravity;
class="kw">private double maxFallSpeed;
class="kw">private double maxSinkSpeed;
class="kw">private double maxRotationSpeed;
class="kw">private float maxMoveTurnAngle;
class="kw">private double minDiveDepth;
class="kw">private double maxDiveDepth;
class="kw">private double minWaterDepth;
class="kw">private double maxWaterDepth;
class="kw">private double minDepthAboveGround;
class="kw">private double minDepthBelowSurface;
class="kw">private double swimDepth;
class="kw">private double sinkRatio;
class="kw">private double fastDiveThreshold;
class="kw">private double desiredDepthWeight;
class="kw">public BuilderMotionControllerDive() {
}
@Nonnull
@Override
class="kw">public String getShortDescription() {
class="kw">return "Provide diving abilities for NPC";
}
@Nonnull
@Override
class="kw">public String getLongDescription() {
class="kw">return this.getShortDescription();
}
@Nonnull
@Override
class="kw">public BuilderDescriptorState getBuilderDescriptorState() {
class="kw">return BuilderDescriptorState.WorkInProgress;
}
@Nonnull
class="kw">public MotionControllerDive build(@Nonnull BuilderSupport var1) {
class="kw">return new MotionControllerDive(var1, this);
}
@Nonnull
class="kw">public BuilderMotionControllerDive readConfig(@Nonnull JsonElement var1) {
this.getDouble(
var1, "MaxSwimSpeed", this.maxHorizontalSpeed, 3.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "Maximum horizontal speed", null
);
this.getDouble(
var1,
"MaxDiveSpeed",
var1x -> this.maxVerticalSpeed = var1x,
8.0,
DoubleSingleValidator.greater0(),
BuilderDescriptorState.Stable,
"Maximum vertical speed",
null
);
this.getDouble(
var1,
"MaxFallSpeed",
var1x -> this.maxFallSpeed = var1x,
10.0,
DoubleSingleValidator.greater0(),
BuilderDescriptorState.Stable,
"Terminal velocity falling in air",
null
);
this.getDouble(
var1,
"MaxSinkSpeed",
var1x -> this.maxSinkSpeed = var1x,
4.0,
DoubleSingleValidator.greater0(),
BuilderDescriptorState.Stable,
"Terminal velocity sinking in water",
null
);
this.getDouble(var1, "Gravity", var1x -> this.gravity = var1x, 10.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "Gravity", null);
this.getDouble(
var1, "Acceleration", var1x -> this.acceleration = var1x, 3.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "Acceleration", null
);
this.getDouble(
var1,
"MaxRotationSpeed",
var1x -> this.maxRotationSpeed = var1x,
360.0,
DoubleSingleValidator.greater0(),
BuilderDescriptorState.Stable,
"Maximum rotational speed in degrees",
null
);
this.getFloat(
var1,
"MaxSwimTurnAngle",
var1x -> this.maxMoveTurnAngle = var1x,
90.0F,
DoubleRangeValidator.between(0.0, 180.0),
BuilderDescriptorState.WorkInProgress,
"Maximum angle NPC can walk without explicit turning in degrees",
null
);
this.validateDoubleRelation("MinSwimSpeed", this.minHorizontalSpeed, RelationalOperator.LessEqual, this.maxHorizontalSpeed);
this.getDouble(
var1,
"FastSwimThreshold",
var1x -> this.fastDiveThreshold = var1x,
0.6,
DoubleRangeValidator.between01(),
BuilderDescriptorState.WorkInProgress,
"Relative threshold when fast swimming animation should be used",
null
);
this.getDouble(
var1,
"SwimDepth",
var1x -> this.swimDepth = var1x,
0.4,
DoubleRangeValidator.between(-1.0, 1.0),
BuilderDescriptorState.WorkInProgress,
"Minimum height NPC needs to be submerged to be able to swim",
"0 is at eye height, -1 is bottom of bounding box, +1 top of bounding box. other values between -1 and +1 scale linear"
);
this.getDouble(
var1,
"SinkRatio",
var1x -> this.sinkRatio = var1x,
1.0,
DoubleSingleValidator.greaterEqual0(),
BuilderDescriptorState.WorkInProgress,
"Relative sink or climb speed while wandering",
null
);
this.getDouble(
var1, "MinDiveDepth", var1x -> this.minDiveDepth = var1x, 0.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.Unknown, null, null
);
this.getDouble(
var1,
"MaxDiveDepth",
var1x -> this.maxDiveDepth = var1x,
Double.MAX_VALUE,
DoubleSingleValidator.greater0(),
BuilderDescriptorState.WorkInProgress,
"Maximum dive depth below surface desired",
null
);
this.getDouble(
var1,
"MinDepthAboveGround",
var1x -> this.minDepthAboveGround = var1x,
1.0,
DoubleSingleValidator.greaterEqual0(),
BuilderDescriptorState.WorkInProgress,
"Minimum distance from ground desired",
null
);
this.getDouble(
var1,
"MinDepthBelowSurface",
var1x -> this.minDepthBelowSurface = var1x,
1.0,
DoubleSingleValidator.greaterEqual0(),
BuilderDescriptorState.WorkInProgress,
"Minimum distance from water surface desired",
null
);
this.getDouble(
var1, "MinWaterDepth", var1x -> this.minWaterDepth = var1x, 1.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.Unknown, null, null
);
this.getDouble(
var1, "MaxWaterDepth", var1x -> this.maxWaterDepth = var1x, 0.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.Unknown, null, null
);
this.getDouble(
var1,
"DesiredDepthWeight",
var1x -> this.desiredDepthWeight = var1x,
0.0,
DoubleRangeValidator.between(0.0, 1.0),
BuilderDescriptorState.Stable,
"How much this NPC prefers being within the desired height range",
"How much this NPC prefers being within the desired height range. 0 means it doesn't care much, 1 means it will do its best to get there fast."
);
class="kw">return this;
}
@Nonnull
@Override
class="kw">public Class<MotionController> category() {
class="kw">return MotionController.class;
}
@Nonnull
@Override
class="kw">public String getType() {
class="kw">return "Dive";
}
class="kw">public double getMinHorizontalSpeed() {
class="kw">return this.minHorizontalSpeed;
}
class="kw">public double getAcceleration() {
class="kw">return this.acceleration;
}
class="kw">public double getMaxVerticalSpeed() {
class="kw">return this.maxVerticalSpeed;
}
class="kw">public double getGravity() {
class="kw">return this.gravity;
}
class="kw">public double getMaxFallSpeed() {
class="kw">return this.maxFallSpeed;
}
class="kw">public double getMaxSinkSpeed() {
class="kw">return this.maxSinkSpeed;
}
class="kw">public float getMaxMoveTurnAngle() {
class="kw">return (float) (Math.PI / 180.0) * this.maxMoveTurnAngle;
}
class="kw">public double getMaxRotationSpeed() {
class="kw">return this.maxRotationSpeed * (float) (Math.PI / 180.0);
}
class="kw">public double getMinDiveDepth() {
class="kw">return this.minDiveDepth;
}
class="kw">public double getMaxDiveDepth() {
class="kw">return this.maxDiveDepth;
}
class="kw">public double getMinWaterDepth() {
class="kw">return this.minWaterDepth;
}
class="kw">public double getMaxWaterDepth() {
class="kw">return this.maxWaterDepth;
}
class="kw">public double getMinDepthAboveGround() {
class="kw">return this.minDepthAboveGround;
}
class="kw">public double getMinDepthBelowSurface() {
class="kw">return this.minDepthBelowSurface;
}
class="kw">public double getSwimDepth() {
class="kw">return this.swimDepth;
}
class="kw">public double getSinkRatio() {
class="kw">return this.sinkRatio;
}
class="kw">public double getFastDiveThreshold() {
class="kw">return this.fastDiveThreshold;
}
class="kw">public double getDesiredDepthWeight() {
class="kw">return this.desiredDepthWeight;
}
@Nonnull
@Override
class="kw">public SpawnTestResult canSpawn(@Nonnull SpawningContext var1) {
if (Double.isNaN(var1.swimDepth)) {
Model var2 = var1.getModel();
var1.swimDepth = var2 == null ? 0.5 : MotionControllerDive.relativeSwimDepthToHeight(this.getSwimDepth(), var2.getBoundingBox(), var2.getEyeHeight());
}
if (!var1.isInWater((float)var1.swimDepth)) {
class="kw">return SpawnTestResult.FAIL_NO_POSITION;
} else {
class="kw">return var1.validatePosition(20) ? SpawnTestResult.TEST_OK : SpawnTestResult.FAIL_INVALID_POSITION;
}
}
@Override
class="kw">public boolean requiresSpawnDropHeightCheck(@Nonnull SpawningContext var1) {
class="kw">return false;
}
@Override
class="kw">public void getMovementModes(
@Nonnull SpawningContext var1, @Nonnull Set<MovementMode> var2, @Nonnull Set<MovementMode> var3, @Nonnull Set<MovementMode> var4
) {
var2.addAll(MotionControllerDive.SUPPORTED_MOVEMENT_MODES);
var3.addAll(MotionControllerDive.DEFAULT_SPAWN_MOVEMENT_MODES);
if (var1.breathesInWater) {
var4.add(MovementMode.DIVE);
}
}
@Nonnull
@Override
class="kw">public Class<? class="kw">extends MotionController> getClassType() {
class="kw">return MotionControllerDive.class;
}
@Nonnull
@Override
class="kw">public Set<MovementMode> getSupportedMovementModes() {
class="kw">return MotionControllerDive.SUPPORTED_MOVEMENT_MODES;
}
}