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