mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 14:37:25 +00:00
b261e63233
* chore: Change entity and component logic to use bitstream references * merge
34 lines
915 B
C++
34 lines
915 B
C++
#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);
|
|
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
|
|
|
if (entity == nullptr || target == nullptr) {
|
|
return;
|
|
}
|
|
|
|
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() {
|
|
}
|