Working in game!

- Add score saving for races
- Fix some bugs
- Still work to do.
This commit is contained in:
David Markowitz
2023-05-09 01:42:11 -07:00
parent 411c9eaf1f
commit 7a067e7b48
7 changed files with 46 additions and 31 deletions

View File

@@ -96,8 +96,7 @@ void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std
}
EntityManager::Instance()->SerializeEntity(self);
//LeaderboardManager::SaveScore(sender->GetObjectID(), scriptedActivityComponent->GetActivityID(),
// 0, (uint32_t)finish);
// LeaderboardManager::Instance().SaveFootRaceScore(sender->GetObjectID(), scriptedActivityComponent->GetActivityID(), finish);
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"ToggleLeaderBoard",
scriptedActivityComponent->GetActivityID(), 0, sender->GetObjectID(),

View File

@@ -73,24 +73,27 @@ void ActivityManager::StopActivity(Entity* self, const LWOOBJID playerID, const
LootGenerator::Instance().GiveActivityLoot(player, self, gameID, CalculateActivityRating(self, playerID));
// Save the new score to the leaderboard and show the leaderboard to the player
//LeaderboardManager::SaveScore(playerID, gameID, score, value1);
//const auto* leaderboard = LeaderboardManager::GetLeaderboard(gameID, InfoType::Standings,
// false, player->GetObjectID());
//GameMessages::SendActivitySummaryLeaderboardData(self->GetObjectID(), leaderboard, player->GetSystemAddress());
//delete leaderboard;
// Makes the leaderboard show up for the player
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"ToggleLeaderBoard",
gameID, 0, playerID, "",
player->GetSystemAddress());
if (sac != nullptr) {
sac->PlayerRemove(player->GetObjectID());
}
}
}
void ActivityManager::SaveScore(Entity* self, LWOOBJID playerID, uint32_t val1, uint32_t val2, uint32_t val3) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
if (!player) return;
auto* sac = self->GetComponent<ScriptedActivityComponent>();
uint32_t gameID = sac != nullptr ? sac->GetActivityID() : self->GetLOT();
// Save the new score to the leaderboard and show the leaderboard to the player
auto leaderboardType = LeaderboardManager::GetLeaderboardType(gameID);
Game::logger->Log("ActivityManager", "leaderboard type %i %i", leaderboardType, gameID);
LeaderboardManager::Instance().SaveScore(playerID, gameID, leaderboardType, 3, val1, val2, val3);
// Makes the leaderboard show up for the player
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"ToggleLeaderBoard", gameID, 0, playerID, "", player->GetSystemAddress());
}
bool ActivityManager::TakeActivityCost(const Entity* self, const LWOOBJID playerID) {
auto* sac = self->GetComponent<ScriptedActivityComponent>();
if (sac == nullptr)

View File

@@ -18,6 +18,7 @@ public:
static bool TakeActivityCost(const Entity* self, LWOOBJID playerID);
static uint32_t GetActivityID(const Entity* self);
void StopActivity(Entity* self, LWOOBJID playerID, uint32_t score, uint32_t value1 = 0, uint32_t value2 = 0, bool quit = false);
void SaveScore(Entity* self, LWOOBJID playerID, uint32_t val1 = 0, uint32_t val2 = 0, uint32_t val3 = 0);
virtual uint32_t CalculateActivityRating(Entity* self, LWOOBJID playerID);
static void GetLeaderboardData(Entity* self, LWOOBJID playerID, uint32_t activityID, uint32_t numResults = 0);
// void FreezePlayer(Entity *self, const LWOOBJID playerID, const bool state) const;

View File

@@ -42,6 +42,7 @@ void BaseFootRaceManager::OnFireEventServerSide(Entity* self, Entity* sender, st
}
StopActivity(self, player->GetObjectID(), 0, param1);
SaveScore(self, player->GetObjectID(), param1, param2, param3);
}
}
}