VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Logic.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LOGIC_H
18 #define LOGIC_H
19 
20 #include <QQuickItem>
21 #include "Actor.h"
22 
31 class Logic : public QObject {
32  Q_OBJECT
36  Q_PROPERTY(Actor* actor READ getActor)
40  Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
41 
42 public:
47  explicit Logic(QObject* parent = nullptr) : QObject(parent) { }
48 
52  Actor* getActor() const { return mActor; }
56  bool isActive() const { return mActive; }
61  void setActive(bool value);
62 
68  virtual void init();
73  virtual void update();
74 
75 signals:
79  void activeChanged();
80 
81 private:
82  bool mActive = true;
83  Actor* mActor = nullptr;
84 };
85 Q_DECLARE_METATYPE(Logic*)
86 
87 #endif // LOGIC_H
bool isActive() const
Returns active.
Definition: Logic.h:56
virtual void init()
Performs initialization of this Logic.
void setActive(bool value)
Sets active.
bool active
Whether or not Engine calls update() on this Logic during the Engine::LOGICS_PHASE.
Definition: Logic.h:40
void activeChanged()
Emitted when active changes.
Actor actor
Parent actor that is affected by this Logic's behavior.
Definition: Logic.h:36
Actor * getActor() const
Returns actor.
Definition: Logic.h:52
virtual void update()
Performs the update (i.e. execution of behavior) of this Logic.
Non-visual entities in the QML item tree that define behavior for their parent Actor.
Definition: Logic.h:31
Representation of an entity within the Game scene.
Definition: Actor.h:40
QObject * parent() const