ActionFlockBeacon class

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

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

extends: ActionBase

Поля (7)

МодификаторыТипИмя
final ComponentType<EntityStore, BeaconSupport> BEACON_SUPPORT_COMPONENT_TYPE
Ref var10
Ref var11
BeaconSupport var4
FlockMembership var7
Ref var8
EntityGroup var9

Методы (5)

МодификаторыВозвратСигнатура
if if(var9 == null)
if if(this.sendToLeaderOnly)
if if(var4 != null)
protected void sendNPCMessagevoid sendNPCMessage(@Nonnull Ref<EntityStore> var1, @Nullable Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3)
abstract super super(var1)

Исходный код

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

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.component.Store;
class="kw">import com.hypixel.hytale.server.core.entity.group.EntityGroup;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.flock.FlockMembership;
class="kw">import com.hypixel.hytale.server.flock.corecomponents.builders.BuilderActionFlockBeacon;
class="kw">import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
class="kw">import com.hypixel.hytale.server.npc.components.messaging.BeaconSupport;
class="kw">import com.hypixel.hytale.server.npc.corecomponents.ActionBase;
class="kw">import com.hypixel.hytale.server.npc.instructions.ExecutionSupport;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.InfoProvider;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class ActionFlockBeacon class="kw">extends ActionBase {
   class="kw">protected class="kw">static class="kw">final ComponentType<EntityStore, BeaconSupport> BEACON_SUPPORT_COMPONENT_TYPE = BeaconSupport.getComponentType();
   class="kw">protected class="kw">static class="kw">final ComponentType<EntityStore, FlockMembership> FLOCK_MEMBERSHIP_COMPONENT_TYPE = FlockMembership.getComponentType();
   class="kw">protected class="kw">static class="kw">final ComponentType<EntityStore, EntityGroup> ENTITY_GROUP_COMPONENT_TYPE = EntityGroup.getComponentType();
   class="kw">protected class="kw">final String message;
   class="kw">protected class="kw">final double expirationTime;
   class="kw">protected class="kw">final boolean sendToSelf;
   class="kw">protected class="kw">final boolean sendToLeaderOnly;
   class="kw">protected class="kw">final int sendTargetSlot;

   class="kw">public ActionFlockBeacon(@Nonnull BuilderActionFlockBeacon var1, @Nonnull BuilderSupport var2) {
      super(var1);
      this.message = var1.getMessage(var2);
      this.sendTargetSlot = var1.getSendTargetSlot(var2);
      this.expirationTime = var1.getExpirationTime();
      this.sendToSelf = var1.isSendToSelf();
      this.sendToLeaderOnly = var1.isSendToLeaderOnly();
   }

   @Override
   class="kw">public boolean canExecute(
      @Nonnull Ref<EntityStore> var1, @Nonnull ExecutionSupport var2, @Nullable InfoProvider var3, double var4, @Nonnull Store<EntityStore> var6
   ) {
      class="kw">return !super.canExecute(var1, var2, var3, var4, var6)
         ? false
         : var6.getArchetype(var1).contains(FLOCK_MEMBERSHIP_COMPONENT_TYPE)
            && (this.sendTargetSlot == Integer.MIN_VALUE || var2.getMarkedEntitySupport().hasMarkedEntityInSlot(this.sendTargetSlot));
   }

   @Override
   class="kw">public boolean execute(
      @Nonnull Ref<EntityStore> var1, @Nonnull ExecutionSupport var2, @Nullable InfoProvider var3, double var4, @Nonnull Store<EntityStore> var6
   ) {
      super.execute(var1, var2, var3, var4, var6);
      FlockMembership var7 = var6.getComponent(var1, FLOCK_MEMBERSHIP_COMPONENT_TYPE);
      Ref var8 = var7 != null ? var7.getFlockRef() : null;
      if (var8 != null && var8.isValid()) {
         EntityGroup var9 = var6.getComponent(var8, ENTITY_GROUP_COMPONENT_TYPE);
         if (var9 == null) {
            class="kw">return true;
         }

         Ref var10 = this.sendTargetSlot >= 0 ? var2.getMarkedEntitySupport().getMarkedEntityRef(this.sendTargetSlot) : var1;
         if (this.sendToLeaderOnly) {
            Ref var11 = var9.getLeaderRef();
            if ((this.sendToSelf || var10 == null || !var10.equals(var11)) && var11.isValid()) {
               this.sendNPCMessage(var11, var10, var6);
            }
         } else {
            var9.forEachMember((var2x, var3x, var4x) -> this.sendNPCMessage(var2x, var4x, var6), var1, var10, this.sendToSelf ? null : var1);
         }

         class="kw">return true;
      } else {
         class="kw">return true;
      }
   }

   class="kw">protected void sendNPCMessage(@Nonnull Ref<EntityStore> var1, @Nullable Ref<EntityStore> var2, @Nonnull ComponentAccessor<EntityStore> var3) {
      BeaconSupport var4 = var3.getComponent(var1, BEACON_SUPPORT_COMPONENT_TYPE);
      if (var4 != null) {
         var4.postMessage(this.message, var2, this.expirationTime);
      }
   }
}