RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.task.impl.ChopVineTask Class Reference
Inheritance diagram for com.runehive.game.task.impl.ChopVineTask:
Collaboration diagram for com.runehive.game.task.impl.ChopVineTask:

Public Member Functions

 ChopVineTask (Player player, GameObject object, int respawn)
void execute ()
 A function representing the unit of work that will be carried out.
Public Member Functions inherited from com.runehive.game.task.Task
Task attach (Object newKey)
 Attaches a new key.
synchronized final void cancel ()
 Cancels all subsequent executions.
synchronized final void cancel (boolean logout)
 Cancels all subsequent executions.
boolean canRun ()
 Determines if the task can be ran.
Optional< Object > getAttachment ()
String getCreationStackTraceStr ()
int getDelay ()
Long getElapsedTimeFromRunStartTime ()
Optional< Long > getRunStartTime ()
long getTaskCreationTime ()
String getTaskId ()
boolean isInstant ()
boolean isRunning ()
void setDelay (int delay)
 Sets the cyclic delay.
void setExecutionTime ()
 Task (boolean instant, int delay)
 Creates a new Task.
 Task (int delay)
 Creates a new Task that doesn't execute instantly.

Protected Member Functions

void onCancel (boolean logout)
 A function executed on cancellation.
void onSchedule ()
 A function executed on registration.
Protected Member Functions inherited from com.runehive.game.task.Task
void baseExecute ()
boolean canSchedule ()
 A function executed on registration.

Private Attributes

final GameObject object
final Player player
final int respawn
int tick = 0

Additional Inherited Members

Package Functions inherited from com.runehive.game.task.Task
void onException (Exception e)
 A function executed on thrown exceptions.
void onLoop ()
 A function executed when iterated over.
final synchronized void process ()
synchronized void setRunning (boolean running)

Detailed Description

Definition at line 15 of file ChopVineTask.java.

Constructor & Destructor Documentation

◆ ChopVineTask()

com.runehive.game.task.impl.ChopVineTask.ChopVineTask ( Player player,
GameObject object,
int respawn )

Definition at line 22 of file ChopVineTask.java.

22 {
23 super(true, 0);
24 this.player = player;
25 this.object = object;
26 this.respawn = respawn;
27 }

References object, player, and respawn.

Member Function Documentation

◆ execute()

void com.runehive.game.task.impl.ChopVineTask.execute ( )

A function representing the unit of work that will be carried out.

Reimplemented from com.runehive.game.task.Task.

Definition at line 56 of file ChopVineTask.java.

56 {
57 if (tick == 1) {
58 object.unregister();
59 } else if (tick == respawn / 2) {
60 Direction direction = Direction.getDirection(player.getPosition(), object.getPosition());
61 player.walk(player.getPosition().transform(direction.getDirectionX() * 2, direction.getDirectionY() * 2), true);
62 } else if (tick >= respawn) {
63 object.register();
64 cancel();
65 }
66
67 tick++;
68 }

References com.runehive.game.task.Task.cancel(), com.runehive.game.world.entity.mob.Direction.getDirection(), com.runehive.game.world.entity.mob.Direction.getDirectionX(), com.runehive.game.world.entity.mob.Direction.getDirectionY(), player, respawn, and tick.

Here is the call graph for this function:

◆ onCancel()

void com.runehive.game.task.impl.ChopVineTask.onCancel ( boolean logout)
protected

A function executed on cancellation.

Reimplemented from com.runehive.game.task.Task.

Definition at line 71 of file ChopVineTask.java.

71 {
72
73 }

◆ onSchedule()

void com.runehive.game.task.impl.ChopVineTask.onSchedule ( )
protected

A function executed on registration.

Reimplemented from com.runehive.game.task.Task.

Definition at line 30 of file ChopVineTask.java.

30 {
31 if (!player.getPosition().isWithinDistance(object.getPosition(), 1)) {
32 cancel();
33 return;
34 }
35
36 if (player.skills.getLevel(Skill.WOODCUTTING) < 34) {
37 player.send(new SendMessage("You need a woodcutting level of 34 or more to cut this."));
38 cancel();
39 return;
40 }
41
42 Optional<AxeData> result = AxeData.getDefinition(player);
43
44 if (!result.isPresent()) {
45 player.send(new SendMessage("You need an axe to cut this."));
46 cancel();
47 return;
48 }
49
50 AxeData data = result.get();
51
52 player.animate(new Animation(data.animation, UpdatePriority.HIGH));
53 }

References com.runehive.content.skill.impl.woodcutting.AxeData.animation, com.runehive.game.task.Task.cancel(), com.runehive.content.skill.impl.woodcutting.AxeData.getDefinition(), com.runehive.game.UpdatePriority.HIGH, player, and com.runehive.game.world.entity.skill.Skill.WOODCUTTING.

Here is the call graph for this function:

Member Data Documentation

◆ object

final GameObject com.runehive.game.task.impl.ChopVineTask.object
private

Definition at line 19 of file ChopVineTask.java.

Referenced by ChopVineTask().

◆ player

final Player com.runehive.game.task.impl.ChopVineTask.player
private

Definition at line 18 of file ChopVineTask.java.

Referenced by ChopVineTask(), execute(), and onSchedule().

◆ respawn

final int com.runehive.game.task.impl.ChopVineTask.respawn
private

Definition at line 20 of file ChopVineTask.java.

Referenced by ChopVineTask(), and execute().

◆ tick

int com.runehive.game.task.impl.ChopVineTask.tick = 0
private

Definition at line 17 of file ChopVineTask.java.

Referenced by execute().


The documentation for this class was generated from the following file: