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 | |
---|
30 | /** |
---|
31 | |
---|
32 | @file |
---|
33 | @author remartin |
---|
34 | @brief An asteroid which can be destroyed. Some smaller asteroids are created and a pickup spawns. |
---|
35 | |
---|
36 | HANDBUCH: |
---|
37 | o Die Collision Shape kann nur im Konstruktor hinzugefügt werden. Die XML-Argumente werden aber erst nach dem Konstruktor gesetzt. |
---|
38 | Darum wird hier beim ersten Aufruf der tick()-Methode via putStuff() ein komplett neuer Asteroid generiert und der alte zerstört. |
---|
39 | o im Level-File includes/pickups.oxi importieren. |
---|
40 | |
---|
41 | OFFEN/Weiterentwicklung: |
---|
42 | o @TODO Add resource pickups. |
---|
43 | --> data_extern/images/effects: PNG's für die Pickups |
---|
44 | --> https://www.orxonox.net/jenkins/view/Management/job/orxonox_doxygen_trunk/javadoc/group___pickup.html |
---|
45 | |
---|
46 | o Density doesn't add up to 1... |
---|
47 | o Does collision damage work properly |
---|
48 | o Add sound effect (crunching etc. ) (No sound in space...) |
---|
49 | o Explosion parts |
---|
50 | |
---|
51 | ANDERORTS VERÄNDERTE SACHEN: |
---|
52 | Pickup-Zeug: |
---|
53 | o Pickup.h: createSpawner() neu public statt private |
---|
54 | o PickupSpawner.h: Zugriffsrechte setPickupTemplateName() und setMaxSpawnedItems() |
---|
55 | o PickupSpawner.h: In Tick() zwei Testbedingungen eingefügt. |
---|
56 | o Pawn.h: Attribut acceptsPickups_ inklusive get/set. |
---|
57 | |
---|
58 | ERLEGTE FEHLER: |
---|
59 | o Grössenabhängige Collision Shape -> putStuff-Methode, Werte noch nicht durchgesickert. |
---|
60 | o setHealth: maxHealth() des pawns setzen! |
---|
61 | o Asteroiden fressen Pickups: Argument in Pawn, Test darauf in Tick() von PickupSpawner. |
---|
62 | o i++ einfach ganz verhindern, ++i stattdessen. |
---|
63 | o Velocity didn-t get passed properly through the 2nd constructor. Used get/set instead. |
---|
64 | o Rand() geht bis zu riesigen Nummern! rnd() ist zwischen 0 und 1 |
---|
65 | |
---|
66 | NOTIZEN: |
---|
67 | o SUPER |
---|
68 | o Warnungsverhinderung anderswo: (void)pickedUp; // To avoid compiler warning. |
---|
69 | o friend class Pickupable; |
---|
70 | |
---|
71 | */ |
---|
72 | |
---|
73 | #ifndef _AsteroidMinable_H__ |
---|
74 | #define _AsteroidMinable_H__ |
---|
75 | |
---|
76 | #include "OrxonoxPrereqs.h" |
---|
77 | |
---|
78 | #include <string> |
---|
79 | #include <vector> |
---|
80 | #include "interfaces/PickupCarrier.h" |
---|
81 | #include "interfaces/RadarViewable.h" |
---|
82 | #include "worldentities/ControllableEntity.h" |
---|
83 | #include "worldentities/ExplosionPart.h" |
---|
84 | |
---|
85 | #include "../../orxonox/worldentities/pawns/Pawn.h" |
---|
86 | |
---|
87 | namespace orxonox{ |
---|
88 | |
---|
89 | |
---|
90 | class _OrxonoxExport AsteroidMinable : public Pawn{ |
---|
91 | |
---|
92 | public: |
---|
93 | // @brief This constructor is for XML access only! |
---|
94 | AsteroidMinable(Context* context); |
---|
95 | // @brief Call this Constructor from other C-files. |
---|
96 | AsteroidMinable(Context* c, float size, Vector3 position, bool dS); |
---|
97 | |
---|
98 | virtual ~AsteroidMinable(); |
---|
99 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
100 | virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; |
---|
101 | virtual void tick(float dt) override; |
---|
102 | |
---|
103 | // @brief overloading that to prevent asteroids from taking damage from each other (domino effect etc. ) |
---|
104 | virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); |
---|
105 | virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); |
---|
106 | |
---|
107 | inline void setSize(int s){this->size = s;} |
---|
108 | inline int getSize(){return this->size;} |
---|
109 | |
---|
110 | inline void toggleShattering(bool b){this->generateSmaller = b;} |
---|
111 | inline bool doesShatter(){return this->generateSmaller;} |
---|
112 | |
---|
113 | inline void toggleDropStuff(bool b){this->dropStuff = b;} |
---|
114 | inline bool doesDropStuff(){return this->dropStuff;} |
---|
115 | |
---|
116 | protected: |
---|
117 | |
---|
118 | Context* context; |
---|
119 | |
---|
120 | int size; //!< Implies health and type of dropped pickups |
---|
121 | bool generateSmaller; //!< Whether this asteroid leaves fragments |
---|
122 | bool dropStuff; //!< Whether this asteroid yields valuable stuff |
---|
123 | |
---|
124 | // @brief Überschreibt die Methode in Pawn |
---|
125 | virtual void death(); |
---|
126 | |
---|
127 | private: |
---|
128 | |
---|
129 | bool initialised; //!< Used in relation to the constructor detour described above |
---|
130 | |
---|
131 | void registerVariables(); |
---|
132 | |
---|
133 | // @brief Helper method. |
---|
134 | virtual void putStuff(); |
---|
135 | |
---|
136 | // @brief If the option generateSmaller is enabled, individual fragments are added with this method. |
---|
137 | virtual void spawnChildren(); |
---|
138 | |
---|
139 | // @brief Just for testing. Don-t work anyways. |
---|
140 | void printArrayString(float thingy[]); |
---|
141 | // @brief Just for testing. Don-t work anyways. |
---|
142 | void printArrayString(int thingy[]); |
---|
143 | |
---|
144 | }; // tolua_export |
---|
145 | } // tolua_export |
---|
146 | |
---|
147 | #endif /* _AsteroidMinable_H__ */ |
---|