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 | #ifndef _SpaceShip_H__ |
---|
30 | #define _SpaceShip_H__ |
---|
31 | |
---|
32 | #include "OrxonoxPrereqs.h" |
---|
33 | |
---|
34 | #include <string> |
---|
35 | #include <LinearMath/btVector3.h> |
---|
36 | #include "tools/Timer.h" |
---|
37 | #include "util/Math.h" |
---|
38 | #include "Pawn.h" |
---|
39 | |
---|
40 | namespace orxonox |
---|
41 | { |
---|
42 | class _OrxonoxExport SpaceShip : public Pawn |
---|
43 | { |
---|
44 | public: |
---|
45 | SpaceShip(BaseObject* creator); |
---|
46 | virtual ~SpaceShip(); |
---|
47 | |
---|
48 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
49 | virtual void tick(float dt); |
---|
50 | void setConfigValues(); |
---|
51 | |
---|
52 | virtual void moveFrontBack(const Vector2& value); |
---|
53 | virtual void moveRightLeft(const Vector2& value); |
---|
54 | virtual void moveUpDown(const Vector2& value); |
---|
55 | |
---|
56 | virtual void rotateYaw(const Vector2& value); |
---|
57 | virtual void rotatePitch(const Vector2& value); |
---|
58 | virtual void rotateRoll(const Vector2& value); |
---|
59 | |
---|
60 | virtual void fire(); |
---|
61 | virtual void boost(bool bBoost); // Starts or stops boosting. |
---|
62 | |
---|
63 | void setEngine(Engine* engine); |
---|
64 | inline Engine* getEngine() const |
---|
65 | { return this->engine_; } |
---|
66 | |
---|
67 | inline void setSteeringDirection(const Vector3& direction) |
---|
68 | { this->steering_ = direction; } |
---|
69 | inline const Vector3& getSteeringDirection() const |
---|
70 | { return this->steering_; } |
---|
71 | |
---|
72 | inline bool getBoost() const |
---|
73 | { return this->bBoost_; } |
---|
74 | |
---|
75 | inline void setEngineTemplate(const std::string& temp) |
---|
76 | { this->enginetemplate_ = temp; this->loadEngineTemplate(); } |
---|
77 | inline const std::string& getEngineTemplate() const |
---|
78 | { return this->enginetemplate_; } |
---|
79 | |
---|
80 | protected: |
---|
81 | virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const; |
---|
82 | bool bInvertYAxis_; |
---|
83 | |
---|
84 | bool bBoost_; |
---|
85 | bool bBoostCooldown_; |
---|
86 | float boostPower_; |
---|
87 | float initialBoostPower_; |
---|
88 | float boostRate_; |
---|
89 | float boostPowerRate_; |
---|
90 | float boostCooldownDuration_; |
---|
91 | Vector3 steering_; |
---|
92 | float primaryThrust_; |
---|
93 | float auxilaryThrust_; |
---|
94 | float rotationThrust_; |
---|
95 | btVector3 localLinearAcceleration_; |
---|
96 | btVector3 localAngularAcceleration_; |
---|
97 | |
---|
98 | float shakeFrequency_; |
---|
99 | float shakeAmplitude_; |
---|
100 | |
---|
101 | private: |
---|
102 | void registerVariables(); |
---|
103 | virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; |
---|
104 | |
---|
105 | void loadEngineTemplate(); |
---|
106 | |
---|
107 | void boostCooledDown(void); |
---|
108 | |
---|
109 | void resetCamera(); |
---|
110 | void shakeCamera(float dt); |
---|
111 | |
---|
112 | std::string enginetemplate_; |
---|
113 | Engine* engine_; |
---|
114 | Timer timer_; |
---|
115 | Vector3 cameraOriginalPosition_; |
---|
116 | Quaternion cameraOriginalOrientation_; |
---|
117 | |
---|
118 | float shakeDt_; |
---|
119 | }; |
---|
120 | } |
---|
121 | |
---|
122 | #endif /* _SpaceShip_H__ */ |
---|