RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ShootingStarAction.java
1package com.osroyale.content.shootingstar;
2
3import com.osroyale.content.skill.impl.mining.Mining;
4import com.osroyale.content.skill.impl.mining.PickaxeData;
5import com.osroyale.game.action.Action;
6import com.osroyale.game.action.policy.WalkablePolicy;
7import com.osroyale.game.world.entity.mob.player.Player;
8import com.osroyale.game.world.entity.skill.Skill;
9import com.osroyale.game.world.items.Item;
10import com.osroyale.game.world.object.GameObject;
11
12public class ShootingStarAction extends Action<Player> {
13
14 private PickaxeData pickaxe;
15 private GameObject object;
16
17 public ShootingStarAction(Player player, PickaxeData pickaxe, GameObject object) {
18 super(player, 3, false);
19 this.pickaxe = pickaxe;
20 this.object = object;
21 }
22
23 @Override
24 public WalkablePolicy getWalkablePolicy() {
25 return WalkablePolicy.NON_WALKABLE;
26 }
27
28 @Override
29 public String getName() {
30 return "shooting-star-action";
31 }
32
33 @Override
34 protected boolean canSchedule() {
35 return !getMob().skills.get(Skill.MINING).isDoingSkill();
36 }
37
38 @Override
39 protected void onSchedule() {
40 getMob().animate(pickaxe.animation);
41 }
42
43 @Override
44 protected void onCancel(boolean logout) {
45 getMob().resetFace();
46 getMob().skills.get(Skill.MINING).setDoingSkill(false);
47 }
48
49 @Override
50 protected void execute() {
51 if (!getMob().skills.get(Skill.MINING).isDoingSkill()) {
52 cancel();
53 return;
54 }
55
56 if (!mine()) {
57 cancel();
58 }
59 }
60
61 private boolean mine() {
62 if (!getMob().inventory.hasCapacityFor(new Item(25527))) {
63 getMob().dialogueFactory.sendStatement("You can't carry anymore star dust.").execute();
64 return false;
65 }
66
67 getMob().animate(pickaxe.animation);
68
69 if (Mining.success(getMob(), ShootingStar.shootingStarData.getMiningLevel(), pickaxe)) {
70 if (object == null || !object.active()) {
71 return false;
72 }
73
74 if (ShootingStar.shootingStarData.availableDust <= 0) {
75 getMob().resetAnimation();
76 return false;
77 }
78
79 ShootingStar.shootingStarData.decreaseDust(getMob());
80 }
81 return true;
82 }
83}
abstract WalkablePolicy getWalkablePolicy()
synchronized final void cancel()
Definition Task.java:147