Merge the only two toys in DiangoItems into toy listeners

Fixed spinning plate animation
This commit is contained in:
Oven Bread
2023-03-31 14:19:58 +00:00
committed by Ryan
parent d431fec1ed
commit d4af3421ba
2 changed files with 18 additions and 69 deletions
@@ -1,69 +0,0 @@
package content.global.handlers.item;
import core.cache.def.impl.ItemDefinition;
import core.game.interaction.OptionHandler;
import core.game.node.Node;
import core.game.node.entity.player.Player;
import core.game.system.task.Pulse;
import core.game.world.update.flag.context.Animation;
import core.plugin.Initializable;
import core.plugin.Plugin;
/**
* Represents the diano item plugin.
* @author 'Vexia
* @version 1.0
*/
@Initializable
public final class DiangoItemPlugin extends OptionHandler {
/**
* Represents the animations.
*/
private static final Animation[] ANIMATIONS = new Animation[] { new Animation(8990), new Animation(1902), new Animation(1904) };
@Override
public boolean handle(final Player player, Node node, String option) {
switch (option) {
case "fly":
player.animate(ANIMATIONS[0]);
break;
case "spin":
player.animate(ANIMATIONS[1]);
player.getPulseManager().run(new Pulse(1) {
int count = 0;
@Override
public boolean pulse() {
if (count++ >= 9) {
player.animate(ANIMATIONS[2]);
return true;
}
return false;
}
@Override
public void stop() {
super.stop();
player.animate(ANIMATIONS[2]);
}
});
break;
}
return true;
}
@Override
public boolean isWalk() {
return false;
}
@Override
public Plugin<Object> newInstance(Object arg) throws Throwable {
ItemDefinition.setOptionHandler("fly", this);
ItemDefinition.setOptionHandler("spin", this);
return this;
}
}
@@ -22,6 +22,9 @@ class ToyListeners : InteractionListener {
private val SNOWGLOBE_DOWNSLOW = Animation(7538) //Used when the player hit 'continue' on the interface
private val SNOWGLOBE_STOMP = Animation(7528) //When player hits continue this animation plays
private val SNOWGLOBE_SNOW = Graphics(1284) //When Animation STOMP is playing this gfx also plays
private val SPINNING_PLATE_SPIN = Animation(1902)
private val SPINNING_PLATE_PUT_DOWN = Animation(1904)
private val TOY_KITE_FLY = Animation(8990)
val YOYO_PLAY = Animation(1457)
val YOYO_LOOP = Animation(1458)
val YOYO_WALK = Animation(1459)
@@ -68,6 +71,21 @@ class ToyListeners : InteractionListener {
return@on true
}
on(Items.SPINNING_PLATE_4613, IntType.ITEM, "spin") { player, _ ->
lockInteractions(player, 2)
animate(player, SPINNING_PLATE_SPIN)
runTask(player, 2) {
animate(player, SPINNING_PLATE_PUT_DOWN)
}
return@on true
}
on(Items.TOY_KITE_12844, IntType.ITEM, "fly"){ player, _ ->
lockInteractions(player, 2)
animate(player, TOY_KITE_FLY)
return@on true
}
on(Items.YO_YO_4079, IntType.ITEM, "play", "loop", "walk", "crazy"){ player, _ ->
val option = getUsedOption(player)