[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: |
---|
[2662] | 25 | * Reto Grieder |
---|
[2072] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _ControllableEntity_H__ |
---|
| 30 | #define _ControllableEntity_H__ |
---|
| 31 | |
---|
| 32 | #include "OrxonoxPrereqs.h" |
---|
| 33 | |
---|
[2662] | 34 | #include "MobileEntity.h" |
---|
| 35 | #include "objects/weaponSystem/WeaponSystem.h" |
---|
[2072] | 36 | |
---|
| 37 | namespace orxonox |
---|
| 38 | { |
---|
[2662] | 39 | class _OrxonoxExport ControllableEntity : public MobileEntity |
---|
[2072] | 40 | { |
---|
| 41 | public: |
---|
| 42 | ControllableEntity(BaseObject* creator); |
---|
| 43 | virtual ~ControllableEntity(); |
---|
| 44 | |
---|
| 45 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 46 | virtual void tick(float dt); |
---|
| 47 | void registerVariables(); |
---|
[2662] | 48 | void setConfigValues(); |
---|
[2072] | 49 | |
---|
[2662] | 50 | virtual void changedGametype(); |
---|
[2839] | 51 | virtual void changedPlayer() {} |
---|
[2662] | 52 | |
---|
[2072] | 53 | virtual void setPlayer(PlayerInfo* player); |
---|
| 54 | virtual void removePlayer(); |
---|
| 55 | inline PlayerInfo* getPlayer() const |
---|
| 56 | { return this->player_; } |
---|
| 57 | |
---|
| 58 | inline void setDestroyWhenPlayerLeft(bool bDestroy) |
---|
| 59 | { this->bDestroyWhenPlayerLeft_ = bDestroy; } |
---|
| 60 | inline bool getDestroyWhenPlayerLeft() const |
---|
| 61 | { return this->bDestroyWhenPlayerLeft_; } |
---|
| 62 | |
---|
| 63 | virtual void moveFrontBack(const Vector2& value) {} |
---|
| 64 | virtual void moveRightLeft(const Vector2& value) {} |
---|
| 65 | virtual void moveUpDown(const Vector2& value) {} |
---|
| 66 | |
---|
[2662] | 67 | virtual void rotateYaw(const Vector2& value); |
---|
| 68 | virtual void rotatePitch(const Vector2& value); |
---|
| 69 | virtual void rotateRoll(const Vector2& value); |
---|
[2072] | 70 | |
---|
[2662] | 71 | inline void moveFrontBack(float value) |
---|
| 72 | { this->moveFrontBack(Vector2(value, 0)); } |
---|
| 73 | inline void moveRightLeft(float value) |
---|
| 74 | { this->moveRightLeft(Vector2(value, 0)); } |
---|
| 75 | inline void moveUpDown(float value) |
---|
| 76 | { this->moveUpDown(Vector2(value, 0)); } |
---|
[2072] | 77 | |
---|
[2662] | 78 | inline void rotateYaw(float value) |
---|
| 79 | { this->rotateYaw(Vector2(value, 0)); } |
---|
| 80 | inline void rotatePitch(float value) |
---|
| 81 | { this->rotatePitch(Vector2(value, 0)); } |
---|
| 82 | inline void rotateRoll(float value) |
---|
| 83 | { this->rotateRoll(Vector2(value, 0)); } |
---|
| 84 | |
---|
| 85 | virtual void fire(WeaponMode::Enum fireMode) {} |
---|
| 86 | virtual void altFire(WeaponMode::Enum fireMode) {} |
---|
| 87 | |
---|
| 88 | virtual void boost() {} |
---|
[2072] | 89 | virtual void greet() {} |
---|
| 90 | virtual void use() {} |
---|
[2662] | 91 | virtual void dropItems() {} |
---|
[2072] | 92 | virtual void switchCamera(); |
---|
[2662] | 93 | virtual void mouseLook(); |
---|
[2072] | 94 | |
---|
| 95 | inline const std::string& getHudTemplate() const |
---|
| 96 | { return this->hudtemplate_; } |
---|
| 97 | |
---|
| 98 | inline Camera* getCamera() const |
---|
| 99 | { return this->camera_; } |
---|
| 100 | inline OverlayGroup* getHUD() const |
---|
| 101 | { return this->hud_; } |
---|
| 102 | |
---|
| 103 | void addCameraPosition(CameraPosition* position); |
---|
| 104 | CameraPosition* getCameraPosition(unsigned int index) const; |
---|
| 105 | inline const std::list<CameraPosition*>& getCameraPositions() const |
---|
| 106 | { return this->cameraPositions_; } |
---|
| 107 | |
---|
| 108 | inline void setCameraPositionTemplate(const std::string& name) |
---|
| 109 | { this->cameraPositionTemplate_ = name; } |
---|
| 110 | inline const std::string& getCameraPositionTemkplate() const |
---|
| 111 | { return this->cameraPositionTemplate_; } |
---|
| 112 | |
---|
[2662] | 113 | using WorldEntity::setPosition; |
---|
| 114 | using WorldEntity::setOrientation; |
---|
| 115 | using MobileEntity::setVelocity; |
---|
| 116 | using MobileEntity::setAngularVelocity; |
---|
| 117 | |
---|
| 118 | void setPosition(const Vector3& position); |
---|
| 119 | void setOrientation(const Quaternion& orientation); |
---|
| 120 | void setVelocity(const Vector3& velocity); |
---|
| 121 | void setAngularVelocity(const Vector3& velocity); |
---|
| 122 | |
---|
| 123 | inline bool hasLocalController() const |
---|
| 124 | { return this->bHasLocalController_; } |
---|
| 125 | inline bool hasHumanController() const |
---|
| 126 | { return this->bHasHumanController_; } |
---|
| 127 | |
---|
| 128 | inline const GametypeInfo* getGametypeInfo() const |
---|
| 129 | { return this->gtinfo_; } |
---|
| 130 | |
---|
| 131 | inline bool isInMouseLook() const |
---|
| 132 | { return this->bMouseLook_; } |
---|
| 133 | inline float getMouseLookSpeed() const |
---|
| 134 | { return this->mouseLookSpeed_; } |
---|
| 135 | |
---|
[2072] | 136 | protected: |
---|
[2662] | 137 | virtual void startLocalHumanControl(); |
---|
| 138 | virtual void stopLocalHumanControl(); |
---|
[2851] | 139 | virtual void parentChanged(); |
---|
[2072] | 140 | |
---|
| 141 | inline void setHudTemplate(const std::string& name) |
---|
| 142 | { this->hudtemplate_ = name; } |
---|
| 143 | |
---|
| 144 | private: |
---|
| 145 | void overwrite(); |
---|
| 146 | void processOverwrite(); |
---|
| 147 | |
---|
| 148 | void processServerPosition(); |
---|
[2662] | 149 | void processServerLinearVelocity(); |
---|
[2072] | 150 | void processServerOrientation(); |
---|
[2662] | 151 | void processServerAngularVelocity(); |
---|
[2072] | 152 | |
---|
| 153 | void processClientPosition(); |
---|
[2662] | 154 | void processClientLinearVelocity(); |
---|
[2072] | 155 | void processClientOrientation(); |
---|
[2662] | 156 | void processClientAngularVelocity(); |
---|
[2072] | 157 | |
---|
| 158 | void networkcallback_changedplayerID(); |
---|
[2662] | 159 | void networkcallback_changedgtinfoID(); |
---|
[2072] | 160 | |
---|
[2662] | 161 | // Bullet btMotionState related |
---|
| 162 | void setWorldTransform(const btTransform& worldTrans); |
---|
| 163 | |
---|
[2072] | 164 | unsigned int server_overwrite_; |
---|
| 165 | unsigned int client_overwrite_; |
---|
| 166 | |
---|
[2662] | 167 | bool bHasLocalController_; |
---|
| 168 | bool bHasHumanController_; |
---|
| 169 | bool bDestroyWhenPlayerLeft_; |
---|
[2072] | 170 | |
---|
| 171 | Vector3 server_position_; |
---|
| 172 | Vector3 client_position_; |
---|
[2662] | 173 | Vector3 server_linear_velocity_; |
---|
| 174 | Vector3 client_linear_velocity_; |
---|
[2072] | 175 | Quaternion server_orientation_; |
---|
| 176 | Quaternion client_orientation_; |
---|
[2662] | 177 | Vector3 server_angular_velocity_; |
---|
| 178 | Vector3 client_angular_velocity_; |
---|
[2072] | 179 | |
---|
| 180 | PlayerInfo* player_; |
---|
| 181 | unsigned int playerID_; |
---|
[2662] | 182 | |
---|
[2072] | 183 | std::string hudtemplate_; |
---|
| 184 | OverlayGroup* hud_; |
---|
[2662] | 185 | |
---|
[2072] | 186 | Camera* camera_; |
---|
[2662] | 187 | bool bMouseLook_; |
---|
| 188 | float mouseLookSpeed_; |
---|
| 189 | Ogre::SceneNode* cameraPositionRootNode_; |
---|
[2072] | 190 | std::list<CameraPosition*> cameraPositions_; |
---|
| 191 | std::string cameraPositionTemplate_; |
---|
[2662] | 192 | |
---|
| 193 | const GametypeInfo* gtinfo_; |
---|
| 194 | unsigned int gtinfoID_; |
---|
[2072] | 195 | }; |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | #endif /* _ControllableEntity_H__ */ |
---|