49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
|
#ifndef QUESTACTIVATEITEMEVENT_H
|
||
|
#define QUESTACTIVATEITEMEVENT_H
|
||
|
|
||
|
#include <memory>
|
||
|
#include <QList>
|
||
|
#include "qw_abstractevent.h"
|
||
|
|
||
|
/* QWSwitchEventsEvent
|
||
|
* Changes events of its linked QWTrigger.
|
||
|
* For example: a door is being closed until we pick up a key.
|
||
|
* It's initial state "to print message "go find a key you punk".
|
||
|
* When we activate its key, execute() changes door event to "go through". */
|
||
|
|
||
|
class QWTrigger;
|
||
|
|
||
|
class QWSwitchEventsEvent : public QWAbstractEvent
|
||
|
{
|
||
|
private:
|
||
|
std::shared_ptr<QWTrigger> ptr_target;
|
||
|
|
||
|
bool b_active;
|
||
|
|
||
|
QList<std::shared_ptr<QWAbstractEvent>> list_disabled_events;
|
||
|
QList<std::shared_ptr<QWAbstractEvent>> list_enabled_events;
|
||
|
|
||
|
public:
|
||
|
explicit QWSwitchEventsEvent(const std::shared_ptr<QWTrigger> &tr);
|
||
|
virtual ~QWSwitchEventsEvent() override {}
|
||
|
|
||
|
void execute() override;
|
||
|
|
||
|
////////////////////////
|
||
|
|
||
|
void setTarget(const std::shared_ptr<QWTrigger> &tr) noexcept;
|
||
|
std::shared_ptr<QWTrigger> target() const noexcept;
|
||
|
|
||
|
void setEventsOnDisable(const QList<std::shared_ptr<QWAbstractEvent>> &evs) noexcept;
|
||
|
void setEventsOnEnable(const QList<std::shared_ptr<QWAbstractEvent>> &evs) noexcept;
|
||
|
|
||
|
// init() sets an inital state of ptr_trigger.
|
||
|
void init();
|
||
|
|
||
|
////////////////////////
|
||
|
|
||
|
void writeToJson(QJsonObject &event_data) override;
|
||
|
};
|
||
|
|
||
|
#endif // QUESTACTIVATEITEMEVENT_H
|