mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-24 22:43:34 +00:00
455f9470a5
* Move EntityManager to Game namespace * move initialization to later Need to wait for dZoneManager to be initialized. * Fix bugs - Cannot delete from a RandomAccessIterator while in a range based for loop. Touchup zone manager initialize replace magic numbers with better named constants replace magic zonecontrol id with a more readable hex alternative condense stack variables move initializers closer to their use initialize entity manager with zone control change initialize timings If zone is not zero we expect to initialize the entity manager during zone manager initialization Add constexpr for zone control LOT * Add proper error handling * revert vanity changes * Update WorldServer.cpp * Update dZoneManager.cpp
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
#include "FallSpeedBehavior.h"
|
|
|
|
#include "ControllablePhysicsComponent.h"
|
|
#include "BehaviorContext.h"
|
|
#include "BehaviorBranchContext.h"
|
|
|
|
|
|
void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
// make sure required parameter has non-default value
|
|
if (m_PercentSlowed == 0.0f) return;
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
|
if (!target) return;
|
|
|
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
if (!controllablePhysicsComponent) return;
|
|
controllablePhysicsComponent->SetGravityScale(m_PercentSlowed);
|
|
Game::entityManager->SerializeEntity(target);
|
|
|
|
if (branch.duration > 0.0f) {
|
|
context->RegisterTimerBehavior(this, branch);
|
|
} else if (branch.start > 0) {
|
|
context->RegisterEndBehavior(this, branch);
|
|
}
|
|
}
|
|
|
|
void FallSpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
Handle(context, bitStream, branch);
|
|
}
|
|
|
|
void FallSpeedBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
|
End(context, branch, second);
|
|
}
|
|
|
|
void FallSpeedBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
|
End(context, branch, LWOOBJID_EMPTY);
|
|
}
|
|
|
|
void FallSpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
|
if (!target) return;
|
|
|
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
if (!controllablePhysicsComponent) return;
|
|
controllablePhysicsComponent->SetGravityScale(1);
|
|
Game::entityManager->SerializeEntity(target);
|
|
}
|
|
|
|
void FallSpeedBehavior::Load(){
|
|
m_PercentSlowed = GetFloat("percent_slowed");
|
|
}
|