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.h

98 lines
2.1 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef _ACTION_H_
#define _ACTION_H_
2018-03-06 22:22:19 +01:00
#include <Common.h>
#include "ForwardsZone.h"
2017-08-08 13:53:47 +02:00
namespace Sapphire::Data
{
struct Action;
using ActionPtr = std::shared_ptr< Action >;
}
namespace Sapphire::Action
{
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
class Action
{
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
public:
Action();
Action( Entity::CharaPtr caster, uint32_t actionId, Data::ActionPtr action, FrameworkPtr fw );
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
virtual ~Action();
2017-08-08 13:53:47 +02:00
uint32_t getId() const;
2017-08-08 13:53:47 +02:00
Common::HandleActionType getType() const;
void setType( Common::HandleActionType type );
void setTargetChara( Entity::CharaPtr chara );
2018-10-28 21:53:21 +01:00
Entity::CharaPtr getTargetChara() const;
Entity::CharaPtr getActionSource() const;
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
bool isInterrupted() const;
void setInterrupted();
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
uint32_t getCastTime() const;
void setCastTime( uint32_t castTime );
2017-08-08 13:53:47 +02:00
/*!
* @brief Tests whether the action is instantly usable or has a cast assoc'd with it
* @return true if action has a cast time
*/
bool isCastedAction() const;
2017-08-08 13:53:47 +02:00
void start();
2017-08-08 13:53:47 +02:00
2019-02-09 17:36:44 +11:00
void buildEffectPacket();
void damageTarget( uint32_t amount, Entity::Chara& chara, Common::ActionAspect aspect = Common::ActionAspect::Unaspected );
void healTarget( uint32_t amount, Entity::Chara& chara );
virtual void onStart();
virtual void onFinish();
virtual void onInterrupt();
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
// update action, if returns true, action is done and has to be removed from the actor
virtual bool update();
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
protected:
2019-02-09 17:36:44 +11:00
/*!
* @brief Some actions are capable of both healing and dealing damage. This identifies them.
*/
enum EffectPacketIdentity : uint8_t
{
DamageEffect,
HealingEffect,
MAX_ACTION_EFFECT_PACKET_IDENT
};
struct EffectPacketData
{
std::vector< Common::EffectEntry > m_entries;
std::vector< uint32_t > m_hitActors;
};
uint32_t m_id;
Common::HandleActionType m_type;
2018-10-28 21:53:21 +01:00
uint64_t m_startTime;
uint32_t m_castTime;
2018-10-28 21:53:21 +01:00
Entity::CharaPtr m_pSource;
Entity::CharaPtr m_pTarget;
uint64_t m_targetId;
2018-10-28 21:53:21 +01:00
bool m_bInterrupt;
2017-08-08 13:53:47 +02:00
FrameworkPtr m_pFw;
2019-02-09 17:36:44 +11:00
std::array< EffectPacketData, MAX_ACTION_EFFECT_PACKET_IDENT > m_effects;
2018-10-28 21:53:21 +01:00
};
2017-08-08 13:53:47 +02:00
}
#endif