2020-10-14 21:07:36 +02:00
|
|
|
package com.minelittlepony.unicopia.ability;
|
|
|
|
|
2021-08-04 15:38:03 +02:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2020-10-14 21:07:36 +02:00
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.Race;
|
|
|
|
import com.minelittlepony.unicopia.ability.data.Hit;
|
2021-11-05 14:18:32 +01:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
2020-10-14 21:07:36 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
|
|
|
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
|
|
|
|
import com.minelittlepony.unicopia.particle.OrientedBillboardParticleEffect;
|
|
|
|
import com.minelittlepony.unicopia.particle.UParticles;
|
|
|
|
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
|
|
|
|
/**
|
2021-02-19 17:10:49 +01:00
|
|
|
* Pegasus ability to perform rainbooms
|
2020-10-14 21:07:36 +02:00
|
|
|
*/
|
|
|
|
public class PegasusRainboomAbility implements Ability<Hit> {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getWarmupTime(Pony player) {
|
|
|
|
return 59;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCooldownTime(Pony player) {
|
|
|
|
return 60;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canUse(Race race) {
|
|
|
|
return race.canInteractWithClouds();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public Hit tryActivate(Pony player) {
|
|
|
|
|
|
|
|
if (!player.getMaster().isCreative() && player.getMagicalReserves().getMana().getPercentFill() < 0.2F) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-12-23 23:36:54 +01:00
|
|
|
if (player.getPhysics().isFlying() && !SpellType.RAINBOOM.isOn(player)) {
|
2020-10-14 21:07:36 +02:00
|
|
|
return Hit.INSTANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Hit.Serializer<Hit> getSerializer() {
|
|
|
|
return Hit.SERIALIZER;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getCostEstimate(Pony player) {
|
2022-10-08 14:45:29 +02:00
|
|
|
return 90F;
|
2020-10-14 21:07:36 +02:00
|
|
|
}
|
|
|
|
|
2022-09-26 21:13:58 +02:00
|
|
|
@Override
|
|
|
|
public boolean onQuickAction(Pony player, ActivationType type) {
|
|
|
|
|
|
|
|
if (type == ActivationType.TAP && player.getPhysics().isFlying()) {
|
|
|
|
player.getPhysics().dashForward((float)player.getReferenceWorld().random.nextTriangular(1, 0.3F));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-10-14 21:07:36 +02:00
|
|
|
@Override
|
|
|
|
public void apply(Pony player, Hit data) {
|
|
|
|
|
|
|
|
if (!player.getMaster().isCreative() && player.getMagicalReserves().getMana().getPercentFill() < 0.2F) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-23 23:36:54 +01:00
|
|
|
if (player.getPhysics().isFlying() && !SpellType.RAINBOOM.isOn(player)) {
|
2022-10-08 14:45:29 +02:00
|
|
|
player.subtractEnergyCost(9);
|
2020-10-14 21:07:36 +02:00
|
|
|
player.addParticle(new OrientedBillboardParticleEffect(UParticles.RAINBOOM_RING, player.getPhysics().getMotionAngle()), player.getOriginVector(), Vec3d.ZERO);
|
2021-12-23 18:46:25 +01:00
|
|
|
SpellType.RAINBOOM.withTraits().apply(player);
|
2020-10-14 21:07:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void preApply(Pony player, AbilitySlot slot) {
|
|
|
|
player.getMagicalReserves().getExertion().add(6);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void postApply(Pony player, AbilitySlot slot) {
|
|
|
|
player.spawnParticles(MagicParticleEffect.UNICORN, 5);
|
|
|
|
}
|
|
|
|
}
|