HeadMotionObserve class
Пакет: com.hypixel.hytale.server.npc.corecomponents.world
Файл: com/hypixel/hytale/server/npc/corecomponents/world/HeadMotionObserve.java
extends: HeadMotionBase
Поля (18)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
float[] |
angleRange |
|
Rotation3f |
var10 |
|
float |
var10 |
|
int |
var11 |
|
float |
var12 |
|
ModelComponent |
var3 |
|
float |
var4 |
|
|
var4 |
|
|
var4 |
|
float |
var5 |
|
|
var5 |
|
|
var5 |
|
CameraSettings |
var6 |
|
Rangef |
var7 |
|
TransformComponent |
var8 |
|
float |
var8 |
|
HeadRotation |
var9 |
|
float |
var9 |
Методы (7)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(this.preDelay > 0.0) |
|
|
if if(this.delay > 0.0) |
|
|
if if(this.pickRandomAngle) |
protected |
void |
pickNextAnglevoid pickNextAngle(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) |
abstract |
|
super super(var1) |
protected |
boolean |
tickDelayboolean tickDelay(double var1) |
protected |
boolean |
tickPreDelayboolean tickPreDelay(double var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.corecomponents.world;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.math.random.RandomExtra;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.protocol.Rangef;
class="kw">import com.hypixel.hytale.server.core.asset.type.model.config.camera.CameraSettings;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.ModelComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.HeadMotionBase;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.world.builders.BuilderHeadMotionObserve;
class="kw">import com.hypixel.hytale.server.npc.instructions.ExecutionSupport;
class="kw">import com.hypixel.hytale.server.npc.movement.Steering;
class="kw">import com.hypixel.hytale.server.npc.movement.steeringforces.SteeringForceRotate;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.InfoProvider;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class HeadMotionObserve class="kw">extends HeadMotionBase {
class="kw">protected class="kw">final float[] angleRange;
class="kw">protected class="kw">final double[] pauseTimeRange;
class="kw">protected class="kw">final boolean pickRandomAngle;
class="kw">protected class="kw">final int viewSegments;
class="kw">protected class="kw">final double relativeTurnSpeed;
class="kw">protected double preDelay;
class="kw">protected double delay;
class="kw">protected int currentViewSegment;
class="kw">protected boolean invertedDirection;
class="kw">protected float targetBodyOffsetYaw;
class="kw">protected class="kw">final SteeringForceRotate steeringForceRotate = new SteeringForceRotate();
class="kw">public HeadMotionObserve(@Nonnull BuilderHeadMotionObserve var1, @Nonnull BuilderSupport var2) {
super(var1);
this.angleRange = var1.getAngleRange(var2);
this.pauseTimeRange = var1.getPauseTimeRange(var2);
this.pickRandomAngle = var1.isPickRandomAngle(var2);
this.viewSegments = var1.getViewSegments(var2);
this.relativeTurnSpeed = var1.getRelativeTurnSpeed(var2);
}
@Override
class="kw">public void activate(@Nonnull Ref<EntityStore> var1, @Nonnull ExecutionSupport var2, @Nonnull ComponentAccessor<EntityStore> var3) {
this.preDelay = RandomExtra.randomRange(this.pauseTimeRange);
this.currentViewSegment = 0;
this.pickNextAngle(var1, var3);
}
@Override
class="kw">public boolean computeSteering(
@Nonnull Ref<EntityStore> var1,
@Nonnull ExecutionSupport var2,
@Nullable InfoProvider var3,
double var4,
@Nonnull Steering var6,
@Nonnull ComponentAccessor<EntityStore> var7
) {
if (this.tickPreDelay(var4)) {
class="kw">return true;
}
TransformComponent var8 = var7.getComponent(var1, TransformComponent.getComponentType());
assert var8 != null;
HeadRotation var9 = var7.getComponent(var1, HeadRotation.getComponentType());
assert var9 != null;
Rotation3f var10 = var9.getRotation();
this.steeringForceRotate.setHeading(var10.yaw());
this.steeringForceRotate.setDesiredHeading(var8.getRotation().yaw() + this.targetBodyOffsetYaw);
if (this.steeringForceRotate.compute(var6)) {
var6.setRelativeTurnSpeed(this.relativeTurnSpeed);
class="kw">return true;
}
var6.setYaw(var8.getRotation().yaw() + this.targetBodyOffsetYaw);
if (this.tickDelay(var4)) {
class="kw">return true;
}
this.pickNextAngle(var1, var7);
class="kw">return true;
}
class="kw">protected boolean tickPreDelay(double var1) {
if (this.preDelay > 0.0) {
this.preDelay -= var1;
class="kw">return true;
} else {
class="kw">return false;
}
}
class="kw">protected boolean tickDelay(double var1) {
if (this.delay > 0.0) {
this.delay -= var1;
class="kw">return true;
} else {
class="kw">return false;
}
}
class="kw">protected void pickNextAngle(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
ModelComponent var3 = var2.getComponent(var1, ModelComponent.getComponentType());
assert var3 != null;
CameraSettings var6 = var3.getModel().getCamera();
float var4;
float var5;
if (var6 != null && var6.getYaw() != null && var6.getYaw().getAngleRange() != null) {
Rangef var7 = var6.getYaw().getAngleRange();
var4 = var7.min;
var5 = var7.max;
} else {
var4 = (float) (-Math.PI / 4);
var5 = (float) (Math.PI / 4);
}
float var12 = Math.max(this.angleRange[0], var4);
float var8 = Math.min(this.angleRange[1], var5);
if (this.pickRandomAngle) {
this.targetBodyOffsetYaw = RandomExtra.randomRange(var12, var8);
} else if (this.viewSegments > 1) {
float var9 = MathUtil.wrapAngle(var8 - var12);
float var10 = var9 / (this.viewSegments - 1);
int var11 = this.currentViewSegment++;
this.currentViewSegment = this.currentViewSegment % this.viewSegments;
this.targetBodyOffsetYaw = var12 + var11 * var10;
} else if (!this.invertedDirection) {
this.targetBodyOffsetYaw = var12;
this.invertedDirection = true;
} else {
this.targetBodyOffsetYaw = var8;
this.invertedDirection = false;
}
this.delay = RandomExtra.randomRange(this.pauseTimeRange);
}
}