DarkflameServer/dScripts/VeBricksampleServer.cpp

22 lines
883 B
C++
Raw Normal View History

#include "VeBricksampleServer.h"
#include "InventoryComponent.h"
#include "EntityManager.h"
#include "MissionComponent.h"
#include "GameMessages.h"
2022-07-28 13:39:57 +00:00
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>();
2022-07-28 13:39:57 +00:00
if (loot && inventoryComponent != nullptr && inventoryComponent->GetLotCount(loot) == 0) {
inventoryComponent->AddItem(loot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY);
2022-07-28 13:39:57 +00:00
for (auto* brickEntity : EntityManager::Instance()->GetEntitiesInGroup("Bricks")) {
GameMessages::SendNotifyClientObject(brickEntity->GetObjectID(), u"Pickedup");
}
}
}
}