2022-01-24 22:02:56 +00:00
|
|
|
#include "JetPackBehavior.h"
|
|
|
|
|
|
|
|
#include "BehaviorBranchContext.h"
|
2023-01-07 07:15:27 +00:00
|
|
|
#include "ControllablePhysicsComponent.h"
|
2022-01-24 22:02:56 +00:00
|
|
|
#include "GameMessages.h"
|
|
|
|
|
2022-08-06 08:19:34 +00:00
|
|
|
#include "Character.h"
|
|
|
|
|
2022-01-24 22:02:56 +00:00
|
|
|
void JetPackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
|
|
|
|
2022-01-24 22:02:56 +00:00
|
|
|
GameMessages::SendSetJetPackMode(entity, true, this->m_BypassChecks, this->m_EnableHover, this->m_effectId, this->m_Airspeed, this->m_MaxAirspeed, this->m_VerticalVelocity, this->m_WarningEffectID);
|
2022-08-06 08:19:34 +00:00
|
|
|
|
|
|
|
if (entity->IsPlayer()) {
|
|
|
|
auto* character = entity->GetCharacter();
|
2023-01-07 07:15:27 +00:00
|
|
|
if (character) character->SetIsFlying(true);
|
2022-08-06 08:19:34 +00:00
|
|
|
}
|
2023-01-07 07:15:27 +00:00
|
|
|
|
|
|
|
auto controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
|
|
|
if (controllablePhysicsComponent) controllablePhysicsComponent->Ser
|
2022-01-24 22:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JetPackBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
2022-01-24 22:02:56 +00:00
|
|
|
|
|
|
|
GameMessages::SendSetJetPackMode(entity, false);
|
2022-08-06 08:19:34 +00:00
|
|
|
|
|
|
|
if (entity->IsPlayer()) {
|
|
|
|
auto* character = entity->GetCharacter();
|
2023-01-07 07:15:27 +00:00
|
|
|
if (character) character->SetIsFlying(false);
|
2022-08-06 08:19:34 +00:00
|
|
|
}
|
2022-01-24 22:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
2022-07-28 13:39:57 +00:00
|
|
|
Handle(context, bit_stream, branch);
|
2022-01-24 22:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JetPackBehavior::Load() {
|
2022-07-28 13:39:57 +00:00
|
|
|
this->m_WarningEffectID = GetInt("warning_effect_id");
|
|
|
|
this->m_Airspeed = GetFloat("airspeed");
|
|
|
|
this->m_MaxAirspeed = GetFloat("max_airspeed");
|
|
|
|
this->m_VerticalVelocity = GetFloat("vertical_velocity");
|
|
|
|
this->m_EnableHover = GetBoolean("enable_hover");
|
|
|
|
this->m_BypassChecks = GetBoolean("bypass_checks", true);
|
2022-01-24 22:02:56 +00:00
|
|
|
}
|