Orxonox  0.0.5 Codename: Arcturus
ShipPart.h
Go to the documentation of this file.
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"
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) override;
50 
51  virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator);
52 
53  virtual void death();
54  virtual void explode();
55 
56  //virtual void attachTo(Pawn* newParent);
57  //virtual void detach();
58 
59  void addEntity(StaticEntity* entity);
60  StaticEntity* getEntity(unsigned int index);
61  bool hasEntity(StaticEntity* entity) const;
62 
63  void addDestructionEvent(PartDestructionEvent* event);
64  PartDestructionEvent* getDestructionEvent(unsigned int index);
65 
66  inline void setDamageAbsorption(float value)
67  { this->damageAbsorption_ = value; }
68  inline float getDamageAbsorption() const
69  { return this->damageAbsorption_; }
70 
71  void setParent(ModularSpaceShip* ship);
72  inline ModularSpaceShip* getParent() const
73  { return this->parent_; }
74 
75  inline void setEventExecution(bool var)
76  { this->eventExecution_ = var; }
77  inline bool isEventExecution() const
78  { return this->eventExecution_; }
79 
80  inline void setHealth(float health)
81  { this->health_ = health; }
82  inline void addHealth(float health)
83  { this->setHealth(this->health_ + health); }
84  inline void removeHealth(float health)
85  { this->setHealth(this->health_ - health); }
86  inline float getHealth() const
87  { return this->health_; }
88 
89  inline void setMaxHealth(float maxhealth)
90  { this->maxHealth_ = maxhealth; this->setHealth(this->health_); }
91  inline float getMaxHealth() const
92  { return this->maxHealth_; }
93 
94  inline void setInitialHealth(float initialhealth)
95  { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); }
96  inline float getInitialHealth() const
97  { return this->initialHealth_; }
98 
99  inline void setExplosionPosition(Vector3 pos)
100  { this->explosionPosition_ = pos; }
101  inline Vector3 getExplosionPosition()
102  { return this->explosionPosition_; }
103 
104 
105  // FIXME: (noep) Why doesn't this work? Works fine in Engine.h
106  //void addToSpaceShip(ModularSpaceShip* ship);
107 
108  protected:
110  unsigned int parentID_; // Object ID of the SpaceShip the Part is mounted on.
111 
113  float health_;
114  float maxHealth_;
116 
117  private:
118  std::vector<StaticEntity*> entityList_; // List of all entities which belong to this part
119  std::vector<PartDestructionEvent*> eventList_; // The list of all PartDestructionEvent assigned to this ShipPart.
120 
122 
123  float healthMem_;
124 
126 
127 
128  }; // tolua_export
129 } // tolua_export
130 
131 #endif /* _ShipPart_H__ */
bool eventExecution_
Definition: ShipPart.h:121
Everything in Orxonox that has a health attribute is a Pawn.
Definition: Pawn.h:56
void setMaxHealth(float maxhealth)
Definition: ShipPart.h:89
float healthMem_
Definition: ShipPart.h:123
The SpaceShip is the principal entity through which the player interacts with the game...
Definition: ModularSpaceShip.h:100
void setExplosionPosition(Vector3 pos)
Definition: ShipPart.h:99
The StaticEntity is the simplest derivative of the orxonox::WorldEntity class.
Definition: StaticEntity.h:50
float maxHealth_
Definition: ShipPart.h:114
float getHealth() const
Definition: ShipPart.h:86
Structure to describe a single event.
Definition: ScriptController.h:42
ModularSpaceShip * parent_
Definition: ShipPart.h:109
ModularSpaceShip * getParent() const
Definition: ShipPart.h:72
Definition: ShipPart.h:41
std::vector< StaticEntity * > entityList_
Definition: ShipPart.h:118
float health_
Definition: ShipPart.h:113
float getDamageAbsorption() const
Definition: ShipPart.h:68
void setHealth(float health)
Definition: ShipPart.h:80
xmlelement
Definition: Super.h:519
void setInitialHealth(float initialhealth)
Definition: ShipPart.h:94
float damageAbsorption_
Definition: ShipPart.h:112
Vector3 explosionPosition_
Definition: ShipPart.h:125
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Definition: Item.h:39
Mode
Definition: CorePrereqs.h:102
Shared library macros, enums, constants and forward declarations for the orxonox library ...
unsigned int parentID_
Definition: ShipPart.h:110
Definition: Context.h:45
void removeHealth(float health)
Definition: ShipPart.h:84
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
void setDamageAbsorption(float value)
Definition: ShipPart.h:66
void addHealth(float health)
Definition: ShipPart.h:82
bool isEventExecution() const
Definition: ShipPart.h:77
void setEventExecution(bool var)
Definition: ShipPart.h:75
float getMaxHealth() const
Definition: ShipPart.h:91
Vector3 getExplosionPosition()
Definition: ShipPart.h:101
float getInitialHealth() const
Definition: ShipPart.h:96
float initialHealth_
Definition: ShipPart.h:115
In order to assign attached entities to a ShipPart, a ShipPart with the same name as the correspondin...
Definition: PartDestructionEvent.h:74
std::vector< PartDestructionEvent * > eventList_
Definition: ShipPart.h:119