2021-12-05 17:54:36 +00:00
|
|
|
#include "NPCAddRemoveItem.h"
|
|
|
|
#include "InventoryComponent.h"
|
2023-01-22 23:38:47 +00:00
|
|
|
#include "eMissionState.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-22 23:38:47 +00:00
|
|
|
void NPCAddRemoveItem::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
|
2023-06-07 07:23:50 +00:00
|
|
|
auto inventory = target->GetComponent<InventoryComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
if (inventory == nullptr)
|
|
|
|
return;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (const auto& missionSetting : m_MissionItemSettings) {
|
|
|
|
if (missionSetting.first == missionID) {
|
|
|
|
for (const auto& itemSetting : missionSetting.second) {
|
|
|
|
for (const auto& lot : itemSetting.items) {
|
2023-01-22 23:38:47 +00:00
|
|
|
if (itemSetting.add && (missionState == eMissionState::AVAILABLE || missionState == eMissionState::COMPLETE_AVAILABLE)) {
|
2023-05-02 22:39:21 +00:00
|
|
|
inventory->AddItem(lot, 1, eLootSourceType::NONE);
|
2023-01-22 23:38:47 +00:00
|
|
|
} else if (itemSetting.remove && (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE)) {
|
2022-07-28 13:39:57 +00:00
|
|
|
inventory->RemoveItem(lot, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::map<uint32_t, std::vector<ItemSetting>> NPCAddRemoveItem::GetSettings() {
|
2022-07-28 13:39:57 +00:00
|
|
|
return std::map<uint32_t, std::vector<ItemSetting>>();
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void NPCAddRemoveItem::OnStartup(Entity* self) {
|
|
|
|
m_MissionItemSettings = GetSettings();
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|