DarkflameServer/dGame/dBehaviors/PullToPointBehavior.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
927 B
C++
Raw Normal View History

#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 = EntityManager::Instance()->GetEntity(context->originator);
2022-07-28 13:39:57 +00:00
auto* target = EntityManager::Instance()->GetEntity(branch.target);
if (entity == nullptr || target == nullptr) {
return;
}
2022-07-28 13:39:57 +00:00
auto* movement = target->GetComponent<MovementAIComponent>();
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);
}
void PullToPointBehavior::Load() {
}