PrefabPathCollection class
Пакет: com.hypixel.hytale.builtin.path
Файл: com/hypixel/hytale/builtin/path/PrefabPathCollection.java
Поля (20)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
HytaleLogger |
LOGGER |
|
private final List<IPrefabPath> |
paths |
|
double |
var10 |
|
IPrefabPath |
var2 |
|
IPrefabPath |
var4 |
|
IPrefabPath |
var4 |
|
|
var4 |
|
IPrefabPath |
var4 |
|
IPrefabPath |
var4 |
|
|
var4 |
|
PrefabPathCollection.PathSet |
var5 |
|
int |
var5 |
|
double |
var5 |
|
|
var5 |
|
double |
var5 |
|
|
var5 |
|
PrefabPathCollection.PathSet |
var6 |
|
IPrefabPath |
var8 |
|
double |
var9 |
|
Vector3dc |
var9 |
Методы (17)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
private |
PathSetprivate PathSet() |
|
public void |
addpublic void add(IPrefabPath var1) |
abstract |
|
for for(int var7 = 0; var7 < this.paths.size() |
public |
void |
forEachvoid forEach(BiConsumer<UUID, IPrefabPath> var1) |
|
public IPrefabPath |
getNearestPathpublic IPrefabPath getNearestPath(@Nonnull Vector3d var1, @Nullable Set<UUID> var2, ComponentAccessor<EntityStore> var3) |
public |
IPrefabPath |
getOrConstructPathIPrefabPath getOrConstructPath(@Nonnull UUID var1, @Nonnull String var2, @Nonnull Int2ObjectConcurrentHashMap.IntBiObjFunction<UUID, String, IPrefabPath> var3) |
public |
IPrefabPath |
getPathIPrefabPath getPath(UUID var1) |
|
|
if if(var9 < var5) |
|
|
if if(var4 == null) |
|
|
if if(var3) |
|
|
if if(var10 < var5) |
public |
boolean |
isEmptyboolean isEmpty() |
|
public void |
removepublic void remove(IPrefabPath var1) |
public |
void |
removePathvoid removePath(UUID var1) |
public |
void |
removePathWaypointvoid removePathWaypoint(UUID var1, int var2) |
private |
void |
removePathWaypointvoid removePathWaypoint(UUID var1, int var2, boolean var3) |
public |
void |
unloadPathWaypointvoid unloadPathWaypoint(UUID var1, int var2) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.path;
class="kw">import com.hypixel.fastutil.ints.Int2ObjectConcurrentHashMap;
class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
class="kw">import com.hypixel.hytale.builtin.path.path.IPrefabPath;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
class="kw">import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectArrayList;
class="kw">import java.util.List;
class="kw">import java.util.Map;
class="kw">import java.util.Set;
class="kw">import java.util.UUID;
class="kw">import java.util.function.BiConsumer;
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">import org.joml.Vector3dc;
class="kw">public class PrefabPathCollection {
class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
class="kw">private class="kw">final int worldgenId;
class="kw">private class="kw">final Map<UUID, IPrefabPath> paths = new Object2ObjectOpenHashMap();
class="kw">private class="kw">final Int2ObjectMap<PrefabPathCollection.PathSet> pathsByFriendlyName = new Int2ObjectOpenHashMap();
class="kw">public PrefabPathCollection(int var1) {
this.worldgenId = var1;
}
@Nullable
class="kw">public IPrefabPath getNearestPrefabPath(int var1, @Nonnull Vector3d var2, Set<UUID> var3, @Nonnull ComponentAccessor<EntityStore> var4) {
PrefabPathCollection.PathSet var5 = (PrefabPathCollection.PathSet)this.pathsByFriendlyName.getOrDefault(var1, null);
class="kw">return var5 == null ? null : var5.getNearestPath(var2, var3, var4);
}
class="kw">public IPrefabPath getPath(UUID var1) {
class="kw">return this.paths.getOrDefault(var1, null);
}
class="kw">public IPrefabPath getOrConstructPath(
@Nonnull UUID var1, @Nonnull String var2, @Nonnull Int2ObjectConcurrentHashMap.IntBiObjFunction<UUID, String, IPrefabPath> var3
) {
IPrefabPath var4 = this.paths.computeIfAbsent(var1, var3x -> {
LOGGER.at(Level.FINER).log("Adding path %s.%s", this.worldgenId, var3x);
class="kw">return var3.apply(this.worldgenId, var3x, var2);
});
int var5 = AssetRegistry.getOrCreateTagIndex(var2);
PrefabPathCollection.PathSet var6 = (PrefabPathCollection.PathSet)this.pathsByFriendlyName
.computeIfAbsent(var5, var0 -> new PrefabPathCollection.PathSet());
var6.add(var4);
class="kw">return var4;
}
@Nullable
class="kw">public IPrefabPath getNearestPrefabPath(@Nonnull Vector3d var1, @Nullable Set<UUID> var2, @Nonnull ComponentAccessor<EntityStore> var3) {
IPrefabPath var4 = null;
double var5 = Double.MAX_VALUE;
for (IPrefabPath var8 : this.paths.values()) {
if (var2 == null || !var2.contains(var8.getId())) {
double var9 = var1.distanceSquared(var8.getNearestWaypointPosition(var1, var3));
if (var9 < var5) {
var4 = var8;
var5 = var9;
}
}
}
class="kw">return var4;
}
class="kw">public void removePathWaypoint(UUID var1, int var2) {
this.removePathWaypoint(var1, var2, false);
}
class="kw">public void unloadPathWaypoint(UUID var1, int var2) {
this.removePathWaypoint(var1, var2, true);
}
class="kw">private void removePathWaypoint(UUID var1, int var2, boolean var3) {
IPrefabPath var4 = this.getPath(var1);
LOGGER.at(Level.FINER).log("%s waypoint %s from path %s.%s", var3 ? "Unloading" : "Removing", var2, this.worldgenId, var1);
if (var4 == null) {
LOGGER.at(Level.SEVERE).log("Path %s.%s not found", this.worldgenId, var1);
} else {
if (var3) {
var4.unloadWaypoint(var2);
} else {
var4.removeWaypoint(var2, this.worldgenId);
}
if (var4.length() == 0 || !var4.hasLoadedWaypoints()) {
LOGGER.at(Level.FINER).log("%s path %s.%s", var3 ? "Unloading" : "Removing", this.worldgenId, var1);
this.removePath(var1);
}
}
}
class="kw">public void removePath(UUID var1) {
IPrefabPath var2 = this.paths.remove(var1);
((PrefabPathCollection.PathSet)this.pathsByFriendlyName.get(AssetRegistry.getTagIndex(var2.getName()))).remove(var2);
}
class="kw">public boolean isEmpty() {
class="kw">return this.paths.isEmpty();
}
class="kw">public void forEach(BiConsumer<UUID, IPrefabPath> var1) {
this.paths.forEach(var1);
}
class="kw">private class="kw">static class PathSet {
class="kw">private class="kw">final List<IPrefabPath> paths = new ObjectArrayList();
class="kw">private PathSet() {
}
class="kw">public void add(IPrefabPath var1) {
this.paths.add(var1);
}
class="kw">public void remove(IPrefabPath var1) {
this.paths.remove(var1);
}
@Nullable
class="kw">public IPrefabPath getNearestPath(@Nonnull Vector3d var1, @Nullable Set<UUID> var2, ComponentAccessor<EntityStore> var3) {
IPrefabPath var4 = null;
double var5 = Double.MAX_VALUE;
for (int var7 = 0; var7 < this.paths.size(); var7++) {
IPrefabPath var8 = this.paths.get(var7);
if (var2 == null || !var2.contains(var8.getId())) {
Vector3dc var9 = var8.getNearestWaypointPosition(var1, var3);
double var10 = var1.distanceSquared(var9);
if (var10 < var5) {
var4 = var8;
var5 = var10;
}
}
}
class="kw">return var4;
}
}
}