BodyMotionFlock class
Пакет: com.hypixel.hytale.server.flock.corecomponents
Файл: com/hypixel/hytale/server/flock/corecomponents/BodyMotionFlock.java
extends: BodyMotionBase
Поля (16)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
ComponentType<EntityStore, FlockMembership> |
FLOCK_MEMBERSHIP_COMPONENT_TYPE |
|
EntityGroup |
var10 |
|
Vector3d |
var11 |
|
double |
var12 |
|
double |
var14 |
|
Ref |
var16 |
|
Vector3d |
var17 |
|
Vector3d |
var18 |
|
Vector3d |
var19 |
|
TransformComponent |
var20 |
|
TransformComponent |
var21 |
|
Vector3d |
var22 |
|
Vector3d |
var23 |
|
Vector3d |
var24 |
|
FlockMembership |
var8 |
|
Ref |
var9 |
Методы (1)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
|
super super(var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.flock.corecomponents;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.ComponentType;
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.modules.physics.util.PhysicsMath;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.flock.FlockMembership;
class="kw">import com.hypixel.hytale.server.flock.corecomponents.builders.BuilderBodyMotionFlock;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.BodyMotionBase;
class="kw">import com.hypixel.hytale.server.npc.instructions.ExecutionSupport;
class="kw">import com.hypixel.hytale.server.npc.movement.GroupSteeringAccumulator;
class="kw">import com.hypixel.hytale.server.npc.movement.Steering;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.InfoProvider;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">public class BodyMotionFlock class="kw">extends BodyMotionBase {
class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, FlockMembership> FLOCK_MEMBERSHIP_COMPONENT_TYPE = FlockMembership.getComponentType();
class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, TransformComponent> TRANSFORM_COMPONENT_TYPE = TransformComponent.getComponentType();
class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, EntityGroup> ENTITY_GROUP_COMPONENT_TYPE = EntityGroup.getComponentType();
class="kw">protected class="kw">final GroupSteeringAccumulator groupSteeringAccumulator = new GroupSteeringAccumulator();
class="kw">public BodyMotionFlock(@Nonnull BuilderBodyMotionFlock var1) {
super(var1);
}
@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
) {
FlockMembership var8 = var7.getComponent(var1, FLOCK_MEMBERSHIP_COMPONENT_TYPE);
Ref var9 = var8 != null ? var8.getFlockRef() : null;
if (var9 != null && var9.isValid()) {
EntityGroup var10 = var7.getComponent(var9, ENTITY_GROUP_COMPONENT_TYPE);
Vector3d var11 = var2.getMotionContextSupport().getActiveMotionController().getComponentSelector();
this.groupSteeringAccumulator.setComponentSelector(var11);
this.groupSteeringAccumulator.setMaxRange(var2.getRole().getFlockInfluenceRange());
this.groupSteeringAccumulator.begin(var1, var7);
var10.forEachMemberExcludingSelf((var0, var1x, var2x, var3x) -> var2x.processEntity(var0, var3x), var1, this.groupSteeringAccumulator, var7);
this.groupSteeringAccumulator.end();
double var12 = 1.0;
double var14 = 1.0;
Ref var16 = var10.getLeaderRef();
if (!var16.isValid()) {
class="kw">return false;
}
Vector3d var17 = this.groupSteeringAccumulator.getSumOfPositions();
Vector3d var18 = this.groupSteeringAccumulator.getSumOfVelocities();
Vector3d var19 = this.groupSteeringAccumulator.getSumOfDistances();
TransformComponent var20 = var7.getComponent(var16, TRANSFORM_COMPONENT_TYPE);
assert var20 != null;
TransformComponent var21 = var7.getComponent(var1, TRANSFORM_COMPONENT_TYPE);
assert var21 != null;
Vector3d var22 = var20.getPosition();
Vector3d var23 = var21.getPosition();
Vector3d var24 = new Vector3d(var22.x(), var22.y(), var22.z());
if (var18.lengthSquared() > 1.0E-4) {
var6.setYaw(PhysicsMath.headingFromDirection(var18.x(), var18.z()));
} else {
var6.setYaw(var21.getRotation().yaw());
}
var17.sub(var22.x(), var22.y(), var22.z()).mul(var11);
if (var17.lengthSquared() > 1.0E-4) {
var17.normalize().mul(var12);
} else {
var17.zero();
}
if (var19.lengthSquared() > 1.0E-4) {
var19.normalize().mul(-var14);
} else {
var19.zero();
}
var24.sub(var23.x(), var23.y(), var23.z()).mul(var11);
var24.normalize().mul(0.5);
var17.add(var19).add(var24);
if (var17.lengthSquared() > 1.0E-4) {
var17.normalize();
} else {
var17.zero();
}
var6.setTranslation(var17);
class="kw">return true;
} else {
class="kw">return false;
}
}
}