RuneHive-Game
Loading...
Searching...
No Matches
SteppingStoneTask.java
Go to the documentation of this file.
1package com.runehive.game.task.impl;
2
3import com.runehive.game.task.Task;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.object.GameObject;
6
7public abstract class SteppingStoneTask extends Task {
8
9 private final Player player;
10 private final GameObject object;
11 protected int tick;
12
14 super(true, 0);
15 this.player = player;
16 this.object = object;
17 }
18
19 @Override
20 protected void onSchedule() {
21 if (!player.getPosition().isWithinDistance(object.getPosition(), 1)) {
22 cancel();
23 return;
24 }
25 }
26
27 public abstract void onExecute();
28
29 @Override
30 public void execute() {
31 onExecute();
32 tick++;
33 }
34
35 @Override
36 protected void onCancel(boolean logout) {
37
38 }
39
40}
synchronized final void cancel()
Cancels all subsequent executions.
Definition Task.java:113
Task(boolean instant, int delay)
Creates a new Task.
Definition Task.java:41
void execute()
A function representing the unit of work that will be carried out.
void onCancel(boolean logout)
A function executed on cancellation.
void onSchedule()
A function executed on registration.
SteppingStoneTask(Player player, GameObject object)
This class represents a character controlled by a player.
Definition Player.java:125