mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-02-17 00:51:49 +00:00
85 lines
3.4 KiB
Text
Executable file
85 lines
3.4 KiB
Text
Executable file
class BaseEvent native { } // just a base class. it doesn't inherit from Object on the scripting side so you can't call Destroy() on it and break everything.
|
|
|
|
class RenderEvent : BaseEvent native
|
|
{
|
|
native readonly Vector3 ViewPos;
|
|
native readonly double ViewAngle;
|
|
native readonly double ViewPitch;
|
|
native readonly double ViewRoll;
|
|
native readonly double FracTic;
|
|
native readonly Actor Camera;
|
|
}
|
|
|
|
class WorldEvent : BaseEvent native
|
|
{
|
|
// for loaded/unloaded
|
|
native readonly bool IsSaveGame;
|
|
// this will be true if we are re-entering the hub level.
|
|
native readonly bool IsReopen;
|
|
// for thingspawned/thingdied/thingdestroyed
|
|
native readonly Actor Thing;
|
|
// for thingdied. can be null
|
|
native readonly Actor Inflictor;
|
|
// for thingdamaged.
|
|
native readonly int Damage;
|
|
native readonly Actor DamageSource;
|
|
native readonly Name DamageType;
|
|
native readonly EDmgFlags DamageFlags;
|
|
native readonly double DamageAngle;
|
|
}
|
|
|
|
class PlayerEvent : BaseEvent native
|
|
{
|
|
// this is the player number that caused the event.
|
|
// note: you can get player struct from this by using players[e.PlayerNumber]
|
|
native readonly int PlayerNumber;
|
|
// this will be true if we are re-entering the hub level.
|
|
native readonly bool IsReturn;
|
|
}
|
|
|
|
class StaticEventHandler : Object native
|
|
{
|
|
// static event handlers CAN register other static event handlers.
|
|
// unlike EventHandler.Create that will not create them.
|
|
protected static native StaticEventHandler Create(class<StaticEventHandler> type);
|
|
protected static native StaticEventHandler CreateOnce(class<StaticEventHandler> type);
|
|
protected static native StaticEventHandler Find(Class<StaticEventHandler> type); // just for convenience. who knows.
|
|
|
|
protected static native bool Register(StaticEventHandler handler);
|
|
protected static native bool Unregister(StaticEventHandler handler);
|
|
|
|
// actual handlers are here
|
|
virtual native void WorldLoaded(WorldEvent e);
|
|
virtual native void WorldUnloaded(WorldEvent e);
|
|
virtual native void WorldThingSpawned(WorldEvent e);
|
|
virtual native void WorldThingDied(WorldEvent e);
|
|
virtual native void WorldThingRevived(WorldEvent e);
|
|
virtual native void WorldThingDamaged(WorldEvent e);
|
|
virtual native void WorldThingDestroyed(WorldEvent e);
|
|
virtual native void WorldLightning(WorldEvent e); // for the sake of completeness.
|
|
virtual native void WorldTick(WorldEvent e);
|
|
|
|
//
|
|
virtual native void RenderFrame(RenderEvent e);
|
|
|
|
//
|
|
virtual native void PlayerEntered(PlayerEvent e);
|
|
virtual native void PlayerRespawned(PlayerEvent e);
|
|
virtual native void PlayerDied(PlayerEvent e);
|
|
virtual native void PlayerDisconnected(PlayerEvent e);
|
|
|
|
// this function should return a value that will be queried on Register() to decide the relative order of this handler to every other.
|
|
// this is most useful in UI systems.
|
|
// default is 0.
|
|
virtual native int GetOrder();
|
|
}
|
|
|
|
class EventHandler : StaticEventHandler native
|
|
{
|
|
static native StaticEventHandler Create(class<StaticEventHandler> type);
|
|
static native StaticEventHandler CreateOnce(class<StaticEventHandler> type);
|
|
static native StaticEventHandler Find(class<StaticEventHandler> type);
|
|
|
|
static native bool Register(StaticEventHandler handler);
|
|
static native bool Unregister(StaticEventHandler handler);
|
|
}
|