1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 23:27:45 +00:00

simplify action interface naming slightly - drops on prefix from vfuncs

This commit is contained in:
NotAdam 2019-03-07 20:33:14 +11:00
parent 9d6622b522
commit fc62be84a2
6 changed files with 25 additions and 22 deletions

View file

@ -145,7 +145,7 @@ bool Sapphire::Action::Action::update()
if( isInterrupted() ) if( isInterrupted() )
{ {
onInterrupt(); interrupt();
return true; return true;
} }
@ -158,14 +158,14 @@ bool Sapphire::Action::Action::update()
if( !hasCastTime() || std::difftime( currTime, m_startTime ) > m_castTime ) if( !hasCastTime() || std::difftime( currTime, m_startTime ) > m_castTime )
{ {
onExecute(); execute();
return true; return true;
} }
return false; return false;
} }
void Sapphire::Action::Action::onStart() void Sapphire::Action::Action::start()
{ {
assert( m_pSource ); assert( m_pSource );
@ -196,7 +196,7 @@ void Sapphire::Action::Action::onStart()
if( !pScriptMgr->onStart( *this ) ) if( !pScriptMgr->onStart( *this ) )
{ {
// script not implemented // script not implemented
onInterrupt(); interrupt();
if( player ) if( player )
{ {
@ -209,10 +209,10 @@ void Sapphire::Action::Action::onStart()
// instantly finish cast if there's no cast time // instantly finish cast if there's no cast time
if( !hasCastTime() ) if( !hasCastTime() )
onExecute(); execute();
} }
void Sapphire::Action::Action::onInterrupt() void Sapphire::Action::Action::interrupt()
{ {
assert( m_pSource ); assert( m_pSource );
@ -249,7 +249,7 @@ void Sapphire::Action::Action::onInterrupt()
pScriptMgr->onInterrupt( *this ); pScriptMgr->onInterrupt( *this );
} }
void Sapphire::Action::Action::onExecute() void Sapphire::Action::Action::execute()
{ {
assert( m_pSource ); assert( m_pSource );

View file

@ -61,21 +61,24 @@ namespace Sapphire::Action
/*! /*!
* @brief Starts the cast. Finishes it immediately if there is no cast time (weaponskills). * @brief Starts the cast. Finishes it immediately if there is no cast time (weaponskills).
*/ */
virtual void onStart(); virtual void start();
/*! /*!
* @brief Finishes the cast, effected targets are calculated here. * @brief Finishes the cast, effected targets are calculated here.
*/ */
virtual void onExecute(); virtual void execute();
/*! /*!
* @brief Called when a cast is interrupted for any reason * @brief Called when a cast is interrupted for any reason
* *
* m_interruptType will have the reason why the action was interrupted (eg. damage, movement, ...) * m_interruptType will have the reason why the action was interrupted (eg. damage, movement, ...)
*/ */
virtual void onInterrupt(); virtual void interrupt();
// update action, if returns true, action is done and has to be removed from the actor /*!
* @brief Called on each player update tick
* @return true if a cast has finished and should be removed from the owning chara
*/
virtual bool update(); virtual bool update();
protected: protected:

View file

@ -35,7 +35,7 @@ Sapphire::Action::EventAction::EventAction( Entity::CharaPtr pActor, uint32_t ev
Sapphire::Action::EventAction::~EventAction() = default; Sapphire::Action::EventAction::~EventAction() = default;
void Sapphire::Action::EventAction::onStart() void Sapphire::Action::EventAction::start()
{ {
if( !m_pSource ) if( !m_pSource )
return; return;
@ -54,7 +54,7 @@ void Sapphire::Action::EventAction::onStart()
m_pSource->sendToInRangeSet( control ); m_pSource->sendToInRangeSet( control );
} }
void Sapphire::Action::EventAction::onExecute() void Sapphire::Action::EventAction::execute()
{ {
if( !m_pSource ) if( !m_pSource )
return; return;
@ -90,7 +90,7 @@ void Sapphire::Action::EventAction::onExecute()
} }
void Sapphire::Action::EventAction::onInterrupt() void Sapphire::Action::EventAction::interrupt()
{ {
if( !m_pSource ) if( !m_pSource )
return; return;

View file

@ -18,11 +18,11 @@ public:
EventAction( Entity::CharaPtr pActor, uint32_t eventId, uint16_t action, EventAction( Entity::CharaPtr pActor, uint32_t eventId, uint16_t action,
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional, FrameworkPtr pFw ); ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional, FrameworkPtr pFw );
void onStart() override; void start() override;
void onExecute() override; void execute() override;
void onInterrupt() override; void interrupt() override;
private: private:
uint32_t m_eventId; uint32_t m_eventId;

View file

@ -303,7 +303,7 @@ void Sapphire::Entity::Player::eventActionStart( uint32_t eventId,
pEvent->setPlayedScene( true ); pEvent->setPlayedScene( true );
setCurrentAction( pEventAction ); setCurrentAction( pEventAction );
pEventAction->onStart(); pEventAction->start();
} }

View file

@ -29,7 +29,7 @@ void World::Manager::ActionMgr::handleAoEPlayerAction( Entity::Player& player, u
if( !actionData->targetArea ) if( !actionData->targetArea )
{ {
// not an action that has an aoe, cancel it // not an action that has an aoe, cancel it
action->onInterrupt(); action->interrupt();
return; return;
} }
@ -44,7 +44,7 @@ void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& play
// cancel any aoe actions casted with this packet // cancel any aoe actions casted with this packet
if( actionData->targetArea ) if( actionData->targetArea )
{ {
action->onInterrupt(); action->interrupt();
return; return;
} }
@ -102,7 +102,7 @@ void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
if( !currentAction->precheck() ) if( !currentAction->precheck() )
{ {
// forcefully interrupt the action and reset the cooldown // forcefully interrupt the action and reset the cooldown
currentAction->onInterrupt(); currentAction->interrupt();
return; return;
} }
@ -113,7 +113,7 @@ void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
} }
// todo: what do in cases of swiftcast/etc? script callback? // todo: what do in cases of swiftcast/etc? script callback?
currentAction->onStart(); currentAction->start();
} }
void World::Manager::ActionMgr::handleItemActionVFX( Sapphire::Entity::Player& player, uint32_t itemId, uint16_t vfxId ) void World::Manager::ActionMgr::handleItemActionVFX( Sapphire::Entity::Player& player, uint32_t itemId, uint16_t vfxId )