2018-03-02 07:22:25 -03:00
|
|
|
#ifndef _ScriptMgr_H_
|
|
|
|
#define _ScriptMgr_H_
|
2017-08-18 17:29:36 +02:00
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#include <mutex>
|
|
|
|
#include <set>
|
|
|
|
|
2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Forwards.h"
|
2017-08-18 17:29:36 +02:00
|
|
|
|
|
|
|
namespace Core
|
|
|
|
{
|
|
|
|
namespace Scripting
|
|
|
|
{
|
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
class ScriptMgr
|
2017-08-18 17:29:36 +02:00
|
|
|
{
|
|
|
|
private:
|
2018-07-24 22:48:42 +10:00
|
|
|
/*!
|
|
|
|
* A shared ptr to NativeScriptMgr, used for accessing and managing the native script system.
|
|
|
|
*/
|
|
|
|
boost::shared_ptr< NativeScriptMgr > m_nativeScriptMgr;
|
2017-08-18 17:29:36 +02:00
|
|
|
|
|
|
|
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
|
|
|
|
|
2018-07-24 22:48:42 +10:00
|
|
|
/*!
|
|
|
|
* Used to ignore the first change notification that Watchdog emits.
|
|
|
|
* Because reasons, it likes to emit an initial notification with all the files that match the filter, we don't want that so we ignore it.
|
|
|
|
*/
|
2017-12-14 22:30:06 +11:00
|
|
|
bool m_firstScriptChangeNotificiation;
|
|
|
|
|
2017-08-18 17:29:36 +02:00
|
|
|
public:
|
2018-03-02 07:22:25 -03:00
|
|
|
ScriptMgr();
|
|
|
|
~ScriptMgr();
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-07-24 22:48:42 +10:00
|
|
|
/*!
|
|
|
|
* @brief Loads all the script modules and readies the ScriptMgr
|
|
|
|
*
|
|
|
|
* This gets all the modules inside the specified scripts folder and then attempts to load each one.
|
|
|
|
* After that, it starts the directory watcher so the server can reload modules at runtime when changes occur.
|
|
|
|
*
|
|
|
|
* @return true if init success
|
|
|
|
*/
|
2017-12-10 23:51:06 +11:00
|
|
|
bool init();
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-07-24 22:48:42 +10:00
|
|
|
/*!
|
|
|
|
* Called on each tick or at a regular interval. Allows for the NativeScriptMgr to process module loading and reloading.
|
|
|
|
*/
|
2017-12-14 22:30:06 +11:00
|
|
|
void update();
|
|
|
|
|
2018-07-24 22:48:42 +10:00
|
|
|
/*!
|
|
|
|
* Registers a directory watcher which allows for script modules to be reloaded when changes to the modules occur
|
|
|
|
*/
|
2017-12-14 22:30:06 +11:00
|
|
|
void watchDirectories();
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
void onPlayerFirstEnterWorld( Entity::Player& player );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
bool onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId );
|
|
|
|
bool onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
|
|
|
bool onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
|
|
|
bool onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
|
|
|
bool onEmote( Entity::Player& player, uint64_t actorId, uint32_t eventId, uint8_t emoteId );
|
|
|
|
bool onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime, uint64_t targetId );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
bool onMobKill( Entity::Player& player, uint16_t nameId );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-02-20 22:46:44 +01:00
|
|
|
bool onCastFinish( Entity::Player& pPlayer, Entity::CharaPtr pTarget, uint32_t actionId );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-02-20 22:46:44 +01:00
|
|
|
bool onStatusReceive( Entity::CharaPtr pActor, uint32_t effectId );
|
|
|
|
bool onStatusTick( Entity::CharaPtr pActor, Core::StatusEffect::StatusEffect& effect );
|
|
|
|
bool onStatusTimeOut( Entity::CharaPtr pActor, uint32_t effectId );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
|
|
|
bool onZoneInit( ZonePtr pZone );
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
bool onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1, uint16_t param2, uint16_t param3 );
|
|
|
|
bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param, uint32_t catalogId );
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2018-02-23 23:47:21 +01:00
|
|
|
bool onInstanceInit( InstanceContentPtr instance );
|
|
|
|
bool onInstanceUpdate( InstanceContentPtr instance, uint32_t currTime );
|
2018-03-05 22:10:14 +11:00
|
|
|
bool onInstanceEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-04-04 11:25:07 +10:00
|
|
|
bool loadDir( const std::string& dirname, std::set<std::string> &files, const std::string& ext );
|
2017-08-18 17:29:36 +02:00
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
NativeScriptMgr& getNativeScriptHandler();
|
2017-08-18 17:29:36 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|