RuneHive-Game
Loading...
Searching...
No Matches
SpellAction.java
Go to the documentation of this file.
1package com.runehive.game.action.impl;
2
3import com.runehive.game.action.Action;
4import com.runehive.game.action.policy.WalkablePolicy;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.content.skill.impl.magic.spell.Spell;
7import com.runehive.game.world.items.Item;
8
9/**
10 * Handles the spell casting action.
11 * @author Daniel
12 */
13public final class SpellAction extends Action<Player> {
14 private final Spell spell;
15 private final Item item;
16
17 /** Creates the <code>SpellAction</code>. */
19 super(player, 3);
20 this.spell = spell;
21 this.item = item;
22 }
23
24 @Override
25 protected void onSchedule() {
26 spell.execute(getMob(), item);
27 }
28
29 @Override
30 public void execute() {
31 cancel();
32 }
33
34 @Override
35 public String getName() {
36 return "spell-action";
37 }
38
39 @Override
40 public boolean prioritized() {
41 return true;
42 }
43
44 @Override
48
49}
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
String getName()
Gets the name of this action.
void execute()
A function representing the unit of work that will be carried out.
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
void onSchedule()
A function executed on registration.
SpellAction(Player player, Spell spell, Item item)
Creates the SpellAction.
boolean prioritized()
Determines if this action is prioritized.
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
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.
WALKABLE
This indicates actions may occur while walking.
The itemcontainer for casting a spell.
Definition Spell.java:11