mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-15 04:38:21 +00:00
Hacky FallSpeedBehavior
This commit is contained in:
parent
22b2516107
commit
4e5b38d602
@ -58,6 +58,7 @@
|
|||||||
#include "SpeedBehavior.h"
|
#include "SpeedBehavior.h"
|
||||||
#include "DamageReductionBehavior.h"
|
#include "DamageReductionBehavior.h"
|
||||||
#include "JetPackBehavior.h"
|
#include "JetPackBehavior.h"
|
||||||
|
#include "FallSpeedBehavior.h"
|
||||||
|
|
||||||
//CDClient includes
|
//CDClient includes
|
||||||
#include "CDBehaviorParameterTable.h"
|
#include "CDBehaviorParameterTable.h"
|
||||||
@ -165,7 +166,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
|
|||||||
case BehaviorTemplates::BEHAVIOR_CAR_BOOST:
|
case BehaviorTemplates::BEHAVIOR_CAR_BOOST:
|
||||||
behavior = new CarBoostBehavior(behaviorId);
|
behavior = new CarBoostBehavior(behaviorId);
|
||||||
break;
|
break;
|
||||||
case BehaviorTemplates::BEHAVIOR_FALL_SPEED: break;
|
case BehaviorTemplates::BEHAVIOR_FALL_SPEED:
|
||||||
|
behavior = new FallSpeedBehavior(behaviorId);
|
||||||
|
break;
|
||||||
case BehaviorTemplates::BEHAVIOR_SHIELD: break;
|
case BehaviorTemplates::BEHAVIOR_SHIELD: break;
|
||||||
case BehaviorTemplates::BEHAVIOR_REPAIR_ARMOR:
|
case BehaviorTemplates::BEHAVIOR_REPAIR_ARMOR:
|
||||||
behavior = new RepairBehavior(behaviorId);
|
behavior = new RepairBehavior(behaviorId);
|
||||||
@ -174,7 +177,7 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
|
|||||||
behavior = new SpeedBehavior(behaviorId);
|
behavior = new SpeedBehavior(behaviorId);
|
||||||
break;
|
break;
|
||||||
case BehaviorTemplates::BEHAVIOR_DARK_INSPIRATION: break;
|
case BehaviorTemplates::BEHAVIOR_DARK_INSPIRATION: break;
|
||||||
case BehaviorTemplates::BEHAVIOR_LOOT_BUFF:
|
case BehaviorTemplates::BEHAVIOR_LOOT_BUFF:
|
||||||
behavior = new LootBuffBehavior(behaviorId);
|
behavior = new LootBuffBehavior(behaviorId);
|
||||||
break;
|
break;
|
||||||
case BehaviorTemplates::BEHAVIOR_VENTURE_VISION:
|
case BehaviorTemplates::BEHAVIOR_VENTURE_VISION:
|
||||||
|
88
dGame/dBehaviors/FallSpeedBehavior.cpp
Normal file
88
dGame/dBehaviors/FallSpeedBehavior.cpp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#include "FallSpeedBehavior.h"
|
||||||
|
|
||||||
|
#include "ControllablePhysicsComponent.h"
|
||||||
|
#include "BehaviorContext.h"
|
||||||
|
#include "BehaviorBranchContext.h"
|
||||||
|
|
||||||
|
|
||||||
|
void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
|
branch.target = context->caster;
|
||||||
|
|
||||||
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
|
if (!target) return;
|
||||||
|
|
||||||
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
|
if (!controllablePhysicsComponent) return;
|
||||||
|
|
||||||
|
const auto current = controllablePhysicsComponent->GetGravityScale();
|
||||||
|
|
||||||
|
controllablePhysicsComponent->SetGravityScale(m_PercentSlowed);
|
||||||
|
|
||||||
|
EntityManager::Instance()->SerializeEntity(target);
|
||||||
|
|
||||||
|
if (branch.duration > 0.0f) {
|
||||||
|
context->RegisterTimerBehavior(this, branch);
|
||||||
|
} else if (branch.start > 0) {
|
||||||
|
controllablePhysicsComponent->SetIgnoreMultipliers(true);
|
||||||
|
|
||||||
|
context->RegisterEndBehavior(this, branch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FallSpeedBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||||
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
|
if (!target) return;
|
||||||
|
|
||||||
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
|
if (!controllablePhysicsComponent) return;
|
||||||
|
|
||||||
|
const auto current = controllablePhysicsComponent->GetGravityScale();
|
||||||
|
|
||||||
|
controllablePhysicsComponent->SetGravityScale(m_PercentSlowed);
|
||||||
|
|
||||||
|
EntityManager::Instance()->SerializeEntity(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FallSpeedBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
|
if (!target) return;
|
||||||
|
|
||||||
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
|
if (!controllablePhysicsComponent) return;
|
||||||
|
|
||||||
|
// const auto current = controllablePhysicsComponent->GetGravityScale();
|
||||||
|
|
||||||
|
controllablePhysicsComponent->SetIgnoreMultipliers(false);
|
||||||
|
|
||||||
|
controllablePhysicsComponent->SetGravityScale(1);
|
||||||
|
|
||||||
|
EntityManager::Instance()->SerializeEntity(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FallSpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||||
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
|
if (!target) return;
|
||||||
|
|
||||||
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
|
if (!controllablePhysicsComponent) return;
|
||||||
|
|
||||||
|
// const auto current = controllablePhysicsComponent->GetGravityScale();
|
||||||
|
|
||||||
|
controllablePhysicsComponent->SetIgnoreMultipliers(false);
|
||||||
|
|
||||||
|
controllablePhysicsComponent->SetGravityScale(1);
|
||||||
|
|
||||||
|
EntityManager::Instance()->SerializeEntity(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FallSpeedBehavior::Load(){
|
||||||
|
m_PercentSlowed = GetFloat("percent_slowed");
|
||||||
|
}
|
25
dGame/dBehaviors/FallSpeedBehavior.h
Normal file
25
dGame/dBehaviors/FallSpeedBehavior.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Behavior.h"
|
||||||
|
|
||||||
|
class FallSpeedBehavior final : public Behavior
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inherited
|
||||||
|
*/
|
||||||
|
explicit FallSpeedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {}
|
||||||
|
|
||||||
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
|
void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override;
|
||||||
|
|
||||||
|
void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override;
|
||||||
|
|
||||||
|
void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override;
|
||||||
|
|
||||||
|
void Load() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
float m_PercentSlowed;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user