VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
ActorEmitterLogic.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 ACTOREMITTERLOGIC_H
18 #define ACTOREMITTERLOGIC_H
19 
20 #include <QList>
21 #include <QMap>
22 #include "EmitterLogic.h"
23 
33  Q_OBJECT
45  Q_PROPERTY(bool decayActors READ decaysActors WRITE setDecayActors NOTIFY decayActorsChanged)
46 public:
50  const QString& getActorModel() const { return mActorModel; }
55  void setActorModel(const QString& value);
59  bool decaysActors() const { return mDecayActors; }
64  void setDecayActors(bool value);
65 
66  virtual int getEntityCount() const override { return mActiveActors.size(); }
67 
72  virtual void update() override;
73 
74 signals:
78  void actorModelChanged();
82  void decayActorsChanged();
83 
84 protected:
92  virtual void emitEntity(const SpawnParameters& parameters) override;
93 
94 private:
95  int getTotalActors() const { return mActiveActors.size() + mInactiveActors.size(); }
100  QString getActorQmlString() const;
101  Actor* createActor(const SpawnParameters& parameters);
102 
103  QString mActorModel = "Actor";
104  bool mDecayActors = false;
105  QMap<Actor*, float> mActiveActors;
106  QList<Actor*> mInactiveActors;
107 };
108 Q_DECLARE_METATYPE(ActorEmitterLogic*)
109 
110 #endif // ACTOREMITTERLOGIC_H
bool decayActors
Whether or not the spawned actors should be decayed.
Definition: ActorEmitterLogic.h:45
void setDecayActors(bool value)
Sets decayActors.
QString actorModel
QML type of Actor to spawn.
Definition: ActorEmitterLogic.h:39
void decayActorsChanged()
Emitted when decayActors changes.
virtual void update() override
Decays any currently active, previously emitted Actors, and places them back into the internal Actor ...
int size() const
virtual void emitEntity(const SpawnParameters &parameters) override
Emits an Actor of type actorModel initialized with parameters.
virtual int getEntityCount() const override
Returns entityCount.
Definition: ActorEmitterLogic.h:66
bool decaysActors() const
Returns decayActors.
Definition: ActorEmitterLogic.h:59
void setActorModel(const QString &value)
Sets actorModel.
Spawns Actors of QML type actorModel into the Game's QML tree through Level::addActor().
Definition: ActorEmitterLogic.h:32
Representation of an entity within the Game scene.
Definition: Actor.h:40
Abstract base class to spawn generic entities into the Game based on configurable parameters...
Definition: EmitterLogic.h:35
const QString & getActorModel() const
Returns actorModel.
Definition: ActorEmitterLogic.h:50
void actorModelChanged()
Emitted when actorModel changes.
int size() const