DebugFlagsChangeListener interface

Пакет: com.hypixel.hytale.server.npc.role.support

Файл: com/hypixel/hytale/server/npc/role/support/DebugSupport.java

Методы (1)

МодификаторыВозвратСигнатура
abstract void onDebugFlagsChangedvoid onDebugFlagsChanged(EnumSet<RoleDebugFlags> var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.role.support;

class="kw">import com.hypixel.hytale.component.Component;
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.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.npc.NPCPlugin;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.SupportConfigBuilder;
class="kw">import com.hypixel.hytale.server.npc.instructions.Sensor;
class="kw">import com.hypixel.hytale.server.npc.role.RoleDebugDisplay;
class="kw">import com.hypixel.hytale.server.npc.role.RoleDebugFlags;
class="kw">import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
class="kw">import java.util.ArrayList;
class="kw">import java.util.EnumSet;
class="kw">import java.util.List;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;

class="kw">public class DebugSupport class="kw">implements Component<EntityStore> {
   @Nullable
   class="kw">protected RoleDebugDisplay debugDisplay;
   class="kw">protected boolean debugRoleSteering;
   class="kw">protected boolean debugMotionSteering;
   class="kw">protected EnumSet<RoleDebugFlags> debugFlags;
   @Nullable
   class="kw">protected String displayCustomString;
   @Nullable
   class="kw">protected String displayPathfinderString;
   class="kw">protected boolean traceSuccess;
   class="kw">protected boolean traceFail;
   class="kw">protected boolean traceSensorFails;
   class="kw">protected Sensor lastFailingSensor;
   class="kw">protected List<DebugSupport.DebugFlagsChangeListener> debugFlagsChangeListeners = new ArrayList<>();
   class="kw">protected boolean visSensorRanges;
   class="kw">protected int currentSensorColorIndex;
   @Nullable
   class="kw">protected List<DebugSupport.SensorVisData> sensorVisDataList;
   @Nullable
   class="kw">protected Map<Ref<EntityStore>, List<DebugSupport.EntityVisData>> entityVisDataMap;
   class="kw">protected boolean visPath;
   @Nullable
   class="kw">protected List<DebugSupport.PathWaypointVisData> pathVisDataList;

   @Nonnull
   class="kw">public class="kw">static ComponentType<EntityStore, DebugSupport> getComponentType() {
      class="kw">return NPCPlugin.get().getDebugSupportComponentType();
   }

   @Nonnull
   class="kw">public class="kw">static DebugSupport get(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1) {
      DebugSupport var2 = var1.getComponent(var0, getComponentType());
      assert var2 != null : "Missing DebugSupport on entity " + var0;
      class="kw">return var2;
   }

   class="kw">public DebugSupport(@Nonnull SupportConfigBuilder<?> var1) {
      this.debugFlags = var1.getDebugFlags();
   }

   class="kw">public DebugSupport() {
      this.debugFlags = EnumSet.noneOf(RoleDebugFlags.class);
   }

   @Nullable
   class="kw">public RoleDebugDisplay getDebugDisplay() {
      class="kw">return this.debugDisplay;
   }

   class="kw">public boolean isTraceSuccess() {
      class="kw">return this.traceSuccess;
   }

   class="kw">public boolean isTraceFail() {
      class="kw">return this.traceFail;
   }

   class="kw">public boolean isTraceSensorFails() {
      class="kw">return this.traceSensorFails;
   }

   class="kw">public void setLastFailingSensor(Sensor var1) {
      this.lastFailingSensor = var1;
   }

   class="kw">public Sensor getLastFailingSensor() {
      class="kw">return this.lastFailingSensor;
   }

   class="kw">public boolean isDebugRoleSteering() {
      class="kw">return this.debugRoleSteering;
   }

   class="kw">public boolean isDebugMotionSteering() {
      class="kw">return this.debugMotionSteering;
   }

   class="kw">public void setDisplayCustomString(@Nullable String var1) {
      this.displayCustomString = var1;
   }

   @Nullable
   class="kw">public String pollDisplayCustomString() {
      String var1 = this.displayCustomString;
      this.displayCustomString = null;
      class="kw">return var1;
   }

   class="kw">public void setDisplayPathfinderString(@Nullable String var1) {
      this.displayPathfinderString = var1;
   }

   @Nullable
   class="kw">public String pollDisplayPathfinderString() {
      String var1 = this.displayPathfinderString;
      this.displayPathfinderString = null;
      class="kw">return var1;
   }

   class="kw">public EnumSet<RoleDebugFlags> getDebugFlags() {
      class="kw">return this.debugFlags;
   }

   class="kw">public void setDebugFlags(EnumSet<RoleDebugFlags> var1) {
      this.debugFlags = var1;
      this.onDebugFlagsChanged();
      this.notifyDebugFlagsListeners(var1);
   }

   class="kw">public boolean isDebugFlagSet(RoleDebugFlags var1) {
      class="kw">return this.debugFlags.contains(var1);
   }

   class="kw">public boolean isAnyDebugFlagSet(@Nonnull EnumSet<RoleDebugFlags> var1) {
      for (RoleDebugFlags var3 : var1) {
         if (this.debugFlags.contains(var3)) {
            class="kw">return true;
         }
      }

      class="kw">return false;
   }

   class="kw">protected void onDebugFlagsChanged() {
      this.debugRoleSteering = this.isDebugFlagSet(RoleDebugFlags.SteeringRole);
      this.debugMotionSteering = this.isDebugFlagSet(RoleDebugFlags.MotionControllerSteer);
      this.traceFail = this.isDebugFlagSet(RoleDebugFlags.TraceFail);
      this.traceSuccess = this.isDebugFlagSet(RoleDebugFlags.TraceSuccess);
      this.traceSensorFails = this.isDebugFlagSet(RoleDebugFlags.TraceSensorFailures);
      this.visSensorRanges = this.isDebugFlagSet(RoleDebugFlags.VisSensorRanges);
      this.visPath = this.isDebugFlagSet(RoleDebugFlags.VisPath);
      this.debugDisplay = RoleDebugDisplay.create(this.debugFlags, this.debugDisplay);
   }

   class="kw">public void registerDebugFlagsListener(DebugSupport.DebugFlagsChangeListener var1) {
      this.debugFlagsChangeListeners.add(var1);
   }

   class="kw">public void removeDebugFlagsListener(DebugSupport.DebugFlagsChangeListener var1) {
      this.debugFlagsChangeListeners.remove(var1);
   }

   class="kw">public void notifyDebugFlagsListeners(EnumSet<RoleDebugFlags> var1) {
      for (DebugSupport.DebugFlagsChangeListener var3 : this.debugFlagsChangeListeners) {
         var3.onDebugFlagsChanged(var1);
      }
   }

   class="kw">public boolean isVisSensorRanges() {
      class="kw">return this.visSensorRanges;
   }

   class="kw">public void beginSensorVisualization() {
      this.currentSensorColorIndex = 0;
      if (this.sensorVisDataList != null) {
         this.sensorVisDataList.clear();
      }

      if (this.entityVisDataMap != null) {
         for (List var2 : this.entityVisDataMap.values()) {
            var2.clear();
         }
      }
   }

   class="kw">public int recordSensorRange(double var1, double var3, double var5) {
      if (this.sensorVisDataList == null) {
         this.sensorVisDataList = new ArrayList<>();
      }

      int var7 = this.currentSensorColorIndex++;
      this.sensorVisDataList.add(new DebugSupport.SensorVisData(var1, var3, var7, var5));
      class="kw">return var7;
   }

   class="kw">public void recordEntityCheck(@Nonnull Ref<EntityStore> var1, int var2, boolean var3) {
      if (this.entityVisDataMap == null) {
         this.entityVisDataMap = new Reference2ObjectOpenHashMap();
      }

      this.entityVisDataMap.computeIfAbsent(var1, var0 -> new ArrayList<>()).add(new DebugSupport.EntityVisData(var2, var3));
   }

   @Nullable
   class="kw">public List<DebugSupport.SensorVisData> getSensorVisData() {
      class="kw">return this.sensorVisDataList;
   }

   @Nullable
   class="kw">public Map<Ref<EntityStore>, List<DebugSupport.EntityVisData>> getEntityVisData() {
      class="kw">return this.entityVisDataMap;
   }

   class="kw">public boolean hasSensorVisData() {
      class="kw">return this.sensorVisDataList != null && !this.sensorVisDataList.isEmpty();
   }

   class="kw">public void clearSensorVisData() {
      if (this.sensorVisDataList != null) {
         this.sensorVisDataList.clear();
      }
   }

   class="kw">public boolean isVisPath() {
      class="kw">return this.visPath;
   }

   class="kw">public void clearPathVisualization() {
      if (this.pathVisDataList != null) {
         this.pathVisDataList.clear();
      }
   }

   class="kw">public void recordPathWaypoint(@Nonnull Vector3d var1, boolean var2, boolean var3) {
      this.recordPathWaypoint(var1, var2, var3, false);
   }

   class="kw">public void recordPathWaypoint(@Nonnull Vector3d var1, boolean var2, boolean var3, boolean var4) {
      if (this.pathVisDataList == null) {
         this.pathVisDataList = new ArrayList<>();
      }

      this.pathVisDataList.add(new DebugSupport.PathWaypointVisData(new Vector3d(var1), var2, var3, var4));
   }

   @Nullable
   class="kw">public List<DebugSupport.PathWaypointVisData> getPathVisData() {
      class="kw">return this.pathVisDataList;
   }

   class="kw">public boolean hasPathVisData() {
      class="kw">return this.pathVisDataList != null && !this.pathVisDataList.isEmpty();
   }

   @Override
   class="kw">public Component<EntityStore> clone() {
      class="kw">return this;
   }

   class="kw">public class="kw">interface DebugFlagsChangeListener {
      void onDebugFlagsChanged(EnumSet<RoleDebugFlags> var1);
   }

   class="kw">public record EntityVisData(int sensorColorIndex, boolean matched) {
      class="kw">public EntityVisData {
      }
   }

   class="kw">public record PathWaypointVisData(Vector3d position, boolean isCurrentTarget, boolean isEndNode, boolean isSeekTarget) {
      class="kw">public PathWaypointVisData {
      }
   }

   class="kw">public record SensorVisData(double range, double minRange, int colorIndex, double viewAngle) {
      class="kw">public SensorVisData {
      }
   }
}