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 _Projectile_H__ |
---|
30 | #define _Projectile_H__ |
---|
31 | |
---|
32 | #include "OrxonoxPrereqs.h" |
---|
33 | |
---|
34 | #include "WorldEntity.h" |
---|
35 | #include "tools/Timer.h" |
---|
36 | #undef SUPER_INTRUSIVE |
---|
37 | #include "core/Super.h" |
---|
38 | |
---|
39 | namespace orxonox |
---|
40 | { |
---|
41 | class _OrxonoxExport Projectile : public WorldEntity |
---|
42 | { |
---|
43 | public: |
---|
44 | virtual ~Projectile(); |
---|
45 | void setConfigValues(); |
---|
46 | void speedChanged(); |
---|
47 | void destroyObject(); |
---|
48 | virtual void tick(float dt); |
---|
49 | virtual void testfunction(); |
---|
50 | |
---|
51 | static float getSpeed() |
---|
52 | { return Projectile::speed_s; } |
---|
53 | |
---|
54 | protected: |
---|
55 | Projectile(SpaceShip* owner = 0); |
---|
56 | SpaceShip* owner_; |
---|
57 | |
---|
58 | private: |
---|
59 | std::string explosionTemplateName_; |
---|
60 | std::string smokeTemplateName_; |
---|
61 | protected: |
---|
62 | static float speed_s; |
---|
63 | float speed_; |
---|
64 | private: |
---|
65 | float lifetime_; |
---|
66 | float damage_; |
---|
67 | Timer<Projectile> destroyTimer_; |
---|
68 | }; |
---|
69 | |
---|
70 | // Partially specialized template (templatehack is now specialized too) |
---|
71 | template <class T> |
---|
72 | struct SuperFunctionCondition<0, 0, T> |
---|
73 | { |
---|
74 | // Checks if class U isA baseclass and sets the functionpointer if the check returned true |
---|
75 | static void check() |
---|
76 | { |
---|
77 | std::cout << "check superfunction \"testfunction\" in " << ClassIdentifier<T>::getIdentifier()->getName() << std::endl; |
---|
78 | |
---|
79 | T* temp = 0; |
---|
80 | SuperFunctionCondition<0, 0, T>::apply(temp); |
---|
81 | |
---|
82 | std::cout << "done" << std::endl; |
---|
83 | |
---|
84 | // Calls the condition of the next super-function |
---|
85 | SuperFunctionCondition<0 + 1, 0, T>::check(); |
---|
86 | } |
---|
87 | |
---|
88 | static void apply(void* temp) |
---|
89 | { |
---|
90 | std::cout << ClassIdentifier<T>::getIdentifier()->getName() << " is not a Projectile" << std::endl; |
---|
91 | // nop |
---|
92 | } |
---|
93 | |
---|
94 | static void apply(Projectile* temp) |
---|
95 | { |
---|
96 | std::cout << ClassIdentifier<T>::getIdentifier()->getName() << " is a Projectile" << std::endl; |
---|
97 | ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); |
---|
98 | |
---|
99 | // Iterate through all children and assign the caller |
---|
100 | for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) |
---|
101 | { |
---|
102 | if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_testfunction_) |
---|
103 | { |
---|
104 | std::cout << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; |
---|
105 | ((ClassIdentifier<T>*)(*it))->superFunctionCaller_testfunction_ = new SuperFunctionClassCaller_testfunction<T>; |
---|
106 | } |
---|
107 | } |
---|
108 | } |
---|
109 | }; |
---|
110 | } |
---|
111 | |
---|
112 | #endif /* _Projectile_H__ */ |
---|