mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Indicate whether an ability can actually do something for a selected activation type
This commit is contained in:
parent
86faeeaa43
commit
0a5ec3da03
8 changed files with 49 additions and 1 deletions
|
@ -83,6 +83,15 @@ public interface Ability<T extends Hit> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether this ability has any special actions for the given activation type.
|
||||||
|
* <p>
|
||||||
|
* The default is to only respond to press-and-hold actions.
|
||||||
|
*/
|
||||||
|
default boolean acceptsQuickAction(Pony player, ActivationType type) {
|
||||||
|
return type == ActivationType.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on the client to get any data required for the quick action.
|
* Called on the client to get any data required for the quick action.
|
||||||
*
|
*
|
||||||
|
|
|
@ -63,6 +63,11 @@ public class CarryAbility implements Ability<Hit> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptsQuickAction(Pony player, ActivationType type) {
|
||||||
|
return type == ActivationType.NONE || type == ActivationType.TAP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pony iplayer, Hit data) {
|
public boolean apply(Pony iplayer, Hit data) {
|
||||||
PlayerEntity player = iplayer.asEntity();
|
PlayerEntity player = iplayer.asEntity();
|
||||||
|
|
|
@ -116,6 +116,11 @@ public class EarthPonyKickAbility implements Ability<Pos> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptsQuickAction(Pony player, ActivationType type) {
|
||||||
|
return type == ActivationType.NONE || type == ActivationType.TAP || type == ActivationType.DOUBLE_TAP;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Optional<Pos> prepare(Pony player) {
|
public Optional<Pos> prepare(Pony player) {
|
||||||
|
|
|
@ -49,6 +49,11 @@ public class FlyingDashAbility implements Ability<Hit> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptsQuickAction(Pony player, ActivationType type) {
|
||||||
|
return type == ActivationType.NONE || type == ActivationType.TAP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pony player, Hit data) {
|
public boolean apply(Pony player, Hit data) {
|
||||||
player.getPhysics().dashForward((float)player.asWorld().random.nextTriangular(2.5F, 0.3F));
|
player.getPhysics().dashForward((float)player.asWorld().random.nextTriangular(2.5F, 0.3F));
|
||||||
|
|
|
@ -54,6 +54,11 @@ public class PegasusRainboomAbility implements Ability<Hit> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptsQuickAction(Pony player, ActivationType type) {
|
||||||
|
return type == ActivationType.NONE || type == ActivationType.TAP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pony player, Hit data) {
|
public boolean apply(Pony player, Hit data) {
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,11 @@ public class UnicornDispellAbility implements Ability<Pos> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptsQuickAction(Pony player, ActivationType type) {
|
||||||
|
return type == ActivationType.NONE || (player.getSpecies() != Race.CHANGELING && type == ActivationType.TAP);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getCostEstimate(Pony player) {
|
public double getCostEstimate(Pony player) {
|
||||||
return getTarget(player)
|
return getTarget(player)
|
||||||
|
|
|
@ -56,6 +56,11 @@ public class UnicornProjectileAbility extends AbstractSpellCastingAbility {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptsQuickAction(Pony player, ActivationType type) {
|
||||||
|
return type == ActivationType.NONE || type == ActivationType.DOUBLE_TAP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Pony player, Hit data) {
|
public boolean apply(Pony player, Hit data) {
|
||||||
TypedActionResult<CustomisedSpellType<?>> thrown = player.getCharms().getSpellInHand(true);
|
TypedActionResult<CustomisedSpellType<?>> thrown = player.getCharms().getSpellInHand(true);
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package com.minelittlepony.unicopia.client.gui;
|
package com.minelittlepony.unicopia.client.gui;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
import com.minelittlepony.unicopia.ability.Ability;
|
||||||
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
||||||
import com.minelittlepony.unicopia.ability.AbilitySlot;
|
import com.minelittlepony.unicopia.ability.AbilitySlot;
|
||||||
import com.minelittlepony.unicopia.ability.ActivationType;
|
import com.minelittlepony.unicopia.ability.ActivationType;
|
||||||
import com.minelittlepony.unicopia.client.KeyBindingsHandler;
|
import com.minelittlepony.unicopia.client.KeyBindingsHandler;
|
||||||
|
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
|
@ -132,7 +136,9 @@ class Slot {
|
||||||
|
|
||||||
void renderLabel(DrawContext context, AbilityDispatcher abilities, float tickDelta) {
|
void renderLabel(DrawContext context, AbilityDispatcher abilities, float tickDelta) {
|
||||||
|
|
||||||
if (abilities.getStat(aSlot).getAbility(Unicopia.getConfig().hudPage.get()).isEmpty()) {
|
Optional<Ability<?>> ability = abilities.getStat(aSlot).getAbility(Unicopia.getConfig().hudPage.get());
|
||||||
|
|
||||||
|
if (ability.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +161,9 @@ class Slot {
|
||||||
ActivationType activation = KeyBindingsHandler.INSTANCE.getForcedActivationType();
|
ActivationType activation = KeyBindingsHandler.INSTANCE.getForcedActivationType();
|
||||||
if (activation.isResult()) {
|
if (activation.isResult()) {
|
||||||
label = label.append("+T" + activation.getTapCount());
|
label = label.append("+T" + activation.getTapCount());
|
||||||
|
if (!ability.get().acceptsQuickAction(UnicopiaClient.getClientPony(), activation)) {
|
||||||
|
label = label.formatted(Formatting.RED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.drawText(uHud.font, label, 0, 0, 0xFFFFFF, true);
|
context.drawText(uHud.font, label, 0, 0, 0xFFFFFF, true);
|
||||||
|
|
Loading…
Reference in a new issue