CombatTargetCollector class
Пакет: com.hypixel.hytale.builtin.npccombatactionevaluator.corecomponents
Файл: com/hypixel/hytale/builtin/npccombatactionevaluator/corecomponents/CombatTargetCollector.java
implements: ISensorEntityCollector
Поля (12)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
break |
|
|
break |
|
double |
var10 |
|
Int2FloatOpenHashMap |
var12 |
|
HytaleLogger.Api |
var13 |
|
TransformComponent |
var14 |
|
Attitude |
var4 |
|
Int2FloatOpenHashMap |
var5 |
|
HytaleLogger.Api |
var6 |
|
Vector3d |
var7 |
|
TransformComponent |
var8 |
|
Vector3d |
var9 |
Методы (3)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
|
if if(this.targetMemory != null) |
|
|
if if(var10 < this.closestHostileDistanceSquared) |
|
|
switch switch(var4) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.npccombatactionevaluator.corecomponents;
class="kw">import com.hypixel.hytale.builtin.npccombatactionevaluator.memory.TargetMemory;
class="kw">import com.hypixel.hytale.builtin.npccombatactionevaluator.memory.TargetMemorySystems;
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.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.server.core.asset.type.attitude.Attitude;
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.corecomponents.ISensorEntityCollector;
class="kw">import com.hypixel.hytale.server.npc.instructions.ExecutionSupport;
class="kw">import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">public class CombatTargetCollector class="kw">implements ISensorEntityCollector {
@Nonnull
class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, TransformComponent> TRANSFORM_COMPONENT_TYPE = TransformComponent.getComponentType();
@Nullable
class="kw">private ExecutionSupport executionSupport;
@Nullable
class="kw">private TargetMemory targetMemory;
class="kw">private double closestHostileDistanceSquared = Double.MAX_VALUE;
class="kw">public CombatTargetCollector() {
}
@Override
class="kw">public void registerWithSupport(@Nonnull ExecutionSupport var1) {
var1.getWorldSupport().requireAttitudeCache();
}
@Override
class="kw">public void init(@Nonnull Ref<EntityStore> var1, @Nonnull ExecutionSupport var2, @Nonnull ComponentAccessor<EntityStore> var3) {
this.targetMemory = var3.getComponent(var1, TargetMemory.getComponentType());
this.executionSupport = var2;
}
@Override
class="kw">public void collectMatching(@Nonnull Ref<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3) {
if (this.targetMemory != null) {
Attitude var4 = this.executionSupport.getWorldSupport().getAttitude(var1, var2, var3);
class="kw">switch (var4) {
case IGNORE:
case NEUTRAL:
class="kw">default:
break;
case HOSTILE:
Int2FloatOpenHashMap var12 = this.targetMemory.getKnownHostiles();
if (var12.put(var2.getIndex(), this.targetMemory.getRememberFor()) <= 0.0F) {
this.targetMemory.getKnownHostilesList().add(var2);
HytaleLogger.Api var13 = TargetMemorySystems.LOGGER.at(Level.FINE);
if (var13.isEnabled()) {
var13.log("%s: Registered new hostile %s", var1, var2);
}
}
TransformComponent var14 = var3.getComponent(var1, TRANSFORM_COMPONENT_TYPE);
assert var14 != null;
Vector3d var7 = var14.getPosition();
TransformComponent var8 = var3.getComponent(var2, TRANSFORM_COMPONENT_TYPE);
assert var8 != null;
Vector3d var9 = var8.getPosition();
double var10 = var7.distanceSquared(var9);
if (var10 < this.closestHostileDistanceSquared) {
this.targetMemory.setClosestHostile(var2);
this.closestHostileDistanceSquared = var10;
}
break;
case FRIENDLY:
case REVERED:
Int2FloatOpenHashMap var5 = this.targetMemory.getKnownFriendlies();
if (var5.put(var2.getIndex(), this.targetMemory.getRememberFor()) <= 0.0F) {
this.targetMemory.getKnownFriendliesList().add(var2);
HytaleLogger.Api var6 = TargetMemorySystems.LOGGER.at(Level.FINE);
if (var6.isEnabled()) {
var6.log("%s: Registered new friendly %s", var1, var2);
}
}
}
}
}
@Override
class="kw">public void collectNonMatching(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
}
@Override
class="kw">public boolean terminateOnFirstMatch() {
class="kw">return this.targetMemory == null;
}
@Override
class="kw">public void cleanup() {
this.executionSupport = null;
this.targetMemory = null;
this.closestHostileDistanceSquared = Double.MAX_VALUE;
}
}