RuneHive-Game
Loading...
Searching...
No Matches
CombatEffectTask.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.effect;
2
3import com.runehive.game.task.Task;
4import com.runehive.game.world.entity.mob.Mob;
5
6/**
7 * The {@link Task} implementation that provides processing for {@link
8 * CombatEffect}s.
9 *
10 * @author lare96 <http://github.org/lare96>
11 */
12final class CombatEffectTask extends Task {
13
14 /** The mob that this task is for. */
15 private final Mob mob;
16
17 /** The combat effect that is being processed. */
18 private final CombatEffect effect;
19
20 /**
21 * Creates a new {@link CombatEffectTask}.
22 *
23 * @param mob the mob that this task is for.
24 * @param effect the combat effect that is being processed.
25 */
27 super(false, effect.getDelay());
28 super.attach(mob);
29 this.mob = mob;
30 this.effect = effect;
31 }
32
33 @Override
34 public void execute() {
35 if (effect.removeOn(mob) || !mob.isValid()) {
36 cancel();
37 return;
38 }
39
40 effect.process(mob);
41 }
42
43}
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
Some sort of temporary effect applied to a Mob during combat.
CombatEffectTask(Mob mob, CombatEffect effect)
Creates a new CombatEffectTask.
final CombatEffect effect
The combat effect that is being processed.
void execute()
A function representing the unit of work that will be carried out.
Handles the mob class.
Definition Mob.java:66