DonutSelector class
Пакет: com.hypixel.hytale.server.core.modules.interaction.interaction.config.selector
Файл: com/hypixel/hytale/server/core/modules/interaction/interaction/config/selector/DonutSelector.java
extends: SelectorType
Поля (50)
| Модификаторы | Тип | Имя |
|---|---|---|
|
private double |
currentRadius |
|
private final IntOpenHashSet |
detected |
|
private double |
heading |
|
private boolean |
headingSet |
|
Vector3d |
var10 |
|
double |
var10 |
|
double |
var10 |
|
double |
var11 |
|
Vector3f |
var11 |
|
boolean |
var12 |
|
boolean |
var12 |
|
double |
var13 |
|
double |
var13 |
|
double |
var13 |
|
double |
var15 |
|
double |
var15 |
|
double |
var15 |
|
double |
var17 |
|
double |
var17 |
|
Vector3d |
var19 |
|
int |
var19 |
|
Vector3d |
var20 |
|
int |
var20 |
|
int |
var21 |
|
Archetype |
var24 |
|
boolean |
var25 |
|
double |
var25 |
|
boolean |
var26 |
|
TransformComponent |
var27 |
|
Vector3d |
var28 |
|
double |
var29 |
|
TransformComponent |
var3 |
|
double |
var31 |
|
double |
var33 |
|
double |
var35 |
|
Vector3d |
var4 |
|
|
var4 |
|
Vector3d |
var4 |
|
HeadRotation |
var5 |
|
double |
var5 |
|
Vector3d |
var5 |
|
double |
var5 |
|
double |
var6 |
|
double |
var6 |
|
HeadRotation |
var7 |
|
CachedAccessor |
var7 |
|
Vector3d |
var8 |
|
double |
var8 |
|
double |
var8 |
|
double |
var8 |
Методы (18)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
private |
RuntimeSelectorprivate RuntimeSelector() |
|
|
for for(int var22 = var19; var22 < var20; var22++) |
|
|
for for(int var23 = 0; var23 < var21; var23++) |
|
|
for for(int var24 = var19; var24 < var20; var24++) |
|
|
if if(this.offset.x != 0.0 || this.offset.y != 0.0 || this.offset.z != 0.0) |
|
|
if if(var4) |
|
|
if if(var11 < 1.0E-9) |
|
|
if if(!this.headingSet) |
|
|
if if(SelectInteraction.SHOW_VISUAL_DEBUG) |
|
|
if if(!var25 && !var26) |
|
private double |
innerRadiusprivate double innerRadius() |
private |
boolean |
isFullCircleboolean isFullCircle() |
|
private double |
outerRadiusprivate double outerRadius() |
|
public void |
selectTargetBlockspublic void selectTargetBlocks(@Nonnull CommandBuffer<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull Selector.BlockConsumer var3) |
|
public void |
selectTargetEntitiespublic void selectTargetEntities(@Nonnull CommandBuffer<EntityStore> var1,
@Nonnull Ref<EntityStore> var2,
@Nonnull BiConsumer<Ref<EntityStore>, Vector4d> var3,
@Nullable Predicate<Ref<EntityStore>> var4) |
|
public void |
tickpublic void tick(@Nonnull CommandBuffer<EntityStore> var1, @Nonnull Ref<EntityStore> var2, float var3, float var4) |
public |
com.hypixel.hytale.protocol.Selector |
toPacketcom.hypixel.hytale.protocol.Selector toPacket() |
static |
boolean |
withinAngleboolean withinAngle(double var0, double var2, boolean var4, double var5, double var7, double var9) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.modules.interaction.interaction.config.selector;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.component.Archetype;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.math.util.HashUtil;
class="kw">import com.hypixel.hytale.math.util.MathUtil;
class="kw">import com.hypixel.hytale.math.vector.Vector3dUtil;
class="kw">import com.hypixel.hytale.server.core.modules.debug.DebugUtils;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.HeadRotation;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.Invulnerable;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.DeathComponent;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.none.SelectInteraction;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.CachedAccessor;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.core.util.TargetUtil;
class="kw">import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
class="kw">import java.util.function.BiConsumer;
class="kw">import java.util.function.Predicate;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3f;
class="kw">import org.joml.Vector4d;
class="kw">public class DonutSelector class="kw">extends SelectorType {
@Nonnull
class="kw">public class="kw">static class="kw">final BuilderCodec<DonutSelector> CODEC = BuilderCodec.builder(DonutSelector.class, DonutSelector::new, BASE_CODEC)
.documentation("A ring-shaped selector whose radius grows from MinRadius to MaxRadius over the run time.")
.<Float>appendInherited(
new KeyedCodec<>("MinRadius", Codec.FLOAT),
(var0, var1) -> var0.minRadius = var1,
var0 -> var0.minRadius,
(var0, var1) -> var0.minRadius = var1.minRadius
)
.addValidator(Validators.min(0.0F))
.documentation("The radius of the ring at the start of the run time.")
.add()
.<Float>appendInherited(
new KeyedCodec<>("MaxRadius", Codec.FLOAT),
(var0, var1) -> var0.maxRadius = var1,
var0 -> var0.maxRadius,
(var0, var1) -> var0.maxRadius = var1.maxRadius
)
.addValidator(Validators.max(50.0F))
.documentation("The radius of the ring at the end of the run time.")
.add()
.<Float>appendInherited(
new KeyedCodec<>("Width", Codec.FLOAT), (var0, var1) -> var0.width = var1, var0 -> var0.width, (var0, var1) -> var0.width = var1.width
)
.addValidator(Validators.min(0.1F))
.documentation("The constant radial thickness of the ring, centered on the current radius.")
.add()
.<Float>appendInherited(
new KeyedCodec<>("Height", Codec.FLOAT), (var0, var1) -> var0.height = var1, var0 -> var0.height, (var0, var1) -> var0.height = var1.height
)
.addValidator(Validators.min(0.1F))
.documentation("The constant vertical height of the ring, extending up from the selector position.")
.add()
.<Double>appendInherited(
new KeyedCodec<>("AngleDeg", Codec.DOUBLE),
(var0, var1) -> var0.angle = Math.toRadians(var1),
var0 -> Math.toDegrees(var0.angle),
(var0, var1) -> var0.angle = var1.angle
)
.addValidator(Validators.min(0.0))
.addValidator(Validators.max(360.0))
.documentation(
"The angular size of the ring in degrees. 360 is a full donut; a smaller value makes an arc centered on the attacker's look direction at the moment the selector starts."
)
.add()
.<Vector3d>append(new KeyedCodec<>("Offset", Vector3dUtil.CODEC), (var0, var1) -> var0.offset.set(var1), var0 -> var0.offset)
.documentation("The offset applied to the transform position used as the origin location of the selector.")
.add()
.<Double>appendInherited(
new KeyedCodec<>("YawOffsetDeg", Codec.DOUBLE),
(var0, var1) -> var0.yawOffset = Math.toRadians(var1),
var0 -> Math.toDegrees(var0.yawOffset),
(var0, var1) -> var0.yawOffset = var1.yawOffset
)
.documentation("The yaw rotation offset in degrees, applied to the arc facing and the origin Offset.")
.add()
.build();
class="kw">protected float minRadius;
class="kw">protected float maxRadius;
class="kw">protected float width = 0.1F;
class="kw">protected float height = 0.1F;
class="kw">protected double angle = Math.PI * 2;
class="kw">protected double yawOffset;
@Nonnull
class="kw">protected class="kw">final Vector3d offset = new Vector3d();
class="kw">public DonutSelector() {
}
@Nonnull
@Override
class="kw">public Selector newSelector() {
class="kw">return new DonutSelector.RuntimeSelector();
}
class="kw">public com.hypixel.hytale.protocol.Selector toPacket() {
class="kw">return new com.hypixel.hytale.protocol.DonutSelector(
this.minRadius, this.maxRadius, this.width, this.height, (float)this.angle, this.getOffset(), (float)this.yawOffset
);
}
@Nonnull
class="kw">public Vector3f getOffset() {
class="kw">return new Vector3f((float)this.offset.x, (float)this.offset.y, (float)this.offset.z);
}
@Nonnull
class="kw">private Vector3d selectTargetPosition(@Nonnull CommandBuffer<EntityStore> var1, @Nonnull Ref<EntityStore> var2) {
TransformComponent var3 = var1.getComponent(var2, TransformComponent.getComponentType());
assert var3 != null;
Vector3d var4 = var3.getPosition();
if (this.offset.x != 0.0 || this.offset.y != 0.0 || this.offset.z != 0.0) {
HeadRotation var5 = var1.getComponent(var2, HeadRotation.getComponentType());
double var6 = var5 != null ? var5.getRotation().yaw() : 0.0;
Vector3d var8 = new Vector3d(this.offset).rotateY(var6 + this.yawOffset);
var4 = var8.add(var3.getPosition());
}
class="kw">return var4;
}
class="kw">private boolean isFullCircle() {
class="kw">return this.angle >= 6.2830853071795865;
}
class="kw">private class="kw">static boolean withinAngle(double var0, double var2, boolean var4, double var5, double var7, double var9) {
if (var4) {
class="kw">return true;
}
double var11 = var0 * var0 + var2 * var2;
if (var11 < 1.0E-9) {
class="kw">return true;
}
double var13 = 1.0 / Math.sqrt(var11);
double var15 = var0 * var13 * var5 + var2 * var13 * var7;
class="kw">return var15 >= var9;
}
class="kw">private class RuntimeSelector class="kw">implements Selector {
@Nonnull
class="kw">private class="kw">final IntOpenHashSet detected = new IntOpenHashSet();
class="kw">private double currentRadius;
class="kw">private double heading;
class="kw">private boolean headingSet;
class="kw">private RuntimeSelector() {
}
@Override
class="kw">public void tick(@Nonnull CommandBuffer<EntityStore> var1, @Nonnull Ref<EntityStore> var2, float var3, float var4) {
double var5 = var4 > 0.0F ? MathUtil.clamp(var3 / var4, 0.0F, 1.0F) : 1.0;
this.currentRadius = DonutSelector.this.minRadius + (DonutSelector.this.maxRadius - DonutSelector.this.minRadius) * var5;
if (!this.headingSet) {
HeadRotation var7 = var1.getComponent(var2, HeadRotation.getComponentType());
double var8 = var7 != null ? var7.getRotation().yaw() : 0.0;
this.heading = var8 + DonutSelector.this.yawOffset + Math.PI;
this.headingSet = true;
}
if (SelectInteraction.SHOW_VISUAL_DEBUG) {
Vector3d var10 = DonutSelector.this.selectTargetPosition(var1, var2);
Vector3f var11 = new Vector3f(
(float)HashUtil.random(var2.getIndex(), this.hashCode(), 10L),
(float)HashUtil.random(var2.getIndex(), this.hashCode(), 11L),
(float)HashUtil.random(var2.getIndex(), this.hashCode(), 12L)
);
DebugUtils.addDonut(
var1.getExternalData().getWorld(),
var10.x,
var10.y,
var10.z,
this.outerRadius(),
this.innerRadius(),
DonutSelector.this.height,
this.heading,
DonutSelector.this.angle,
var11,
0.8F,
0.01F,
1
);
}
}
@Override
class="kw">public void selectTargetEntities(
@Nonnull CommandBuffer<EntityStore> var1,
@Nonnull Ref<EntityStore> var2,
@Nonnull BiConsumer<Ref<EntityStore>, Vector4d> var3,
@Nullable Predicate<Ref<EntityStore>> var4
) {
Vector3d var5 = DonutSelector.this.selectTargetPosition(var1, var2);
double var6 = this.outerRadius();
double var8 = this.innerRadius() * this.innerRadius();
double var10 = var6 * var6;
boolean var12 = DonutSelector.this.isFullCircle();
double var13 = Math.sin(this.heading);
double var15 = Math.cos(this.heading);
double var17 = Math.cos(DonutSelector.this.angle / 2.0);
Vector3d var19 = new Vector3d(var5.x - var6, var5.y, var5.z - var6);
Vector3d var20 = new Vector3d(var5.x + var6, var5.y + DonutSelector.this.height, var5.z + var6);
for (Ref var23 : TargetUtil.getAllEntitiesInBox(var19, var20, var1)) {
if (var23.isValid() && !var23.equals(var2) && (var4 == null || var4.test(var23)) && !this.detected.contains(var23.getIndex())) {
Archetype var24 = var1.getArchetype(var23);
boolean var25 = var24.contains(DeathComponent.getComponentType());
boolean var26 = var24.contains(Invulnerable.getComponentType());
if (!var25 && !var26) {
TransformComponent var27 = var1.getComponent(var23, TransformComponent.getComponentType());
assert var27 != null;
Vector3d var28 = var27.getPosition();
double var29 = var28.x - var5.x;
double var31 = var28.y - var5.y;
double var33 = var28.z - var5.z;
double var35 = var29 * var29 + var33 * var33;
if (var35 >= var8
&& var35 <= var10
&& var31 <= DonutSelector.this.height
&& var31 >= 0.0
&& DonutSelector.withinAngle(var29, var33, var12, var13, var15, var17)) {
this.detected.add(var23.getIndex());
var3.accept(var23, new Vector4d(var5.x, var5.y, var5.z, 1.0));
}
}
}
}
}
@Override
class="kw">public void selectTargetBlocks(@Nonnull CommandBuffer<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull Selector.BlockConsumer var3) {
Vector3d var4 = DonutSelector.this.selectTargetPosition(var1, var2);
double var5 = this.outerRadius();
CachedAccessor var7 = SelectorBlockScan.accessorAt(var1.getExternalData().getWorld(), var4.x, var4.y, var4.z, var5, DonutSelector.this.height);
double var8 = this.innerRadius() * this.innerRadius();
double var10 = var5 * var5;
boolean var12 = DonutSelector.this.isFullCircle();
double var13 = Math.sin(this.heading);
double var15 = Math.cos(this.heading);
double var17 = Math.cos(DonutSelector.this.angle / 2.0);
int var19 = MathUtil.floor(-var5);
int var20 = MathUtil.floor(var5);
int var21 = MathUtil.floor(DonutSelector.this.height);
for (int var22 = var19; var22 < var20; var22++) {
for (int var23 = 0; var23 < var21; var23++) {
for (int var24 = var19; var24 < var20; var24++) {
double var25 = (double)var22 * var22 + (double)var24 * var24;
if (var25 >= var8 && var25 <= var10 && DonutSelector.withinAngle(var22, var24, var12, var13, var15, var17)) {
SelectorBlockScan.accept(var7, MathUtil.floor(var4.x + var22), MathUtil.floor(var4.y + var23), MathUtil.floor(var4.z + var24), var3);
}
}
}
}
}
class="kw">private double innerRadius() {
class="kw">return Math.max(0.0, this.currentRadius - DonutSelector.this.width / 2.0);
}
class="kw">private double outerRadius() {
class="kw">return this.currentRadius + DonutSelector.this.width / 2.0;
}
}
}