Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/graphics/ParticleSpawner.h @ 12380

Last change on this file since 12380 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _ParticleSpawner_H__
30#define _ParticleSpawner_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "tools/Timer.h"
35#include "ParticleEmitter.h"
36
37namespace orxonox
38{
39    class _OrxonoxExport ParticleSpawner : public ParticleEmitter
40    {
41        public:
42            ParticleSpawner(Context* context);
43            virtual ~ParticleSpawner();
44
45            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
46            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;
47
48            inline void stop(bool bDestroy)
49                { this->bForceDestroy_ = bDestroy; this->stopParticleSpawner(); }
50            inline void spawn()
51                { this->bSuppressStart_ = false; this->startParticleSpawner(); }
52
53            void configure(float lifetime = 0, float startdelay = 0, float destroydelay = 0, bool autodestroy = true);
54
55            inline void setAutoStart(bool autostart)
56                { this->bAutostart_ = autostart; this->bSuppressStart_ = !autostart; }
57            inline bool getAutoStart() const
58                { return this->bAutostart_; }
59
60            inline void setDestroyAfterLife(bool destroy)
61                { this->bAutoDestroy_ = destroy; }
62            inline bool getDestroyAfterLife() const
63                { return this->bAutoDestroy_; }
64
65            inline void setLoop(bool loop)
66                { this->bLoop_ = loop; }
67            inline bool getLoop() const
68                { return this->bLoop_; }
69
70            inline void setLifetime(float lifetime)
71                { this->lifetime_ = lifetime; this->startParticleSpawner(); }
72            inline float getLifetime() const
73                { return this->lifetime_; }
74
75            inline void setStartdelay(float startdelay)
76                { this->startdelay_ = startdelay; this->startParticleSpawner(); }
77            inline float getStartdelay() const
78                { return this->startdelay_; }
79
80            inline void setDestroydelay(float destroydelay)
81                { this->destroydelay_ = destroydelay; this->startParticleSpawner(); }
82            inline float getDestroydelay() const
83                { return this->destroydelay_; }
84
85        private:
86            void startParticleSpawner();
87            void fireParticleSpawner();
88            void stopParticleSpawner();
89            void destroyParticleSpawner();
90
91            Timer timer_;
92
93            bool  bSuppressStart_;
94            bool  bAutostart_;
95            bool  bForceDestroy_;
96            bool  bAutoDestroy_;
97            bool  bLoop_;
98            float startdelay_;
99            float lifetime_;
100            float destroydelay_;
101    };
102}
103
104#endif /* _ParticleSpawner_H__ */
Note: See TracBrowser for help on using the repository browser.