[2072] | 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 | |
---|
[3196] | 34 | #include <string> |
---|
| 35 | #include <LinearMath/btVector3.h> |
---|
[7801] | 36 | #include "tools/Timer.h" |
---|
[3196] | 37 | #include "util/Math.h" |
---|
[2072] | 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(); |
---|
[8580] | 61 | virtual void boost(bool bBoost); // Starts or stops boosting. |
---|
[2072] | 62 | |
---|
[8589] | 63 | void addEngine(Engine* engine); |
---|
| 64 | bool hasEngine(Engine* engine); |
---|
| 65 | Engine* getEngine(unsigned int i); // This one's for XMLPort |
---|
| 66 | inline const std::vector<Engine*>& getEngineList() |
---|
| 67 | { return this->engineList_; } |
---|
[8648] | 68 | void removeEngine(Engine* engine); |
---|
[8589] | 69 | void removeAllEngines(); |
---|
[2072] | 70 | |
---|
[8589] | 71 | void setSpeedFactor(float factor); |
---|
| 72 | float getSpeedFactor(); // Gets mean speed factor |
---|
| 73 | float getMaxSpeedFront(); // gets largest speed forward |
---|
| 74 | float getBoostFactor(); // gets mean boost factor |
---|
| 75 | |
---|
[2662] | 76 | inline void setSteeringDirection(const Vector3& direction) |
---|
| 77 | { this->steering_ = direction; } |
---|
| 78 | inline const Vector3& getSteeringDirection() const |
---|
| 79 | { return this->steering_; } |
---|
[8589] | 80 | inline void resetEngineTicks() |
---|
| 81 | { this->engineTicksNotDone = this->engineList_.size(); } |
---|
| 82 | inline void oneEngineTickDone() |
---|
| 83 | { this->engineTicksNotDone--; } |
---|
[8594] | 84 | inline bool hasEngineTicksRemaining() |
---|
[8589] | 85 | { return (this->engineTicksNotDone>0); } |
---|
[2072] | 86 | |
---|
[2662] | 87 | inline bool getBoost() const |
---|
| 88 | { return this->bBoost_; } |
---|
| 89 | |
---|
[8673] | 90 | inline float getBoostPower() const |
---|
| 91 | { return this->boostPower_; } |
---|
| 92 | inline float getInitialBoostPower() const |
---|
| 93 | { return this->initialBoostPower_; } |
---|
| 94 | |
---|
| 95 | inline bool isBoostCoolingDown() const |
---|
| 96 | { return bBoostCooldown_; } |
---|
| 97 | |
---|
[2072] | 98 | protected: |
---|
[7547] | 99 | virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const; |
---|
[2072] | 100 | bool bInvertYAxis_; |
---|
| 101 | |
---|
[2662] | 102 | bool bBoost_; |
---|
[7801] | 103 | bool bBoostCooldown_; |
---|
| 104 | float boostPower_; |
---|
| 105 | float initialBoostPower_; |
---|
| 106 | float boostRate_; |
---|
| 107 | float boostPowerRate_; |
---|
| 108 | float boostCooldownDuration_; |
---|
[8597] | 109 | float lift_; |
---|
| 110 | float stallSpeed_; |
---|
[2662] | 111 | Vector3 steering_; |
---|
| 112 | float primaryThrust_; |
---|
| 113 | float auxilaryThrust_; |
---|
| 114 | float rotationThrust_; |
---|
| 115 | btVector3 localLinearAcceleration_; |
---|
| 116 | btVector3 localAngularAcceleration_; |
---|
[2072] | 117 | |
---|
[8580] | 118 | float shakeFrequency_; |
---|
| 119 | float shakeAmplitude_; |
---|
| 120 | |
---|
[2662] | 121 | private: |
---|
[7163] | 122 | void registerVariables(); |
---|
[2662] | 123 | virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; |
---|
[7801] | 124 | |
---|
[8589] | 125 | //All things booster |
---|
| 126 | void changedEnableMotionBlur(); |
---|
[7801] | 127 | void boostCooledDown(void); |
---|
[8580] | 128 | |
---|
| 129 | void resetCamera(); |
---|
[8582] | 130 | void backupCamera(); |
---|
[8580] | 131 | void shakeCamera(float dt); |
---|
[2662] | 132 | |
---|
[8589] | 133 | Shader* boostBlur_; |
---|
| 134 | float blurStrength_; |
---|
| 135 | bool bEnableMotionBlur_; |
---|
| 136 | |
---|
| 137 | std::vector<Engine*> engineList_; |
---|
| 138 | int engineTicksNotDone; // Used for knowing when to reset temporary variables. |
---|
[7801] | 139 | Timer timer_; |
---|
[8580] | 140 | Vector3 cameraOriginalPosition_; |
---|
| 141 | Quaternion cameraOriginalOrientation_; |
---|
| 142 | |
---|
| 143 | float shakeDt_; |
---|
[2072] | 144 | }; |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | #endif /* _SpaceShip_H__ */ |
---|