RuneHive-Game
Loading...
Searching...
No Matches
CombatEffect.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.effect;
2
3import com.runehive.game.world.World;
4import com.runehive.game.world.entity.mob.Mob;
5
6import java.util.Collection;
7import java.util.Collections;
8import java.util.HashMap;
9import java.util.Map;
10
11/**
12 * Some sort of temporary effect applied to a {@link Mob} during
13 * combat. Combat effects include but are not limited to; being poisoned,
14 * skulled, and teleblocked.
15 *
16 * @author lare96 <http://github.org/lare96>
17 */
18public abstract class CombatEffect {
19
20 /** The map of all of the combat effect types mapped to their respective listeners. */
21 public static final Map<CombatEffectType, CombatEffect> EFFECTS = new HashMap<>();
22
23 /** The delay for this individual combat effect. */
24 private final int delay;
25
26 /** Creates a new {@link CombatEffect}. */
27 public CombatEffect(int delay) {
28 this.delay = delay;
29 }
30
31 /** Starts this combat effect by scheduling a task utilizing the abstract methods in this class. */
32 public final boolean start(Mob mob) {
33 if (apply(mob)) {
35 return true;
36 }
37 return false;
38 }
39
40 /** Applies this effect to {@code mob}. */
41 public abstract boolean apply(Mob mob);
42
43 /** Removes this effect from {@code mob} if needed. */
44 public abstract boolean removeOn(Mob mob);
45
46 /** Provides processing for this effect on {@code mob}. */
47 public abstract void process(Mob mob);
48
49 /** Executed on login, primarily used to re-apply the effect to {@code mob}. */
50 public abstract boolean onLogin(Mob mob);
51
52 /** Gets the delay for this individual combat effect. */
53 protected final int getDelay() {
54 return delay;
55 }
56
57 /** Returns an unmodifiable view of the combat effect listeners. */
58 public static Collection<CombatEffect> values() {
59 return Collections.unmodifiableCollection(EFFECTS.values());
60 }
61}
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
CombatEffect(int delay)
Creates a new CombatEffect.
abstract boolean removeOn(Mob mob)
Removes this effect from mob if needed.
static Collection< CombatEffect > values()
Returns an unmodifiable view of the combat effect listeners.
final int getDelay()
Gets the delay for this individual combat effect.
abstract boolean apply(Mob mob)
Applies this effect to mob.
final boolean start(Mob mob)
Starts this combat effect by scheduling a task utilizing the abstract methods in this class.
abstract boolean onLogin(Mob mob)
Executed on login, primarily used to re-apply the effect to mob.
abstract void process(Mob mob)
Provides processing for this effect on mob.
static final Map< CombatEffectType, CombatEffect > EFFECTS
The map of all of the combat effect types mapped to their respective listeners.
final int delay
The delay for this individual combat effect.
The Task implementation that provides processing for CombatEffects.
Handles the mob class.
Definition Mob.java:66