BlackboardSubscription class

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

Файл: com/hypixel/hytale/server/npc/blackboard/BlackboardSubscription.java

implements: Component<EntityStore>

Поля (24)

МодификаторыТипИмя
BlockTypeView var1
EventSlotMapper var10
EventSlotMapper var11
PlayerEntityEventSupport var12
EventSlotMapper var13
NPCEntityEventSupport var15
BlackboardSubscription var2
IntSet var20
BlockEventView var3
EventSlotMapper var3
EntityEventView var4
Ref var4
Ref var4
PlayerBlockEventSupport var4
boolean var5
boolean var5
NPCBlockEventSupport var5
EventSupport var6
var6
var6
EntityEventSupport var6
var6
var6
IntSet var9

Методы (27)

МодификаторыВозвратСигнатура
private void addBlockChangeSetsvoid addBlockChangeSets(@Nonnull BlockEventType var1, @Nonnull IntSet var2)
private void addBlockTypeSetsvoid addBlockTypeSets(@Nonnull IntList var1)
private void addEntityEventSetsvoid addEntityEventSets(@Nonnull EntityEventType var1, @Nonnull IntSet var2)
static void buildAndAttachvoid buildAndAttach(@Nonnull Holder<EntityStore> var0, @Nonnull BuilderSupport var1)
for for(BlockEventType var8 : BlockEventType.VALUES)
for for(EntityEventType var19 : EntityEventType.VALUES)
private boolean hasAnySubscriptionboolean hasAnySubscription()
if if(this.blockTypeView == null)
if if(this.blockTypeSets != null)
if if(this.blockChangeSets != null)
if if(this.entityEventSets != null)
if if(var5)
if if(var6 != null)
if if(var5)
if if(var6 != null)
if if(this.blockChangeSets == null)
if if(this.entityEventSets == null)
if if(var3 != null)
if if(var11 != null)
if if(var9 != null)
if if(var10 != null)
if if(var13 != null)
if if(var20 != null)
public void initBlockTypeViewvoid initBlockTypeView(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2)
public void initEventViewsvoid initEventViews(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2)
static void notifyBlockChangevoid notifyBlockChange(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, @Nonnull BlockEventType var2, @Nonnull EventNotification var3)
static void notifyEntityEventvoid notifyEntityEvent(@Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, @Nonnull EntityEventType var2, @Nonnull EntityEventNotification var3)

Исходный код

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

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.Holder;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
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.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.EventSlotMapper;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.blocktype.BlockTypeView;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.EntityEventNotification;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.EventNotification;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.block.BlockEventType;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.block.BlockEventView;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.entity.EntityEventType;
class="kw">import com.hypixel.hytale.server.npc.blackboard.view.event.entity.EntityEventView;
class="kw">import com.hypixel.hytale.server.npc.components.messaging.EntityEventSupport;
class="kw">import com.hypixel.hytale.server.npc.components.messaging.EventSupport;
class="kw">import com.hypixel.hytale.server.npc.components.messaging.NPCBlockEventSupport;
class="kw">import com.hypixel.hytale.server.npc.components.messaging.NPCEntityEventSupport;
class="kw">import com.hypixel.hytale.server.npc.components.messaging.PlayerBlockEventSupport;
class="kw">import com.hypixel.hytale.server.npc.components.messaging.PlayerEntityEventSupport;
class="kw">import it.unimi.dsi.fastutil.ints.IntList;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import java.util.EnumMap;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class BlackboardSubscription class="kw">implements Component<EntityStore> {
   @Nullable
   class="kw">private BlockTypeView blockTypeView;
   @Nullable
   class="kw">private IntList blockTypeSets;
   @Nullable
   class="kw">private Map<BlockEventType, IntSet> blockChangeSets;
   @Nullable
   class="kw">private Map<EntityEventType, IntSet> entityEventSets;

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

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

   @Nonnull
   class="kw">public BlockTypeView getBlockTypeBlackboardView(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2) {
      if (this.blockTypeView == null) {
         this.initBlockTypeView(var1, var2);
      }

      if (this.blockTypeView.isOutdated(var1, var2)) {
         this.blockTypeView = this.blockTypeView.getUpdatedView(var1, var2);
      }

      class="kw">return this.blockTypeView;
   }

   @Nullable
   class="kw">public BlockTypeView removeBlockTypeBlackboardView() {
      BlockTypeView var1 = this.blockTypeView;
      this.blockTypeView = null;
      class="kw">return var1;
   }

   class="kw">public void initBlockTypeView(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      if (this.blockTypeSets != null) {
         this.blockTypeView = var2.getResource(Blackboard.getResourceType()).getView(BlockTypeView.class, var1, var2);
         this.blockTypeView.initialiseEntity(var1, this);
      }
   }

   @Nullable
   class="kw">public IntList getBlockTypeSets() {
      class="kw">return this.blockTypeSets;
   }

   class="kw">public void initEventViews(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      if (this.blockChangeSets != null) {
         BlockEventView var3 = var2.getResource(Blackboard.getResourceType()).getView(BlockEventView.class, var1, var2);
         var3.initialiseEntity(var1, this);
      }

      if (this.entityEventSets != null) {
         EntityEventView var4 = var2.getResource(Blackboard.getResourceType()).getView(EntityEventView.class, var1, var2);
         var4.initialiseEntity(var1, this);
      }
   }

   @Nullable
   class="kw">public IntSet getBlockChangeSet(@Nonnull BlockEventType var1) {
      class="kw">return this.blockChangeSets == null ? null : this.blockChangeSets.getOrDefault(var1, null);
   }

   class="kw">public class="kw">static void notifyBlockChange(
      @Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, @Nonnull BlockEventType var2, @Nonnull EventNotification var3
   ) {
      Ref var4 = var3.getInitiator();
      boolean var5 = var1.getArchetype(var4).contains(Player.getComponentType());
      EventSupport var6;
      if (var5) {
         var6 = var1.getComponent(var0, PlayerBlockEventSupport.getComponentType());
      } else {
         var6 = var1.getComponent(var0, NPCBlockEventSupport.getComponentType());
      }

      if (var6 != null) {
         var6.postMessage(var2, var3, var0, var1);
      }
   }

   @Nullable
   class="kw">public IntSet getEntityEventSet(@Nonnull EntityEventType var1) {
      class="kw">return this.entityEventSets == null ? null : this.entityEventSets.getOrDefault(var1, null);
   }

   class="kw">public class="kw">static void notifyEntityEvent(
      @Nonnull Ref<EntityStore> var0, @Nonnull ComponentAccessor<EntityStore> var1, @Nonnull EntityEventType var2, @Nonnull EntityEventNotification var3
   ) {
      Ref var4 = var3.getInitiator();
      boolean var5 = var1.getArchetype(var4).contains(Player.getComponentType());
      EntityEventSupport var6;
      if (var5) {
         var6 = var1.getComponent(var0, PlayerEntityEventSupport.getComponentType());
      } else {
         var6 = var1.getComponent(var0, NPCEntityEventSupport.getComponentType());
      }

      if (var6 != null) {
         var6.postMessage(var2, var3, var0, var1);
      }
   }

   class="kw">private void addBlockTypeSets(@Nonnull IntList var1) {
      this.blockTypeSets = var1;
   }

   class="kw">private void addBlockChangeSets(@Nonnull BlockEventType var1, @Nonnull IntSet var2) {
      if (this.blockChangeSets == null) {
         this.blockChangeSets = new EnumMap<>(BlockEventType.class);
      }

      this.blockChangeSets.put(var1, var2);
   }

   class="kw">private void addEntityEventSets(@Nonnull EntityEventType var1, @Nonnull IntSet var2) {
      if (this.entityEventSets == null) {
         this.entityEventSets = new EnumMap<>(EntityEventType.class);
      }

      this.entityEventSets.put(var1, var2);
   }

   class="kw">private boolean hasAnySubscription() {
      class="kw">return this.blockTypeSets != null || this.blockChangeSets != null || this.entityEventSets != null;
   }

   class="kw">public class="kw">static void buildAndAttach(@Nonnull Holder<EntityStore> var0, @Nonnull BuilderSupport var1) {
      BlackboardSubscription var2 = new BlackboardSubscription();
      if (var1.requiresBlockTypeBlackboard()) {
         var2.addBlockTypeSets(var1.getBlockTypeBlackboardBlockSets());
      }

      if (var1.hasBlockEventSupport()) {
         EventSlotMapper var3 = var1.getPlayerBlockEventSlotMapper();
         if (var3 != null) {
            PlayerBlockEventSupport var4 = new PlayerBlockEventSupport();
            var4.initialise(var3.getEventSlotMappings(), var3.getEventSlotRanges(), var3.getEventSlotCount());
            var0.putComponent(PlayerBlockEventSupport.getComponentType(), var4);
         }

         EventSlotMapper var11 = var1.getNPCBlockEventSlotMapper();
         if (var11 != null) {
            NPCBlockEventSupport var5 = new NPCBlockEventSupport();
            var5.initialise(var11.getEventSlotMappings(), var11.getEventSlotRanges(), var11.getEventSlotCount());
            var0.putComponent(NPCBlockEventSupport.getComponentType(), var5);
         }

         for (BlockEventType var8 : BlockEventType.VALUES) {
            IntSet var9 = var1.getBlockChangeSets(var8);
            if (var9 != null) {
               var2.addBlockChangeSets(var8, var9);
            }
         }
      }

      if (var1.hasEntityEventSupport()) {
         EventSlotMapper var10 = var1.getPlayerEntityEventSlotMapper();
         if (var10 != null) {
            PlayerEntityEventSupport var12 = new PlayerEntityEventSupport();
            var12.initialise(var10.getEventSlotMappings(), var10.getEventSlotRanges(), var10.getEventSlotCount());
            var0.putComponent(PlayerEntityEventSupport.getComponentType(), var12);
         }

         EventSlotMapper var13 = var1.getNPCEntityEventSlotMapper();
         if (var13 != null) {
            NPCEntityEventSupport var15 = new NPCEntityEventSupport();
            var15.initialise(var13.getEventSlotMappings(), var13.getEventSlotRanges(), var13.getEventSlotCount());
            var0.putComponent(NPCEntityEventSupport.getComponentType(), var15);
         }

         for (EntityEventType var19 : EntityEventType.VALUES) {
            IntSet var20 = var1.getEventNPCGroups(var19);
            if (var20 != null) {
               var2.addEntityEventSets(var19, var20);
            }
         }
      }

      if (var2.hasAnySubscription()) {
         var0.putComponent(getComponentType(), var2);
      }
   }

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