BodyMotionTestProbe class

Пакет: com.hypixel.hytale.server.npc.corecomponents.debug

Файл: com/hypixel/hytale/server/npc/corecomponents/debug/BodyMotionTestProbe.java

extends: BodyMotionBase

Поля (23)

МодификаторыТипИмя
final double adjustX
NPCEntity var10
double var10
var10
double var12
double var14
double var16
float var18
var18
float var19
boolean var2
double var20
boolean var3
EnumSet var4
TransformComponent var4
boolean var5
Vector3d var5
double var6
var6
double var8
var8
TransformComponent var8
Vector3d var9

Методы (9)

МодификаторыВозвратСигнатура
abstract applyEscapeConstraints applyEscapeConstraints(var2, this.probeMoveData)
if if(var4 != null)
if if(this.adjustX >= 0.0)
if if(this.adjustZ >= 0.0)
if if(var8 == null)
if if(!this.displayText)
if if(var10 <= 1.0E-6)
if if(this.adjustDistance > 0.0)
abstract super super(var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.corecomponents.debug;

class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
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.npc.corecomponents.BodyMotionBase;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.debug.builders.BuilderBodyMotionTestProbe;
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.Steering;
class="kw">import com.hypixel.hytale.server.npc.movement.constraints.RelaxedConstraint;
class="kw">import com.hypixel.hytale.server.npc.movement.controllers.ProbeMoveData;
class="kw">import com.hypixel.hytale.server.npc.role.RoleDebugFlags;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.InfoProvider;
class="kw">import java.util.EnumSet;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class BodyMotionTestProbe class="kw">extends BodyMotionBase {
   class="kw">protected class="kw">final double adjustX;
   class="kw">protected class="kw">final double adjustZ;
   class="kw">protected class="kw">final double adjustDistance;
   class="kw">protected class="kw">final float snapAngle;
   @Nonnull
   class="kw">protected class="kw">final EnumSet<RelaxedConstraint> cachedEffectiveConstraints;
   class="kw">protected boolean displayText;
   class="kw">protected class="kw">final Vector3d direction = new Vector3d();
   class="kw">protected class="kw">final ProbeMoveData probeMoveData = new ProbeMoveData();

   class="kw">public BodyMotionTestProbe(@Nonnull BuilderBodyMotionTestProbe var1) {
      super(var1);
      this.probeMoveData.setSaveSegments(true);
      this.adjustX = var1.getAdjustX();
      this.adjustZ = var1.getAdjustZ();
      this.adjustDistance = var1.getAdjustDistance();
      this.snapAngle = var1.getSnapAngle() * (float) (Math.PI / 180.0);
      boolean var2 = var1.isLegacyRelaxedMoveConstraints();
      boolean var3 = !var1.isRelaxedConstraintsPresent();
      EnumSet var4 = var1.getRelaxedConstraints();
      boolean var5 = var1.isAvoidingBlockDamage();
      this.cachedEffectiveConstraints = computeEffectiveRelaxedConstraints(var3, var4, var2, var5);
   }

   @Nullable
   @Override
   class="kw">public EnumSet<RelaxedConstraint> getRelaxedConstraints() {
      class="kw">return this.cachedEffectiveConstraints;
   }

   @Override
   class="kw">public void activate(@Nonnull Ref<EntityStore> var1, @Nonnull ExecutionSupport var2, @Nonnull ComponentAccessor<EntityStore> var3) {
      this.displayText = var2.getDebugSupport().isDebugFlagSet(RoleDebugFlags.DisplayCustom);
      if (!(this.adjustX < 0.0) || !(this.adjustZ < 0.0)) {
         TransformComponent var4 = var3.getComponent(var1, TransformComponent.getComponentType());
         if (var4 != null) {
            Vector3d var5 = var4.getPosition();
            double var6 = var5.x;
            double var8 = var5.z;
            if (this.adjustX >= 0.0) {
               var6 = MathUtil.fastFloor(var6) + this.adjustX;
            }

            if (this.adjustZ >= 0.0) {
               var8 = MathUtil.fastFloor(var8) + this.adjustZ;
            }

            NPCEntity var10 = var3.getComponent(var1, NPCEntity.getComponentType());
            assert var10 != null;
            var10.moveTo(var1, var6, var5.y, var8, 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
   ) {
      var6.clear();
      this.probeMoveData.setRelaxedConstraints(this.cachedEffectiveConstraints);
      applyEscapeConstraints(var2, this.probeMoveData);
      if (var3 != null && var3.getPositionProvider().providePosition(this.direction)) {
         TransformComponent var8 = var7.getComponent(var1, TransformComponent.getComponentType());
         if (var8 == null) {
            class="kw">return false;
         }

         Vector3d var9 = var8.getPosition();
         this.direction.sub(var9);
         if (!this.displayText) {
            class="kw">return true;
         }

         double var10 = this.direction.length();
         if (var10 <= 1.0E-6) {
            class="kw">return true;
         }

         if (this.adjustDistance > 0.0) {
            var10 = this.adjustDistance;
            this.direction.normalize(this.adjustDistance);
         }

         double var12 = this.direction.x();
         double var14 = this.direction.y();
         double var16 = this.direction.z();
         float var18 = PhysicsMath.normalizeTurnAngle(PhysicsMath.headingFromDirection(var12, var16));
         float var19 = PhysicsMath.pitchFromDirection(var12, var14, var16);
         if (this.snapAngle > 0.0F && this.snapAngle < (float) Math.PI) {
            var18 = MathUtil.fastRound(var18 / this.snapAngle) * this.snapAngle;
            PhysicsMath.vectorFromAngles(var18, var19, this.direction).normalize(var10);
         }

         var6.setYaw(var18);
         var6.setPitch(var19);
         double var20 = var2.getMotionContextSupport().getActiveMotionController().probeMove(var1, var9, this.direction, this.probeMoveData, var7);
         var2.getDebugSupport().setDisplayCustomString(String.format("PR: %.2f DX: %.2f DZ: %.2f", var20, this.direction.x, this.direction.z));
         class="kw">return true;
      } else {
         class="kw">return false;
      }
   }
}