You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugins can opt in to handle events with methods with the following naming convention::
8
+
9
+
def handleEventName(self, event, replay)
10
+
11
+
In addition to handling specific event types, plugins can also handle events more generally by handling built-in parent classes from the list below:
12
+
13
+
* handleEvent - called for every single event of all types
14
+
* handleMessageEvent - called for events in replay.message.events
15
+
* handleGameEvent - called for events in replay.game.events
16
+
* handleTrackerEvent - called for events in replay.tracker.events
17
+
* handlePlayerActionEvent - called for all game events indicating player actions
18
+
* handleAbilityEvent - called for all types of ability events
19
+
* handleHotkeyEvent - called for all player hotkey events
20
+
21
+
For every event in a replay, the GameEngine will loop over all of its registered plugins looking for functions to handle that event. Matching handlers are called in order of plugin registration from most general to most specific.
An engine handling a ``TargetAbilityEvent`` would call handlers in the following order::
37
+
38
+
Plugin1.handleAbilityEvent(event, replay)
39
+
Plugin2.handleEvent(event, replay)
40
+
Plugin2.handleTargetAbilityEvent(event, replay)
41
+
42
+
Setup and Cleanup
43
+
---------------------
44
+
45
+
Plugins may also handle special ``InitGame`` and ``EndGame`` events. These handlers for these events are called directly before and after the processing of the replay events:
46
+
47
+
* handleInitGame - is called prior to processing a new replay to provide
48
+
an opportunity for the plugin to clear internal state and set up any
49
+
replay state necessary.
50
+
51
+
* handleEndGame - is called after all events have been processed and
52
+
can be used to perform post processing on aggrated data or clean up
53
+
intermediate data caches.
54
+
55
+
Message Passing
56
+
--------------------
57
+
58
+
Event handlers can choose to ``yield`` additional events which will be injected into the event stream directly after the event currently being processed. This feature allows for message passing between plugins. An ExpansionTracker plugin could notify all other plugins of a new ExpansionEvent that they could opt to process::
59
+
60
+
def handleUnitDoneEvent(self, event, replay):
61
+
if event.unit.name == 'Nexus':
62
+
yield ExpansionEvent(event.frame, event.unit)
63
+
...
64
+
65
+
Early Exits
66
+
--------------------
67
+
68
+
If a plugin wishes to stop processing a replay it can yield a PluginExit event::
The GameEngine will intercept this event and remove the plugin from the list of active plugins for this replay. The exit code and details will be available from the replay::
0 commit comments