Game Events¶
Handles Source 1 style game events (schema + payload decoding) used for objectives, runes, chat, and related signals.
See also: Game Events
gem.game_events.GameEventManager
¶
Manages game event schema registration and handler dispatch.
Attributes:
| Name | Type | Description |
|---|---|---|
_schemas_by_id |
dict[int, GameEventSchema]
|
event_id → GameEventSchema. |
_schemas_by_name |
dict[str, GameEventSchema]
|
event_name → GameEventSchema. |
_handlers |
dict[str, list[GameEventHandler]]
|
event_name → list of handlers. |
Source code in src/gem/game_events.py
register_schema(schema_dict: dict[str, Any]) -> None
¶
Register an event schema from a dict (e.g. from CSVCMsg_GameEventList).
Expected keys: eventid, name, keys (list of {name, type}).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_dict
|
dict[str, Any]
|
Dict with event schema data. |
required |
Source code in src/gem/game_events.py
has_event(name: str) -> bool
¶
Return True if an event schema with the given name is registered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Event name to check. |
required |
on_game_event(name: str, handler: GameEventHandler) -> None
¶
Register a handler for the named event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Event name to listen for. |
required |
handler
|
GameEventHandler
|
Callable |
required |
Source code in src/gem/game_events.py
dispatch(raw_event: Any) -> None
¶
Dispatch a raw CMsgSource1LegacyGameEvent message to registered handlers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_event
|
Any
|
A |
required |
Source code in src/gem/game_events.py
gem.game_events.GameEvent
¶
A decoded game event instance.
Wraps a raw CSVCMsg_GameEvent message and its schema to provide
typed field accessors.
Attributes:
| Name | Type | Description |
|---|---|---|
schema |
The GameEventSchema for this event type. |
|
msg |
The raw protobuf message. |
Source code in src/gem/game_events.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
get_string(name: str) -> tuple[str, str | None]
¶
Return (value, None) as str, or ('', error) on failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Field name. |
required |
Source code in src/gem/game_events.py
get_float(name: str) -> tuple[float, str | None]
¶
Return (value, None) as float, or (0.0, error) on failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Field name. |
required |
Source code in src/gem/game_events.py
get_int32(name: str) -> tuple[int, str | None]
¶
Return (value, None) as int32 (long/short/byte), or (0, error).
Accepts long (3), short (4), or byte (5) type IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Field name. |
required |
Source code in src/gem/game_events.py
get_bool(name: str) -> tuple[bool, str | None]
¶
Return (value, None) as bool, or (False, error) on failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Field name. |
required |
Source code in src/gem/game_events.py
get_uint64(name: str) -> tuple[int, str | None]
¶
Return (value, None) as uint64, or (0, error) on failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Field name. |
required |
Source code in src/gem/game_events.py
gem.game_events.GameEventSchema
dataclass
¶
Schema for a single game event type.
Attributes:
| Name | Type | Description |
|---|---|---|
event_id |
int
|
Numeric event identifier. |
name |
str
|
Human-readable event name. |
fields |
dict[str, tuple[int, int]]
|
Mapping of field name → (key_index, type_id). |