2021-12-05 17:54:36 +00:00
|
|
|
#include "VeBricksampleServer.h"
|
|
|
|
#include "InventoryComponent.h"
|
|
|
|
#include "EntityManager.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "MissionComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "GameMessages.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "eMissionState.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void VeBricksampleServer::OnUse(Entity* self, Entity* user) {
|
2023-06-07 07:23:50 +00:00
|
|
|
auto missionComponent = user->GetComponent<MissionComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (missionComponent != nullptr && missionComponent->GetMissionState(1183) == eMissionState::ACTIVE) {
|
|
|
|
const auto loot = self->GetVar<int32_t>(m_LootVariable);
|
2023-06-07 07:23:50 +00:00
|
|
|
auto inventoryComponent = user->GetComponent<InventoryComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (loot && inventoryComponent != nullptr && inventoryComponent->GetLotCount(loot) == 0) {
|
2023-05-02 22:39:21 +00:00
|
|
|
inventoryComponent->AddItem(loot, 1, eLootSourceType::ACTIVITY);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
for (auto* brickEntity : EntityManager::Instance()->GetEntitiesInGroup("Bricks")) {
|
|
|
|
GameMessages::SendNotifyClientObject(brickEntity->GetObjectID(), u"Pickedup");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|