2021-12-05 17:54:36 +00:00
|
|
|
#include "VeBricksampleServer.h"
|
|
|
|
#include "InventoryComponent.h"
|
|
|
|
#include "EntityManager.h"
|
2022-06-23 05:19:49 +00:00
|
|
|
#include "MissionComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "GameMessages.h"
|
|
|
|
|
|
|
|
void VeBricksampleServer::OnUse(Entity *self, Entity *user) {
|
|
|
|
auto* missionComponent = user->GetComponent<MissionComponent>();
|
|
|
|
if (missionComponent != nullptr && missionComponent->GetMissionState(1183) == MissionState::MISSION_STATE_ACTIVE) {
|
|
|
|
const auto loot = self->GetVar<int32_t>(m_LootVariable);
|
|
|
|
auto* inventoryComponent = user->GetComponent<InventoryComponent>();
|
|
|
|
|
|
|
|
if (loot && inventoryComponent != nullptr && inventoryComponent->GetLotCount(loot) == 0) {
|
2022-04-24 03:35:34 +00:00
|
|
|
inventoryComponent->AddItem(loot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
for (auto* brickEntity : EntityManager::Instance()->GetEntitiesInGroup("Bricks")) {
|
|
|
|
GameMessages::SendNotifyClientObject(brickEntity->GetObjectID(), u"Pickedup");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|