| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef SPRITEGOALAFFECTOR_H |
| 5 | #define SPRITEGOALAFFECTOR_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | #include "qquickparticleaffector_p.h" |
| 18 | #include <QtQml/qqmlinfo.h> |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | class QQuickStochasticEngine; |
| 23 | |
| 24 | class Q_QUICKPARTICLES_EXPORT QQuickSpriteGoalAffector : public QQuickParticleAffector |
| 25 | { |
| 26 | Q_OBJECT |
| 27 | Q_PROPERTY(QString goalState READ goalState WRITE setGoalState NOTIFY goalStateChanged) |
| 28 | Q_PROPERTY(bool jump READ jump WRITE setJump NOTIFY jumpChanged) |
| 29 | Q_PROPERTY(bool systemStates READ systemStates WRITE setSystemStates NOTIFY systemStatesChanged) |
| 30 | QML_NAMED_ELEMENT(SpriteGoal) |
| 31 | QML_ADDED_IN_VERSION(2, 0) |
| 32 | public: |
| 33 | explicit QQuickSpriteGoalAffector(QQuickItem *parent = nullptr); |
| 34 | |
| 35 | QString goalState() const |
| 36 | { |
| 37 | return m_goalState; |
| 38 | } |
| 39 | |
| 40 | bool jump() const |
| 41 | { |
| 42 | return m_jump; |
| 43 | } |
| 44 | bool systemStates() const |
| 45 | { |
| 46 | return m_systemStates; |
| 47 | } |
| 48 | |
| 49 | protected: |
| 50 | bool affectParticle(QQuickParticleData *d, qreal dt) override; |
| 51 | |
| 52 | Q_SIGNALS: |
| 53 | |
| 54 | void goalStateChanged(const QString &arg); |
| 55 | |
| 56 | void jumpChanged(bool arg); |
| 57 | |
| 58 | void systemStatesChanged(bool arg); |
| 59 | |
| 60 | public Q_SLOTS: |
| 61 | |
| 62 | void setGoalState(const QString &arg); |
| 63 | |
| 64 | void setJump(bool arg) |
| 65 | { |
| 66 | if (m_jump != arg) { |
| 67 | m_jump = arg; |
| 68 | Q_EMIT jumpChanged(arg); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | void setSystemStates(bool arg) |
| 73 | { |
| 74 | if (m_systemStates != arg) { |
| 75 | //TODO: GroupGoal was added (and this deprecated) Oct 4 - remove it in a few weeks. |
| 76 | qmlWarning(me: this) << "systemStates is deprecated and will be removed soon. Use GroupGoal instead."; |
| 77 | m_systemStates = arg; |
| 78 | Q_EMIT systemStatesChanged(arg); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | private: |
| 83 | void updateStateIndex(QQuickStochasticEngine* e); |
| 84 | QString m_goalState; |
| 85 | int m_goalIdx; |
| 86 | QQuickStochasticEngine* m_lastEngine; |
| 87 | bool m_jump; |
| 88 | bool m_systemStates; |
| 89 | |
| 90 | bool m_notUsingEngine; |
| 91 | }; |
| 92 | |
| 93 | QT_END_NAMESPACE |
| 94 | |
| 95 | #endif // SPRITEGOALAFFECTOR_H |
| 96 |
