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

86 lines
1.3 KiB
C++
Raw Normal View History

2017-08-08 13:53:47 +02:00
#include "Action.h"
2018-03-06 22:22:19 +01:00
#include <Util/Util.h>
2017-08-08 13:53:47 +02:00
Sapphire::Action::Action::Action()
2017-08-08 13:53:47 +02:00
{
}
Sapphire::Action::Action::~Action()
2017-08-08 13:53:47 +02:00
{
}
uint16_t Sapphire::Action::Action::getId() const
2017-08-08 13:53:47 +02:00
{
return m_id;
2017-08-08 13:53:47 +02:00
}
Sapphire::Common::HandleActionType Sapphire::Action::Action::getHandleActionType() const
2017-08-08 13:53:47 +02:00
{
return m_handleActionType;
2017-08-08 13:53:47 +02:00
}
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getTargetChara() const
2017-08-08 13:53:47 +02:00
{
return m_pTarget;
2017-08-08 13:53:47 +02:00
}
bool Sapphire::Action::Action::isInterrupted() const
2017-08-08 13:53:47 +02:00
{
return m_bInterrupt;
2017-08-08 13:53:47 +02:00
}
void Sapphire::Action::Action::setInterrupted()
2017-08-08 13:53:47 +02:00
{
m_bInterrupt = true;
2017-08-08 13:53:47 +02:00
}
uint64_t Sapphire::Action::Action::getStartTime() const
2017-08-08 13:53:47 +02:00
{
return m_startTime;
2017-08-08 13:53:47 +02:00
}
void Sapphire::Action::Action::setStartTime( uint64_t startTime )
2017-08-08 13:53:47 +02:00
{
m_startTime = startTime;
2017-08-08 13:53:47 +02:00
}
uint32_t Sapphire::Action::Action::getCastTime() const
2017-08-08 13:53:47 +02:00
{
return m_castTime;
2017-08-08 13:53:47 +02:00
}
void Sapphire::Action::Action::setCastTime( uint32_t castTime )
2017-08-08 13:53:47 +02:00
{
m_castTime = castTime;
2017-08-08 13:53:47 +02:00
}
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getActionSource() const
2017-08-08 13:53:47 +02:00
{
return m_pSource;
2017-08-08 13:53:47 +02:00
}
bool Sapphire::Action::Action::update()
2017-08-08 13:53:47 +02:00
{
// action has not been started yet
if( m_startTime == 0 )
return false;
if( m_bInterrupt )
{
onInterrupt();
return true;
}
uint64_t currTime = Util::getTimeMs();
if( ( currTime - m_startTime ) > m_castTime )
{
onFinish();
return true;
}
return false;
2017-08-08 13:53:47 +02:00
}