RuneHive-Game
Loading...
Searching...
No Matches
ShootingStarAction.java
Go to the documentation of this file.
1package com.runehive.content.shootingstar;
2
3import com.runehive.content.skill.impl.mining.Mining;
4import com.runehive.content.skill.impl.mining.PickaxeData;
5import com.runehive.game.action.Action;
6import com.runehive.game.action.policy.WalkablePolicy;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.game.world.entity.skill.Skill;
9import com.runehive.game.world.items.Item;
10import com.runehive.game.world.object.GameObject;
11
12public class ShootingStarAction extends Action<Player> {
13
16
18 super(player, 3, false);
19 this.pickaxe = pickaxe;
20 this.object = object;
21 }
22
23 @Override
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
70 if (object == null || !object.active()) {
71 return false;
72 }
73
75 getMob().resetAnimation();
76 return false;
77 }
78
80 }
81 return true;
82 }
83}
void onCancel(boolean logout)
A function executed on cancellation.
ShootingStarAction(Player player, PickaxeData pickaxe, GameObject object)
void execute()
A function representing the unit of work that will be carried out.
boolean canSchedule()
A function executed on registration.
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
void onSchedule()
A function executed on registration.
int availableDust
How much dust there currently is in the star.
void decreaseDust(Player player)
Handles decreasing the dust for a star.
int getMiningLevel()
The required mining level for the star level.
static ShootingStarData shootingStarData
The current data of the shooting star.
static boolean success(Player player, OreData ore, PickaxeData pickaxe)
Definition Mining.java:126
T getMob()
Gets the player.
Definition Action.java:44
Action(T mob, int delay, boolean instant)
Creates a new Action randomevent.
Definition Action.java:24
synchronized final void cancel()
Cancels all subsequent executions.
Definition Task.java:113
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final int MINING
The mining skill id.
Definition Skill.java:63
The container class that represents an item that can be interacted with.
Definition Item.java:21
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.