# EventManager

# Description

The EventManager namespace provides a series of event handling functions, allowing you to register and remove callback functions for various game events. Through these events, you can execute custom code at specific moments in the game.

# How to Use

#include "Noble.h"

void OnGameUpdateCallback()
{
    // Code executed on each game frame update
    Console::Add("Game update");
}

void OnLoadCallback()
{
    // Register game update event
    EventManager::OnGameUpdate::Add(&OnGameUpdateCallback);
}

// Register OnLoad event during plugin initialization
EventManager::OnLoad::Add(&OnLoadCallback);

# OnLoad.Add

void EventManager::OnLoad::Add(void* function)

Registers a callback function to be called when the plugin is loaded.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnLoad()
void OnLoadCallback() 
{
    Console::Add("Plugin loaded");
}

EventManager::OnLoad::Add(&OnLoadCallback);

# OnLoad.Remove

void EventManager::OnLoad::Remove(void* function)

Removes a previously registered OnLoad callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnLoad::Remove(&OnLoadCallback);

# OnUnLoad.Add

void EventManager::OnUnLoad::Add(void* function)

Registers a callback function to be called when the plugin is unloaded.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnUnLoad()
void OnUnLoadCallback() 
{
    Console::Add("Plugin unloaded");
}

EventManager::OnUnLoad::Add(&OnUnLoadCallback);

# OnUnLoad.Remove

void EventManager::OnUnLoad::Remove(void* function)

Removes a previously registered OnUnLoad callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnUnLoad::Remove(&OnUnLoadCallback);

# OnGameUpdate.Add

void EventManager::OnGameUpdate::Add(void* function)

Registers a callback function to be called on each game frame update.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnGameUpdate()
void OnGameUpdateCallback() 
{
    // Code executed every frame
}

EventManager::OnGameUpdate::Add(&OnGameUpdateCallback);

# OnGameUpdate.Remove

void EventManager::OnGameUpdate::Remove(void* function)

Removes a previously registered OnGameUpdate callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnGameUpdate::Remove(&OnGameUpdateCallback);

# OnRender.Add

void EventManager::OnRender::Add(void* function)

Registers a callback function to be called during game rendering.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnRender()
void OnRenderCallback() 
{
    // Draw custom graphics
    Drawing::DrawText(Vector(100, 100), 20, MAKE_COLOR(255, 0, 0, 255), "Hello World");
}

EventManager::OnRender::Add(&OnRenderCallback);

# OnRender.Remove

void EventManager::OnRender::Remove(void* function)

Removes a previously registered OnRender callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnRender::Remove(&OnRenderCallback);

# OnWndProc.Add

void EventManager::OnWndProc::Add(void* function)

Registers a callback function to handle Windows messages.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnWndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
void OnWndProcCallback(UINT uMsg, WPARAM wParam, LPARAM lParam) 
{
    // Handle Windows messages
    if (uMsg == WM_KEYDOWN && wParam == VK_SPACE)
    {
        Console::Add("Space key pressed");
    }
}

EventManager::OnWndProc::Add(&OnWndProcCallback);

# OnWndProc.Remove

void EventManager::OnWndProc::Remove(void* function)

Removes a previously registered OnWndProc callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnWndProc::Remove(&OnWndProcCallback);

# OnCreateObject.Add

void EventManager::OnCreateObject::Add(void* function)

Registers a callback function to be called when a game object is created.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnCreateObject(GameObject* sender)
void OnCreateObjectCallback(GameObject* sender) 
{
    // Handle newly created game object
    if (sender->IsAIHero() && sender->IsEnemy())
    {
        Console::Add("Enemy hero created: %s", sender->Name());
    }
}

EventManager::OnCreateObject::Add(&OnCreateObjectCallback);

# OnCreateObject.Remove

void EventManager::OnCreateObject::Remove(void* function)

Removes a previously registered OnCreateObject callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnCreateObject::Remove(&OnCreateObjectCallback);

# OnDeleteObject.Add

void EventManager::OnDeleteObject::Add(void* function)

Registers a callback function to be called when a game object is deleted.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnDeleteObject(GameObject* sender)
void OnDeleteObjectCallback(GameObject* sender) 
{
    // Handle deleted game object
    if (sender->IsAIHero())
    {
        Console::Add("Hero deleted: %s", sender->Name());
    }
}

EventManager::OnDeleteObject::Add(&OnDeleteObjectCallback);

# OnDeleteObject.Remove

void EventManager::OnDeleteObject::Remove(void* function)

Removes a previously registered OnDeleteObject callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnDeleteObject::Remove(&OnDeleteObjectCallback);

# OnProcessSpellCast.Add

void EventManager::OnProcessSpellCast::Add(void* function)

Registers a callback function to be called when a spell cast begins.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnProcessSpellCast(Spellbook* args)
void OnProcessSpellCastCallback(Spellbook* args) 
{
    // Handle spell cast event
    if (args->Sender()->IsEnemy() && args->Sender()->IsAIHero())
    {
        Console::Add("Enemy casting spell: %s", args->SData()->Name());
    }
}

EventManager::OnProcessSpellCast::Add(&OnProcessSpellCastCallback);

# OnProcessSpellCast.Remove

void EventManager::OnProcessSpellCast::Remove(void* function)

Removes a previously registered OnProcessSpellCast callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnProcessSpellCast::Remove(&OnProcessSpellCastCallback);

# OnDoCast.Add

void EventManager::OnDoCast::Add(void* function)

Registers a callback function to be called when a spell cast is completed.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnDoCast(Spellbook* args)
void OnDoCastCallback(Spellbook* args) 
{
    // Handle spell cast completion event
    if (args->Sender()->IsMe())
    {
        Console::Add("I finished casting: %s", args->SData()->Name());
    }
}

EventManager::OnDoCast::Add(&OnDoCastCallback);

# OnDoCast.Remove

void EventManager::OnDoCast::Remove(void* function)

Removes a previously registered OnDoCast callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnDoCast::Remove(&OnDoCastCallback);

# OnStopCast.Add

void EventManager::OnStopCast::Add(void* function)

Registers a callback function to be called when a spell cast is interrupted.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnStopCast(AIBaseClient* sender)
void OnStopCastCallback(AIBaseClient* sender) 
{
    // Handle spell cast interruption event
    if (sender->IsMe())
    {
        Console::Add("My spell cast was interrupted");
    }
}

EventManager::OnStopCast::Add(&OnStopCastCallback);

# OnStopCast.Remove

void EventManager::OnStopCast::Remove(void* function)

Removes a previously registered OnStopCast callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnStopCast::Remove(&OnStopCastCallback);

# OnNewPath.Add

void EventManager::OnNewPath::Add(void* function)

Registers a callback function to be called when a unit gets a new path.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnNewPath(AIBaseClient* sender, std::vector<Vector> const& path, bool IsDash, float dashSpeed)
void OnNewPathCallback(AIBaseClient* sender, std::vector<Vector> const& path, bool IsDash, float dashSpeed) 
{
    // Handle new path event
    if (sender->IsEnemy() && sender->IsAIHero() && IsDash)
    {
        Console::Add("Enemy hero dashing with speed: %f", dashSpeed);
    }
}

EventManager::OnNewPath::Add(&OnNewPathCallback);

# OnNewPath.Remove

void EventManager::OnNewPath::Remove(void* function)

Removes a previously registered OnNewPath callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnNewPath::Remove(&OnNewPathCallback);

# OnIssueOrder.Add

void EventManager::OnIssueOrder::Add(void* function)

Registers a callback function to be called when a movement or attack command is issued.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnIssueOrder(eGameObjectOrder Order, AIBaseClient* m_target, Vector const& TargetPosition, bool& Process)
void OnIssueOrderCallback(eGameObjectOrder Order, AIBaseClient* m_target, Vector const& TargetPosition, bool& Process) 
{
    // Handle command issuing event
    if (Order == eGameObjectOrder::AttackUnit && m_target && m_target->IsAIHero())
    {
        Console::Add("Attacking enemy hero");
    }
}

EventManager::OnIssueOrder::Add(&OnIssueOrderCallback);

# OnIssueOrder.Remove

void EventManager::OnIssueOrder::Remove(void* function)

Removes a previously registered OnIssueOrder callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnIssueOrder::Remove(&OnIssueOrderCallback);

# OnCastSpell.Add

void EventManager::OnCastSpell::Add(void* function)

Registers a callback function to be called when a spell is cast through the API (Note: Only valid for internal Noble requests, manual spell casts by the user won't trigger this event).

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnCastSpell(eSpellSlot Slot, AIBaseClient* Target, Vector const& StartPosition, Vector const& EndPosition, bool& Process)
void OnCastSpellCallback(eSpellSlot Slot, AIBaseClient* Target, Vector const& StartPosition, Vector const& EndPosition, bool& Process) 
{
    // Handle spell casting event
    if (Slot == eSpellSlot::R && Target && Target->IsEnemy() && Target->IsAIHero())
    {
        Console::Add("Casting ultimate on enemy hero");
    }
}

EventManager::OnCastSpell::Add(&OnCastSpellCallback);

# OnCastSpell.Remove

void EventManager::OnCastSpell::Remove(void* function)

Removes a previously registered OnCastSpell callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnCastSpell::Remove(&OnCastSpellCallback);

# OnMinionProcessSpellCast.Add

void EventManager::OnMinionProcessSpellCast::Add(void* function)

Registers a callback function to be called when a minion begins casting a spell.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnMinionProcessSpellCast(AIBaseClient* sender, AIBaseClient* Target, float MissileSpeed)
void OnMinionProcessSpellCastCallback(AIBaseClient* sender, AIBaseClient* Target, float MissileSpeed) 
{
    // Handle minion spell cast event
    if (sender->IsMinion() && Target && Target->IsMe())
    {
        Console::Add("Minion attacking me with missile speed: %f", MissileSpeed);
    }
}

EventManager::OnMinionProcessSpellCast::Add(&OnMinionProcessSpellCastCallback);

# OnMinionProcessSpellCast.Remove

void EventManager::OnMinionProcessSpellCast::Remove(void* function)

Removes a previously registered OnMinionProcessSpellCast callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnMinionProcessSpellCast::Remove(&OnMinionProcessSpellCastCallback);

# OnMinionOnDoCast.Add

void EventManager::OnMinionOnDoCast::Add(void* function)

Registers a callback function to be called when a minion completes casting a spell.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnMinionOnDoCast(AIBaseClient* sender)
void OnMinionOnDoCastCallback(AIBaseClient* sender) 
{
    // Handle minion spell cast completion event
    if (sender->IsMinion())
    {
        Console::Add("Minion finished casting");
    }
}

EventManager::OnMinionOnDoCast::Add(&OnMinionOnDoCastCallback);

# OnMinionOnDoCast.Remove

void EventManager::OnMinionOnDoCast::Remove(void* function)

Removes a previously registered OnMinionOnDoCast callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnMinionOnDoCast::Remove(&OnMinionOnDoCastCallback);

# OnMinionOnStopCast.Add

void EventManager::OnMinionOnStopCast::Add(void* function)

Registers a callback function to be called when a minion interrupts casting a spell.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnMinionOnStopCast(AIBaseClient* sender)
void OnMinionOnStopCastCallback(AIBaseClient* sender) 
{
    // Handle minion spell cast interruption event
    if (sender->IsMinion())
    {
        Console::Add("Minion stopped casting");
    }
}

EventManager::OnMinionOnStopCast::Add(&OnMinionOnStopCastCallback);

# OnMinionOnStopCast.Remove

void EventManager::OnMinionOnStopCast::Remove(void* function)

Removes a previously registered OnMinionOnStopCast callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnMinionOnStopCast::Remove(&OnMinionOnStopCastCallback);

# OnAttackDelay.Add

void EventManager::OnAttackDelay::Add(void* function)

Registers a callback function to be called when attack delay is calculated.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnAttackDelay(bool& Process, AIBaseClient* lastTarget, int LastAAFinishTick)
void OnAttackDelayCallback(bool& Process, AIBaseClient* lastTarget, int LastAAFinishTick) 
{
    // Handle attack delay event
    if (lastTarget && lastTarget->IsEnemy() && lastTarget->IsAIHero())
    {
        Console::Add("Attack delay on enemy hero");
    }
}

EventManager::OnAttackDelay::Add(&OnAttackDelayCallback);

# OnAttackDelay.Remove

void EventManager::OnAttackDelay::Remove(void* function)

Removes a previously registered OnAttackDelay callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnAttackDelay::Remove(&OnAttackDelayCallback);

# AfterAttack.Add

void EventManager::AfterAttack::Add(void* function)

Registers a callback function to be called after an attack is completed.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void AfterAttack(AIBaseClient* target)
void AfterAttackCallback(AIBaseClient* target) 
{
    // Handle after attack event
    if (target && target->IsEnemy() && target->IsAIHero())
    {
        Console::Add("Finished attacking enemy hero");
    }
}

EventManager::AfterAttack::Add(&AfterAttackCallback);

# AfterAttack.Remove

void EventManager::AfterAttack::Remove(void* function)

Removes a previously registered AfterAttack callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::AfterAttack::Remove(&AfterAttackCallback);

# BeforeAttack.Add

void EventManager::BeforeAttack::Add(void* function)

Registers a callback function to be called before an attack begins.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void BeforeAttack(bool& Process, AIBaseClient* target)
void BeforeAttackCallback(bool& Process, AIBaseClient* target) 
{
    // Handle before attack event
    if (target && target->IsMinion() && target->Health() > 100)
    {
        // Cancel the attack
        Process = false;
    }
}

EventManager::BeforeAttack::Add(&BeforeAttackCallback);

# BeforeAttack.Remove

void EventManager::BeforeAttack::Remove(void* function)

Removes a previously registered BeforeAttack callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::BeforeAttack::Remove(&BeforeAttackCallback);

# OnAttack.Add

void EventManager::OnAttack::Add(void* function)

Registers a callback function to be called when an attack begins.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnAttack(AIBaseClient* target)
void OnAttackCallback(AIBaseClient* target) 
{
    // Handle attack begin event
    if (target && target->IsEnemy() && target->IsAIHero())
    {
        Console::Add("Started attacking enemy hero");
    }
}

EventManager::OnAttack::Add(&OnAttackCallback);

# OnAttack.Remove

void EventManager::OnAttack::Remove(void* function)

Removes a previously registered OnAttack callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnAttack::Remove(&OnAttackCallback);

# OnNonKillableMinion.Add

void EventManager::OnNonKillableMinion::Add(void* function)

Registers a callback function to be called when a minion cannot be killed.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnNonKillableMinion(AIBaseClient* minion)
void OnNonKillableMinionCallback(AIBaseClient* minion) 
{
    // Handle non-killable minion event
    if (minion && minion->IsMinion())
    {
        Console::Add("Cannot last hit minion with health: %f", minion->Health());
    }
}

EventManager::OnNonKillableMinion::Add(&OnNonKillableMinionCallback);

# OnNonKillableMinion.Remove

void EventManager::OnNonKillableMinion::Remove(void* function)

Removes a previously registered OnNonKillableMinion callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnNonKillableMinion::Remove(&OnNonKillableMinionCallback);

# OnTargetChange.Add

void EventManager::OnTargetChange::Add(void* function)

Registers a callback function to be called when the target changes.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnTargetChange(AIBaseClient* newTarget)
void OnTargetChangeCallback(AIBaseClient* newTarget) 
{
    // Handle target change event
    if (newTarget && newTarget->IsEnemy() && newTarget->IsAIHero())
    {
        Console::Add("Target changed to enemy hero: %s", newTarget->ChampionName());
    }
}

EventManager::OnTargetChange::Add(&OnTargetChangeCallback);

# OnTargetChange.Remove

void EventManager::OnTargetChange::Remove(void* function)

Removes a previously registered OnTargetChange callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnTargetChange::Remove(&OnTargetChangeCallback);

# OnEnemyGapcloser.Add

void EventManager::OnEnemyGapcloser::Add(void* function)

Registers a callback function to be called when an enemy uses a gap-closing ability.

Parameter Name Parameter Type Description
function void* Callback function pointer, function prototype is void OnEnemyGapcloser(AIBaseClient* sender, const ActiveGapcloser& args)
void OnEnemyGapcloserCallback(AIBaseClient* sender, const ActiveGapcloser& args) 
{
    // Handle enemy gap-closer event
    if (sender && sender->IsEnemy() && sender->IsAIHero())
    {
        Console::Add("Enemy gapclosing from %f,%f to %f,%f", 
            args.StartPosition.X, args.StartPosition.Z, 
            args.EndPosition.X, args.EndPosition.Z);
    }
}

EventManager::OnEnemyGapcloser::Add(&OnEnemyGapcloserCallback);

# OnEnemyGapcloser.Remove

void EventManager::OnEnemyGapcloser::Remove(void* function)

Removes a previously registered OnEnemyGapcloser callback function.

Parameter Name Parameter Type Description
function void* Previously registered callback function pointer
EventManager::OnEnemyGapcloser::Remove(&OnEnemyGapcloserCallback);