2021-12-05 17:54:36 +00:00
|
|
|
#include "BaseFootRaceManager.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "Character.h"
|
2023-05-09 07:06:26 +00:00
|
|
|
#include "Entity.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void BaseFootRaceManager::OnStartup(Entity* self) {
|
|
|
|
// TODO: Add to FootRaceStarter group
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
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) {
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
const auto eventName = splitArguments[0];
|
|
|
|
const auto player = EntityManager::Instance()->GetEntity(std::stoull(splitArguments[1]));
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
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);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
SetActivityScore(self, player->GetObjectID(), 1);
|
|
|
|
} else if (eventName == "updatePlayerTrue") {
|
|
|
|
auto* character = player->GetCharacter();
|
|
|
|
if (character != nullptr) {
|
|
|
|
character->SetPlayerFlag(115, false);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
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
|
2023-05-02 22:39:21 +00:00
|
|
|
character->SetPlayerFlag(static_cast<uint32_t>(param2), true);
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
StopActivity(self, player->GetObjectID(), 0, param1);
|
2023-05-09 08:42:11 +00:00
|
|
|
SaveScore(self, player->GetObjectID(), param1, param2, param3);
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|