mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-09-21 01:51:31 +00:00
![David Markowitz](/assets/img/avatar_default.png)
* 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
50 lines
1.8 KiB
C++
50 lines
1.8 KiB
C++
#include "FvPandaSpawnerServer.h"
|
|
#include "Character.h"
|
|
#include "EntityManager.h"
|
|
#include "GameMessages.h"
|
|
#include "EntityInfo.h"
|
|
#include "ScriptedActivityComponent.h"
|
|
|
|
void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
|
|
auto* character = target->GetCharacter();
|
|
if (character != nullptr && character->GetPlayerFlag(81)) {
|
|
|
|
auto raceObjects = Game::entityManager->GetEntitiesInGroup("PandaRaceObject");
|
|
if (raceObjects.empty())
|
|
return;
|
|
|
|
// Check if the player is currently in a footrace
|
|
auto* scriptedActivityComponent = raceObjects.at(0)->GetComponent<ScriptedActivityComponent>();
|
|
if (scriptedActivityComponent == nullptr || !scriptedActivityComponent->IsPlayedBy(target))
|
|
return;
|
|
|
|
// If the player already spawned a panda
|
|
auto playerPandas = Game::entityManager->GetEntitiesInGroup("panda" + std::to_string(target->GetObjectID()));
|
|
if (!playerPandas.empty()) {
|
|
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"playerPanda",
|
|
target->GetObjectID(), 0, 0, target->GetObjectID());
|
|
return;
|
|
}
|
|
|
|
// If there's already too many spawned pandas
|
|
auto pandas = Game::entityManager->GetEntitiesInGroup("pandas");
|
|
if (pandas.size() > 4) {
|
|
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"tooManyPandas",
|
|
target->GetObjectID(), 0, 0, target->GetObjectID());
|
|
return;
|
|
}
|
|
|
|
EntityInfo info{};
|
|
info.spawnerID = target->GetObjectID();
|
|
info.pos = self->GetPosition();
|
|
info.lot = 5643;
|
|
info.settings = {
|
|
new LDFData<LWOOBJID>(u"tamer", target->GetObjectID()),
|
|
new LDFData<std::u16string>(u"groupID", u"panda" + (GeneralUtils::to_u16string(target->GetObjectID())) + u";pandas")
|
|
};
|
|
|
|
auto* panda = Game::entityManager->CreateEntity(info);
|
|
Game::entityManager->ConstructEntity(panda);
|
|
}
|
|
}
|