RuneHive-Game
Loading...
Searching...
No Matches
EventDispatcher.java
Go to the documentation of this file.
1package com.runehive.content.event;
2
3import com.runehive.content.activity.Activity;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.content.event.InteractionEvent.InteractionType;
6
7public class EventDispatcher {
8
10
12 this.interactionEvent = interactionEvent;
13 }
14
15 public static boolean execute(Player player, InteractionEvent event) {
16 return player.inActivity() && Activity.evaluate(player, it -> it.onEvent(player, event)) || player.skills.onEvent(event);
17 }
18
19 public void dispatch(InteractionType type, EventHandler eventHandler) {
20 if (interactionEvent.isHandled()) {
21 return;
22 }
23
24 if (interactionEvent.getType() == type) {
25 interactionEvent.setHandled(eventHandler.handle(interactionEvent));
26 }
27 }
28
29}
A Activity object constructs an in-game activity and sequences it through the start() and finish() me...
Definition Activity.java:31
static boolean evaluate(Mob mob, Predicate< Activity > predicate)
Definition Activity.java:74
static boolean execute(Player player, InteractionEvent event)
void dispatch(InteractionType type, EventHandler eventHandler)
EventDispatcher(InteractionEvent interactionEvent)
This class represents a character controlled by a player.
Definition Player.java:125
boolean onEvent(InteractionEvent interactionEvent)
The interactionEvent listener.
boolean handle(InteractionEvent interactionEvent)