quest-wizard/models/events/qw_pickupitemevent.cpp

38 lines
956 B
C++
Raw Normal View History

2023-02-09 08:41:24 -05:00
#include "qw_pickupitemevent.h"
#include "../qw_trigger.h"
QWPickupItemEvent::QWPickupItemEvent(const std::shared_ptr<QWTrigger> &tr) :
ptr_inventory_trigger(tr)
{
Q_ASSERT(ptr_inventory_trigger);
}
void QWPickupItemEvent::execute()
{
ptr_inventory->addInventoryIcon(ptr_inventory_trigger);
}
////////////////////////
void QWPickupItemEvent::setInventoryTrigger(const std::shared_ptr<QWTrigger> &tr) noexcept
{
ptr_inventory_trigger = tr;
}
std::shared_ptr<QWTrigger> QWPickupItemEvent::inventoryTrigger() const noexcept
{
return ptr_inventory_trigger;
}
////////////////////////
void QWPickupItemEvent::writeToJson(QJsonObject &event_data)
{
event_data.insert("id", tag());
event_data.insert("type", EVENT_TYPE::PICKUP_ITEM);
event_data.insert("target", ptr_inventory_trigger->tag());
qDebug() << " The pickup_item event:\n" << " id " << tag()
<< "\n target " << ptr_inventory_trigger->tag();
}