54 lines
990 B
C++
54 lines
990 B
C++
#ifndef ACTOR_H
|
|
#define ACTOR_H
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QJsonObject>
|
|
|
|
#include "src/items/item.h"
|
|
|
|
class Actor : public Item
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
|
|
uint8_t triggerValue = 0;
|
|
|
|
protected:
|
|
bool active = true;
|
|
bool exausted = false;
|
|
|
|
void performAction();
|
|
|
|
signals:
|
|
|
|
void sigValue(uint8_t value);
|
|
|
|
public slots:
|
|
virtual void makeActive();
|
|
virtual void makeInactive();
|
|
virtual void setActive(uint8_t state);
|
|
virtual void onValueChanged(uint8_t state);
|
|
|
|
virtual void setValue(uint8_t value);
|
|
|
|
public:
|
|
Actor(QObject* parent = nullptr);
|
|
virtual ~Actor();
|
|
bool isExausted();
|
|
|
|
virtual QString actionName();
|
|
|
|
bool isActive();
|
|
void setTriggerValue(uint8_t value);
|
|
|
|
uint8_t getTriggerValue();
|
|
|
|
static std::shared_ptr<Actor> createActor(const QString& type);
|
|
|
|
virtual void store(QJsonObject& json);
|
|
virtual void load(const QJsonObject& json, const bool preserve = false);
|
|
static std::shared_ptr<Actor> loadActor(const QJsonObject& json);
|
|
};
|
|
|
|
#endif // ACTOR_H
|