RuneHive-Game
Loading...
Searching...
No Matches
FlaxPickingAction.java
Go to the documentation of this file.
1package com.runehive.game.action.impl;
2
3import com.runehive.Config;
4import com.runehive.game.Animation;
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;
11import com.runehive.util.Utility;
12
13/**
14 * Handles picking up a flax.
15 * @author Daniel
16 */
17public final class FlaxPickingAction extends Action<Player> {
18
19 /** The flax game object. */
20 private final GameObject object;
21
22 /** The ticks. */
23 private boolean pickup;
24
25 /**
26 * Constructs a new <code>FlaxPickingAction</code>.
27 *
28 * @param player The player instance.
29 * @param object The flax game object.
30 */
31 public FlaxPickingAction(Player player, GameObject object) {
32 super(player, 2, true);
33 this.object = object;
34 }
35
36 @Override
37 public void execute() {
38 Player player = getMob().getPlayer();
39
40 if (pickup) {
41 player.inventory.add(new Item(1779, 1));
42// if (Utility.random(6) == 1) {
43// World.submit(new ObjectReplacementEvent(object, 20));
44// }
45 cancel();
46 } else {
47 player.animate(new Animation(827));
48 pickup = true;
49 setDelay(1);
50 }
51 }
52
53 @Override
54 public String getName() {
55 return "Flax picking";
56 }
57
58 @Override
59 public boolean prioritized() {
60 return false;
61 }
62
63 @Override
67}
Class that models a single animation used by an entity.
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
boolean prioritized()
Determines if this action is prioritized.
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
final GameObject object
The flax game object.
FlaxPickingAction(Player player, GameObject object)
Constructs a new FlaxPickingAction.
void execute()
A function representing the unit of work that will be carried out.
String getName()
Gets the name of this action.
synchronized final void cancel()
Cancels all subsequent executions.
Definition Task.java:113
void setDelay(int delay)
Sets the cyclic delay.
Definition Task.java:164
This class represents a character controlled by a player.
Definition Player.java:125
The container class that represents an item that can be interacted with.
Definition Item.java:21
boolean add(Item item)
Attempts to deposit item into this container.
A queue policy determines whether the action can occur while walking.
NON_WALKABLE
This indicates actions cannot occur while walking.