BodyMotionWanderInCircle class
Пакет: com.hypixel.hytale.server.npc.corecomponents.movement
Файл: com/hypixel/hytale/server/npc/corecomponents/movement/BodyMotionWanderInCircle.java
extends: BodyMotionWanderBase
Поля (18)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
double |
radius |
|
Vector3d |
var10 |
|
MotionController |
var11 |
|
World |
var11 |
|
Vector3dc |
var12 |
|
double |
var13 |
|
double |
var14 |
|
double |
var15 |
|
double |
var17 |
|
NPCEntity |
var3 |
|
TransformComponent |
var4 |
|
Vector3d |
var5 |
|
Ref |
var6 |
|
EntityGroup |
var7 |
|
Vector3d |
var8 |
|
Ref |
var8 |
|
double |
var9 |
|
TransformComponent |
var9 |
Методы (9)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
protected |
Vector3d |
getReferencePointVector3d getReferencePoint(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) |
|
|
if if(this.useSphere) |
|
|
if if(var17 <= var9) |
|
|
if if(var14 >= var9) |
|
|
if if(var13 <= var9) |
|
|
if if(var15 >= var9) |
|
|
if if(this.flock) |
|
|
if if(var6 != null) |
abstract |
|
super super(var1, var2) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.corecomponents.movement;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.server.core.entity.group.EntityGroup;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.flock.FlockPlugin;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.movement.builders.BuilderBodyMotionWanderInCircle;
class="kw">import com.hypixel.hytale.server.npc.entities.NPCEntity;
class="kw">import com.hypixel.hytale.server.npc.instructions.ExecutionSupport;
class="kw">import com.hypixel.hytale.server.npc.movement.controllers.MotionController;
class="kw">import com.hypixel.hytale.server.npc.util.NPCPhysicsMath;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3dc;
class="kw">public class BodyMotionWanderInCircle class="kw">extends BodyMotionWanderBase {
class="kw">protected class="kw">final double radius;
class="kw">protected class="kw">final boolean flock;
class="kw">protected class="kw">final boolean useSphere;
class="kw">protected class="kw">final Vector3d referencePoint = new Vector3d();
class="kw">public BodyMotionWanderInCircle(@Nonnull BuilderBodyMotionWanderInCircle var1, @Nonnull BuilderSupport var2) {
super(var1, var2);
this.radius = var1.getRadius(var2);
this.flock = var1.isFlock();
this.useSphere = var1.isUseSphere();
}
@Override
class="kw">protected double constrainMove(
@Nonnull Ref<EntityStore> var1,
@Nonnull ExecutionSupport var2,
@Nonnull Vector3d var3,
@Nonnull Vector3d var4,
double var5,
@Nonnull ComponentAccessor<EntityStore> var7
) {
Vector3d var8 = this.getReferencePoint(var1, var7);
double var9 = this.radius * this.radius;
MotionController var11 = var2.getMotionContextSupport().getActiveMotionController();
if (this.useSphere) {
double var17 = var11.waypointDistanceSquared(var4, var8);
if (var17 <= var9) {
class="kw">return var5;
} else {
double var14 = var11.waypointDistanceSquared(var3, var8);
if (var14 >= var9) {
class="kw">return var17 <= var14 ? var5 : 0.0;
} else {
class="kw">return NPCPhysicsMath.intersectLineSphereLerp(var8, this.radius, var3, var4, var11.getComponentSelector()) * var5;
}
}
} else {
Vector3dc var12 = var11.getWorldNormal();
double var13 = NPCPhysicsMath.squaredDistProjected(var4.x(), var4.y(), var4.z(), var8, var12);
if (var13 <= var9) {
class="kw">return var5;
} else {
double var15 = NPCPhysicsMath.squaredDistProjected(var3.x(), var3.y(), var3.z(), var8, var12);
if (var15 >= var9) {
class="kw">return var13 <= var15 ? var5 : 0.0;
} else {
class="kw">return var5 * Math.max(0.0, NPCPhysicsMath.rayCircleIntersect(var3, var4, var8, this.radius, var12));
}
}
}
}
class="kw">protected Vector3d getReferencePoint(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
if (this.flock) {
World var11 = var2.getExternalData().getWorld();
TransformComponent var4 = var2.getComponent(var1, TransformComponent.getComponentType());
assert var4 != null;
Vector3d var5 = var4.getPosition();
Ref var6 = FlockPlugin.getFlockReference(var1, var2);
if (var6 != null) {
EntityGroup var7 = var2.getComponent(var6, EntityGroup.getComponentType());
assert var7 != null;
Ref var8 = var7.getLeaderRef();
if (var8.isValid()) {
TransformComponent var9 = var2.getComponent(var8, TransformComponent.getComponentType());
assert var9 != null;
Vector3d var10 = var9.getPosition();
this.referencePoint.set(var10.x(), var10.y(), var10.z());
class="kw">return this.referencePoint;
}
}
this.referencePoint.set(var5);
class="kw">return this.referencePoint;
} else {
NPCEntity var3 = var2.getComponent(var1, NPCEntity.getComponentType());
assert var3 != null;
class="kw">return var3.getLeashPoint();
}
}
}