mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-14 12:18:22 +00:00
fc75d6048f
* moving branch * Add deleteinven slash command * Change name of BRICKS_IN_BBB * Use string_view instead of strcmp * Clean up include tree * Remove unneeded headers from PCH files Removes unneeded headers from pre-compiled headers. This increases compile time, however reduces development time for most files. * Update Entity.h * Update EntityManager.h * Update GameMessages.cpp * There it compiles now Co-authored-by: Aaron Kimbrell <aronwk.aaron@gmail.com>
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 = EntityManager::Instance()->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 = EntityManager::Instance()->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 = EntityManager::Instance()->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 = EntityManager::Instance()->CreateEntity(info);
|
|
EntityManager::Instance()->ConstructEntity(panda);
|
|
}
|
|
}
|