DeployableAoeConfig class

Пакет: com.hypixel.hytale.builtin.deployables.config

Файл: com/hypixel/hytale/builtin/deployables/config/DeployableAoeConfig.java

extends: DeployableConfig

Поля (23)

МодификаторыТипИмя
Sphere, Cylinder
break
break
break
Ref var10
float var11
Ref var12
EffectControllerComponent var3
float var3
UUID var4
float var4
Damage var5
UUIDComponent var5
Instant var5
Ref var6
float var6
TransformComponent var7
EntityGroup var7
float var7
Vector3d var8
var var8
EntityEffect var8
World var9

Методы (25)

МодификаторыВозвратСигнатура
Shape Shape()
public void acceptpublic void accept(@Nonnull Ref<EntityStore> var1x)
protected void applyEffectToTargetvoid applyEffectToTarget(@Nonnull Store<EntityStore> var1, @Nonnull Ref<EntityStore> var2)
protected void attackTargetvoid attackTarget(@Nonnull Ref<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull DamageCause var3, @Nonnull CommandBuffer<EntityStore> var4)
protected boolean canAttackEntityboolean canAttackEntity(@Nonnull Ref<EntityStore> var1, @Nonnull DeployableComponent var2, @Nonnull Store<EntityStore> var3)
for for(String var7 : this.effectsToApply)
protected float getRadiusfloat getRadius(@Nonnull Store<EntityStore> var1, @Nonnull Instant var2)
protected void handleDebugGraphicsvoid handleDebugGraphics(World var1, Vector3f var2, Vector3d var3, float var4)
protected void handleDetectionvoid handleDetection(@Nonnull final Store<EntityStore> var1, @Nonnull final CommandBuffer<EntityStore> var2, @Nonnull final Ref<EntityStore> var3, @Nonnull final DeployableComponent var4, @Nonnull Vector3d var5, float var6, @Nonnull final DamageCause var7)
if if(var7 != null)
if if(var11 >= this.endRadius)
if if(var1x != var3)
if if(this.effectsToApply != null)
if if(var3 != null)
if if(var7 != null)
if if(var8 != null)
if if(!this.attackOwner)
if if(var4 != null)
if if(!this.attackTeam)
if if(var6 > this.radiusChangeTime)
if if(this.processedDamageCause == null)
if if(this.processedDamageCause == null)
abstract playAnimation playAnimation(var5, var10, this, "Grow")
abstract playAnimation playAnimation(var5, var10, this, "Looping")
switch switch(this.shape)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.deployables.component.DeployableComponent;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.EnumCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.component.ArchetypeChunk;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.server.core.asset.type.entityeffect.config.EntityEffect;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.entity.effect.EffectControllerComponent;
class="kw">import com.hypixel.hytale.server.core.entity.group.EntityGroup;
class="kw">import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.Damage;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.DamageCause;
class="kw">import com.hypixel.hytale.server.core.modules.entity.damage.DamageSystems;
class="kw">import com.hypixel.hytale.server.core.modules.time.TimeResource;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import com.hypixel.hytale.server.core.util.TargetUtil;
class="kw">import java.time.Duration;
class="kw">import java.time.Instant;
class="kw">import java.util.UUID;
class="kw">import java.util.function.Consumer;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import org.joml.Vector3d;
class="kw">import org.joml.Vector3f;

class="kw">public class DeployableAoeConfig class="kw">extends DeployableConfig {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<DeployableAoeConfig> CODEC = BuilderCodec.builder(
         DeployableAoeConfig.class, DeployableAoeConfig::new, DeployableConfig.BASE_CODEC
      )
      .append(new KeyedCodec<>("Shape", new EnumCodec<>(DeployableAoeConfig.Shape.class)), (var0, var1) -> var0.shape = var1, var0 -> var0.shape)
      .documentation("The shape of the detection area")
      .add()
      .<Float>append(new KeyedCodec<>("StartRadius", Codec.FLOAT), (var0, var1) -> var0.startRadius = var1, var0 -> var0.startRadius)
      .documentation("The initial detection radius")
      .add()
      .<Float>append(new KeyedCodec<>("EndRadius", Codec.FLOAT), (var0, var1) -> var0.endRadius = var1, var0 -> var0.endRadius)
      .documentation("If set, the detection radius will expand to this size over the RadiusChangeTime (RadiusChangeTime must be set)")
      .add()
      .<Float>append(new KeyedCodec<>("Height", Codec.FLOAT), (var0, var1) -> var0.height = var1, var0 -> var0.height)
      .documentation("The height of the Shape, if using a cylinder shape")
      .add()
      .<Float>append(new KeyedCodec<>("RadiusChangeTime", Codec.FLOAT), (var0, var1) -> var0.radiusChangeTime = var1, var0 -> var0.radiusChangeTime)
      .documentation("The time (starting at spawn) it takes to change from StartRadius to EndRadius")
      .add()
      .<Float>append(new KeyedCodec<>("DamageInterval", Codec.FLOAT), (var0, var1) -> var0.damageInterval = var1, var0 -> var0.damageInterval)
      .documentation("The interval between damage being applied to targets in seconds")
      .add()
      .<Float>append(new KeyedCodec<>("DamageAmount", Codec.FLOAT), (var0, var1) -> var0.damageAmount = var1, var0 -> var0.damageAmount)
      .documentation("The amount of damage to apply to targets per interval")
      .add()
      .<String>append(new KeyedCodec<>("DamageCause", DamageCause.CHILD_ASSET_CODEC), (var0, var1) -> var0.damageCause = var1, var0 -> var0.damageCause)
      .documentation("The amount of damage to apply to targets per interval")
      .add()
      .append(
         new KeyedCodec<>("ApplyEffects", new ArrayCodec<>(EntityEffect.CHILD_ASSET_CODEC, String[]::new)),
         (var0, var1) -> var0.effectsToApply = var1,
         var0 -> var0.effectsToApply
      )
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("AttackOwner", Codec.BOOLEAN),
         (var0, var1) -> var0.attackOwner = var1,
         var0 -> var0.attackOwner,
         (var0, var1) -> var0.attackOwner = var1.attackOwner
      )
      .documentation("Whether or not the owner is affected by the attack & effect of this deployable")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("AttackTeam", Codec.BOOLEAN),
         (var0, var1) -> var0.attackTeam = var1,
         var0 -> var0.attackTeam,
         (var0, var1) -> var0.attackTeam = var1.attackTeam
      )
      .documentation("Whether or not the team is affected by the attack & effect of this deployable")
      .add()
      .<Boolean>appendInherited(
         new KeyedCodec<>("AttackEnemies", Codec.BOOLEAN),
         (var0, var1) -> var0.attackEnemies = var1,
         var0 -> var0.attackEnemies,
         (var0, var1) -> var0.attackEnemies = var1.attackEnemies
      )
      .documentation("Whether or not this deployable interacts with non-team entities")
      .add()
      .build();
   class="kw">protected float startRadius = 1.0F;
   class="kw">protected float endRadius = -1.0F;
   class="kw">protected float radiusChangeTime = -1.0F;
   class="kw">protected float damageInterval = 1.0F;
   class="kw">protected float damageAmount = 1.0F;
   class="kw">protected String damageCause = "Physical";
   class="kw">protected String[] effectsToApply;
   class="kw">protected boolean attackOwner;
   class="kw">protected boolean attackTeam;
   class="kw">protected boolean attackEnemies = true;
   class="kw">protected DeployableAoeConfig.Shape shape = DeployableAoeConfig.Shape.Sphere;
   class="kw">protected float height = 1.0F;
   @Nullable
   class="kw">protected DamageCause processedDamageCause;

   class="kw">protected DeployableAoeConfig() {
   }

   @Override
   class="kw">public void tick(
      @Nonnull DeployableComponent var1,
      float var2,
      int var3,
      @Nonnull ArchetypeChunk<EntityStore> var4,
      @Nonnull Store<EntityStore> var5,
      @Nonnull CommandBuffer<EntityStore> var6
   ) {
      TransformComponent var7 = var4.getComponent(var3, TransformComponent.getComponentType());
      if (var7 != null) {
         Vector3d var8 = var7.getPosition();
         World var9 = var5.getExternalData().getWorld();
         Ref var10 = var4.getReferenceTo(var3);
         float var11 = this.getRadius(var5, var1.getSpawnInstant());
         this.handleDebugGraphics(var9, var1.getDebugColor(), var8, var11 * 2.0F);
         class="kw">switch (var1.getFlag(DeployableComponent.DeployableFlag.STATE)) {
            case 0:
               var1.setFlag(DeployableComponent.DeployableFlag.STATE, 1);
               break;
            case 1:
               var1.setFlag(DeployableComponent.DeployableFlag.STATE, 2);
               playAnimation(var5, var10, this, "Grow");
               break;
            case 2:
               if (var11 >= this.endRadius) {
                  var1.setFlag(DeployableComponent.DeployableFlag.STATE, 3);
                  playAnimation(var5, var10, this, "Looping");
               }
         }

         Ref var12 = var4.getReferenceTo(var3);
         if (var1.incrementTimeSinceLastAttack(var2) > this.damageInterval) {
            var1.setTimeSinceLastAttack(0.0F);
            this.handleDetection(var5, var6, var12, var1, var8, var11, this.getDamageCause());
         }

         super.tick(var1, var2, var3, var4, var5, var6);
      }
   }

   class="kw">protected void handleDetection(
      @Nonnull class="kw">final Store<EntityStore> var1,
      @Nonnull class="kw">final CommandBuffer<EntityStore> var2,
      @Nonnull class="kw">final Ref<EntityStore> var3,
      @Nonnull class="kw">final DeployableComponent var4,
      @Nonnull Vector3d var5,
      float var6,
      @Nonnull class="kw">final DamageCause var7
   ) {
      var var8 = new Consumer<Ref<EntityStore>>() {
         class="kw">public void accept(@Nonnull Ref<EntityStore> var1x) {
            if (var1x != var3) {
               if (DeployableAoeConfig.this.canAttackEntity(var1x, var4, var1)) {
                  DeployableAoeConfig.this.attackTarget(var1x, var4.getOwner(), var7, var2);
                  DeployableAoeConfig.this.applyEffectToTarget(var1, var1x);
               }
            }
         }
      };
      class="kw">switch (this.shape) {
         case Sphere:
            for (Ref var14 : TargetUtil.getAllEntitiesInSphere(var5, var6, var1)) {
               var8.accept(var14);
            }
            break;
         case Cylinder:
            for (Ref var11 : TargetUtil.getAllEntitiesInCylinder(var5, var6, this.height, var1)) {
               var8.accept(var11);
            }
      }
   }

   class="kw">protected void handleDebugGraphics(World var1, Vector3f var2, Vector3d var3, float var4) {
      if (this.getDebugVisuals()) {
         ;
      }
   }

   class="kw">protected void attackTarget(
      @Nonnull Ref<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull DamageCause var3, @Nonnull CommandBuffer<EntityStore> var4
   ) {
      if (!(this.damageAmount <= 0.0F)) {
         Damage var5 = new Damage(new Damage.EntitySource(var2), var3, this.damageAmount);
         if (var1.equals(var2)) {
            var5.setSource(Damage.NULL_SOURCE);
         }

         DamageSystems.executeDamage(var1, var4, var5);
      }
   }

   class="kw">protected void applyEffectToTarget(@Nonnull Store<EntityStore> var1, @Nonnull Ref<EntityStore> var2) {
      if (this.effectsToApply != null) {
         EffectControllerComponent var3 = var1.getComponent(var2, EffectControllerComponent.getComponentType());
         if (var3 != null) {
            for (String var7 : this.effectsToApply) {
               if (var7 != null) {
                  EntityEffect var8 = EntityEffect.getAssetMap().getAsset(var7);
                  if (var8 != null) {
                     var3.addEffect(var2, var8, var1);
                  }
               }
            }
         }
      }
   }

   class="kw">protected boolean canAttackEntity(@Nonnull Ref<EntityStore> var1, @Nonnull DeployableComponent var2, @Nonnull Store<EntityStore> var3) {
      if (!this.attackOwner) {
         UUID var4 = var2.getOwnerUUID();
         if (var4 != null) {
            UUIDComponent var5 = var3.getComponent(var1, UUIDComponent.getComponentType());
            if (var5 != null && var4.equals(var5.getUuid())) {
               class="kw">return false;
            }
         }
      }

      if (!this.attackTeam) {
         Ref var6 = var2.getOwner();
         if (var6 != null && var6.isValid()) {
            EntityGroup var7 = var3.getComponent(var6, EntityGroup.getComponentType());
            class="kw">return var7 == null || !var7.isMember(var1);
         }
      }

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

   class="kw">protected float getRadius(@Nonnull Store<EntityStore> var1, @Nonnull Instant var2) {
      if (!(this.radiusChangeTime <= 0.0F) && !(this.endRadius < 0.0F)) {
         float var3 = this.endRadius - this.startRadius;
         float var4 = var3 / this.radiusChangeTime;
         Instant var5 = var1.getResource(TimeResource.getResourceType()).getNow();
         float var6 = (float)Duration.between(var2, var5).toMillis() / 1000.0F;
         if (var6 > this.radiusChangeTime) {
            class="kw">return this.endRadius;
         }

         float var7 = var4 * var6;
         class="kw">return this.startRadius + var7;
      } else {
         class="kw">return this.startRadius;
      }
   }

   @Nullable
   class="kw">protected DamageCause getDamageCause() {
      if (this.processedDamageCause == null) {
         this.processedDamageCause = DamageCause.getAssetMap().getAsset(this.damageCause);
         if (this.processedDamageCause == null) {
            this.processedDamageCause = DamageCause.PHYSICAL;
         }
      }

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

   @Override
   class="kw">public String toString() {
      class="kw">return "DeployableAoeConfig{}" + super.toString();
   }

   class="kw">public enum Shape {
      Sphere,
      Cylinder;

      Shape() {
      }
   }
}