2021-12-05 17:54:36 +00:00
|
|
|
#include "TreasureChestDragonServer.h"
|
|
|
|
#include "ScriptedActivityComponent.h"
|
|
|
|
#include "TeamManager.h"
|
|
|
|
#include "EntityManager.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "Loot.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void TreasureChestDragonServer::OnStartup(Entity* self) {
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TreasureChestDragonServer::OnUse(Entity* self, Entity* user) {
|
|
|
|
if (self->GetVar<bool>(u"bUsed")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->SetVar<bool>(u"bUsed", true);
|
|
|
|
|
|
|
|
auto* scriptedActivityComponent = self->GetComponent<ScriptedActivityComponent>();
|
|
|
|
|
|
|
|
if (scriptedActivityComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto rating = 1;
|
|
|
|
|
|
|
|
auto* team = TeamManager::Instance()->GetTeam(user->GetObjectID());
|
|
|
|
|
|
|
|
if (team != nullptr) {
|
|
|
|
rating = team->members.size();
|
|
|
|
|
|
|
|
for (const auto member : team->members) {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* memberObject = Game::entityManager->GetEntity(member);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (memberObject == nullptr) continue;
|
|
|
|
|
2023-10-09 20:33:22 +00:00
|
|
|
Loot::DropActivityLoot(memberObject, self, scriptedActivityComponent->GetActivityID(), rating);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
} else {
|
2023-10-09 20:33:22 +00:00
|
|
|
Loot::DropActivityLoot(user, self, scriptedActivityComponent->GetActivityID(), rating);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self->Smash(self->GetObjectID());
|
|
|
|
}
|