Class PositionCache
java.lang.Object
com.hypixel.hytale.server.npc.role.support.PositionCache
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ComponentType<EntityStore, BoundingBox> private floatprivate booleanprivate final List<Ref<EntityStore>> private final it.unimi.dsi.fastutil.objects.Object2ByteMap<Ref<EntityStore>> static final Stringprivate final it.unimi.dsi.fastutil.objects.Object2ByteMap<Ref<EntityStore>> static final BiPredicate<Ref<EntityStore>, ComponentAccessor<EntityStore>> static final BiPredicate<Ref<EntityStore>, ComponentAccessor<EntityStore>> private booleanprivate booleanprivate static final ComponentType<EntityStore, ItemComponent> private final it.unimi.dsi.fastutil.objects.Object2ByteMap<Ref<EntityStore>> protected final PositionCache.LineOfSightBufferprotected final PositionCache.LineOfSightEntityBufferprivate static final floatprivate static final floatprivate doubleprivate intprivate doublestatic final doubleprivate static final ComponentType<EntityStore, ModelComponent> protected EntityListprivate intprotected EntityListprivate static final floatprivate floatprivate final Roleprivate final List<Ref<EntityStore>> private final List<Ref<EntityStore>> private static final ComponentType<EntityStore, TransformComponent> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExternalPositionCacheRegistration(Consumer<Role> registration) voidclear(double tickTime) private voidprivate voidclearLineOfSightCache(double tickTime) boolean<S,T> int countEntitiesInRange(double minRange, double maxRange, boolean findPlayers, QuadPredicate<S, Ref<EntityStore>, T, ComponentAccessor<EntityStore>> filter, S s, T t, ComponentAccessor<EntityStore> componentAccessor) void<T,U> void forEachEntityInAvoidanceRange(Set<Ref<EntityStore>> ignoredEntitiesForAvoidance, QuadConsumer<Ref<EntityStore>, T, U, CommandBuffer<EntityStore>> consumer, T t, U u, CommandBuffer<EntityStore> commandBuffer) <T> voidforEachEntityInAvoidanceRange(Set<Ref<EntityStore>> ignoredEntitiesForAvoidance, TriConsumer<Ref<EntityStore>, T, CommandBuffer<EntityStore>> consumer, T t, CommandBuffer<EntityStore> commandBuffer) <T,U, V, R>
voidforEachNPCUnordered(double maxDistance, QuadPredicate<Ref<EntityStore>, T, U, ComponentAccessor<EntityStore>> predicate, QuadConsumer<Ref<EntityStore>, T, V, R> consumer, T t, U u, V v, R r, ComponentAccessor<EntityStore> componentAccessor) <T,U, V> void forEachPlayer(DoubleQuadObjectConsumer<Ref<EntityStore>, T, U, V> consumer, T t, U u, V v, double d, ComponentAccessor<EntityStore> componentAccessor) <S> Ref<EntityStore> getClosestDroppedItemInRange(Ref<EntityStore> ref, double minRange, double maxRange, QuadPredicate<S, Ref<EntityStore>, Role, ComponentAccessor<EntityStore>> filter, Role role, S s, ComponentAccessor<EntityStore> componentAccessor) getClosestNPCInRange(double minRange, double maxRange, Predicate<Ref<EntityStore>> filter, ComponentAccessor<EntityStore> componentAccessor) getClosestPlayerInRange(double minRange, double maxRange, ComponentAccessor<EntityStore> componentAccessor) getClosestPlayerInRange(double minRange, double maxRange, Predicate<Ref<EntityStore>> filter, ComponentAccessor<EntityStore> componentAccessor) doubleintdoublegetNpcs()getRole()booleanhasInverseLineOfSight(Ref<EntityStore> ref, Ref<EntityStore> targetRef, ComponentAccessor<EntityStore> componentAccessor) booleanhasLineOfSight(Ref<EntityStore> ref, Ref<EntityStore> targetRef, ComponentAccessor<EntityStore> componentAccessor) private booleanhasLineOfSightInternal(Ref<EntityStore> ref, Ref<EntityStore> targetRef, ComponentAccessor<EntityStore> componentAccessor) boolean<S> booleanisEntityCountInRange(double minRange, double maxRange, int minCount, int maxCount, boolean findPlayers, Role role, QuadPredicate<S, Ref<EntityStore>, Role, ComponentAccessor<EntityStore>> filter, S s, ComponentAccessor<EntityStore> componentAccessor) booleanisFriendlyBlockingLineOfSight(Ref<EntityStore> ref, Ref<EntityStore> targetRef, ComponentAccessor<EntityStore> componentAccessor) <S,T> void processEntitiesInRange(Ref<EntityStore> ref, EntityList entities, double minRange, double maxRange, boolean useProjectedDistance, Ref<EntityStore> ignoredEntityReference, Role role, QuadPredicate<S, Ref<EntityStore>, Role, T> filter, S s, T t, ComponentAccessor<EntityStore> componentAccessor) <S,T> void processNPCsInRange(Ref<EntityStore> ref, double minRange, double maxRange, boolean useProjectedDistance, Ref<EntityStore> ignoredEntityReference, Role role, QuadPredicate<S, Ref<EntityStore>, Role, T> filter, S s, T t, ComponentAccessor<EntityStore> componentAccessor) <S,T> void processPlayersInRange(Ref<EntityStore> ref, double minRange, double maxRange, boolean useProjectedDistance, Ref<EntityStore> ignoredEntityReference, Role role, QuadPredicate<S, Ref<EntityStore>, Role, T> filter, S s, T t, ComponentAccessor<EntityStore> componentAccessor) protected static booleanrayIsIntersectingEntity(Ref<EntityStore> ref, Vector3d pos, Vector3d dir, Vector2d minMax, double length2, ComponentAccessor<EntityStore> componentAccessor) voidrequireDroppedItemDistance(double value) voidrequireEntityDistanceAvoidance(double v) voidrequireEntityDistanceSorted(double v) voidrequireEntityDistanceUnsorted(double v) voidrequirePlayerDistanceAvoidance(double v) voidrequirePlayerDistanceSorted(double v) voidrequirePlayerDistanceUnsorted(double v) voidrequireSpawnBeaconDistance(int value) voidrequireSpawnMarkerDistance(double value) voidreset(boolean isConfiguring) voidvoidsetBenchmarking(boolean benchmarking) voidsetCouldBreathe(boolean couldBreathe) voidsetOpaqueBlockSet(int blockSet) private booleantestLineOfSightEntity(Ref<EntityStore> ref, Ref<EntityStore> targetRef, PositionCache.LineOfSightEntityBuffer buffer, ComponentAccessor<EntityStore> componentAccessor, double length2) private static <T> booleantestLineOfSightRays(Ref<EntityStore> ref, Ref<EntityStore> targetRef, PositionCache.RayPredicate<T> predicate, T t, ComponentAccessor<EntityStore> componentAccessor) booleantickPositionCacheNextUpdate(float dt)
-
Field Details
-
IS_VALID_PLAYER
-
IS_VALID_NPC
-
MIN_LOS_BLOCKING_DISTANCE_SQUARED
public static final double MIN_LOS_BLOCKING_DISTANCE_SQUARED- See Also:
-
FUNCTION_CAN_BE_ONLY_CALLED_WHILE_CONFIGURING_POSITION_CACHE
- See Also:
-
LOS_CACHE_TTL_MIN_SECONDS
private static final float LOS_CACHE_TTL_MIN_SECONDS- See Also:
-
LOS_CACHE_TTL_MAX_SECONDS
private static final float LOS_CACHE_TTL_MAX_SECONDS- See Also:
-
POSITION_CACHE_TTL_SECONDS
private static final float POSITION_CACHE_TTL_SECONDS- See Also:
-
TRANSFORM_COMPONENT_TYPE
-
ITEM_COMPONENT_TYPE
-
MODEL_COMPONENT_TYPE
-
BOUNDING_BOX_COMPONENT_TYPE
-
maxDroppedItemDistance
private double maxDroppedItemDistance -
maxSpawnMarkerDistance
private double maxSpawnMarkerDistance -
maxSpawnBeaconDistance
private int maxSpawnBeaconDistance -
role
-
opaqueBlockSet
private int opaqueBlockSet -
players
-
npcs
-
externalRegistrations
-
droppedItems
-
spawnMarkers
-
spawnBeacons
-
lineOfSightCache
-
inverseLineOfSightCache
private final it.unimi.dsi.fastutil.objects.Object2ByteMap<Ref<EntityStore>> inverseLineOfSightCache -
friendlyFireCache
-
lineOfSightComputeBuffer
-
lineOfSightEntityComputeBuffer
-
cacheTTL
private float cacheTTL -
positionCacheNextUpdate
private float positionCacheNextUpdate -
isBenchmarking
private boolean isBenchmarking -
isConfiguring
private boolean isConfiguring -
couldBreathe
private boolean couldBreathe
-
-
Constructor Details
-
PositionCache
-
-
Method Details
-
isBenchmarking
public boolean isBenchmarking() -
setBenchmarking
public void setBenchmarking(boolean benchmarking) -
setCouldBreathe
public void setCouldBreathe(boolean couldBreathe) -
getPlayers
-
getNpcs
-
tickPositionCacheNextUpdate
public boolean tickPositionCacheNextUpdate(float dt) -
resetPositionCacheNextUpdate
public void resetPositionCacheNextUpdate() -
getMaxDroppedItemDistance
public double getMaxDroppedItemDistance() -
getMaxSpawnMarkerDistance
public double getMaxSpawnMarkerDistance() -
getMaxSpawnBeaconDistance
public int getMaxSpawnBeaconDistance() -
addExternalPositionCacheRegistration
-
getExternalRegistrations
-
reset
public void reset(boolean isConfiguring) -
finalizeConfiguration
public void finalizeConfiguration() -
clear
public void clear(double tickTime) -
couldBreatheCached
public boolean couldBreatheCached() -
forEachPlayer
public <T,U, void forEachPlayerV> (@Nonnull DoubleQuadObjectConsumer<Ref<EntityStore>, T, U, V> consumer, T t, U u, V v, double d, ComponentAccessor<EntityStore> componentAccessor) -
getClosestPlayerInRange
@Nullable public Ref<EntityStore> getClosestPlayerInRange(double minRange, double maxRange, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
getClosestPlayerInRange
@Nullable public Ref<EntityStore> getClosestPlayerInRange(double minRange, double maxRange, @Nonnull Predicate<Ref<EntityStore>> filter, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
getClosestNPCInRange
@Nullable public Ref<EntityStore> getClosestNPCInRange(double minRange, double maxRange, @Nonnull Predicate<Ref<EntityStore>> filter, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
processNPCsInRange
public <S,T> void processNPCsInRange(@Nonnull Ref<EntityStore> ref, double minRange, double maxRange, boolean useProjectedDistance, Ref<EntityStore> ignoredEntityReference, @Nonnull Role role, @Nonnull QuadPredicate<S, Ref<EntityStore>, Role, T> filter, S s, T t, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
processPlayersInRange
public <S,T> void processPlayersInRange(@Nonnull Ref<EntityStore> ref, double minRange, double maxRange, boolean useProjectedDistance, Ref<EntityStore> ignoredEntityReference, @Nonnull Role role, @Nonnull QuadPredicate<S, Ref<EntityStore>, Role, T> filter, S s, T t, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
processEntitiesInRange
public <S,T> void processEntitiesInRange(@Nonnull Ref<EntityStore> ref, @Nonnull EntityList entities, double minRange, double maxRange, boolean useProjectedDistance, Ref<EntityStore> ignoredEntityReference, @Nonnull Role role, @Nonnull QuadPredicate<S, Ref<EntityStore>, Role, T> filter, S s, T t, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
getClosestDroppedItemInRange
@Nullable public <S> Ref<EntityStore> getClosestDroppedItemInRange(@Nonnull Ref<EntityStore> ref, double minRange, double maxRange, @Nonnull QuadPredicate<S, Ref<EntityStore>, Role, ComponentAccessor<EntityStore>> filter, Role role, S s, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
isEntityCountInRange
public <S> boolean isEntityCountInRange(double minRange, double maxRange, int minCount, int maxCount, boolean findPlayers, Role role, @Nonnull QuadPredicate<S, Ref<EntityStore>, Role, ComponentAccessor<EntityStore>> filter, S s, ComponentAccessor<EntityStore> componentAccessor) -
countEntitiesInRange
public <S,T> int countEntitiesInRange(double minRange, double maxRange, boolean findPlayers, @Nonnull QuadPredicate<S, Ref<EntityStore>, T, ComponentAccessor<EntityStore>> filter, S s, T t, ComponentAccessor<EntityStore> componentAccessor) -
requirePlayerDistanceSorted
public void requirePlayerDistanceSorted(double v) -
requirePlayerDistanceUnsorted
public void requirePlayerDistanceUnsorted(double v) -
requirePlayerDistanceAvoidance
public void requirePlayerDistanceAvoidance(double v) -
requireEntityDistanceSorted
public void requireEntityDistanceSorted(double v) -
requireEntityDistanceUnsorted
public void requireEntityDistanceUnsorted(double v) -
requireEntityDistanceAvoidance
public void requireEntityDistanceAvoidance(double v) -
requireDroppedItemDistance
public void requireDroppedItemDistance(double value) -
requireSpawnMarkerDistance
public void requireSpawnMarkerDistance(double value) -
requireSpawnBeaconDistance
public void requireSpawnBeaconDistance(int value) -
getRole
-
forEachNPCUnordered
public <T,U, void forEachNPCUnorderedV, R> (double maxDistance, @Nonnull QuadPredicate<Ref<EntityStore>, T, U, ComponentAccessor<EntityStore>> predicate, @Nonnull QuadConsumer<Ref<EntityStore>, T, V, R> consumer, T t, U u, V v, R r, ComponentAccessor<EntityStore> componentAccessor) -
forEachEntityInAvoidanceRange
public <T> void forEachEntityInAvoidanceRange(@Nonnull Set<Ref<EntityStore>> ignoredEntitiesForAvoidance, @Nonnull TriConsumer<Ref<EntityStore>, T, CommandBuffer<EntityStore>> consumer, T t, CommandBuffer<EntityStore> commandBuffer) -
forEachEntityInAvoidanceRange
public <T,U> void forEachEntityInAvoidanceRange(@Nonnull Set<Ref<EntityStore>> ignoredEntitiesForAvoidance, @Nonnull QuadConsumer<Ref<EntityStore>, T, U, CommandBuffer<EntityStore>> consumer, T t, U u, CommandBuffer<EntityStore> commandBuffer) -
setOpaqueBlockSet
public void setOpaqueBlockSet(int blockSet) -
testLineOfSightRays
private static <T> boolean testLineOfSightRays(@Nonnull Ref<EntityStore> ref, @Nonnull Ref<EntityStore> targetRef, @Nonnull PositionCache.RayPredicate<T> predicate, @Nonnull T t, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
hasLineOfSightInternal
private boolean hasLineOfSightInternal(@Nonnull Ref<EntityStore> ref, @Nonnull Ref<EntityStore> targetRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
hasLineOfSight
public boolean hasLineOfSight(@Nonnull Ref<EntityStore> ref, @Nonnull Ref<EntityStore> targetRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
hasInverseLineOfSight
public boolean hasInverseLineOfSight(@Nonnull Ref<EntityStore> ref, @Nonnull Ref<EntityStore> targetRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
isFriendlyBlockingLineOfSight
public boolean isFriendlyBlockingLineOfSight(@Nonnull Ref<EntityStore> ref, @Nonnull Ref<EntityStore> targetRef, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
testLineOfSightEntity
private boolean testLineOfSightEntity(@Nonnull Ref<EntityStore> ref, @Nonnull Ref<EntityStore> targetRef, @Nonnull PositionCache.LineOfSightEntityBuffer buffer, @Nonnull ComponentAccessor<EntityStore> componentAccessor, double length2) -
clearLineOfSightCache
private void clearLineOfSightCache(double tickTime) -
clearLineOfSightCache
private void clearLineOfSightCache() -
rayIsIntersectingEntity
protected static boolean rayIsIntersectingEntity(@Nonnull Ref<EntityStore> ref, @Nonnull Vector3d pos, @Nonnull Vector3d dir, @Nonnull Vector2d minMax, double length2, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
getDroppedItemList
-
getSpawnMarkerList
-
getSpawnBeaconList
-