mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-21 06:48:11 +00:00
chore: Move ghosting functionality to component
Tested that ghosting still works and players are still firing off the OnPlayerLeave and relevant handlers.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "eGameMessageType.h"
|
||||
#include "ePlayerFlag.h"
|
||||
#include "dConfig.h"
|
||||
#include "GhostComponent.h"
|
||||
#include "StringifiedEnum.h"
|
||||
|
||||
void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID) {
|
||||
@@ -108,9 +109,9 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
GameMessages::SendRestoreToPostLoadStats(entity, sysAddr);
|
||||
entity->SetPlayerReadyForUpdates();
|
||||
|
||||
auto* player = dynamic_cast<Player*>(entity);
|
||||
if (player != nullptr) {
|
||||
player->ConstructLimboEntities();
|
||||
auto* ghostComponent = entity->GetComponent<GhostComponent>();
|
||||
if (ghostComponent != nullptr) {
|
||||
ghostComponent->ConstructLimboEntities();
|
||||
}
|
||||
|
||||
InventoryComponent* inv = entity->GetComponent<InventoryComponent>();
|
||||
@@ -137,14 +138,14 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
|
||||
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
||||
script->OnPlayerLoaded(zoneControl, player);
|
||||
script->OnPlayerLoaded(zoneControl, entity);
|
||||
}
|
||||
|
||||
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
|
||||
for (Entity* scriptEntity : scriptedActs) {
|
||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
||||
script->OnPlayerLoaded(scriptEntity, player);
|
||||
script->OnPlayerLoaded(scriptEntity, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -78,6 +78,7 @@
|
||||
#include "RailActivatorComponent.h"
|
||||
#include "LevelProgressionComponent.h"
|
||||
#include "DonationVendorComponent.h"
|
||||
#include "GhostComponent.h"
|
||||
|
||||
// Message includes:
|
||||
#include "dZoneManager.h"
|
||||
@@ -4605,7 +4606,8 @@ void GameMessages::HandleToggleGhostReferenceOverride(RakNet::BitStream* inStrea
|
||||
auto* player = PlayerManager::GetPlayer(sysAddr);
|
||||
|
||||
if (player != nullptr) {
|
||||
player->SetGhostOverride(bOverride);
|
||||
auto* ghostComponent = entity->GetComponent<GhostComponent>();
|
||||
if (ghostComponent) ghostComponent->SetGhostOverride(bOverride);
|
||||
|
||||
Game::entityManager->UpdateGhosting(player);
|
||||
}
|
||||
@@ -4620,7 +4622,8 @@ void GameMessages::HandleSetGhostReferencePosition(RakNet::BitStream* inStream,
|
||||
auto* player = PlayerManager::GetPlayer(sysAddr);
|
||||
|
||||
if (player != nullptr) {
|
||||
player->SetGhostOverridePoint(position);
|
||||
auto* ghostComponent = entity->GetComponent<GhostComponent>();
|
||||
if (ghostComponent) ghostComponent->SetGhostOverridePoint(position);
|
||||
|
||||
Game::entityManager->UpdateGhosting(player);
|
||||
}
|
||||
|
Reference in New Issue
Block a user