DarkflameServer/dGame/dBehaviors/PullToPointBehavior.cpp

34 lines
915 B
C++
Raw Normal View History

2022-08-06 03:01:59 +00:00
#include "PullToPointBehavior.h"
#include "BehaviorContext.h"
#include "BehaviorBranchContext.h"
#include "EntityManager.h"
#include "MovementAIComponent.h"
void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
auto* entity = Game::entityManager->GetEntity(context->originator);
2022-07-28 13:39:57 +00:00
auto* target = Game::entityManager->GetEntity(branch.target);
2022-07-28 13:39:57 +00:00
if (entity == nullptr || target == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
auto* movement = target->GetComponent<MovementAIComponent>();
2022-07-28 13:39:57 +00:00
if (movement == nullptr) {
return;
}
const auto position = branch.isProjectile ? branch.referencePosition : entity->GetPosition();
movement->PullToPoint(position);
}
void PullToPointBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
Handle(context, bitStream, branch);
}
2022-07-28 13:39:57 +00:00
void PullToPointBehavior::Load() {
}