Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/modularships/src/orxonox/items/ShipPart.h @ 10049

Last change on this file since 10049 was 10023, checked in by noep, 11 years ago

ShipParts can "die" and detach the corresponding Entity while doing so. Issue: The Entity being detached while a hit on a collisionshape is being handled causes a runtime-error.

File size: 3.5 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 *      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
35#include <string>
36
37
38namespace orxonox // tolua_export
39{ // tolua_export
40    class _OrxonoxExport ShipPart // tolua_export
41        : public Item
42    { // tolua_export
43
44        public:
45            ShipPart(Context* context);
46            virtual ~ShipPart();
47
48            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
49
50            virtual void handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator);
51
52            virtual void death();
53
54            //virtual void attachTo(Pawn* newParent);
55            //virtual void detach();
56
57            void addEntity(StaticEntity* entity);
58            StaticEntity* getEntity(unsigned int index);
59            bool hasEntity(StaticEntity* entity) const;
60
61            void printEntities(); // FIXME: (noep) remove debug
62
63            virtual void setDamageAbsorption(float value);
64            inline float getDamageAbsorption()
65                { return this->damageAbsorption_; }
66
67            void setParent(ModularSpaceShip* ship);
68            inline ModularSpaceShip* getParent()
69                { return this->parent_; }
70
71            virtual void setHealth(float health);
72            inline void addHealth(float health)
73                { this->setHealth(this->health_ + health); }
74            inline void removeHealth(float health)
75                { this->setHealth(this->health_ - health); }
76            inline float getHealth() const
77                { return this->health_; }
78
79            inline void setMaxHealth(float maxhealth)
80                { this->maxHealth_ = maxhealth; this->setHealth(this->health_); }
81            inline float getMaxHealth() const
82                { return this->maxHealth_; }
83
84            inline void setInitialHealth(float initialhealth)
85                { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); }
86            inline float getInitialHealth() const
87                { return this->initialHealth_; }
88
89
90            // FIXME: (noep) Why doesn't this work? Works fine in Engine.h
91            //void addToSpaceShip(ModularSpaceShip* ship);
92
93        protected:
94            ModularSpaceShip* parent_;
95            unsigned int parentID_; // Object ID of the SpaceShip the Part is mounted on.
96
97            float damageAbsorption_;
98            float health_;
99            float maxHealth_;
100            float initialHealth_;
101
102        private:
103            std::vector<StaticEntity*> entityList_; // list of all entities which belong to this part
104
105    }; // tolua_export
106} // tolua_export
107
108#endif /* _ShipPart_H__ */
Note: See TracBrowser for help on using the repository browser.