mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 17:49:10 +00:00
feat(Core/Scripts): Optimize LootScript (#18715)
* Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Update LootScript.h
This commit is contained in:
@@ -23,13 +23,16 @@ void ScriptMgr::OnLootMoney(Player* player, uint32 gold)
|
||||
{
|
||||
ASSERT(player);
|
||||
|
||||
ExecuteScript<LootScript>([&](LootScript* script)
|
||||
{
|
||||
script->OnLootMoney(player, gold);
|
||||
});
|
||||
CALL_ENABLED_HOOKS(LootScript, LOOTHOOK_ON_LOOT_MONEY, script->OnLootMoney(player, gold));
|
||||
}
|
||||
|
||||
LootScript::LootScript(const char* name) : ScriptObject(name)
|
||||
LootScript::LootScript(const char* name, std::vector<uint16> enabledHooks)
|
||||
: ScriptObject(name, LOOTHOOK_END)
|
||||
{
|
||||
ScriptRegistry<LootScript>::AddScript(this);
|
||||
// If empty - enable all available hooks.
|
||||
if (enabledHooks.empty())
|
||||
for (uint16 i = 0; i < LOOTHOOK_END; ++i)
|
||||
enabledHooks.emplace_back(i);
|
||||
|
||||
ScriptRegistry<LootScript>::AddScript(this, std::move(enabledHooks));
|
||||
}
|
||||
|
||||
@@ -19,11 +19,18 @@
|
||||
#define SCRIPT_OBJECT_LOOT_SCRIPT_H_
|
||||
|
||||
#include "ScriptObject.h"
|
||||
#include <vector>
|
||||
|
||||
enum LootHook
|
||||
{
|
||||
LOOTHOOK_ON_LOOT_MONEY,
|
||||
LOOTHOOK_END
|
||||
};
|
||||
|
||||
class LootScript : public ScriptObject
|
||||
{
|
||||
protected:
|
||||
LootScript(const char* name);
|
||||
LootScript(const char* name, std::vector<uint16> enabledHooks = std::vector<uint16>());
|
||||
|
||||
public:
|
||||
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
|
||||
|
||||
Reference in New Issue
Block a user