Class PapyrusEvent
- Namespace
- SkyrimForge.Papyrus
- Assembly
- SkyrimForge.Game.dll
One event a plugin publishes to Papyrus, and the objects registered to receive it.
Raising it enters every script attached to a registered object that declares the event, so the script that registered and the script that receives need not be the same one. Registrations are written into the co-save and come back with it. Registering an object already registered adds nothing and reports false, which a save restoring the set makes ordinary.
public sealed class PapyrusEvent
- Inheritance
-
PapyrusEvent
- Inherited Members
Remarks
// The script declares the event and a native to register with:
// Event OnGoldSpent(int amount)
// Function RegisterForGoldSpent(Form target) global native
PapyrusEvent spent = events.Declare("OnGoldSpent");
papyrus.RegisterStatic("MyScript", "RegisterForGoldSpent", (Form target) => { spent.Register(target); });
spent.Send(PapyrusArguments.Create().Add(120));
Properties
Name
The name the script declares for the event.
public string Name { get; }
Property Value
RegistrationCount
How many objects are registered. Without it, an event nothing listens for and one never raised read alike.
public int RegistrationCount { get; }
Property Value
Methods
Register(IActiveMagicEffect)
Registers an active magic effect, whose script is the usual receiver for an effect's own event.
public bool Register(IActiveMagicEffect target)
Parameters
targetIActiveMagicEffect
Returns
- bool
Whether this registered it, false where it was registered already or the game could give no handle for it. The game gives an effect a handle only where it has a target and a non-zero
UsUniqueID, and many effects have aUsUniqueIDof 0.
Exceptions
- ArgumentNullException
targetisnull.
Register(IAlias)
Registers a quest alias, whose script is the usual receiver for a quest's own event.
public bool Register(IAlias target)
Parameters
targetIAlias
Returns
- bool
Whether this registered it, false where it was registered already or the game could give no handle for it.
Exceptions
- ArgumentNullException
targetisnull.
Register<TForm>(TForm)
Registers a form, so scripts attached to it receive this event.
public bool Register<TForm>(TForm target) where TForm : IForm
Parameters
targetTForm
Returns
- bool
Whether this registered it, false where it was registered already or the game could give no handle for it.
Type Parameters
TForm
Exceptions
- ArgumentNullException
targetisnull.
Send(PapyrusArguments?)
Raises the event on every registered object.
public void Send(PapyrusArguments? arguments = null)
Parameters
argumentsPapyrusArgumentsThe arguments the event declares, in order, or
nullfor one declaring none. This takes the list over and frees it, as a dispatch does, so build one for each raising rather than retaining one to reuse.
Remarks
A registered object whose scripts declare no such event receives nothing, which is how the virtual machine dispatches rather than a failure.
Exceptions
- InvalidOperationException
No Papyrus VM exists.
argumentswas passed to a call already, or contains a form where the event was declared by name alone. For an event declared with a script, the script does not declare the event or the arguments do not match its declaration.
Unregister(IActiveMagicEffect)
Stops an active magic effect receiving this event.
public bool Unregister(IActiveMagicEffect target)
Parameters
targetIActiveMagicEffect
Returns
- bool
Whether it was registered beforehand.
Exceptions
- ArgumentNullException
targetisnull.
Unregister(IAlias)
Stops a quest alias receiving this event.
public bool Unregister(IAlias target)
Parameters
targetIAlias
Returns
- bool
Whether it was registered beforehand.
Exceptions
- ArgumentNullException
targetisnull.
UnregisterAll()
Stops everything receiving this event. The game does this itself before a save is loaded and on a new game.
public void UnregisterAll()
Unregister<TForm>(TForm)
Stops a form receiving this event.
public bool Unregister<TForm>(TForm target) where TForm : IForm
Parameters
targetTForm
Returns
- bool
Whether it was registered beforehand.
Type Parameters
TForm
Exceptions
- ArgumentNullException
targetisnull.