EntityPositionProvider class

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

Файл: com/hypixel/hytale/server/npc/sensorinfo/EntityPositionProvider.java

extends: PositionProvider

implements: IPositionSet

Поля (19)

МодификаторыТипИмя
return
Store var1
int var2
var2
Ref var2
int var3
Rotation3f var3
var3
var3
var3
Vector3d var3
var3
var3
Rotation3f var3
Vector3d var4
var4
var4
Rotation3f var4
Vector3d var5

Методы (11)

МодификаторыВозвратСигнатура
public void addTargetvoid addTarget(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2)
public void clearTargetsvoid clearTargets()
if if(var3 == null)
if if(var2 != 0)
if if(var2 < 0)
if if(this.target == null)
if if(var3 == null)
public void promotePrimaryvoid promotePrimary(@Nonnull Ref<EntityStore> var1)
public void setIncludeDeadvoid setIncludeDead(boolean var1)
private void storeOrientationAtvoid storeOrientationAt(int var1, @Nonnull PositionProvider var2)
abstract super super(var1)

Исходный код

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

class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.math.vector.Rotation3f;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.DeathComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.parameterproviders.ParameterProvider;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectArrayList;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3dc;

class="kw">public class EntityPositionProvider class="kw">extends PositionProvider class="kw">implements IPositionSet {
   @Nullable
   class="kw">private Ref<EntityStore> target;
   @Nonnull
   class="kw">private class="kw">final ObjectArrayList<Ref<EntityStore>> targets = new ObjectArrayList();
   @Nonnull
   class="kw">private class="kw">final ObjectArrayList<Vector3d> positions = new ObjectArrayList();
   @Nonnull
   class="kw">private class="kw">final ObjectArrayList<Rotation3f> orientations = new ObjectArrayList();
   @Nonnull
   class="kw">private class="kw">final PositionProvider positionResolver = new PositionProvider();
   class="kw">private boolean includeDead;

   class="kw">public EntityPositionProvider() {
   }

   class="kw">public EntityPositionProvider(ParameterProvider var1) {
      super(var1);
   }

   class="kw">public void setIncludeDead(boolean var1) {
      this.includeDead = var1;
   }

   @Override
   class="kw">public void clear() {
      super.clear();
      this.target = null;
      this.targets.clear();
   }

   @Override
   class="kw">public Ref<EntityStore> setTarget(@Nullable Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      class="kw">return this.target = super.setTarget(var1, var2, this.includeDead);
   }

   class="kw">public void addTarget(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      if (this.positionResolver.setTarget(var1, var2, this.includeDead) != null) {
         int var3 = this.targets.size();
         Vector3d var4;
         if (var3 < this.positions.size()) {
            var4 = (Vector3d)this.positions.get(var3);
         } else {
            var4 = new Vector3d();
            this.positions.add(var4);
         }

         var4.set(this.positionResolver.getX(), this.positionResolver.getY(), this.positionResolver.getZ());
         this.storeOrientationAt(var3, this.positionResolver);
         this.targets.add(var1);
      }
   }

   class="kw">private void storeOrientationAt(int var1, @Nonnull PositionProvider var2) {
      Rotation3f var3;
      if (var1 < this.orientations.size()) {
         var3 = (Rotation3f)this.orientations.get(var1);
         if (var3 == null) {
            var3 = new Rotation3f();
            this.orientations.set(var1, var3);
         }
      } else {
         var3 = new Rotation3f();
         this.orientations.add(var3);
      }

      if (!var2.provideOrientation(var3)) {
         this.orientations.set(var1, null);
      }
   }

   class="kw">public void clearTargets() {
      this.targets.clear();
   }

   class="kw">public void promotePrimary(@Nonnull Ref<EntityStore> var1) {
      if (!this.targets.isEmpty()) {
         int var2 = this.targets.indexOf(var1);
         if (var2 != 0) {
            if (var2 < 0) {
               if (!this.hasPosition()) {
                  class="kw">return;
               }

               var2 = this.targets.size();
               Vector3d var3;
               if (var2 < this.positions.size()) {
                  var3 = (Vector3d)this.positions.get(var2);
               } else {
                  var3 = new Vector3d();
                  this.positions.add(var3);
               }

               var3.set(this.getX(), this.getY(), this.getZ());
               this.storeOrientationAt(var2, this);
               this.targets.add(var1);
            }

            this.targets.set(var2, (Ref)this.targets.getFirst());
            this.targets.set(0, var1);
            Vector3d var5 = (Vector3d)this.positions.getFirst();
            this.positions.set(0, (Vector3d)this.positions.get(var2));
            this.positions.set(var2, var5);
            Rotation3f var4 = (Rotation3f)this.orientations.getFirst();
            this.orientations.set(0, (Rotation3f)this.orientations.get(var2));
            this.orientations.set(var2, var4);
         }
      }
   }

   @Nullable
   @Override
   class="kw">public Ref<EntityStore> getTarget() {
      if (this.target == null) {
         class="kw">return null;
      }

      Store var1 = this.target.getStore();
      if (!this.target.isValid() || !this.includeDead && var1.getArchetype(this.target).contains(DeathComponent.getComponentType())) {
         super.clear();
         this.target = null;
      }

      class="kw">return this.target;
   }

   @Override
   class="kw">public boolean hasPosition() {
      class="kw">return this.getTarget() != null;
   }

   @Override
   class="kw">public int size() {
      if (!this.targets.isEmpty()) {
         class="kw">return this.targets.size();
      } else {
         class="kw">return this.getTarget() != null ? 1 : 0;
      }
   }

   @Nullable
   @Override
   class="kw">public Ref<EntityStore> getTarget(int var1) {
      if (this.targets.isEmpty()) {
         class="kw">return var1 == 0 ? this.getTarget() : null;
      } else if (var1 >= 0 && var1 < this.targets.size()) {
         Ref var2 = (Ref<EntityStore>)this.targets.get(var1);
         class="kw">return var2 != null && var2.isValid() ? var2 : null;
      } else {
         class="kw">return null;
      }
   }

   @Override
   class="kw">public boolean getPosition(int var1, @Nonnull Vector3d var2) {
      if (!this.targets.isEmpty()) {
         if (var1 >= 0 && var1 < this.targets.size()) {
            var2.set((Vector3dc)this.positions.get(var1));
            class="kw">return true;
         } else {
            class="kw">return false;
         }
      } else {
         class="kw">return var1 == 0 && this.providePosition(var2);
      }
   }

   @Override
   class="kw">public boolean getOrientation(int var1, @Nonnull Rotation3f var2) {
      if (!this.targets.isEmpty()) {
         if (var1 >= 0 && var1 < this.targets.size()) {
            Rotation3f var3 = (Rotation3f)this.orientations.get(var1);
            if (var3 == null) {
               class="kw">return false;
            }

            var2.set(var3);
            class="kw">return true;
         } else {
            class="kw">return false;
         }
      } else {
         class="kw">return var1 == 0 && this.provideOrientation(var2);
      }
   }
}