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 | * Noe Pedrazzini |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef _ShipPart_H__ |
---|
30 | #define _ShipPart_H__ |
---|
31 | |
---|
32 | #include "OrxonoxPrereqs.h" |
---|
33 | #include "Item.h" |
---|
34 | #include "items/PartDestructionEvent.h" |
---|
35 | |
---|
36 | #include <string> |
---|
37 | |
---|
38 | |
---|
39 | namespace orxonox // tolua_export |
---|
40 | { // tolua_export |
---|
41 | class _OrxonoxExport ShipPart // tolua_export |
---|
42 | : public Item |
---|
43 | { // tolua_export |
---|
44 | |
---|
45 | public: |
---|
46 | ShipPart(Context* context); |
---|
47 | virtual ~ShipPart(); |
---|
48 | |
---|
49 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
50 | |
---|
51 | virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator); |
---|
52 | |
---|
53 | virtual void death(); |
---|
54 | |
---|
55 | //virtual void attachTo(Pawn* newParent); |
---|
56 | //virtual void detach(); |
---|
57 | |
---|
58 | void addEntity(StaticEntity* entity); |
---|
59 | StaticEntity* getEntity(unsigned int index); |
---|
60 | bool hasEntity(StaticEntity* entity) const; |
---|
61 | |
---|
62 | void addDestructionEvent(PartDestructionEvent* event); |
---|
63 | PartDestructionEvent* getDestructionEvent(unsigned int index); |
---|
64 | |
---|
65 | void printEntities(); // FIXME: (noep) remove debug |
---|
66 | |
---|
67 | virtual void setDamageAbsorption(float value); |
---|
68 | inline float getDamageAbsorption() |
---|
69 | { return this->damageAbsorption_; } |
---|
70 | |
---|
71 | void setParent(ModularSpaceShip* ship); |
---|
72 | inline ModularSpaceShip* getParent() |
---|
73 | { return this->parent_; } |
---|
74 | |
---|
75 | inline void setAlive(bool var) |
---|
76 | { this->alive_ = var; } |
---|
77 | inline bool isAlive() |
---|
78 | { return this->alive_; } |
---|
79 | |
---|
80 | inline void setEventExecution(bool var) |
---|
81 | { this->eventExecution_ = var; } |
---|
82 | inline bool isEventExecution() |
---|
83 | { return this->eventExecution_; } |
---|
84 | |
---|
85 | virtual void setHealth(float health); |
---|
86 | inline void addHealth(float health) |
---|
87 | { this->setHealth(this->health_ + health); } |
---|
88 | inline void removeHealth(float health) |
---|
89 | { this->setHealth(this->health_ - health); } |
---|
90 | inline float getHealth() const |
---|
91 | { return this->health_; } |
---|
92 | |
---|
93 | inline void setMaxHealth(float maxhealth) |
---|
94 | { this->maxHealth_ = maxhealth; this->setHealth(this->health_); } |
---|
95 | inline float getMaxHealth() const |
---|
96 | { return this->maxHealth_; } |
---|
97 | |
---|
98 | inline void setInitialHealth(float initialhealth) |
---|
99 | { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); } |
---|
100 | inline float getInitialHealth() const |
---|
101 | { return this->initialHealth_; } |
---|
102 | |
---|
103 | |
---|
104 | // FIXME: (noep) Why doesn't this work? Works fine in Engine.h |
---|
105 | //void addToSpaceShip(ModularSpaceShip* ship); |
---|
106 | |
---|
107 | protected: |
---|
108 | ModularSpaceShip* parent_; |
---|
109 | unsigned int parentID_; // Object ID of the SpaceShip the Part is mounted on. |
---|
110 | |
---|
111 | float damageAbsorption_; |
---|
112 | float health_; |
---|
113 | float maxHealth_; |
---|
114 | float initialHealth_; |
---|
115 | |
---|
116 | private: |
---|
117 | std::vector<StaticEntity*> entityList_; // List of all entities which belong to this part |
---|
118 | std::vector<PartDestructionEvent*> eventList_; // The list of all PartDestructionEvent assigned to this ShipPart. |
---|
119 | |
---|
120 | bool alive_; |
---|
121 | bool eventExecution_; |
---|
122 | |
---|
123 | |
---|
124 | }; // tolua_export |
---|
125 | } // tolua_export |
---|
126 | |
---|
127 | #endif /* _ShipPart_H__ */ |
---|