2020-10-14 21:07:36 +02:00
|
|
|
package com.minelittlepony.unicopia.ability;
|
|
|
|
|
2023-08-16 00:18:41 +02:00
|
|
|
import java.util.Optional;
|
|
|
|
|
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;
|
2023-08-06 19:26:17 +02:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod;
|
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
|
2023-08-16 00:18:41 +02:00
|
|
|
public Optional<Hit> prepare(Pony player) {
|
|
|
|
return Hit.of(player.canUseSuperMove() && player.getPhysics().isFlying() && !SpellType.RAINBOOM.isOn(player));
|
2020-10-14 21:07:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Hit.Serializer<Hit> getSerializer() {
|
|
|
|
return Hit.SERIALIZER;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getCostEstimate(Pony player) {
|
2023-08-09 23:10:02 +02:00
|
|
|
return 0;
|
2020-10-14 21:07:36 +02:00
|
|
|
}
|
|
|
|
|
2022-09-26 21:13:58 +02:00
|
|
|
@Override
|
2023-08-16 00:18:41 +02:00
|
|
|
public boolean onQuickAction(Pony player, ActivationType type, Optional<Hit> data) {
|
2022-09-26 21:13:58 +02:00
|
|
|
|
2022-10-08 17:12:25 +02:00
|
|
|
if (type == ActivationType.TAP && player.getPhysics().isFlying() && player.getMagicalReserves().getMana().get() > 40) {
|
2022-12-19 18:13:15 +01:00
|
|
|
player.getPhysics().dashForward((float)player.asWorld().random.nextTriangular(2.5F, 0.3F));
|
2022-10-08 17:12:25 +02:00
|
|
|
player.subtractEnergyCost(4);
|
2023-08-09 23:10:02 +02:00
|
|
|
player.getMagicalReserves().getCharge().add(2);
|
2022-09-26 21:13:58 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-10-14 21:07:36 +02:00
|
|
|
@Override
|
2023-08-16 00:18:41 +02:00
|
|
|
public boolean apply(Pony player, Hit data) {
|
2020-10-14 21:07:36 +02:00
|
|
|
|
2023-08-16 00:18:41 +02:00
|
|
|
if (prepare(player).isEmpty()) {
|
|
|
|
return false;
|
2020-10-14 21:07:36 +02:00
|
|
|
}
|
|
|
|
|
2023-08-09 23:10:02 +02:00
|
|
|
if (player.consumeSuperMove()) {
|
|
|
|
player.addParticle(new OrientedBillboardParticleEffect(UParticles.RAINBOOM_RING, player.getPhysics().getMotionAngle()), player.getOriginVector(), Vec3d.ZERO);
|
|
|
|
SpellType.RAINBOOM.withTraits().apply(player, CastingMethod.INNATE);
|
|
|
|
}
|
2023-08-16 00:18:41 +02:00
|
|
|
return true;
|
2020-10-14 21:07:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-08-16 00:18:41 +02:00
|
|
|
public void warmUp(Pony player, AbilitySlot slot) {
|
2020-10-14 21:07:36 +02:00
|
|
|
player.getMagicalReserves().getExertion().add(6);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-08-16 00:18:41 +02:00
|
|
|
public void coolDown(Pony player, AbilitySlot slot) {
|
2020-10-14 21:07:36 +02:00
|
|
|
player.spawnParticles(MagicParticleEffect.UNICORN, 5);
|
|
|
|
}
|
|
|
|
}
|