InteractionSystems class

Пакет: com.hypixel.hytale.server.core.modules.interaction.system

Файл: com/hypixel/hytale/server/core/modules/interaction/system/InteractionSystems.java

Поля (27)

МодификаторыТипИмя
private static final HytaleLogger LOGGER
private static final HytaleLogger LOGGER
private final ComponentType<EntityStore, InteractionManager> interactionComponentType
private final ComponentType<EntityStore, InteractionManager> interactionManagerComponent
private final Query<EntityStore> query
private final Query<EntityStore> query
private final Query<EntityStore> query
String var12
Object2IntOpenHashMap var3
Player var4
InteractionManager var5
Interactions var5
EntityTrackerSystems.Visible var5
PlayerRef var5
IndexedLookupTableAssetMap var6
Ref var6
EntityTrackerSystems.Visible var6
int var6
int var7
InteractionManager var7
Interactions var7
InteractionsUpdate var7
PlayerRef var8
Ref var8
ObjectList var9
private final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType
private final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType

Методы (34)

МодификаторыВозвратСигнатура
public CleanUpSystempublic CleanUpSystem()
public DropUnresolvedInteractionspublic DropUnresolvedInteractions()
public EntityTrackerRemovepublic EntityTrackerRemove(ComponentType<EntityStore, EntityTrackerSystems.Visible> var1)
public PlayerAddManagerSystempublic PlayerAddManagerSystem()
public TickInteractionManagerSystempublic TickInteractionManagerSystem()
public TrackerTickSystempublic TrackerTickSystem()
public ComponentType<EntityStore, Interactions> componentTypepublic ComponentType<EntityStore, Interactions> componentType()
public SystemGroup<EntityStore> getGrouppublic SystemGroup<EntityStore> getGroup()
public SystemGroup<EntityStore> getGrouppublic SystemGroup<EntityStore> getGroup()
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 Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
public Query<EntityStore> getQuerypublic Query<EntityStore> getQuery()
if if(var5 != null)
if if(var7 != 0)
if if(var5 != null)
if if(var6 != Integer.MIN_VALUE)
public boolean isParallelpublic boolean isParallel(int var1, int var2)
public void onComponentAddedpublic void onComponentAdded(@Nonnull Ref<EntityStore> var1, @Nonnull Interactions var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
public void onComponentRemovedpublic void onComponentRemoved(@Nonnull Ref<EntityStore> var1, @Nonnull Interactions var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
public void onComponentSetpublic void onComponentSet(@Nonnull Ref<EntityStore> var1, Interactions var2, @Nonnull Interactions var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5)
public void onEntityAddpublic void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3)
public void onEntityAddedpublic void onEntityAdded(@Nonnull Ref<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
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)
public void onEntityRemovepublic void onEntityRemove(@Nonnull Ref<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
public void onEntityRemovedpublic void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3)
private static void queueUpdatesForprivate static void queueUpdatesFor(@Nonnull Ref<EntityStore> var0, @Nonnull Map<Ref<EntityStore>, EntityTrackerSystems.EntityViewer> var1, @Nonnull Interactions var2)
abstract queueUpdatesFor queueUpdatesFor(var8, var6.visibleTo, var7)
abstract queueUpdatesFor queueUpdatesFor(var8, var6.newlyVisibleTo, var7)
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.core.modules.interaction.system;

class="kw">import com.hypixel.hytale.assetstore.map.IndexedLookupTableAssetMap;
class="kw">import com.hypixel.hytale.component.AddReason;
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.Holder;
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.SystemGroup;
class="kw">import com.hypixel.hytale.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.HolderSystem;
class="kw">import com.hypixel.hytale.component.system.RefChangeSystem;
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.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.protocol.ComponentUpdateType;
class="kw">import com.hypixel.hytale.protocol.InteractionType;
class="kw">import com.hypixel.hytale.protocol.InteractionsUpdate;
class="kw">import com.hypixel.hytale.protocol.packets.interaction.SyncInteractionChain;
class="kw">import com.hypixel.hytale.protocol.packets.interaction.SyncInteractionChains;
class="kw">import com.hypixel.hytale.server.core.entity.InteractionManager;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.DamageModule;
class="kw">import com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems;
class="kw">import com.hypixel.hytale.server.core.modules.entitystats.EntityStatsSystems;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.InteractionModule;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.InteractionSimulationHandler;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.Interactions;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
class="kw">import it.unimi.dsi.fastutil.objects.ObjectList;
class="kw">import java.util.Map;
class="kw">import java.util.Map.Entry;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

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

   class="kw">public class="kw">static class CleanUpSystem class="kw">extends RefSystem<EntityStore> {
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, InteractionManager> interactionComponentType = InteractionModule.get().getInteractionManagerComponent();

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

      @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
      ) {
         InteractionManager var5 = var3.getComponent(var1, this.interactionComponentType);
         assert var5 != null;
         var5.clear();
      }

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

   class="kw">public class="kw">static class DropUnresolvedInteractions class="kw">extends RefSystem<EntityStore> {
      class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
      @Nonnull
      class="kw">private class="kw">final Query<EntityStore> query = Query.and(Interactions.getComponentType(), Player.getComponentType());

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

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

      @Override
      class="kw">public void onEntityAdded(
         @Nonnull Ref<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
         Interactions var5 = var4.getComponent(var1, Interactions.getComponentType());
         if (var5 != null) {
            IndexedLookupTableAssetMap var6 = RootInteraction.getAssetMap();
            int var7 = 0;

            for (InteractionType var11 : InteractionType.values()) {
               String var12 = var5.getInteractionId(var11);
               if (var12 != null && var6.getIndex(var12) == Integer.MIN_VALUE) {
                  var5.removeInteractionId(var11);
                  var7++;
               }
            }

            if (var7 != 0) {
               LOGGER.at(Level.WARNING).log("Dropped %d unresolved interaction override(s) from persisted player data", var7);
               if (var5.isEmpty()) {
                  var4.tryRemoveComponent(var1, Interactions.getComponentType());
               }
            }
         }
      }

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

   class="kw">public class="kw">static class EntityTrackerRemove class="kw">extends RefChangeSystem<EntityStore, Interactions> {
      class="kw">private class="kw">final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType;

      class="kw">public EntityTrackerRemove(ComponentType<EntityStore, EntityTrackerSystems.Visible> var1) {
         this.visibleComponentType = var1;
      }

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

      @Nonnull
      @Override
      class="kw">public ComponentType<EntityStore, Interactions> componentType() {
         class="kw">return Interactions.getComponentType();
      }

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

      class="kw">public void onComponentSet(
         @Nonnull Ref<EntityStore> var1,
         Interactions var2,
         @Nonnull Interactions var3,
         @Nonnull Store<EntityStore> var4,
         @Nonnull CommandBuffer<EntityStore> var5
      ) {
      }

      class="kw">public void onComponentRemoved(
         @Nonnull Ref<EntityStore> var1, @Nonnull Interactions var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
      ) {
         EntityTrackerSystems.Visible var5 = var4.getComponent(var1, this.visibleComponentType);
         if (var5 != null) {
            for (EntityTrackerSystems.EntityViewer var7 : var5.visibleTo.values()) {
               var7.queueRemove(var1, ComponentUpdateType.Interactions);
            }
         }
      }
   }

   class="kw">public class="kw">static class PlayerAddManagerSystem class="kw">extends HolderSystem<EntityStore> {
      @Nonnull
      class="kw">private class="kw">final Query<EntityStore> query = Query.and(
         Player.getComponentType(), PlayerRef.getComponentType(), Query.not(InteractionModule.get().getInteractionManagerComponent())
      );

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

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

      @Override
      class="kw">public void onEntityAdd(@Nonnull Holder<EntityStore> var1, @Nonnull AddReason var2, @Nonnull Store<EntityStore> var3) {
         Player var4 = var1.getComponent(Player.getComponentType());
         assert var4 != null;
         PlayerRef var5 = var1.getComponent(PlayerRef.getComponentType());
         assert var5 != null;
         var1.addComponent(InteractionModule.get().getInteractionManagerComponent(), new InteractionManager(var5, new InteractionSimulationHandler()));
      }

      @Override
      class="kw">public void onEntityRemoved(@Nonnull Holder<EntityStore> var1, @Nonnull RemoveReason var2, @Nonnull Store<EntityStore> var3) {
      }
   }

   class="kw">public class="kw">static class TickInteractionManagerSystem class="kw">extends EntityTickingSystem<EntityStore> class="kw">implements EntityStatsSystems.StatModifyingSystem {
      @Nonnull
      class="kw">private class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, InteractionManager> interactionManagerComponent = InteractionModule.get().getInteractionManagerComponent();

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

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

      @Override
      class="kw">public void tick(
         float var1, int var2, @Nonnull ArchetypeChunk<EntityStore> var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5
      ) {
         Ref var6 = var3.getReferenceTo(var2);

         try {
            InteractionManager var7 = var3.getComponent(var2, this.interactionManagerComponent);
            assert var7 != null;
            PlayerRef var8 = var3.getComponent(var2, PlayerRef.getComponentType());
            var7.tick(var6, var5, var1);
            ObjectList var9 = var7.getSyncPackets();
            if (var8 != null && !var9.isEmpty()) {
               if (var9.size() > 128) {
                  LOGGER.at(Level.WARNING)
                     .log("Dropping %d excess interaction sync packets for %s (had %d, limit 128)", var9.size() - 128, var8.getUuid(), var9.size());
                  var9.removeElements(128, var9.size());
               }

               var8.getPacketHandler().writeNoCache(new SyncInteractionChains((SyncInteractionChain[])var9.toArray(SyncInteractionChain[]::new)));
               var9.clear();
            }
         } catch (Throwable var10) {
            ((HytaleLogger.Api)LOGGER.at(Level.SEVERE).withCause(var10)).log("Exception while ticking entity interactions! Removing!");
            var5.removeEntity(var6, RemoveReason.REMOVE);
         }
      }

      @Nullable
      @Override
      class="kw">public SystemGroup<EntityStore> getGroup() {
         class="kw">return DamageModule.get().getGatherDamageGroup();
      }
   }

   class="kw">public class="kw">static class TrackerTickSystem class="kw">extends EntityTickingSystem<EntityStore> {
      @Nonnull
      class="kw">private class="kw">final ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType = EntityTrackerSystems.Visible.getComponentType();
      @Nonnull
      class="kw">private class="kw">final Query<EntityStore> query = Query.and(this.visibleComponentType, Interactions.getComponentType());

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

      @Nullable
      @Override
      class="kw">public SystemGroup<EntityStore> getGroup() {
         class="kw">return EntityTrackerSystems.QUEUE_UPDATE_GROUP;
      }

      @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
      ) {
         EntityTrackerSystems.Visible var6 = var3.getComponent(var2, this.visibleComponentType);
         assert var6 != null;
         Interactions var7 = var3.getComponent(var2, Interactions.getComponentType());
         assert var7 != null;
         Ref var8 = var3.getReferenceTo(var2);
         if (var7.consumeNetworkOutdated()) {
            queueUpdatesFor(var8, var6.visibleTo, var7);
         } else if (!var6.newlyVisibleTo.isEmpty()) {
            queueUpdatesFor(var8, var6.newlyVisibleTo, var7);
         }
      }

      class="kw">private class="kw">static void queueUpdatesFor(
         @Nonnull Ref<EntityStore> var0, @Nonnull Map<Ref<EntityStore>, EntityTrackerSystems.EntityViewer> var1, @Nonnull Interactions var2
      ) {
         Object2IntOpenHashMap var3 = new Object2IntOpenHashMap();

         for (Entry var5 : var2.getInteractions().entrySet()) {
            int var6 = RootInteraction.getAssetMap().getIndex(var5.getValue());
            if (var6 != Integer.MIN_VALUE) {
               var3.put(var5.getKey(), var6);
            }
         }

         InteractionsUpdate var7 = new InteractionsUpdate(var3, var2.getInteractionHint(), var2.isOverrideAll());

         for (EntityTrackerSystems.EntityViewer var9 : var1.values()) {
            var9.queueUpdate(var0, var7);
         }
      }
   }
}