FlockSystems class

Пакет: com.hypixel.hytale.server.flock

Файл: com/hypixel/hytale/server/flock/FlockSystems.java

Поля (58)

МодификаторыТипИмя
private static final float DEBUG_SHAPE_TIME
private static final float FLOCK_VIS_LEADER_EXTRA_RING_OFFSET
private static final float FLOCK_VIS_LINE_THICKNESS
private static final float FLOCK_VIS_RING_OUTER_RADIUS_OFFSET
private static final int FLOCK_VIS_RING_SEGMENTS
private static final float FLOCK_VIS_RING_THICKNESS
private final Archetype<EntityStore> archetype
private final ComponentType<EntityStore, BoundingBox> boundingBoxComponentType
break
private final ComponentType<EntityStore, EntityGroup> entityGroupComponentType
private final ComponentType<EntityStore, EntityGroup> entityGroupComponentType
private final ComponentType<EntityStore, Flock> flockComponentType
private final ComponentType<EntityStore, Flock> flockComponentType
private final ComponentType<EntityStore, Flock> flockComponentType
private final ComponentType<EntityStore, UUIDComponent> flockIdComponentType
private final Query<EntityStore> query
private final ComponentType<EntityStore, TransformComponent> transformComponentType
private final ComponentType<EntityStore, UUIDComponent> uuidComponentType
Dirty var10
int var10
Vector3f var11
Ref var12
TransformComponent var13
BoundingBox var14
Vector3d var15
Box var16
double var17
double var18
double var19
double var20
double var21
double var22
double var23
double var24
double var25
double var26
double var27
double var28
double var30
TransformComponent var31
BoundingBox var32
double var32
Vector3d var33
Box var34
double var34
double var35
double var37
double var39
double var41
UUID var5
EntityGroup var6
Flock var6
Ref var6
Flock var6
Flock var7
EntityGroup var7
UUIDComponent var8
World var9

Методы (23)

МодификаторыВозвратСигнатура
public EntityRemovedpublic EntityRemoved(ComponentType<EntityStore, Flock> var1)
public FlockDebugSystempublic FlockDebugSystem(@Nonnull ComponentType<EntityStore, Flock> var1)
public PlayerChangeGameModeEventSystempublic PlayerChangeGameModeEventSystem()
public Tickingpublic Ticking(ComponentType<EntityStore, Flock> var1)
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public void handlepublic void handle(int var1, @Nonnull ArchetypeChunk<EntityStore> var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4, @Nonnull ChangeGameModeEvent var5)
if if(var10 != null)
if if(var13 != null && var14 != null)
if if(var31 != null && var32 != null)
if if(var22 < 0.001)
public boolean isParallelpublic boolean isParallel(int var1, int var2)
public boolean isParallelpublic boolean isParallel(int var1, int var2)
public void onEntityAddedpublic void onEntityAdded(@Nonnull Ref<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
public void onEntityRemovepublic void onEntityRemove(@Nonnull Ref<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
private static void renderConnectingLineprivate static void renderConnectingLine(@Nonnull World var0, double var1, double var3, double var5, double var7, double var9, double var11, double var13, double var15, @Nonnull Vector3f var17)
abstract renderConnectingLine renderConnectingLine(var9, var33.x, var35, var33.z, var39, var15.x, var17, var15.z, var25, var11)
abstract super super(ChangeGameModeEvent.class)
switch switch(var2)
public void tickpublic void tick(float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5)
public void tickpublic void tick(float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5)

Исходный код

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

class="kw">import com.hypixel.hytale.component.AddReason;
class="kw">import com.hypixel.hytale.component.Archetype;
class="kw">import com.hypixel.hytale.component.ArchetypeChunk;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.RemoveReason;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.EntityEventSystem;
class="kw">import com.hypixel.hytale.component.system.RefSystem;
class="kw">import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
class="kw">import com.hypixel.hytale.math.shape.Box;
class="kw">import com.hypixel.hytale.protocol.GameMode;
class="kw">import com.hypixel.hytale.server.core.entity.Dirty;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.entity.group.EntityGroup;
class="kw">import com.hypixel.hytale.server.core.event.events.ecs.ChangeGameModeEvent;
class="kw">import com.hypixel.hytale.server.core.modules.debug.DebugUtils;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.BoundingBox;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.UUID;
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.Vector3f;

class="kw">public class FlockSystems {
   class="kw">public FlockSystems() {
   }

   class="kw">public class="kw">static class EntityRemoved class="kw">extends RefSystem<EntityStore> {
      class="kw">private class="kw">final ComponentType<EntityStore, UUIDComponent> flockIdComponentType = UUIDComponent.getComponentType();
      class="kw">private class="kw">final ComponentType<EntityStore, EntityGroup> entityGroupComponentType = EntityGroup.getComponentType();
      class="kw">private class="kw">final ComponentType<EntityStore, Flock> flockComponentType;
      class="kw">private class="kw">final Archetype<EntityStore> archetype;

      class="kw">public EntityRemoved(ComponentType<EntityStore, Flock> var1) {
         this.flockComponentType = var1;
         this.archetype = Archetype.of(this.flockIdComponentType, this.entityGroupComponentType, var1);
      }

      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return this.archetype;
      }

      @Override
      class="kw">public void onEntityAdded(
         @Nonnull Ref<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
      }

      @Override
      class="kw">public void onEntityRemove(
         @Nonnull Ref<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
         UUID var5 = var3.getComponent(var1, this.flockIdComponentType).getUuid();
         EntityGroup var6 = var3.getComponent(var1, this.entityGroupComponentType);
         Flock var7 = var3.getComponent(var1, this.flockComponentType);
         class="kw">switch (var2) {
            case REMOVE:
            case BUILDER_TOOLS_UNDO:
               var6.setDissolved(true);

               for (Ref var9 : var6.getMemberList()) {
                  var4.removeComponent(var9, FlockMembership.getComponentType());
                  Dirty var10 = var4.getComponent(var9, Dirty.getComponentType());
                  if (var10 != null) {
                     var10.markDirty();
                  }
               }

               var7.setRemovedStatus(Flock.FlockRemovedStatus.DISSOLVED);
               var6.clear();
               if (var7.isTrace()) {
                  FlockPlugin.get().getLogger().at(Level.INFO).log("Flock %s: Dissolving", var5);
               }
               break;
            case UNLOAD:
               var7.setRemovedStatus(Flock.FlockRemovedStatus.UNLOADED);
               var6.clear();
               if (var7.isTrace()) {
                  FlockPlugin.get().getLogger().at(Level.INFO).log("Flock %s: Flock unloaded, size=%s", var5, var6.size());
               }
         }
      }
   }

   class="kw">public class="kw">static class FlockDebugSystem class="kw">extends EntityTickingSystem<EntityStore> {
      class="kw">private class="kw">static class="kw">final float DEBUG_SHAPE_TIME = 0.1F;
      class="kw">private class="kw">static class="kw">final float FLOCK_VIS_RING_OUTER_RADIUS_OFFSET = 0.3F;
      class="kw">private class="kw">static class="kw">final float FLOCK_VIS_RING_THICKNESS = 0.08F;
      class="kw">private class="kw">static class="kw">final float FLOCK_VIS_LINE_THICKNESS = 0.04F;
      class="kw">private class="kw">static class="kw">final int FLOCK_VIS_RING_SEGMENTS = 8;
      class="kw">private class="kw">static class="kw">final float FLOCK_VIS_LEADER_EXTRA_RING_OFFSET = 0.15F;
      class="kw">private class="kw">final ComponentType<EntityStore, Flock> flockComponentType;
      class="kw">private class="kw">final ComponentType<EntityStore, EntityGroup> entityGroupComponentType;
      class="kw">private class="kw">final ComponentType<EntityStore, UUIDComponent> uuidComponentType;
      class="kw">private class="kw">final ComponentType<EntityStore, TransformComponent> transformComponentType;
      class="kw">private class="kw">final ComponentType<EntityStore, BoundingBox> boundingBoxComponentType;
      @Nonnull
      class="kw">private class="kw">final Query<EntityStore> query;

      class="kw">public FlockDebugSystem(@Nonnull ComponentType<EntityStore, Flock> var1) {
         this.flockComponentType = var1;
         this.entityGroupComponentType = EntityGroup.getComponentType();
         this.uuidComponentType = UUIDComponent.getComponentType();
         this.transformComponentType = TransformComponent.getComponentType();
         this.boundingBoxComponentType = BoundingBox.getComponentType();
         this.query = Query.and(var1, this.entityGroupComponentType, this.uuidComponentType);
      }

      @Nonnull
      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return this.query;
      }

      @Override
      class="kw">public boolean isParallel(int var1, int var2) {
         class="kw">return EntityTickingSystem.maybeUseParallel(var1, var2);
      }

      @Override
      class="kw">public void tick(
         float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5
      ) {
         Flock var6 = var3.getComponent(var2, this.flockComponentType);
         assert var6 != null;
         if (var6.hasVisFlockMember()) {
            EntityGroup var7 = var3.getComponent(var2, this.entityGroupComponentType);
            assert var7 != null;
            if (!var7.isDissolved() && var7.size() >= 2) {
               UUIDComponent var8 = var3.getComponent(var2, this.uuidComponentType);
               assert var8 != null;
               World var9 = var4.getExternalData().getWorld();
               int var10 = Math.floorMod(var8.getUuid().hashCode(), DebugUtils.INDEXED_COLORS.length);
               Vector3f var11 = DebugUtils.INDEXED_COLORS[var10];
               Ref var12 = var7.getLeaderRef();
               if (var12 != null && var12.isValid()) {
                  TransformComponent var13 = var4.getComponent(var12, this.transformComponentType);
                  BoundingBox var14 = var4.getComponent(var12, this.boundingBoxComponentType);
                  if (var13 != null && var14 != null) {
                     Vector3d var15 = var13.getPosition();
                     Box var16 = var14.getBoundingBox();
                     double var17 = var15.y + var16.max.y / 2.0;
                     double var19 = Math.max(var16.max.x - var16.min.x, var16.max.z - var16.min.z);
                     double var21 = var19 / 2.0 + 0.3F;
                     double var23 = var21 - 0.08F;
                     double var25 = var21 + 0.15F;
                     double var27 = var25 - 0.08F;
                     DebugUtils.addDisc(var9, var15.x, var17, var15.z, var21, var23, var11, 0.8F, 8, 0.1F, 0);
                     DebugUtils.addDisc(var9, var15.x, var17, var15.z, var25, var27, var11, 0.8F, 8, 0.1F, 0);

                     for (Ref var30 : var7.getMemberList()) {
                        if (var30.isValid() && !var30.equals(var12)) {
                           TransformComponent var31 = var4.getComponent(var30, this.transformComponentType);
                           BoundingBox var32 = var4.getComponent(var30, this.boundingBoxComponentType);
                           if (var31 != null && var32 != null) {
                              Vector3d var33 = var31.getPosition();
                              Box var34 = var32.getBoundingBox();
                              double var35 = var33.y + var34.max.y / 2.0;
                              double var37 = Math.max(var34.max.x - var34.min.x, var34.max.z - var34.min.z);
                              double var39 = var37 / 2.0 + 0.3F;
                              double var41 = var39 - 0.08F;
                              DebugUtils.addDisc(var9, var33.x, var35, var33.z, var39, var41, var11, 0.8F, 8, 0.1F, 0);
                              renderConnectingLine(var9, var33.x, var35, var33.z, var39, var15.x, var17, var15.z, var25, var11);
                           }
                        }
                     }
                  }
               }
            }
         }
      }

      class="kw">private class="kw">static void renderConnectingLine(
         @Nonnull World var0,
         double var1,
         double var3,
         double var5,
         double var7,
         double var9,
         double var11,
         double var13,
         double var15,
         @Nonnull Vector3f var17
      ) {
         double var18 = var9 - var1;
         double var20 = var13 - var5;
         double var22 = Math.sqrt(var18 * var18 + var20 * var20);
         if (var22 < 0.001) {
            DebugUtils.addLine(var0, var1, var3, var5, var9, var11, var13, var17, 0.04F, 0.1F, 0);
         } else {
            double var24 = var18 / var22;
            double var26 = var20 / var22;
            double var28 = var1 + var24 * var7;
            double var30 = var5 + var26 * var7;
            double var32 = var9 - var24 * var15;
            double var34 = var13 - var26 * var15;
            DebugUtils.addLine(var0, var28, var3, var30, var32, var11, var34, var17, 0.04F, 0.1F, 0);
         }
      }
   }

   class="kw">public class="kw">static class PlayerChangeGameModeEventSystem class="kw">extends EntityEventSystem<EntityStore, ChangeGameModeEvent> {
      class="kw">public PlayerChangeGameModeEventSystem() {
         super(ChangeGameModeEvent.class);
      }

      class="kw">public void handle(
         int var1,
         @Nonnull ArchetypeChunk<EntityStore> var2,
         @Nonnull Store<EntityStore> var3,
         @Nonnull CommandBuffer<EntityStore> var4,
         @Nonnull ChangeGameModeEvent var5
      ) {
         if (var5.getGameMode() != GameMode.Adventure) {
            Ref var6 = var2.getReferenceTo(var1);
            var4.tryRemoveComponent(var6, FlockMembership.getComponentType());
         }
      }

      @Nullable
      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return Archetype.empty();
      }
   }

   class="kw">public class="kw">static class Ticking class="kw">extends EntityTickingSystem<EntityStore> {
      class="kw">private class="kw">final ComponentType<EntityStore, Flock> flockComponentType;

      class="kw">public Ticking(ComponentType<EntityStore, Flock> var1) {
         this.flockComponentType = var1;
      }

      @Override
      class="kw">public Query<EntityStore> getQuery() {
         class="kw">return this.flockComponentType;
      }

      @Override
      class="kw">public boolean isParallel(int var1, int var2) {
         class="kw">return EntityTickingSystem.maybeUseParallel(var1, var2);
      }

      @Override
      class="kw">public void tick(
         float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5
      ) {
         Flock var6 = var3.getComponent(var2, this.flockComponentType);
         var6.swapDamageDataBuffers();
      }
   }
}