Implement flying command (#713)

* Implement flying command

* Add documentation.
This commit is contained in:
Jett
2022-08-06 09:19:34 +01:00
committed by GitHub
parent ea86988521
commit 6c97ea8208
4 changed files with 70 additions and 0 deletions

View File

@@ -3,16 +3,34 @@
#include "BehaviorBranchContext.h"
#include "GameMessages.h"
#include "Character.h"
void JetPackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
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);
if (entity->IsPlayer()) {
auto* character = entity->GetCharacter();
if (character) {
character->SetIsFlying(true);
}
}
}
void JetPackBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
GameMessages::SendSetJetPackMode(entity, false);
if (entity->IsPlayer()) {
auto* character = entity->GetCharacter();
if (character) {
character->SetIsFlying(false);
}
}
}
void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {