1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00
sapphire/src/world/Script/ScriptMgr.h

120 lines
4 KiB
C
Raw Normal View History

#ifndef _ScriptMgr_H_
#define _ScriptMgr_H_
2017-08-18 17:29:36 +02:00
2018-10-25 12:44:51 +11:00
#include <memory>
2017-08-18 17:29:36 +02:00
#include <mutex>
#include <set>
2018-03-06 22:22:19 +01:00
#include <Common.h>
#include "Forwards.h"
2017-08-18 17:29:36 +02:00
namespace Sapphire::Scripting
2017-08-18 17:29:36 +02:00
{
2020-03-01 01:00:57 +11:00
class ScriptMgr
2018-10-28 21:53:21 +01:00
{
private:
/*!
* @brief A shared ptr to NativeScriptMgr, used for accessing and managing the native script system.
*/
std::shared_ptr< NativeScriptMgr > m_nativeScriptMgr;
2018-10-28 21:53:21 +01:00
std::function< std::string( Entity::Player & ) > m_onFirstEnterWorld;
2018-10-28 21:53:21 +01:00
/*!
* @brief 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.
*/
bool m_firstScriptChangeNotificiation;
2018-10-28 21:53:21 +01:00
public:
2020-03-01 01:00:57 +11:00
ScriptMgr();
2018-10-28 21:53:21 +01:00
~ScriptMgr();
2018-10-28 21:53:21 +01: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
*/
bool init();
2018-10-28 21:53:21 +01:00
/*!
* @brief Called on each tick or at a regular interval. Allows for the NativeScriptMgr to process module loading and reloading.
*/
void update();
2018-10-28 21:53:21 +01:00
/*!
* @brief Registers a directory watcher which allows for script modules to be reloaded when changes to the modules occur
*/
void watchDirectories();
2018-10-28 21:53:21 +01:00
void onPlayerFirstEnterWorld( Entity::Player& player );
2018-10-28 21:53:21 +01:00
bool onTalk( Entity::Player& player, uint64_t actorId, uint32_t eventId );
2018-10-28 21:53:21 +01:00
bool onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 );
2018-10-28 21:53:21 +01:00
bool onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
2018-10-28 21:53:21 +01:00
bool onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
2018-10-28 21:53:21 +01:00
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, uint64_t targetId );
bool onBNpcKill( Entity::Player& player, uint16_t nameId );
bool onEObjHit( Entity::Player& player, uint64_t actorId, uint32_t actionId );
2019-02-10 22:13:47 +11:00
bool onStart( World::Action::Action& action );
bool onInterrupt( World::Action::Action& action );
bool onExecute( World::Action::Action& action );
2018-10-28 21:53:21 +01:00
bool onStatusReceive( Entity::CharaPtr pActor, uint32_t effectId );
bool onStatusTick( Entity::CharaPtr pActor, Sapphire::StatusEffect::StatusEffect& effect );
2018-10-28 21:53:21 +01:00
bool onStatusTimeOut( Entity::CharaPtr pActor, uint32_t effectId );
bool onZoneInit( const Territory& zone );
2018-10-28 21:53:21 +01:00
bool onEventHandlerReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param1,
uint16_t param2, uint16_t param3 );
2018-10-28 21:53:21 +01:00
bool onEventHandlerTradeReturn( Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
uint32_t catalogId );
bool onInstanceInit( InstanceContent& instance );
bool onInstanceUpdate( InstanceContent& instance, uint64_t tickCount );
2018-10-28 21:53:21 +01:00
bool
onInstanceEnterTerritory( InstanceContent& instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
2018-10-28 21:53:21 +01:00
uint16_t param2 );
bool onPlayerSetup( QuestBattle& instance, Entity::Player& player );
bool onInstanceInit( QuestBattle& instance );
2019-03-31 11:27:11 +02:00
bool onInstanceUpdate( QuestBattle& instance, uint64_t tickCount );
2019-03-31 11:27:11 +02:00
bool onDutyCommence( QuestBattle& instance, Entity::Player& player );
bool onInstanceEnterTerritory( QuestBattle& instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
2019-03-31 11:27:11 +02:00
uint16_t param2 );
bool onDutyComplete( QuestBattle& instance, Entity::Player& player );
2018-10-28 21:53:21 +01:00
bool loadDir( const std::string& dirname, std::set< std::string >& files, const std::string& ext );
NativeScriptMgr& getNativeScriptHandler();
};
2017-08-18 17:29:36 +02:00
}
#endif