Plugin class structure – Helpful inherited members - TiberiumFusion/TTPlugins GitHub Wiki
← Back to the Plugin class structure article.
The HPlugin
base type provides several helpful members for you to use.
These are all instance members and thus are not available in your plugin's static
stub patch methods.
void
CreateHPatchOperation
(string targetTypeFullName, string targetMethodName, string stubMethodName, HPatchLocation patchLocation, int patchPriority = -1)
Method This is the most convenient overload of the method you must use to define HPatchOperation
s in your plugin. To learn about writing patch methods and defining patch operations, please refer to the Writing stub patch methods article.
Parameters:
targetTypeFullName
- The full name of theType
that contains the target method. For example,"Terraria.Player"
.targetMethodName
- The name of the target method that will be patched. For example,"UpdateEquips"
.stubMethodName
- The name of the stub patch method in the plugin class that will be patched onto the target method.patchLocation
- A value fromHPatchLocation
, eitherHPatchLocation.Prefix
,HPatchLocation.Postifx
, orHPatchLocation.Transpiler
. Determines whether your stub patch method will be applied as a prefix, postfix, or transpiler patch.
Example usage:
CreateHPatchOperation("Terraria.Player", "UpdateEquips", "MyPrefixPatch", HPatchLocation.Prefix); // MyPrefixPatch is a static method in the calling class
This method has several overloads. You can view them all here.
Assembly
PluginAssembly
Property Gets the Assembly
that contains your plugin class.
byte[]
GetPluginAssemblyResourceBytes
(string resourceName)
Method Gets the byte[]
that constitutes an embedded assembly resource from your plugin's PluginAssembly
property. This method is particularly useful under Security Level 3, which prohibits direct use of Stream
s.
Internally, this method uses GetManifestResourceStream()
.
Example usage:
byte[] pngBytes = GetPluginAssemblyResourceBytes("CoolTerrariaDude.Plugins.MyCoolWeapon.WeaponSprite.png");
TIP: For information on how to use embedded resources, please refer to the Embedding resources in your plugin article.
← Back to the Plugin class structure article.