[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: |
---|
[2407] | 25 | * Reto Grieder |
---|
[2072] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _ControllableEntity_H__ |
---|
| 30 | #define _ControllableEntity_H__ |
---|
| 31 | |
---|
| 32 | #include "OrxonoxPrereqs.h" |
---|
| 33 | |
---|
[2408] | 34 | #include "MobileEntity.h" |
---|
[2072] | 35 | |
---|
| 36 | namespace orxonox |
---|
| 37 | { |
---|
[2408] | 38 | class _OrxonoxExport ControllableEntity : public MobileEntity |
---|
[2072] | 39 | { |
---|
| 40 | public: |
---|
| 41 | ControllableEntity(BaseObject* creator); |
---|
| 42 | virtual ~ControllableEntity(); |
---|
| 43 | |
---|
| 44 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 45 | virtual void tick(float dt); |
---|
| 46 | void registerVariables(); |
---|
| 47 | |
---|
| 48 | virtual void setPlayer(PlayerInfo* player); |
---|
| 49 | virtual void removePlayer(); |
---|
| 50 | inline PlayerInfo* getPlayer() const |
---|
| 51 | { return this->player_; } |
---|
| 52 | |
---|
| 53 | inline void setDestroyWhenPlayerLeft(bool bDestroy) |
---|
| 54 | { this->bDestroyWhenPlayerLeft_ = bDestroy; } |
---|
| 55 | inline bool getDestroyWhenPlayerLeft() const |
---|
| 56 | { return this->bDestroyWhenPlayerLeft_; } |
---|
| 57 | |
---|
| 58 | virtual void moveFrontBack(const Vector2& value) {} |
---|
| 59 | virtual void moveRightLeft(const Vector2& value) {} |
---|
| 60 | virtual void moveUpDown(const Vector2& value) {} |
---|
| 61 | |
---|
| 62 | virtual void rotateYaw(const Vector2& value) {} |
---|
| 63 | virtual void rotatePitch(const Vector2& value) {} |
---|
| 64 | virtual void rotateRoll(const Vector2& value) {} |
---|
| 65 | |
---|
| 66 | virtual void fire() {} |
---|
| 67 | virtual void altFire() {} |
---|
| 68 | |
---|
| 69 | virtual void greet() {} |
---|
| 70 | virtual void use() {} |
---|
| 71 | virtual void switchCamera(); |
---|
| 72 | |
---|
| 73 | inline const std::string& getHudTemplate() const |
---|
| 74 | { return this->hudtemplate_; } |
---|
| 75 | |
---|
| 76 | inline Camera* getCamera() const |
---|
| 77 | { return this->camera_; } |
---|
| 78 | inline OverlayGroup* getHUD() const |
---|
| 79 | { return this->hud_; } |
---|
| 80 | |
---|
| 81 | void addCameraPosition(CameraPosition* position); |
---|
| 82 | CameraPosition* getCameraPosition(unsigned int index) const; |
---|
| 83 | inline const std::list<CameraPosition*>& getCameraPositions() const |
---|
| 84 | { return this->cameraPositions_; } |
---|
| 85 | |
---|
| 86 | inline void setCameraPositionTemplate(const std::string& name) |
---|
| 87 | { this->cameraPositionTemplate_ = name; } |
---|
| 88 | inline const std::string& getCameraPositionTemkplate() const |
---|
| 89 | { return this->cameraPositionTemplate_; } |
---|
| 90 | |
---|
| 91 | protected: |
---|
| 92 | virtual void startLocalControl(); |
---|
| 93 | virtual void stopLocalControl(); |
---|
| 94 | |
---|
| 95 | inline void setHudTemplate(const std::string& name) |
---|
| 96 | { this->hudtemplate_ = name; } |
---|
| 97 | |
---|
| 98 | inline bool isLocallyControlled() const |
---|
| 99 | { return this->bControlled_; } |
---|
| 100 | |
---|
| 101 | private: |
---|
| 102 | void overwrite(); |
---|
| 103 | void processOverwrite(); |
---|
| 104 | |
---|
| 105 | void processServerPosition(); |
---|
[2374] | 106 | void processServerLinearVelocity(); |
---|
[2072] | 107 | void processServerOrientation(); |
---|
[2374] | 108 | void processServerAngularVelocity(); |
---|
[2072] | 109 | |
---|
| 110 | void processClientPosition(); |
---|
[2374] | 111 | void processClientLinearVelocity(); |
---|
[2072] | 112 | void processClientOrientation(); |
---|
[2374] | 113 | void processClientAngularVelocity(); |
---|
[2072] | 114 | |
---|
[2374] | 115 | void positionChanged (bool bContinuous); |
---|
| 116 | void orientationChanged (bool bContinuous); |
---|
| 117 | void linearVelocityChanged (bool bContinuous); |
---|
| 118 | void angularVelocityChanged(bool bContinuous); |
---|
[2292] | 119 | |
---|
[2072] | 120 | void networkcallback_changedplayerID(); |
---|
| 121 | |
---|
| 122 | unsigned int server_overwrite_; |
---|
| 123 | unsigned int client_overwrite_; |
---|
| 124 | |
---|
| 125 | bool bControlled_; |
---|
| 126 | Vector3 server_position_; |
---|
| 127 | Vector3 client_position_; |
---|
[2374] | 128 | Vector3 server_linear_velocity_; |
---|
| 129 | Vector3 client_linear_velocity_; |
---|
[2072] | 130 | Quaternion server_orientation_; |
---|
| 131 | Quaternion client_orientation_; |
---|
[2374] | 132 | Vector3 server_angular_velocity_; |
---|
| 133 | Vector3 client_angular_velocity_; |
---|
[2072] | 134 | |
---|
| 135 | PlayerInfo* player_; |
---|
| 136 | unsigned int playerID_; |
---|
| 137 | std::string hudtemplate_; |
---|
| 138 | OverlayGroup* hud_; |
---|
| 139 | Camera* camera_; |
---|
| 140 | bool bDestroyWhenPlayerLeft_; |
---|
| 141 | |
---|
| 142 | std::list<CameraPosition*> cameraPositions_; |
---|
| 143 | std::string cameraPositionTemplate_; |
---|
| 144 | }; |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | #endif /* _ControllableEntity_H__ */ |
---|