#include "qw_addtriggerevent.h" #include "models/qw_trigger.h" QWAddTriggerEvent::QWAddTriggerEvent(const std::shared_ptr &tr) : trigger(tr) { Q_ASSERT(trigger); } void QWAddTriggerEvent::execute() { Q_ASSERT(location); if (location->triggers().contains(trigger)) return; location->addTriggers(trigger); if (location == ptr_scene->currentLocation()) ptr_scene->addItem(trigger.get()); } //////////////////////// void QWAddTriggerEvent::setLocation(const std::shared_ptr &loc) noexcept { location = loc; Q_ASSERT(location); } void QWAddTriggerEvent::setTrigger(const std::shared_ptr &tr) noexcept { trigger = tr; Q_ASSERT(trigger); } //////////////////////// void QWAddTriggerEvent::writeToJson(QJsonObject &event_data) { event_data.insert("id", tag()); event_data.insert("type", EVENT_TYPE::ADD_TRIGGER); event_data.insert("location", location->tag()); event_data.insert("trigger", trigger->tag()); qDebug() << " The add_trigger event:\n" << " id " << tag() << "\n location :" << location->tag() << "\n trigger :" << trigger->tag(); }