[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(); |
---|
[2072] | 139 | |
---|
| 140 | inline void setHudTemplate(const std::string& name) |
---|
| 141 | { this->hudtemplate_ = name; } |
---|
| 142 | |
---|
| 143 | private: |
---|
| 144 | void overwrite(); |
---|
| 145 | void processOverwrite(); |
---|
| 146 | |
---|
| 147 | void processServerPosition(); |
---|
[2662] | 148 | void processServerLinearVelocity(); |
---|
[2072] | 149 | void processServerOrientation(); |
---|
[2662] | 150 | void processServerAngularVelocity(); |
---|
[2072] | 151 | |
---|
| 152 | void processClientPosition(); |
---|
[2662] | 153 | void processClientLinearVelocity(); |
---|
[2072] | 154 | void processClientOrientation(); |
---|
[2662] | 155 | void processClientAngularVelocity(); |
---|
[2072] | 156 | |
---|
| 157 | void networkcallback_changedplayerID(); |
---|
[2662] | 158 | void networkcallback_changedgtinfoID(); |
---|
[2072] | 159 | |
---|
[2662] | 160 | // Bullet btMotionState related |
---|
| 161 | void setWorldTransform(const btTransform& worldTrans); |
---|
| 162 | |
---|
[2072] | 163 | unsigned int server_overwrite_; |
---|
| 164 | unsigned int client_overwrite_; |
---|
| 165 | |
---|
[2662] | 166 | bool bHasLocalController_; |
---|
| 167 | bool bHasHumanController_; |
---|
| 168 | bool bDestroyWhenPlayerLeft_; |
---|
[2072] | 169 | |
---|
| 170 | Vector3 server_position_; |
---|
| 171 | Vector3 client_position_; |
---|
[2662] | 172 | Vector3 server_linear_velocity_; |
---|
| 173 | Vector3 client_linear_velocity_; |
---|
[2072] | 174 | Quaternion server_orientation_; |
---|
| 175 | Quaternion client_orientation_; |
---|
[2662] | 176 | Vector3 server_angular_velocity_; |
---|
| 177 | Vector3 client_angular_velocity_; |
---|
[2072] | 178 | |
---|
| 179 | PlayerInfo* player_; |
---|
| 180 | unsigned int playerID_; |
---|
[2662] | 181 | |
---|
[2072] | 182 | std::string hudtemplate_; |
---|
| 183 | OverlayGroup* hud_; |
---|
[2662] | 184 | |
---|
[2072] | 185 | Camera* camera_; |
---|
[2662] | 186 | bool bMouseLook_; |
---|
| 187 | float mouseLookSpeed_; |
---|
| 188 | Ogre::SceneNode* cameraPositionRootNode_; |
---|
[2072] | 189 | std::list<CameraPosition*> cameraPositions_; |
---|
| 190 | std::string cameraPositionTemplate_; |
---|
[2662] | 191 | |
---|
| 192 | const GametypeInfo* gtinfo_; |
---|
| 193 | unsigned int gtinfoID_; |
---|
[2072] | 194 | }; |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | #endif /* _ControllableEntity_H__ */ |
---|