ActionChangeTargetRole class

Пакет: com.hypixel.hytale.builtin.encountermanager.npc

Файл: com/hypixel/hytale/builtin/encountermanager/npc/ActionChangeTargetRole.java

extends: ActionBase

Поля (7)

МодификаторыТипИмя
final int roleIndex
Role var10
String var3
String[] var4
IPositionProvider var7
Ref var8
NPCEntity var9

Методы (3)

МодификаторыВозвратСигнатура
if if(var3 != null)
if if(var9 == null)
abstract super super(var1)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.encountermanager.npc.builders.BuilderActionChangeTargetRole;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
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.corecomponents.ActionBase;
class="kw">import com.hypixel.hytale.server.npc.entities.NPCEntity;
class="kw">import com.hypixel.hytale.server.npc.instructions.ExecutionSupport;
class="kw">import com.hypixel.hytale.server.npc.role.Role;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.IPositionProvider;
class="kw">import com.hypixel.hytale.server.npc.sensorinfo.InfoProvider;
class="kw">import com.hypixel.hytale.server.npc.systems.RoleChangeSystem;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class ActionChangeTargetRole class="kw">extends ActionBase {
   class="kw">protected class="kw">final int roleIndex;
   class="kw">protected class="kw">final String kind;
   class="kw">protected class="kw">final boolean changeAppearance;
   class="kw">protected class="kw">final boolean detachFromSpawning;
   @Nullable
   class="kw">protected class="kw">final String state;
   @Nullable
   class="kw">protected class="kw">final String subState;

   class="kw">public ActionChangeTargetRole(@Nonnull BuilderActionChangeTargetRole var1, @Nonnull BuilderSupport var2) {
      super(var1);
      this.kind = var1.getRole(var2);
      this.roleIndex = NPCPlugin.get().getIndex(this.kind);
      this.changeAppearance = var1.getChangeAppearance(var2);
      this.detachFromSpawning = var1.getDetachFromSpawning(var2);
      String var3 = var1.getState(var2);
      if (var3 != null) {
         String[] var4 = var3.split("\\.", 0);
         this.state = var4[0];
         this.subState = var4.length > 1 && var4[1] != null && !var4[1].isEmpty() ? var4[1] : null;
      } else {
         this.state = null;
         this.subState = null;
      }
   }

   @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) && this.roleIndex >= 0;
   }

   @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);
      IPositionProvider var7 = var3 != null ? var3.getPositionProvider() : null;
      Ref var8 = var7 != null ? var7.getTarget() : null;
      if (var8 != null && var8.isValid()) {
         NPCEntity var9 = var6.getComponent(var8, NPCEntity.getComponentType());
         if (var9 == null) {
            class="kw">return false;
         } else {
            Role var10 = var9.getRole();
            if (var10 != null && !var10.isRoleChangeRequested()) {
               RoleChangeSystem.requestRoleChange(var8, var10, this.roleIndex, this.changeAppearance, this.state, this.subState, this.detachFromSpawning, var6);
               class="kw">return true;
            } else {
               class="kw">return false;
            }
         }
      } else {
         class="kw">return false;
      }
   }
}