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