mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 14:07:20 +00:00
84c5d74450
* moving branch
* Add deleteinven slash command
* Change name of BRICKS_IN_BBB
* Use string_view instead of strcmp
* Remove GameConfig
* Revert "Remove GameConfig"
This reverts commit cef5cdeea2
.
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#include "OverTimeBehavior.h"
|
|
#include "BehaviorBranchContext.h"
|
|
#include "BehaviorContext.h"
|
|
#include "Game.h"
|
|
#include "dLogger.h"
|
|
#include "EntityManager.h"
|
|
#include "SkillComponent.h"
|
|
#include "DestroyableComponent.h"
|
|
#include "CDClientDatabase.h"
|
|
#include "CDClientManager.h"
|
|
|
|
void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
const auto originator = context->originator;
|
|
|
|
auto* entity = EntityManager::Instance()->GetEntity(originator);
|
|
|
|
if (entity == nullptr) return;
|
|
|
|
for (size_t i = 0; i < m_NumIntervals; i++) {
|
|
entity->AddCallbackTimer((i + 1) * m_Delay, [originator, branch, this]() {
|
|
auto* entity = EntityManager::Instance()->GetEntity(originator);
|
|
|
|
if (entity == nullptr) return;
|
|
|
|
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
|
|
|
if (skillComponent == nullptr) return;
|
|
|
|
skillComponent->CalculateBehavior(m_Action, m_ActionBehaviorId, branch.target, true, true);
|
|
});
|
|
}
|
|
}
|
|
|
|
void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
|
|
}
|
|
|
|
void OverTimeBehavior::Load() {
|
|
m_Action = GetInt("action");
|
|
// Since m_Action is a skillID and not a behavior, get is correlated behaviorID.
|
|
|
|
CDSkillBehaviorTable* skillTable = CDClientManager::Instance()->GetTable<CDSkillBehaviorTable>("SkillBehavior");
|
|
m_ActionBehaviorId = skillTable->GetSkillByID(m_Action).behaviorID;
|
|
|
|
m_Delay = GetFloat("delay");
|
|
m_NumIntervals = GetInt("num_intervals");
|
|
}
|