Interface IPlugin
- Namespace
- SharpPluginLoader.Core
- Assembly
- SharpPluginLoader.Core.dll
The base interface for all plugins. This is where you define the events that your plugin listens to.
public interface IPlugin
Properties
Author
The author of the plugin.
string Author { get; }
Property Value
Name
The name of the plugin.
string Name { get; }
Property Value
Methods
Initialize()
Gets called when the plugin is loaded. This is where you can optionally configure your plugin within the framework.
Default event, always called once per plugin [re]load.
PluginData Initialize()
Returns
- PluginData
The filled out PluginData
OnChatMessageSent(string)
Gets called when a chat message is sent (on the local side).
void OnChatMessageSent(string message)
Parameters
message
stringThe contents of the message
OnEntityAction(Entity, ref ActionInfo)
Gets called when any entity does an action.
void OnEntityAction(Entity entity, ref ActionInfo action)
Parameters
entity
EntityThe entity doing the action
action
ActionInfoThe action to be executed
Remarks
The action parameter can be modified to change the executed action
OnEntityAnimation(Entity, ref AnimationId, ref float, ref float)
Gets called when any entity does an animation.
void OnEntityAnimation(Entity entity, ref AnimationId animationId, ref float startFrame, ref float interFrame)
Parameters
entity
EntityThe entity doing the animation
animationId
AnimationIdThe id of the animation to be executed
startFrame
floatThe starting frame of the animation
interFrame
floatThe number of frames to use for interpolation between animations
Remarks
Both the animationId and the startFrame parameters can be modified to change the executed animation.
OnEntityAnimationUpdate(Entity, AnimationId, float)
Gets called when an entity's animation component is updated.
void OnEntityAnimationUpdate(Entity entity, AnimationId currentAnimation, float deltaTime)
Parameters
entity
EntityThe entity whos animation component is updated
currentAnimation
AnimationIdThe current active animation
deltaTime
floatThe time since the last time this entity's animation component was updated
OnImGuiFreeRender()
The user can use this function to render their own ImGui windows.
void OnImGuiFreeRender()
Remarks
Note: To render any ImGui widgets inside this function, you must create your own ImGui window.
OnImGuiRender()
The user can use this function to render ImGui widgets on the screen. Widgets rendered here will be inside the main SPL ImGui window.
void OnImGuiRender()
OnLoad()
Gets called after the game has initialized it's singletons. This is you initialize anything in your plugin that uses the game state (e.g. reading pointers, accessing singletons, etc).
Default event, always called once per plugin [re]load.
void OnLoad()
OnLobbySearch(ref int)
Gets called when the game is about to search for lobbies.
void OnLobbySearch(ref int maxResults)
Parameters
maxResults
intThe maximum number of results to return.
Remarks
To modify the lobby search, take a look at the Matchmaking class
OnMonsterAction(Monster, ref int)
Gets called when a monster does an action.
void OnMonsterAction(Monster monster, ref int actionId)
Parameters
Remarks
The actionId parameter can be modified to change the executed action
OnMonsterCreate(Monster)
Gets called when a monster is created.
void OnMonsterCreate(Monster monster)
Parameters
monster
MonsterThe monster being created
Remarks
This function is called immediately after the monsters constructor is run, most of its data is not yet initialized by this point.
OnMonsterDeath(Monster)
Gets called when a monster dies.
void OnMonsterDeath(Monster monster)
Parameters
monster
MonsterThe monster that died
OnMonsterDestroy(Monster)
Gets called when a monster is destroyed (its destructor is called).
void OnMonsterDestroy(Monster monster)
Parameters
monster
MonsterThe monster that is about to be destroyed
OnMonsterEnrage(Monster)
Gets called when a monster gets enraged.
void OnMonsterEnrage(Monster monster)
Parameters
monster
MonsterThe monster getting enraged
OnMonsterFlinch(Monster, ref int)
Gets called when a monster gets flinched.
bool OnMonsterFlinch(Monster monster, ref int actionId)
Parameters
Returns
- bool
False to cancel the flinch
OnMonsterInitialized(Monster)
Gets called after a monster is initialized.
void OnMonsterInitialized(Monster monster)
Parameters
monster
MonsterThe monster that was initialized
Remarks
Most data in the monster is ready to be used by this point.
OnMonsterUnenrage(Monster)
Gets called when a monster leaves its enraged state.
void OnMonsterUnenrage(Monster monster)
Parameters
monster
MonsterThe monster leaving its enraged state
OnPlayerAction(Player, ref ActionInfo)
Gets called when the player does an action.
void OnPlayerAction(Player player, ref ActionInfo action)
Parameters
player
PlayerThe player doing the action
action
ActionInfoThe action to be executed
Remarks
The action parameter can be modified to change the executed action
OnPreMain()
Called before any of the game's code runs (including static initializers). This is only used for special cases, and is not applicable to most plugins. This will NOT be called during hot-reloading.
void OnPreMain()
OnQuestAbandon(int)
Gets called when the player selects "Abandon Quest" in the menu.
void OnQuestAbandon(int questId)
Parameters
questId
intThe id of the quest
OnQuestAccept(int)
Gets called when a quest is accepted on the quest board.
void OnQuestAccept(int questId)
Parameters
questId
intThe id of the quest
OnQuestCancel(int)
Gets called when a quest is cancelled on the quest board.
void OnQuestCancel(int questId)
Parameters
questId
intThe id of the quest
OnQuestComplete(int)
Gets called when a quest is completed.
void OnQuestComplete(int questId)
Parameters
questId
intThe id of the quest
OnQuestDepart(int)
Gets called when the player departs on a quest.
void OnQuestDepart(int questId)
Parameters
questId
intThe id of the quest
OnQuestEnter(int)
Gets called when the player arrives in the quest area.
void OnQuestEnter(int questId)
Parameters
questId
intThe id of the quest
OnQuestFail(int)
Gets called when a quest is failed.
void OnQuestFail(int questId)
Parameters
questId
intThe id of the quest
OnQuestLeave(int)
Gets called when the player leaves the quest area.
void OnQuestLeave(int questId)
Parameters
questId
intThe id of the quest
OnQuestReturn(int)
Gets called when the player selects "Return from Quest" in the menu.
void OnQuestReturn(int questId)
Parameters
questId
intThe id of the quest
OnReceivePacket(uint, PacketType, SessionIndex, NetBuffer)
Gets called when a packet is received.
void OnReceivePacket(uint id, PacketType type, SessionIndex sourceSession, NetBuffer data)
Parameters
id
uintThe id of the packet
type
PacketTypeThe type of the packet
sourceSession
SessionIndexThe session the packet was sent from
data
NetBufferThe data of the packet
OnRender()
The user can use this function to render arbitrary things on the screen (after the game has rendered).
void OnRender()
OnResourceLoad(Resource?, MtDti, string, LoadFlags)
Gets called when a resource is requested/loaded.
void OnResourceLoad(Resource? resource, MtDti dti, string path, LoadFlags flags)
Parameters
resource
ResourceThe loaded resource, or null if the request failed
dti
MtDtiThe DTI of the resource
path
stringThe file path of the resource, without its extension
flags
LoadFlagsThe flags passed to the request
OnSave()
Gets called when the game is saved.
void OnSave()
OnSelectSaveSlot(int)
Gets called when the player selects a save slot.
void OnSelectSaveSlot(int slot)
Parameters
slot
intThe save slot that was selected
OnSendPacket(Packet, bool, SessionIndex)
Gets called when a packet is sent.
void OnSendPacket(Packet packet, bool isBroadcast, SessionIndex session)
Parameters
packet
PacketThe packet being sent
isBroadcast
boolWhether the packet is broadcasted to all players in the session or not
session
SessionIndexThe session the packet is sent to
OnUnload()
Gets called when the plugin is unloaded. This is where you can clean up any resources used by your plugin. For example, threads, file handles, etc.
void OnUnload()
Remarks
Note: IDisposable fields are automatically disposed when the plugin is unloaded.
OnUpdate(float)
Gets called every frame.
void OnUpdate(float deltaTime)
Parameters
deltaTime
floatThe time elapsed since the last time this function was called, in seconds
OnWeaponChange(Player, WeaponType, int)
Gets called when the player changes their weapon.
void OnWeaponChange(Player player, WeaponType weaponType, int weaponId)
Parameters
player
PlayerThe player changing weapons
weaponType
WeaponTypeThe new weapon type
weaponId
intThe new weapon id
Remarks
This function is called asynchronously.
OnWinMain()
Called after game's static initializers, but before WinMain. This is only for special cases, and is not applicable to most plugins. This will NOT be called during hot-reloading.
void OnWinMain()