Table of Contents

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

string

Name

The name of the plugin.

string Name { get; }

Property Value

string

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 string

The 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 Entity

The entity doing the action

action ActionInfo

The 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 Entity

The entity doing the animation

animationId AnimationId

The id of the animation to be executed

startFrame float

The starting frame of the animation

interFrame float

The 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 Entity

The entity whos animation component is updated

currentAnimation AnimationId

The current active animation

deltaTime float

The 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 int

The 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

monster Monster

The monster doing the action

actionId int

The id of the action to be executed

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 Monster

The 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 Monster

The monster that died

OnMonsterDestroy(Monster)

Gets called when a monster is destroyed (its destructor is called).

void OnMonsterDestroy(Monster monster)

Parameters

monster Monster

The monster that is about to be destroyed

OnMonsterEnrage(Monster)

Gets called when a monster gets enraged.

void OnMonsterEnrage(Monster monster)

Parameters

monster Monster

The monster getting enraged

OnMonsterFlinch(Monster, ref int)

Gets called when a monster gets flinched.

bool OnMonsterFlinch(Monster monster, ref int actionId)

Parameters

monster Monster

The monster getting flinched

actionId int

The flinch action it will perform

Returns

bool

False to cancel the flinch

OnMonsterInitialized(Monster)

Gets called after a monster is initialized.

void OnMonsterInitialized(Monster monster)

Parameters

monster Monster

The 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 Monster

The 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 Player

The player doing the action

action ActionInfo

The 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 int

The id of the quest

OnQuestAccept(int)

Gets called when a quest is accepted on the quest board.

void OnQuestAccept(int questId)

Parameters

questId int

The id of the quest

OnQuestCancel(int)

Gets called when a quest is cancelled on the quest board.

void OnQuestCancel(int questId)

Parameters

questId int

The id of the quest

OnQuestComplete(int)

Gets called when a quest is completed.

void OnQuestComplete(int questId)

Parameters

questId int

The id of the quest

OnQuestDepart(int)

Gets called when the player departs on a quest.

void OnQuestDepart(int questId)

Parameters

questId int

The id of the quest

OnQuestEnter(int)

Gets called when the player arrives in the quest area.

void OnQuestEnter(int questId)

Parameters

questId int

The id of the quest

OnQuestFail(int)

Gets called when a quest is failed.

void OnQuestFail(int questId)

Parameters

questId int

The id of the quest

OnQuestLeave(int)

Gets called when the player leaves the quest area.

void OnQuestLeave(int questId)

Parameters

questId int

The id of the quest

OnQuestReturn(int)

Gets called when the player selects "Return from Quest" in the menu.

void OnQuestReturn(int questId)

Parameters

questId int

The 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 uint

The id of the packet

type PacketType

The type of the packet

sourceSession SessionIndex

The session the packet was sent from

data NetBuffer

The 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 Resource

The loaded resource, or null if the request failed

dti MtDti

The DTI of the resource

path string

The file path of the resource, without its extension

flags LoadFlags

The 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 int

The 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 Packet

The packet being sent

isBroadcast bool

Whether the packet is broadcasted to all players in the session or not

session SessionIndex

The 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 float

The 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 Player

The player changing weapons

weaponType WeaponType

The new weapon type

weaponId int

The 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()