TriggerEffectAsset class

Пакет: com.hypixel.hytale.builtin.triggervolumes.asset

Файл: com/hypixel/hytale/builtin/triggervolumes/asset/TriggerEffectAsset.java

implements: JsonAssetWithMap<String, DefaultAssetMap<String, TriggerEffectAsset>>

Поля (1)

МодификаторыТипИмя
TriggerEffectAsset var7

Методы (8)

МодификаторыВозвратСигнатура
public record VolumeSettingsrecord VolumeSettings(@Nonnull Set<EntityTargetType> targetTypes, @Nonnull Map<String, String> tags, @Nonnull RejectionDelayMode rejectionDelayMode, float cooldown, @Nonnull CooldownMode cooldownMode, float activationDelay, @Nonnull ProjectileSource projectileSource, boolean keepLoaded, boolean rotateEffectsOnPaste, boolean cancelDelayedOnExit)
abstract return createreturn create(var0, new TriggerCondition[0], var1, new TriggerEffect[0], ConditionTiming.AFTER_VOLUME_DELAY)
abstract return createreturn create(var0, var1, var2, var3, new TriggerRule[0], var4, null)
if if(this.targetTypeArray != null)
if if(var6 != null)
public boolean isIncludeVolumeSettingsboolean isIncludeVolumeSettings()
private void resolveTargetTypesvoid resolveTargetTypes()
public void setIdvoid setId(@Nonnull String var1)

Исходный код

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

class="kw">import com.hypixel.hytale.assetstore.AssetExtraInfo;
class="kw">import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
class="kw">import com.hypixel.hytale.assetstore.map.DefaultAssetMap;
class="kw">import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.EntityTargetType;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerCondition;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerEffect;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerRule;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.effect.TriggerVolumeCodecs;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.manager.ConditionTiming;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.manager.CooldownMode;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.manager.ProjectileSource;
class="kw">import com.hypixel.hytale.builtin.triggervolumes.manager.RejectionDelayMode;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.codecs.EnumCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import java.util.Arrays;
class="kw">import java.util.Collections;
class="kw">import java.util.EnumSet;
class="kw">import java.util.Map;
class="kw">import java.util.Objects;
class="kw">import java.util.Set;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class TriggerEffectAsset class="kw">implements JsonAssetWithMap<String, DefaultAssetMap<String, TriggerEffectAsset>> {
   @Nonnull
   class="kw">public class="kw">static class="kw">final AssetBuilderCodec<String, TriggerEffectAsset> CODEC = AssetBuilderCodec.builder(
         TriggerEffectAsset.class,
         TriggerEffectAsset::new,
         Codec.STRING,
         (var0, var1) -> var0.id = var1,
         var0 -> var0.id,
         (var0, var1) -> var0.data = var1,
         var0 -> var0.data
      )
      .append(
         new KeyedCodec<>("Conditions", TriggerVolumeCodecs.TOLERANT_CONDITIONS, false),
         (var0, var1) -> var0.conditions = filterConditions(var1),
         var0 -> var0.conditions.length == 0 ? null : var0.conditions
      )
      .add()
      .append(new KeyedCodec<>("Effects", TriggerVolumeCodecs.TOLERANT_EFFECTS), (var0, var1) -> var0.effects = filterEffects(var1), var0 -> var0.effects)
      .add()
      .append(
         new KeyedCodec<>("RejectionEffects", TriggerVolumeCodecs.TOLERANT_EFFECTS, false),
         (var0, var1) -> var0.rejectionEffects = filterEffects(var1),
         var0 -> var0.rejectionEffects.length == 0 ? null : var0.rejectionEffects
      )
      .add()
      .append(
         new KeyedCodec<>("Rules", TriggerVolumeCodecs.TOLERANT_RULES, false),
         (var0, var1) -> var0.rules = filterRules(var1),
         var0 -> var0.rules.length == 0 ? null : var0.rules
      )
      .add()
      .append(
         new KeyedCodec<>("ConditionTiming", new EnumCodec<>(ConditionTiming.class, EnumCodec.EnumStyle.LEGACY), false),
         (var0, var1) -> var0.conditionTiming = var1,
         var0 -> var0.conditionTiming != ConditionTiming.AFTER_VOLUME_DELAY ? var0.conditionTiming : null
      )
      .add()
      .append(
         new KeyedCodec<>("TargetTypes", new ArrayCodec<>(new EnumCodec<>(EntityTargetType.class), EntityTargetType[]::new), false),
         (var0, var1) -> var0.targetTypeArray = var1,
         var0 -> var0.targetTypeArray
      )
      .add()
      .append(
         new KeyedCodec<>("IncludeVolumeSettings", Codec.BOOLEAN, false),
         (var0, var1) -> var0.includeVolumeSettings = var1,
         var0 -> var0.includeVolumeSettings ? Boolean.TRUE : null
      )
      .add()
      .append(
         new KeyedCodec<>("VolumeTags", TriggerVolumeCodecs.TAGS, false),
         (var0, var1) -> var0.tags = var1,
         var0 -> var0.includeVolumeSettings && !var0.tags.isEmpty() ? var0.tags : null
      )
      .add()
      .append(
         new KeyedCodec<>("RejectionDelayMode", new EnumCodec<>(RejectionDelayMode.class), false),
         (var0, var1) -> var0.rejectionDelayMode = var1,
         var0 -> var0.includeVolumeSettings ? var0.rejectionDelayMode : null
      )
      .add()
      .append(new KeyedCodec<>("Cooldown", Codec.FLOAT, false), (var0, var1) -> var0.cooldown = var1, var0 -> var0.includeVolumeSettings ? var0.cooldown : null)
      .add()
      .append(
         new KeyedCodec<>("CooldownMode", new EnumCodec<>(CooldownMode.class), false),
         (var0, var1) -> var0.cooldownMode = var1,
         var0 -> var0.includeVolumeSettings ? var0.cooldownMode : null
      )
      .add()
      .append(
         new KeyedCodec<>("ActivationDelay", Codec.FLOAT, false),
         (var0, var1) -> var0.activationDelay = var1,
         var0 -> var0.includeVolumeSettings ? var0.activationDelay : null
      )
      .add()
      .append(
         new KeyedCodec<>("ProjectileSource", new EnumCodec<>(ProjectileSource.class), false),
         (var0, var1) -> var0.projectileSource = var1,
         var0 -> var0.includeVolumeSettings ? var0.projectileSource : null
      )
      .add()
      .append(
         new KeyedCodec<>("KeepLoaded", Codec.BOOLEAN, false),
         (var0, var1) -> var0.keepLoaded = var1,
         var0 -> var0.includeVolumeSettings ? var0.keepLoaded : null
      )
      .add()
      .append(
         new KeyedCodec<>("RotateEffectsOnPaste", Codec.BOOLEAN, false),
         (var0, var1) -> var0.rotateEffectsOnPaste = var1,
         var0 -> var0.includeVolumeSettings && !var0.rotateEffectsOnPaste ? Boolean.FALSE : null
      )
      .add()
      .append(
         new KeyedCodec<>("CancelDelayedOnExit", Codec.BOOLEAN, false),
         (var0, var1) -> var0.cancelDelayedEffectsOnExit = var1,
         var0 -> var0.includeVolumeSettings ? var0.cancelDelayedEffectsOnExit : null
      )
      .add()
      .afterDecode(TriggerEffectAsset::resolveTargetTypes)
      .build();
   class="kw">private String id;
   class="kw">private AssetExtraInfo.Data data;
   class="kw">private TriggerCondition[] conditions = new TriggerCondition[0];
   class="kw">private TriggerEffect[] effects = new TriggerEffect[0];
   class="kw">private TriggerEffect[] rejectionEffects = new TriggerEffect[0];
   class="kw">private TriggerRule[] rules = new TriggerRule[0];
   @Nonnull
   class="kw">private ConditionTiming conditionTiming = ConditionTiming.AFTER_VOLUME_DELAY;
   @Nullable
   class="kw">private EntityTargetType[] targetTypeArray;
   class="kw">private class="kw">transient Set<EntityTargetType> targetTypes;
   class="kw">private boolean includeVolumeSettings;
   @Nonnull
   class="kw">private Map<String, String> tags = Collections.emptyMap();
   @Nonnull
   class="kw">private RejectionDelayMode rejectionDelayMode = RejectionDelayMode.USE_VOLUME_DELAY;
   class="kw">private float cooldown;
   @Nonnull
   class="kw">private CooldownMode cooldownMode = CooldownMode.PER_ENTITY;
   class="kw">private float activationDelay;
   @Nonnull
   class="kw">private ProjectileSource projectileSource = ProjectileSource.SHOOTER;
   class="kw">private boolean keepLoaded;
   class="kw">private boolean rotateEffectsOnPaste = true;
   class="kw">private boolean cancelDelayedEffectsOnExit;

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

   class="kw">private void resolveTargetTypes() {
      this.targetTypes = EnumSet.noneOf(EntityTargetType.class);
      if (this.targetTypeArray != null) {
         this.targetTypes.addAll(Arrays.asList(this.targetTypeArray));
      }

      if (this.targetTypes.isEmpty()) {
         this.targetTypes.add(EntityTargetType.PLAYER);
      }
   }

   @Nonnull
   class="kw">public class="kw">static TriggerEffectAsset create(@Nonnull String var0, @Nonnull TriggerEffect[] var1) {
      class="kw">return create(var0, new TriggerCondition[0], var1, new TriggerEffect[0], ConditionTiming.AFTER_VOLUME_DELAY);
   }

   @Nonnull
   class="kw">public class="kw">static TriggerEffectAsset create(
      @Nonnull String var0, @Nonnull TriggerCondition[] var1, @Nonnull TriggerEffect[] var2, @Nonnull TriggerEffect[] var3, @Nonnull ConditionTiming var4
   ) {
      class="kw">return create(var0, var1, var2, var3, new TriggerRule[0], var4, null);
   }

   @Nonnull
   class="kw">public class="kw">static TriggerEffectAsset create(
      @Nonnull String var0,
      @Nonnull TriggerCondition[] var1,
      @Nonnull TriggerEffect[] var2,
      @Nonnull TriggerEffect[] var3,
      @Nonnull TriggerRule[] var4,
      @Nonnull ConditionTiming var5,
      @Nullable TriggerEffectAsset.VolumeSettings var6
   ) {
      TriggerEffectAsset var7 = new TriggerEffectAsset();
      var7.id = var0;
      var7.conditions = var1;
      var7.effects = var2;
      var7.rejectionEffects = var3;
      var7.rules = var4;
      var7.conditionTiming = var5;
      if (var6 != null) {
         var7.includeVolumeSettings = true;
         var7.targetTypeArray = var6.targetTypes().isEmpty() ? null : var6.targetTypes().toArray(EntityTargetType[]::new);
         var7.tags = var6.tags();
         var7.rejectionDelayMode = var6.rejectionDelayMode();
         var7.cooldown = var6.cooldown();
         var7.cooldownMode = var6.cooldownMode();
         var7.activationDelay = var6.activationDelay();
         var7.projectileSource = var6.projectileSource();
         var7.keepLoaded = var6.keepLoaded();
         var7.rotateEffectsOnPaste = var6.rotateEffectsOnPaste();
         var7.cancelDelayedEffectsOnExit = var6.cancelDelayedOnExit();
      }

      var7.resolveTargetTypes();
      class="kw">return var7;
   }

   @Nonnull
   class="kw">public String getId() {
      class="kw">return this.id;
   }

   class="kw">public void setId(@Nonnull String var1) {
      this.id = var1;
   }

   @Nonnull
   class="kw">public TriggerEffect[] getEffects() {
      class="kw">return this.effects;
   }

   @Nonnull
   class="kw">public TriggerCondition[] getConditions() {
      class="kw">return this.conditions;
   }

   @Nonnull
   class="kw">public TriggerEffect[] getRejectionEffects() {
      class="kw">return this.rejectionEffects;
   }

   @Nonnull
   class="kw">public TriggerRule[] getRules() {
      class="kw">return this.rules;
   }

   @Nonnull
   class="kw">public ConditionTiming getConditionTiming() {
      class="kw">return this.conditionTiming;
   }

   @Nonnull
   class="kw">public Set<EntityTargetType> getTargetTypes() {
      class="kw">return this.targetTypes != null ? this.targetTypes : Set.of(EntityTargetType.PLAYER);
   }

   class="kw">public boolean isIncludeVolumeSettings() {
      class="kw">return this.includeVolumeSettings;
   }

   @Nullable
   class="kw">public TriggerEffectAsset.VolumeSettings getVolumeSettings() {
      class="kw">return !this.includeVolumeSettings
         ? null
         : new TriggerEffectAsset.VolumeSettings(
            this.getTargetTypes(),
            this.tags,
            this.rejectionDelayMode,
            this.cooldown,
            this.cooldownMode,
            this.activationDelay,
            this.projectileSource,
            this.keepLoaded,
            this.rotateEffectsOnPaste,
            this.cancelDelayedEffectsOnExit
         );
   }

   @Nonnull
   class="kw">private class="kw">static TriggerCondition[] filterConditions(@Nonnull TriggerCondition[] var0) {
      class="kw">return Arrays.stream(var0).filter(Objects::nonNull).toArray(TriggerCondition[]::new);
   }

   @Nonnull
   class="kw">private class="kw">static TriggerEffect[] filterEffects(@Nonnull TriggerEffect[] var0) {
      class="kw">return Arrays.stream(var0).filter(Objects::nonNull).toArray(TriggerEffect[]::new);
   }

   @Nonnull
   class="kw">private class="kw">static TriggerRule[] filterRules(@Nonnull TriggerRule[] var0) {
      class="kw">return Arrays.stream(var0).filter(Objects::nonNull).toArray(TriggerRule[]::new);
   }

   class="kw">public record VolumeSettings(
      @Nonnull Set<EntityTargetType> targetTypes,
      @Nonnull Map<String, String> tags,
      @Nonnull RejectionDelayMode rejectionDelayMode,
      float cooldown,
      @Nonnull CooldownMode cooldownMode,
      float activationDelay,
      @Nonnull ProjectileSource projectileSource,
      boolean keepLoaded,
      boolean rotateEffectsOnPaste,
      boolean cancelDelayedOnExit
   ) {
      class="kw">public VolumeSettings {
      }
   }
}