AttitudeMap class

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

Файл: com/hypixel/hytale/server/npc/blackboard/view/attitude/AttitudeMap.java

Поля (14)

МодификаторыТипИмя
private final Int2ObjectMap<Attitude>[] map
TagSetPlugin.TagSetLookup var1
IntSet var10
String var2
Int2ObjectOpenHashMap var2
Int2ObjectMap var3
int var3
int var5
Int2ObjectMap var6
int var7
var7
var7
NPCEntity var8
int var9

Методы (18)

МодификаторыВозвратСигнатура
public Builderpublic Builder()
abstract throw new IllegalArgumentExceptionthrow new IllegalArgumentException("Unknown key! " + var2)
private void addAttitudeGroupprivate void addAttitudeGroup(@Nonnull AttitudeGroup var1)
public void addAttitudeGroupspublic void addAttitudeGroups(@Nonnull Map<String, AttitudeGroup> var1)
public AttitudeMap buildpublic AttitudeMap build()
private static Int2ObjectMap<Attitude> createGroupMapprivate static Int2ObjectMap<Attitude> createGroupMap(@Nonnull AttitudeGroup var0)
for for(Attitude var6 : Attitude.VALUES)
for for(String var8 : var2)
public int getAttitudeGroupCountint getAttitudeGroupCount()
if if(var5 == Integer.MIN_VALUE)
if if(var6 == null)
if if(var8 != null)
if if(var3 == Integer.MIN_VALUE)
if if(var2 != null)
if if(var9 == Integer.MIN_VALUE)
if if(var10 != null)
private static void putGroupsprivate static void putGroups(String var0, @Nonnull TagSetPlugin.TagSetLookup var1, @Nullable String[] var2, Attitude var3, @Nonnull Int2ObjectMap<Attitude> var4)
public void updateAttitudeGroupvoid updateAttitudeGroup(int var1, @Nonnull AttitudeGroup var2)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.tagset.TagSetPlugin;
class="kw">import com.hypixel.hytale.builtin.tagset.config.NPCGroup;
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.server.core.asset.type.attitude.Attitude;
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.BuilderManager;
class="kw">import com.hypixel.hytale.server.npc.config.AttitudeGroup;
class="kw">import com.hypixel.hytale.server.npc.entities.NPCEntity;
class="kw">import com.hypixel.hytale.server.npc.role.support.WorldSupport;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
class="kw">import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
class="kw">import it.unimi.dsi.fastutil.ints.IntSet;
class="kw">import java.util.Map;
class="kw">import java.util.logging.Level;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class AttitudeMap {
   @Nullable
   class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, NPCEntity> NPC_COMPONENT_TYPE = NPCEntity.getComponentType();
   class="kw">private class="kw">static class="kw">final ComponentType<EntityStore, Player> PLAYER_COMPONENT_TYPE = Player.getComponentType();
   class="kw">private class="kw">final Int2ObjectMap<Attitude>[] map;

   class="kw">private AttitudeMap(Int2ObjectMap<Attitude>[] var1) {
      this.map = var1;
   }

   @Nullable
   class="kw">public Attitude getAttitude(@Nonnull Ref<EntityStore> var1, int var2, @Nonnull Ref<EntityStore> var3, @Nonnull ComponentAccessor<EntityStore> var4) {
      int var5 = WorldSupport.get(var1, var4).getAttitudeGroup();
      if (var5 == Integer.MIN_VALUE) {
         class="kw">return null;
      }

      Int2ObjectMap var6 = this.map[var5];
      if (var6 == null) {
         class="kw">return null;
      }

      NPCEntity var8 = var4.getComponent(var3, NPC_COMPONENT_TYPE);
      int var7;
      if (var8 != null) {
         var7 = var8.getRoleIndex();
      } else {
         if (!var4.getArchetype(var3).contains(PLAYER_COMPONENT_TYPE)) {
            class="kw">return null;
         }

         var7 = BuilderManager.getPlayerGroupID();
      }

      class="kw">return var7 == var2 ? (Attitude)var6.get(BuilderManager.getSelfGroupID()) : (Attitude)var6.get(var7);
   }

   class="kw">public int getAttitudeGroupCount() {
      class="kw">return this.map.length;
   }

   class="kw">public void updateAttitudeGroup(int var1, @Nonnull AttitudeGroup var2) {
      Int2ObjectMap var3 = AttitudeMap.Builder.createGroupMap(var2);
      this.map[var1] = var3;
   }

   class="kw">public class="kw">static class Builder {
      class="kw">private class="kw">final Int2ObjectMap<Attitude>[] map = new Int2ObjectMap[AttitudeGroup.getAssetMap().getNextIndex()];

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

      class="kw">public void addAttitudeGroups(@Nonnull Map<String, AttitudeGroup> var1) {
         var1.forEach((var1x, var2) -> this.addAttitudeGroup(var2));
      }

      class="kw">private void addAttitudeGroup(@Nonnull AttitudeGroup var1) {
         String var2 = var1.getId();
         int var3 = AttitudeGroup.getAssetMap().getIndex(var2);
         if (var3 == Integer.MIN_VALUE) {
            throw new IllegalArgumentException("Unknown key! " + var2);
         }

         this.map[var3] = createGroupMap(var1);
      }

      @Nonnull
      class="kw">private class="kw">static Int2ObjectMap<Attitude> createGroupMap(@Nonnull AttitudeGroup var0) {
         TagSetPlugin.TagSetLookup var1 = TagSetPlugin.get(NPCGroup.class);
         Int2ObjectOpenHashMap var2 = new Int2ObjectOpenHashMap();

         for (Attitude var6 : Attitude.VALUES) {
            putGroups(var0.getId(), var1, var0.getAttitudeGroups().get(var6), var6, var2);
         }

         var2.trim();
         class="kw">return var2;
      }

      class="kw">private class="kw">static void putGroups(
         String var0, @Nonnull TagSetPlugin.TagSetLookup var1, @Nullable String[] var2, Attitude var3, @Nonnull Int2ObjectMap<Attitude> var4
      ) {
         if (var2 != null) {
            for (String var8 : var2) {
               int var9 = NPCGroup.getAssetMap().getIndex(var8);
               if (var9 == Integer.MIN_VALUE) {
                  NPCPlugin.get()
                     .getLogger()
                     .at(Level.SEVERE)
                     .log("Creating attitude groups: NPC Group '%s' does not exist in attitude group '%s'!", var8, var0);
               } else {
                  IntSet var10 = var1.getSet(var9);
                  if (var10 != null) {
                     var10.forEach(var2x -> var4.put(var2x, var3));
                  }
               }
            }
         }
      }

      @Nonnull
      class="kw">public AttitudeMap build() {
         class="kw">return new AttitudeMap(this.map);
      }
   }
}