Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapon2/src/orxonox/objects/worldentities/ControllableEntity.h @ 2672

Last change on this file since 2672 was 2145, checked in by polakma, 16 years ago

added firemodes and a lot of other things

  • Property svn:eol-style set to native
File size: 6.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#include "objects/weaponSystem/WeaponSystem.h"
37
38namespace orxonox
39{
40    class _OrxonoxExport ControllableEntity : public WorldEntity, public Tickable
41    {
42        public:
43            ControllableEntity(BaseObject* creator);
44            virtual ~ControllableEntity();
45
46            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
47            virtual void tick(float dt);
48            void registerVariables();
49
50            virtual void setPlayer(PlayerInfo* player);
51            virtual void removePlayer();
52            inline PlayerInfo* getPlayer() const
53                { return this->player_; }
54
55            inline void setDestroyWhenPlayerLeft(bool bDestroy)
56                { this->bDestroyWhenPlayerLeft_ = bDestroy; }
57            inline bool getDestroyWhenPlayerLeft() const
58                { return this->bDestroyWhenPlayerLeft_; }
59
60            virtual void moveFrontBack(const Vector2& value) {}
61            virtual void moveRightLeft(const Vector2& value) {}
62            virtual void moveUpDown(const Vector2& value) {}
63
64            virtual void rotateYaw(const Vector2& value) {}
65            virtual void rotatePitch(const Vector2& value) {}
66            virtual void rotateRoll(const Vector2& value) {}
67
68            virtual void fire(WeaponMode::Enum fireMode) {}
69            virtual void altFire(WeaponMode::Enum fireMode) {}
70
71            virtual void greet() {}
72            virtual void use() {}
73            virtual void switchCamera();
74
75            inline const Vector3& getVelocity() const
76                { return this->velocity_; }
77            inline const Vector3& getAcceleration() const
78                { return this->acceleration_; }
79            inline const std::string& getHudTemplate() const
80                { return this->hudtemplate_; }
81
82            using WorldEntity::setPosition;
83            using WorldEntity::translate;
84            using WorldEntity::setOrientation;
85            using WorldEntity::rotate;
86            using WorldEntity::yaw;
87            using WorldEntity::pitch;
88            using WorldEntity::roll;
89            using WorldEntity::lookAt;
90            using WorldEntity::setDirection;
91
92            void setPosition(const Vector3& position);
93            void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
94            void setOrientation(const Quaternion& orientation);
95            void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
96            void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
97            void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
98            void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
99            void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
100            void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
101
102            void setVelocity(const Vector3& velocity);
103            inline void setVelocity(float x, float y, float z)
104                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
105
106            inline void setAcceleration(const Vector3& acceleration)
107                { this->acceleration_ = acceleration; }
108            inline void setAcceleration(float x, float y, float z)
109                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
110
111            inline Camera* getCamera() const
112                { return this->camera_; }
113            inline OverlayGroup* getHUD() const
114                { return this->hud_; }
115
116            void addCameraPosition(CameraPosition* position);
117            CameraPosition* getCameraPosition(unsigned int index) const;
118            inline const std::list<CameraPosition*>& getCameraPositions() const
119                { return this->cameraPositions_; }
120
121            inline void setCameraPositionTemplate(const std::string& name)
122                { this->cameraPositionTemplate_ = name; }
123            inline const std::string& getCameraPositionTemkplate() const
124                { return this->cameraPositionTemplate_; }
125
126        protected:
127            virtual void startLocalControl();
128            virtual void stopLocalControl();
129
130            inline void setHudTemplate(const std::string& name)
131                { this->hudtemplate_ = name; }
132
133            inline bool isLocallyControlled() const
134                { return this->bControlled_; }
135
136            Vector3 acceleration_;
137
138        private:
139            void overwrite();
140            void processOverwrite();
141
142            void processServerPosition();
143            void processServerVelocity();
144            void processServerOrientation();
145
146            void processClientPosition();
147            void processClientVelocity();
148            void processClientOrientation();
149
150            void networkcallback_changedplayerID();
151
152            unsigned int server_overwrite_;
153            unsigned int client_overwrite_;
154
155            Vector3 velocity_;
156
157            bool bControlled_;
158            Vector3 server_position_;
159            Vector3 client_position_;
160            Vector3 server_velocity_;
161            Vector3 client_velocity_;
162            Quaternion server_orientation_;
163            Quaternion client_orientation_;
164
165            PlayerInfo* player_;
166            unsigned int playerID_;
167            std::string hudtemplate_;
168            OverlayGroup* hud_;
169            Camera* camera_;
170            bool bDestroyWhenPlayerLeft_;
171
172            std::list<CameraPosition*> cameraPositions_;
173            std::string cameraPositionTemplate_;
174    };
175}
176
177#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.