DarkflameServer/dScripts/ai/ACT/FootRace/BaseFootRaceManager.cpp
David Markowitz 455f9470a5
Move EntityManager to Game namespace (#1140)
* 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
2023-07-15 13:56:33 -07:00

48 lines
1.5 KiB
C++

#include "BaseFootRaceManager.h"
#include "EntityManager.h"
#include "Character.h"
void BaseFootRaceManager::OnStartup(Entity* self) {
// TODO: Add to FootRaceStarter group
}
void BaseFootRaceManager::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
const auto splitArguments = GeneralUtils::SplitString(args, '_');
if (splitArguments.size() > 1) {
const auto eventName = splitArguments[0];
const auto player = Game::entityManager->GetEntity(std::stoull(splitArguments[1]));
if (player != nullptr) {
if (eventName == "updatePlayer") {
UpdatePlayer(self, player->GetObjectID());
} else if (IsPlayerInActivity(self, player->GetObjectID())) {
if (eventName == "initialActivityScore") {
auto* character = player->GetCharacter();
if (character != nullptr) {
character->SetPlayerFlag(115, true);
}
SetActivityScore(self, player->GetObjectID(), 1);
} else if (eventName == "updatePlayerTrue") {
auto* character = player->GetCharacter();
if (character != nullptr) {
character->SetPlayerFlag(115, false);
}
UpdatePlayer(self, player->GetObjectID(), true);
} else if (eventName == "PlayerWon") {
auto* character = player->GetCharacter();
if (character != nullptr) {
character->SetPlayerFlag(115, false);
if (param2 != -1) // Certain footraces set a flag
character->SetPlayerFlag(param2, true);
}
StopActivity(self, player->GetObjectID(), 0, param1);
}
}
}
}
}