Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.h @ 10368

Last change on this file since 10368 was 10262, checked in by landauf, 10 years ago

eol-style native. no changes in code.

  • Property svn:eol-style set to native
File size: 6.0 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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      Noe Pedrazzini
26 *
27 */
28
29#ifndef _ModularSpaceShip_H__
30#define _ModularSpaceShip_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include <string>
35#include <LinearMath/btVector3.h>
36
37#include "tools/Timer.h"
38#include "util/Math.h"
39#include "util/OrxAssert.h"
40
41#include "SpaceShip.h"
42#include "items/ShipPart.h"
43#include <map>
44
45namespace orxonox
46{
47
48    /**
49    @brief
50        The SpaceShip is the principal entity through which the player interacts with the game. Its main function is to fly, however many things, such as @ref orxonox::Engine Engines or @ref orxonox::Weapon Weapons, can be attached to it.
51        The ModularSpaceShip is an extension of a @ref orxonox::SpaceShip SpaceShip, which uses @ref orxonox::ShipPart ShipParts to allow entities attached to it to be destroyed individually.
52
53        There are several parameters that define the behavior of the ModularSpaceShip>
54        - The <b>rotationThrust</b>, specifies the force with which the ModularSpaceShip rotates.
55        - The <b>boost</b>, there are quite some parameters pertaining to boosting. The boost is a special move of the ModularSpaceShip, where, for a limited amount of time, it can fly considerably faster than usual. The <b>boostPower</b> is the amount of power available for boosting. The <b>boostPowerRate</b> is the rate at which the boost power is replenished. The <b>boostRate</b> is the rate at which boosting uses power. And the <b>boostCooldownDuration</b> is the time the ModularSpaceShip cannot boost, once all the boost power has been used up. Naturally all of these parameters must be non-negative.
56        - The <b>boost shaking</b>, when the ModularSpaceShip boosts, the camera shakes to create a more immersive effect. Two parameters can be used to adjust the effect. The <b>shakeFrequency</b> is the frequency with which the camera shakes. And the <b>shakeAmplitude</b> is the amount with which the camera shakes. Again these parameters must bee non-negative.
57        - The <b>lift</b> creates a more natural flight feeling through the addition of a lift force. There are again tow parameters that can be specified. The <b>lift</b> which is the lift force that is applied. And the <b>stallSpeed</b> which is the forward speed after which no more lift is generated.
58
59        As mentioned @ref orxonox::Engine Engines can be mounted on the ModularSpaceShip.
60        In order to assign attached entities to a ShipPart, a ShipPart with the same name as the corresponding entity needs to be created in the <parts> tag.
61        Here is a (primitive) example of a ModularSpaceShip defined in XML:
62        @code
63        <ModularSpaceShip
64            rotationThrust    = 50
65
66            lift = 1;
67            stallSpeed = 220;
68
69            boostPower            = 15
70            boostPowerRate        = 1
71            boostRate             = 5
72            boostCooldownDuration = 10
73
74            shakeFrequency = 15
75            shakeAmplitude = 9
76
77            collisionType     = "dynamic"
78            mass              = 100
79            linearDamping     = 0.7
80            angularDamping    = 0.9999999
81            >
82                <attached>
83                    <StaticEntity name="wing"  . . .  />
84                    <StaticEntity name="tail" . . . />
85                </attached>
86                <parts>
87                    <ShipPart name="wing" . . . />
88                    <ShipPart name="tail" . . . />
89                </parts>
90                <engines>
91                    <Engine />
92                    <Engine />
93                </engines>
94            </ModularSpaceShip>
95        @endcode
96
97    @author
98        Fabian 'x3n' Landau, Noe Pedrazzini
99    */
100    class _OrxonoxExport ModularSpaceShip : public SpaceShip
101    {
102        public:
103            ModularSpaceShip(Context* context);
104            virtual ~ModularSpaceShip();
105
106            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
107
108            void addPartEntityAssignment(StaticEntity* entity, ShipPart* part);
109            ShipPart* getPartOfEntity(StaticEntity* entity) const;
110
111            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
112
113            static void killShipPartStatic(std::string name);
114            void killShipPart(std::string name);
115
116            void addShipPart(ShipPart* part);
117            ShipPart* getShipPart(unsigned int index);
118            ShipPart* getShipPartByName(std::string name);
119            bool hasShipPart(ShipPart* part) const;
120            void removeShipPart(ShipPart* part);
121
122            inline void setRotationThrust(float val)
123                { this->rotationThrust_ = val; }
124            inline float getRotationThrust()
125                { return this->rotationThrust_; }
126
127            virtual void updatePartAssignment();
128
129        protected:
130
131
132        private:
133            void registerVariables();
134            std::vector<ShipPart*> partList_;                       // The list of all Parts mounted on this ModularSpaceShip.
135            std::map<StaticEntity*, ShipPart*> partMap_;            // Map of Part-Entity-assignments
136            static std::map<StaticEntity*, ShipPart*>* partMap_s;
137       
138    };
139}
140
141#endif /* _ModularSpaceShip_H__ */
Note: See TracBrowser for help on using the repository browser.