mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 18:54:13 +00:00
format codebase
This commit is contained in:
@@ -8,23 +8,19 @@
|
||||
#include "DestroyableComponent.h"
|
||||
#include "RebuildComponent.h"
|
||||
|
||||
void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
||||
{
|
||||
void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
auto* origin = EntityManager::Instance()->GetEntity(context->originator);
|
||||
|
||||
if (origin == nullptr)
|
||||
{
|
||||
if (origin == nullptr) {
|
||||
Game::logger->Log("SpawnBehavior", "Failed to find self entity (%llu)!", context->originator);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (branch.isProjectile)
|
||||
{
|
||||
if (branch.isProjectile) {
|
||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
if (target != nullptr)
|
||||
{
|
||||
if (target != nullptr) {
|
||||
origin = target;
|
||||
}
|
||||
}
|
||||
@@ -42,11 +38,10 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
|
||||
auto* entity = EntityManager::Instance()->CreateEntity(
|
||||
info,
|
||||
nullptr,
|
||||
EntityManager::Instance()->GetEntity(context->originator)
|
||||
EntityManager::Instance()->GetEntity(context->originator)
|
||||
);
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
if (entity == nullptr) {
|
||||
Game::logger->Log("SpawnBehavior", "Failed to spawn entity (%i)!", this->m_lot);
|
||||
|
||||
return;
|
||||
@@ -57,39 +52,33 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
|
||||
// Unset the flag to reposition the player, this makes it harder to glitch out of the map
|
||||
auto* rebuildComponent = entity->GetComponent<RebuildComponent>();
|
||||
|
||||
if (rebuildComponent != nullptr)
|
||||
{
|
||||
if (rebuildComponent != nullptr) {
|
||||
rebuildComponent->SetRepositionPlayer(false);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(entity);
|
||||
|
||||
if (branch.duration > 0)
|
||||
{
|
||||
if (branch.duration > 0) {
|
||||
context->RegisterTimerBehavior(this, branch, entity->GetObjectID());
|
||||
}
|
||||
|
||||
if (branch.start != 0)
|
||||
{
|
||||
if (branch.start != 0) {
|
||||
context->RegisterEndBehavior(this, branch, entity->GetObjectID());
|
||||
}
|
||||
|
||||
entity->AddCallbackTimer(60, [entity] () {
|
||||
entity->AddCallbackTimer(60, [entity]() {
|
||||
entity->Smash();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void SpawnBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
||||
{
|
||||
void SpawnBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext branch, const LWOOBJID second)
|
||||
{
|
||||
void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext branch, const LWOOBJID second) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(second);
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
if (entity == nullptr) {
|
||||
Game::logger->Log("SpawnBehavior", "Failed to find spawned entity (%llu)!", second);
|
||||
|
||||
return;
|
||||
@@ -97,8 +86,7 @@ void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext
|
||||
|
||||
auto* destroyable = static_cast<DestroyableComponent*>(entity->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
||||
|
||||
if (destroyable == nullptr)
|
||||
{
|
||||
if (destroyable == nullptr) {
|
||||
entity->Smash(context->originator);
|
||||
|
||||
return;
|
||||
@@ -107,14 +95,12 @@ void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext
|
||||
destroyable->Smash(second);
|
||||
}
|
||||
|
||||
void SpawnBehavior::End(BehaviorContext* context, const BehaviorBranchContext branch, const LWOOBJID second)
|
||||
{
|
||||
void SpawnBehavior::End(BehaviorContext* context, const BehaviorBranchContext branch, const LWOOBJID second) {
|
||||
Timer(context, branch, second);
|
||||
}
|
||||
|
||||
|
||||
void SpawnBehavior::Load()
|
||||
{
|
||||
void SpawnBehavior::Load() {
|
||||
this->m_lot = GetInt("LOT_ID");
|
||||
this->m_Distance = GetFloat("distance");
|
||||
}
|
||||
|
Reference in New Issue
Block a user