Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.h @ 2428

Last change on this file since 2428 was 2428, checked in by landauf, 15 years ago
  • Moved some variables from Gametype to GametypeInfo (Gametype exists only on the Server while GametypeInfo is synchronized)
  • Created a new HUD-element, GametypeStatus, based on GametypeInfo (the same effect was formerly achieved by using a hack in Spectator and a TextOverlay)
  • HumanController creates a HUD (additionally to the SpaceShips HUD) which includes GametypeStatus and ChatOverlay and even more in the future
  • Property svn:eol-style set to native
File size: 7.8 KB
Line 
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 _ControllableEntity_H__
30#define _ControllableEntity_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include "WorldEntity.h"
35#include "objects/Tickable.h"
36
37namespace orxonox
38{
39    class _OrxonoxExport ControllableEntity : public WorldEntity, public Tickable
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();
48
49            virtual void changedGametype();
50
51            virtual void setPlayer(PlayerInfo* player);
52            virtual void removePlayer();
53            inline PlayerInfo* getPlayer() const
54                { return this->player_; }
55
56            inline void setDestroyWhenPlayerLeft(bool bDestroy)
57                { this->bDestroyWhenPlayerLeft_ = bDestroy; }
58            inline bool getDestroyWhenPlayerLeft() const
59                { return this->bDestroyWhenPlayerLeft_; }
60
61            virtual void moveFrontBack(const Vector2& value) {}
62            virtual void moveRightLeft(const Vector2& value) {}
63            virtual void moveUpDown(const Vector2& value) {}
64
65            virtual void rotateYaw(const Vector2& value) {}
66            virtual void rotatePitch(const Vector2& value) {}
67            virtual void rotateRoll(const Vector2& value) {}
68
69            inline void moveFrontBack(float value)
70                { this->moveFrontBack(Vector2(value, 0)); }
71            inline void moveRightLeft(float value)
72                { this->moveRightLeft(Vector2(value, 0)); }
73            inline void moveUpDown(float value)
74                { this->moveUpDown(Vector2(value, 0)); }
75
76            inline void rotateYaw(float value)
77                { this->rotateYaw(Vector2(value, 0)); }
78            inline void rotatePitch(float value)
79                { this->rotatePitch(Vector2(value, 0)); }
80            inline void rotateRoll(float value)
81                { this->rotateRoll(Vector2(value, 0)); }
82
83            virtual void fire() {}
84            virtual void altFire() {}
85
86            virtual void boost() {}
87            virtual void greet() {}
88            virtual void use() {}
89            virtual void switchCamera();
90
91            inline const Vector3& getVelocity() const
92                { return this->velocity_; }
93            inline const Vector3& getAcceleration() const
94                { return this->acceleration_; }
95            inline const std::string& getHudTemplate() const
96                { return this->hudtemplate_; }
97
98            using WorldEntity::setPosition;
99            using WorldEntity::translate;
100            using WorldEntity::setOrientation;
101            using WorldEntity::rotate;
102            using WorldEntity::yaw;
103            using WorldEntity::pitch;
104            using WorldEntity::roll;
105            using WorldEntity::lookAt;
106            using WorldEntity::setDirection;
107
108            void setPosition(const Vector3& position);
109            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
110            void setOrientation(const Quaternion& orientation);
111            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
112            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
113            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
114            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
115            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
116            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
117
118            void setVelocity(const Vector3& velocity);
119            inline void setVelocity(float x, float y, float z)
120                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
121
122            inline void setAcceleration(const Vector3& acceleration)
123                { this->acceleration_ = acceleration; }
124            inline void setAcceleration(float x, float y, float z)
125                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
126
127            inline Camera* getCamera() const
128                { return this->camera_; }
129            inline OverlayGroup* getHUD() const
130                { return this->hud_; }
131
132            void addCameraPosition(CameraPosition* position);
133            CameraPosition* getCameraPosition(unsigned int index) const;
134            inline const std::list<CameraPosition*>& getCameraPositions() const
135                { return this->cameraPositions_; }
136
137            inline void setCameraPositionTemplate(const std::string& name)
138                { this->cameraPositionTemplate_ = name; }
139            inline const std::string& getCameraPositionTemkplate() const
140                { return this->cameraPositionTemplate_; }
141
142            inline bool hasLocalController() const
143                { return this->bHasLocalController_; }
144            inline bool hasHumanController() const
145                { return this->bHasHumanController_; }
146
147            inline const GametypeInfo* getGametypeInfo() const
148                { return this->gtinfo_; }
149
150        protected:
151            virtual void startLocalHumanControl();
152            virtual void stopLocalHumanControl();
153
154            inline void setHudTemplate(const std::string& name)
155                { this->hudtemplate_ = name; }
156
157            Vector3 acceleration_;
158
159        private:
160            void overwrite();
161            void processOverwrite();
162
163            void processServerPosition();
164            void processServerVelocity();
165            void processServerOrientation();
166
167            void processClientPosition();
168            void processClientVelocity();
169            void processClientOrientation();
170
171            void networkcallback_changedplayerID();
172            void networkcallback_changedgtinfoID();
173
174            unsigned int server_overwrite_;
175            unsigned int client_overwrite_;
176
177            Vector3 velocity_;
178
179            bool bHasLocalController_;
180            bool bHasHumanController_;
181
182            Vector3 server_position_;
183            Vector3 client_position_;
184            Vector3 server_velocity_;
185            Vector3 client_velocity_;
186            Quaternion server_orientation_;
187            Quaternion client_orientation_;
188
189            PlayerInfo* player_;
190            unsigned int playerID_;
191            std::string hudtemplate_;
192            OverlayGroup* hud_;
193            Camera* camera_;
194            bool bDestroyWhenPlayerLeft_;
195
196            std::list<CameraPosition*> cameraPositions_;
197            std::string cameraPositionTemplate_;
198
199            const GametypeInfo* gtinfo_;
200            unsigned int gtinfoID_;
201    };
202}
203
204#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.