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
An engine handling a ``TargetAbilityEvent`` would call handlers in the following order::
36
+
sc2reader.engine.register_plugin(Plugin1())
37
+
sc2reader.engine.register_plugin(Plugin2())
38
+
39
+
When the engine handles a ``TargetAbilityEvent`` it will call handlers in the following order::
37
40
38
41
Plugin1.handleAbilityEvent(event, replay)
39
42
Plugin2.handleEvent(event, replay)
@@ -84,3 +87,12 @@ If a plugin wishes to stop processing a replay it can yield a PluginExit event b
84
87
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::
85
88
86
89
code, details = replay.plugins['MyPlugin']
90
+
91
+
Using Your Plugin
92
+
-----------------
93
+
94
+
To use your plugin with sc2reader, just register it to the game engine:
95
+
96
+
sc2reader.engine.register_plugin(MyPlugin())
97
+
98
+
Plugins will be called in order of registration for each event. If plugin B depends on plugin A make sure to register plugin A first!
A plugin is pretty much just a callable function or object that accepts a replay
5
-
file as a single argument. sc2reader supports assignment of plugins to different
6
-
resource types via the :meth:`SC2Factory.register_plugin` factory method.
4
+
sc2reader has a built in game engine that you can plug into to efficiently process replay events. You can add plugins to the engine by calling :meth:`~sc2reader.engine.engine.GameEngine.register_plugin`::
7
5
8
-
::
6
+
import sc2reader
7
+
from sc2reader.engine.plugins import APMTracker, SelectionTracker
Plugins will be called in order of registration for each event. If plugin B depends on plugin A make sure to register plugin A first!
14
12
15
-
The order you register plugins is the order they are executed in so be careful to
16
-
put register in the right order if you have dependencies between plugins.
13
+
See the :doc:`articles/creatingagameengineplugin` article for instructions on making your own plugins.
14
+
15
+
16
+
ContextLoader
17
+
-------------
18
+
19
+
.. note::
20
+
21
+
This plugin is registered by default.
22
+
23
+
This plugin creates and maintains all the :class:`~sc2reader.data.Unit` and :class:`~sc2reader.data.Ability` data objects from the raw replay data. This creates all the ``event.player``, ``event.unit``, ``event.ability`` object references and maintains other game data structures like :attr:`~sc2reader.resources.Replay.objects`.
24
+
25
+
26
+
GameHeartNormalizer
27
+
---------------------
28
+
29
+
.. note::
30
+
31
+
This plugin is registered by default.
32
+
33
+
This plugin fixes player lists, teams, game lengths, and frames for games that were played with the GameHeart mod.
17
34
18
35
19
36
APMTracker
20
37
----------------
21
38
22
-
The APMTracker adds three simple fields based on a straight tally of non-camera
23
-
player action events such as selections, abilities, and hotkeys.
39
+
The :class:`~sc2reader.engine.plugins.APMTracker` adds three simple fields based on a straight tally of non-camera player action events such as selections, abilities, and hotkeys.
24
40
25
41
* ``player.aps`` = a dictionary of second => total actions in that second
26
42
* ``player.apm`` = a dictionary of minute => total actions in that minute
@@ -30,21 +46,12 @@ player action events such as selections, abilities, and hotkeys.
30
46
SelectionTracker
31
47
--------------------
32
48
33
-
The :class:`SelectionTracker` plugin simulates every person's selection at every
34
-
frame in both the hotkey and active selection buffers. This selection information
35
-
is stored in ``person.selection`` as a two dimensional array of lists.
Where buffer is a control group 0-9 or 10 which represents the active selection.
51
+
This plugin is intended to be used in conjunction with other user written plugins. If you attempt to use the ``player.selection`` attribute outside of a registered plugin the values will be the values as they were at the end of the game.
42
52
43
-
Keep in mind that the buffers are only updated for the following events:
53
+
The :class:`SelectionTracker` maintains a ``person.selection`` structure maps selection buffers for that player to the player's current selection::
44
54
45
-
* The active selection changes
46
-
* When unit types change (eggs hatch, tanks siege)
55
+
active_selection = event.player.selection[10]
47
56
48
-
Buffers are not updated when units die unless the unit dies while selected (because
49
-
the active selection must change). Units that die while deslected won't get deselected
50
-
until the next time the control group they were saved in becomes active.
57
+
Where buffer is a control group 0-9 or a 10 which represents the active selection.
0 commit comments