Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h @ 3050

Last change on this file since 3050 was 2918, checked in by landauf, 16 years ago

Added many new features in the Munition class:

  • there are now 3 modes: a) every weapon has it's own magazine b) all weapons use the same magazin c) no magazines, just a big munition pool
  • the Munition class handles the reloading of the magazine

Split the Weapon class into Weapon and WeaponMode. WeaponMode creates the fire of the Weapon. A weapon can own several WeaponModes (for example primary and secondary fire). But it's also possible to have a weapon with several muzzles which all fire at the same time (there's a WeaponMode for each muzzle).

Renamed LaserGun to LaserFire and Fusion to FusionFire. They inherit now from WeaponMode.

Changed the code in the Weapon class to use the new Munition functionality.

Added ReplenishingMunition, a subclass of Munition that replenishes itself (used for LaserGunMunition).

Added a reload command to reload magazines.

  • Property svn:eol-style set to native
File size: 6.9 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 *      Reto Grieder
26 *
27 */
28
29#ifndef _ControllableEntity_H__
30#define _ControllableEntity_H__
31
32#include "OrxonoxPrereqs.h"
33#include "MobileEntity.h"
34
35namespace orxonox
36{
37    class _OrxonoxExport ControllableEntity : public MobileEntity
38    {
39        public:
40            ControllableEntity(BaseObject* creator);
41            virtual ~ControllableEntity();
42
43            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
44            virtual void tick(float dt);
45            void registerVariables();
46            void setConfigValues();
47
48            virtual void changedGametype();
49            virtual void changedPlayer() {}
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(unsigned int firemode) {}
84            virtual void reload() {}
85
86            virtual void boost() {}
87            virtual void greet() {}
88            virtual void use() {}
89            virtual void dropItems() {}
90            virtual void switchCamera();
91            virtual void mouseLook();
92
93            inline const std::string& getHudTemplate() const
94                { return this->hudtemplate_; }
95
96            inline Camera* getCamera() const
97                { return this->camera_; }
98            inline OverlayGroup* getHUD() const
99                { return this->hud_; }
100
101            void addCameraPosition(CameraPosition* position);
102            CameraPosition* getCameraPosition(unsigned int index) const;
103            inline const std::list<CameraPosition*>& getCameraPositions() const
104                { return this->cameraPositions_; }
105
106            inline void setCameraPositionTemplate(const std::string& name)
107                { this->cameraPositionTemplate_ = name; }
108            inline const std::string& getCameraPositionTemkplate() const
109                { return this->cameraPositionTemplate_; }
110
111            using WorldEntity::setPosition;
112            using WorldEntity::setOrientation;
113            using MobileEntity::setVelocity;
114            using MobileEntity::setAngularVelocity;
115
116            void setPosition(const Vector3& position);
117            void setOrientation(const Quaternion& orientation);
118            void setVelocity(const Vector3& velocity);
119            void setAngularVelocity(const Vector3& velocity);
120
121            inline bool hasLocalController() const
122                { return this->bHasLocalController_; }
123            inline bool hasHumanController() const
124                { return this->bHasHumanController_; }
125
126            inline const GametypeInfo* getGametypeInfo() const
127                { return this->gtinfo_; }
128
129            inline bool isInMouseLook() const
130                { return this->bMouseLook_; }
131            inline float getMouseLookSpeed() const
132                { return this->mouseLookSpeed_; }
133
134        protected:
135            virtual void startLocalHumanControl();
136            virtual void stopLocalHumanControl();
137            virtual void parentChanged();
138
139            inline void setHudTemplate(const std::string& name)
140                { this->hudtemplate_ = name; }
141
142        private:
143            void overwrite();
144            void processOverwrite();
145
146            void processServerPosition();
147            void processServerLinearVelocity();
148            void processServerOrientation();
149            void processServerAngularVelocity();
150
151            void processClientPosition();
152            void processClientLinearVelocity();
153            void processClientOrientation();
154            void processClientAngularVelocity();
155
156            void networkcallback_changedplayerID();
157            void networkcallback_changedgtinfoID();
158
159            // Bullet btMotionState related
160            void setWorldTransform(const btTransform& worldTrans);
161
162            unsigned int server_overwrite_;
163            unsigned int client_overwrite_;
164
165            bool bHasLocalController_;
166            bool bHasHumanController_;
167            bool bDestroyWhenPlayerLeft_;
168
169            Vector3 server_position_;
170            Vector3 client_position_;
171            Vector3 server_linear_velocity_;
172            Vector3 client_linear_velocity_;
173            Quaternion server_orientation_;
174            Quaternion client_orientation_;
175            Vector3 server_angular_velocity_;
176            Vector3 client_angular_velocity_;
177
178            PlayerInfo* player_;
179            unsigned int playerID_;
180
181            std::string hudtemplate_;
182            OverlayGroup* hud_;
183
184            Camera* camera_;
185            bool bMouseLook_;
186            float mouseLookSpeed_;
187            Ogre::SceneNode* cameraPositionRootNode_;
188            std::list<CameraPosition*> cameraPositions_;
189            std::string cameraPositionTemplate_;
190
191            const GametypeInfo* gtinfo_;
192            unsigned int gtinfoID_;
193    };
194}
195
196#endif /* _ControllableEntity_H__ */
Note: See TracBrowser for help on using the repository browser.