SensorPoints class
Пакет: com.hypixel.hytale.server.npc.corecomponents.world
Файл: com/hypixel/hytale/server/npc/corecomponents/world/SensorPoints.java
extends: SensorBase
Поля (7)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
double |
range |
|
PointEntry |
var10 |
|
Vector3d |
var11 |
|
Vector3f |
var12 |
|
TransformComponent |
var6 |
|
PointManager |
var7 |
|
Vector3d |
var8 |
Методы (4)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
|
for for(int var9 = 0; var9 < this.queryResults.size() |
|
|
if if(var6 == null) |
|
|
if if(this.tagIndex >= 0) |
abstract |
|
super super(var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.corecomponents.world;
class="kw">import com.hypixel.hytale.builtin.points.PointsPlugin;
class="kw">import com.hypixel.hytale.builtin.points.manager.PointEntry;
class="kw">import com.hypixel.hytale.builtin.points.manager.PointManager;
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.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.SensorBase;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.world.builders.BuilderSensorPoints;
class="kw">import com.hypixel.hytale.server.npc.instructions.ExecutionSupport;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.InfoProvider;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.PositionSetProvider;
class="kw">import java.util.ArrayList;
class="kw">import java.util.List;
class="kw">import javax.annotation.Nonnull;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3f;
class="kw">public class SensorPoints class="kw">extends SensorBase {
class="kw">private class="kw">final double range;
class="kw">private class="kw">final int tagIndex;
class="kw">private class="kw">final PositionSetProvider positionProvider = new PositionSetProvider();
class="kw">private class="kw">final List<PointEntry> queryResults = new ArrayList<>();
class="kw">private class="kw">final Rotation3f scratchRotation = new Rotation3f();
class="kw">public SensorPoints(@Nonnull BuilderSensorPoints var1, @Nonnull BuilderSupport var2) {
super(var1);
this.range = var1.getRange(var2);
this.tagIndex = var1.getTagIndex(var2);
}
@Override
class="kw">public boolean matches(@Nonnull Ref<EntityStore> var1, @Nonnull ExecutionSupport var2, double var3, @Nonnull Store<EntityStore> var5) {
if (!super.matches(var1, var2, var3, var5)) {
this.positionProvider.clear();
class="kw">return false;
}
TransformComponent var6 = var5.getComponent(var1, TransformComponent.getComponentType());
if (var6 == null) {
this.positionProvider.clear();
class="kw">return false;
}
PointManager var7 = var5.getResource(PointsPlugin.get().getManagerResourceType());
Vector3d var8 = var6.getPosition();
if (this.tagIndex >= 0) {
var7.queryRadius(var8, this.range, this.tagIndex, this.queryResults);
} else {
var7.queryRadius(var8, this.range, this.queryResults);
}
this.positionProvider.reset();
for (int var9 = 0; var9 < this.queryResults.size(); var9++) {
PointEntry var10 = this.queryResults.get(var9);
Vector3d var11 = var10.getPosition();
Vector3f var12 = var10.getRotation();
this.scratchRotation.set(var12.x() * (float) (Math.PI / 180.0), var12.y() * (float) (Math.PI / 180.0), var12.z() * (float) (Math.PI / 180.0));
this.positionProvider.add(var11.x(), var11.y(), var11.z(), null, this.scratchRotation);
}
class="kw">return this.positionProvider.size() > 0;
}
@Override
class="kw">public InfoProvider getSensorInfo() {
class="kw">return this.positionProvider;
}
}