Class ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1, TEvent2, TEvent3, TEvent4, TEvent5>
- Namespace
- MonkeyLoader.Resonite
- Assembly
- MonkeyLoader.Resonite.Integration.dll
Represents the base class for patchers that run after Resonite's assemblies have been loaded and that hook into the game's lifecycle.
Specifically, to act as an event handler for the cancelable TEvent
generic parameter(s).
public abstract class ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1, TEvent2, TEvent3, TEvent4, TEvent5> : ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1, TEvent2, TEvent3, TEvent4>, IResoniteMonkey, IMonkey, IRun, IShutdown, IComparable<IMonkey>, INestedIdentifiable<Mod>, INestedIdentifiable, IIdentifiable, IAuthorable, ICancelableEventHandler<TEvent1>, ICancelableEventHandler<TEvent2>, ICancelableEventHandler<TEvent3>, ICancelableEventHandler<TEvent4>, ICancelableEventHandler<TEvent5>, IPrioritizable where TMonkey : ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1, TEvent2, TEvent3, TEvent4, TEvent5>, new() where TEvent1 : CancelableSyncEvent where TEvent2 : CancelableSyncEvent where TEvent3 : CancelableSyncEvent where TEvent4 : CancelableSyncEvent where TEvent5 : CancelableSyncEvent
Type Parameters
TMonkey
The type of the actual patcher.
TEvent1
The first CancelableSyncEvent type to handle.
TEvent2
The second CancelableSyncEvent type to handle.
TEvent3
The third CancelableSyncEvent type to handle.
TEvent4
The fourth CancelableSyncEvent type to handle.
TEvent5
The fifth CancelableSyncEvent type to handle.
- Inheritance
-
MonkeyBase<TMonkey>Monkey<TMonkey>ResoniteMonkey<TMonkey>ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1>ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1, TEvent2>ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1, TEvent2, TEvent3>ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1, TEvent2, TEvent3, TEvent4>ResoniteCancelableEventHandlerMonkey<TMonkey, TEvent1, TEvent2, TEvent3, TEvent4, TEvent5>
- Implements
-
ICancelableEventHandler<TEvent1>ICancelableEventHandler<TEvent2>ICancelableEventHandler<TEvent3>ICancelableEventHandler<TEvent4>ICancelableEventHandler<TEvent5>
- Derived
- Inherited Members
- Extension Methods
Remarks
Game assemblies and their types can be directly referenced from these.
Contains useful overridable methods that are hooked to different points in the game's lifecycle.
Constructors
ResoniteCancelableEventHandlerMonkey()
Allows creating only a single TMonkey
instance.
protected ResoniteCancelableEventHandlerMonkey()
Methods
AppliesTo(TEvent5)
Determines whether the given event should be handled by this event handler based on its data.
protected virtual bool AppliesTo(TEvent5 eventData)
Parameters
eventData
TEvent5An object containing all the relevant information for the event.
Returns
- bool
true
if this event handler applies to the event; otherwise,false
.
Remarks
By default: Returns this monkey's Enabled state.
Handle(TEvent5)
Handles the given event based on its data, if AppliesTo returned true
.
protected abstract void Handle(TEvent5 eventData)
Parameters
eventData
TEvent5An object containing all the relevant information for the applicable event.
OnEngineReady()
Override this method to be called when the FrooxEngine.Engine is ready.
This is the primary method for patching used by Resonite Mods as basic facilities of the game
are ready to use, while most other code hasn't been run yet.
Return true
if patching was successful.
protected override bool OnEngineReady()
Returns
- bool
Whether the patching was successful.
Remarks
Override OnLoaded() to patch before anything is initialized,
but strongly consider also overriding this method if you do that.
Otherwise your patches will be applied twice, if you're using [HarmonyLib.HarmonyPatchCategory(nameof(MyPatcher))]
attributes.
Easy to apply by using
[HarmonyLib.HarmonyPatchCategory(nameof(MyPatcher))]
attribute.
OnShutdown(bool)
Lets this monkey cleanup and shutdown.
protected override bool OnShutdown(bool applicationExiting)
Parameters
applicationExiting
boolWhether the shutdown was caused by the application exiting.
Returns
- bool
true
if it ran successfully; otherwise,false
.
Remarks
By default: Unregisters
this monkey as an event handler for TEvent
s
and removes all HarmonyLib.Harmony patches done
using this Monkey's Harmony instance,
if not exiting, and returns true
.