2019-04-02 10:37:02 -07:00
|
|
|
# StaticEventHandler
|
|
|
|
|
|
|
|
Static event handlers handle events on a per-instance level. This means that
|
|
|
|
they are registered when you start GZDoom, and un-register when you exit
|
|
|
|
GZDoom. This is unlike `EventHandler`, which registers when a new game is
|
|
|
|
started, and un-registers when it ends. Care should be taken to make sure that
|
|
|
|
variables kept in a static event handler don't interact with the game directly,
|
|
|
|
or it will act **non-deterministically** and cause a desync.
|
|
|
|
|
|
|
|
All of the virtual functions on `StaticEventHandler` have empty implementations
|
|
|
|
by default, so you only need to override the events your event handler needs to
|
|
|
|
override.
|
|
|
|
|
|
|
|
Differences in virtual function behaviour are listed in the `EventHandler`
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
```
|
|
|
|
class StaticEventHandler : Object play
|
|
|
|
{
|
2019-08-14 03:32:51 -07:00
|
|
|
clearscope static StaticEventHandler Find(class<StaticEventHandler> type);
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual void OnRegister();
|
|
|
|
virtual void OnUnregister();
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual void WorldLoaded(WorldEvent e);
|
|
|
|
virtual void WorldUnloaded(WorldEvent e);
|
|
|
|
virtual void WorldThingSpawned(WorldEvent e);
|
|
|
|
virtual void WorldThingDied(WorldEvent e);
|
|
|
|
virtual void WorldThingRevived(WorldEvent e);
|
|
|
|
virtual void WorldThingDamaged(WorldEvent e);
|
|
|
|
virtual void WorldThingDestroyed(WorldEvent e);
|
|
|
|
virtual void WorldLinePreActivated(WorldEvent e);
|
|
|
|
virtual void WorldLineActivated(WorldEvent e);
|
|
|
|
virtual void WorldSectorDamaged(WorldEvent e);
|
|
|
|
virtual void WorldLineDamaged(WorldEvent e);
|
|
|
|
virtual void WorldLightning(WorldEvent e);
|
|
|
|
virtual void WorldTick();
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual ui void RenderOverlay(RenderEvent e);
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual void PlayerEntered(PlayerEvent e);
|
|
|
|
virtual void PlayerRespawned(PlayerEvent e);
|
|
|
|
virtual void PlayerDied(PlayerEvent e);
|
|
|
|
virtual void PlayerDisconnected(PlayerEvent e);
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual ui bool UiProcess(UiEvent e);
|
|
|
|
virtual ui void UiTick();
|
|
|
|
virtual ui void PostUiTick();
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual ui bool InputProcess(InputEvent e);
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual ui void ConsoleProcess(ConsoleEvent e);
|
|
|
|
virtual void NetworkProcess(ConsoleEvent e);
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual void CheckReplacement(ReplaceEvent e);
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
virtual void NewGame();
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
void SetOrder(int order);
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:32:51 -07:00
|
|
|
readonly int Order;
|
|
|
|
bool IsUiProcessor;
|
|
|
|
bool RequireMouse;
|
2019-04-02 10:37:02 -07:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `Find`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Finds and returns the `StaticEventHandler` type `type` if it is registered, or
|
|
|
|
`null` if it does not exist.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `OnRegister`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when this type is registered. This is where you should set `Order`,
|
|
|
|
`IsUiProcessor` and `RequireMouse`.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `OnUnregister`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when this type is un-registered. With `StaticEventHandler`s this is
|
|
|
|
called when the engine shuts down, so it isn't particularly useful.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldLoaded`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called directly after the status bar is attached to the player and after
|
|
|
|
`REOPEN` ACS scripts are called, just before the display is flushed and
|
|
|
|
auto-save is done.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldUnloaded`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called directly after `UNLOADING` ACS scripts, just before the level is
|
|
|
|
changed.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldThingSpawned`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called directly after an actor's `PostBeginPlay` function.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldThingDied`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called after `MorphedDeath`, inventory items have called `OwnerDied`, and the
|
|
|
|
target is set to the damage source, just before `KILL` ACS scripts are called
|
|
|
|
and the rest of the death handling is done.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldThingRevived`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when an actor is revived, after everything is finished.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldThingDamaged`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called directly before `Die`, or directly after after `DamageMobj` finishes.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldThingDestroyed`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called at the beginning of an actor's `OnDestroy` function.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldLinePreActivated`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called directly after a line is tested for activation, before any other
|
|
|
|
activation specials are called (such as checking for keys, executing the line
|
|
|
|
special, etc.)
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldLineActivated`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called directly after a line's special is executed, if it succeeded, before any
|
|
|
|
other handling (such as changing a switch's texture) is completed.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldSectorDamaged`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when a sector is damaged if it has any health groups, before any other
|
|
|
|
handling is done.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldLineDamaged`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when a line is damaged if it has any health groups, before any other
|
|
|
|
handling is done.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldLightning`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when lightning strikes, directly after the sound is played, just before
|
|
|
|
`LIGHTNING` ACS scripts are called.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `WorldTick`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called on every world tick, after interpolators are updated, world freeze is
|
|
|
|
updated, sight counters are reset, particles have run their thinkers, and
|
|
|
|
players have run their thinkers, just before the status bar is ticked, the
|
|
|
|
level ticks, thinkers are ticked, and the level time is updated. This is not
|
|
|
|
called when the game is paused, and its execution is entirely deterministic
|
|
|
|
regardless of how this event handler is applied.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `RenderOverlay`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Despite the name, this is actually run on the status bar, specifically in
|
|
|
|
`BaseStatusBar::DrawTopStuff`. It is run after `HudMessage`s are drawn and
|
|
|
|
power-ups are drawn, just before ゴゴゴ「The Log」ゴゴゴ is drawn. You may use
|
|
|
|
`Screen` functions in this function.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `PlayerEntered`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called during level load when each player enters the game, after the camera is
|
|
|
|
set but just before `RETURN` ACS scripts are called.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `PlayerRespawned`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when a player spawns, directly after the teleport fog is spanwed and
|
|
|
|
just before `RESPAWN` ACS scripts are called. Also called similarly at the end
|
|
|
|
of the `Respawn` function, for example when the `resurrect` cheat is used.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `PlayerDied`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called after `WorldThingDied` and `GetDeathHeight`, and after the actor's thing
|
|
|
|
special is activated, when the obituary has been displayed, just before `DEATH`
|
|
|
|
ACS scripts have been called.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `PlayerDisconnected`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when a bot is removed and when a player disconnects from the game, just
|
|
|
|
before `DISCONNECT` ACS scripts are called.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `UiProcess`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called only if `IsUiProcessor` is `true`. Called when a GUI event is dispatched
|
|
|
|
by the engine, for example when the UI is active and the player has pressed a
|
|
|
|
key or moved the mouse. Mouse movements will only be captured if `RequireMouse`
|
|
|
|
is `true`. Because this interacts directly with the OS it is not part of the
|
|
|
|
game simulation, therefore has `ui` scope and must dispatch commands to the
|
|
|
|
game as networked events. If the return value is `true`, the function will
|
|
|
|
block any further handlers from processing this event, essentially "eating"
|
|
|
|
it. If the return value is `false`, other handlers will continue to be called
|
|
|
|
as normal.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `UiTick`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Despite what it may seem, this function is actually called deterministically
|
|
|
|
within the game loop, just before the level is ticked and after the player's
|
|
|
|
network commands are created. Albeit this, it is `ui` scope, so it should be
|
|
|
|
used to process UI code.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `PostUiTick`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Similar to `UiTick`, this is also deterministic, but called after all other
|
|
|
|
tickers.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `InputProcess`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
The same as `UiProcess`, but this is only called when inputs are being directed
|
|
|
|
to the game, rather than to the GUI. All of the same restrictions apply to this
|
|
|
|
as they do to `UiProcess`, and the return value acts the same.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `ConsoleProcess`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when network events which have no player activator are received.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `NetworkProcess`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called when network events which have a player activator are received.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `CheckReplacement`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called during actor replacement, after skill replacement is done, but before
|
|
|
|
any other replacement (such as actor replacements done in ZScript actor
|
|
|
|
definitions.)
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `NewGame`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Called on a new game, directly after level data is reset and right before the
|
|
|
|
level is set up.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `SetOrder`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
Sets the ordering of this event handler, which can be read from `Order`.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `Order`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
The arbitrary ordering of this event handler relative to other ones. Event
|
|
|
|
handlers with lower ordering numbers have their functions executed first. You
|
|
|
|
can set this variable with `SetOrder`.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `IsUiProcessor`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
If `true`, GUI events will be sent to this event handler through `UiProcess`.
|
|
|
|
This is mainly for optimization purposes.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
### `RequireMouse`
|
2019-04-02 10:37:02 -07:00
|
|
|
|
2019-08-14 03:31:41 -07:00
|
|
|
If `true`, mouse events will be sent to this event handler through
|
|
|
|
`InputProcess` and/or `UiProcess`. This is mainly for optimization purposes.
|
2019-04-02 10:37:02 -07:00
|
|
|
|
|
|
|
<!-- EOF -->
|