Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/campaignHS15/src/orxonox/controllers/CommonController.h @ 10869

Last change on this file since 10869 was 10869, checked in by gania, 8 years ago

fixed a bug and got rid of unnecessary Rank enumeration, used getIdentifire instead

File size: 5.6 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 _CommonController_H__
30#define _CommonController_H__
31
32
33#include "controllers/Controller.h"
34#include "worldentities/ControllableEntity.h"
35#include "worldentities/pawns/Pawn.h"
36#include "util/Math.h"
37
38#include "tools/Timer.h"
39#include "tools/interfaces/Tickable.h"
40#include <limits>
41#include <algorithm>
42#include "worldentities/Actionpoint.h"
43#include "worldentities/pawns/SpaceShip.h"
44
45namespace orxonox
46{
47
48    namespace FormationMode
49    {
50        enum Value
51        {
52            FINGER4, DIAMOND, WALL
53        };
54    }
55
56
57   
58 
59
60    class _OrxonoxExport CommonController : public Controller, public Tickable
61    {
62
63        public:
64            static const float hardcoded_projectile_speed = 750;
65            static const float ACTION_INTERVAL = 1.0f;
66
67            CommonController(Context* context);
68            virtual ~CommonController();
69
70            virtual void tick(float dt); 
71
72            //----[XML methods]----
73                virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
74               
75                void setFormationModeXML(std::string val);
76                std::string getFormationModeXML();
77                void setFormationMode(FormationMode::Value val);
78                FormationMode::Value getFormationMode() const;
79
80               
81
82            //----[/XML methods]----
83
84            //----[Interaction with other Controllers]----
85                virtual bool setWingman(CommonController* wingman);
86                virtual bool hasWingman();       
87               
88                bool hasTarget();
89                ControllableEntity* getTarget();
90                     
91             //----[/Interaction with other Controllers]----
92
93            //----[Helper methods]----
94                float randomInRange(float a, float b);
95                static float distance(ControllableEntity* entity1, ControllableEntity* entity2);
96                static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt);
97                static bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) ;
98                static std::string getName( Pawn* entity ) ;
99
100                float squaredDistanceToTarget() const;
101                bool isLookingAtTarget(float angle);
102            //----[/Helper methods]----
103
104 
105        protected:
106            //----[Flying methods]----
107                void stopMoving();
108                void stopLookingAtTarget();
109                void startLookingAtTarget();
110
111                void moveToPosition(const Vector3& target, float dt);
112                void moveToTargetPosition(float dt);
113
114                void copyOrientation(const Quaternion& orient, float dt);
115                void copyTargetOrientation(float dt);
116
117                void lookAtTarget(float dt);
118
119                void setTargetPosition(const Vector3& target);
120                void setTargetOrientation(const Quaternion& orient);
121                void setTargetOrientation(ControllableEntity* target);
122                virtual void boostControl();
123
124
125            //----[/Flying methods]----
126           
127            //----[Fighting methods]----
128                void setTarget(ControllableEntity* target);
129
130                void setPositionOfTarget(const Vector3& target);
131                void setOrientationOfTarget(const Quaternion& orient);
132
133
134                void maneuver();
135                void dodge(Vector3& thisPosition, Vector3& diffUnit);
136                bool canFire();
137                void doFire();
138
139            //----[/Fighting methods]----           
140           
141            //----[where-to-fly information]----
142               
143                bool bHasTargetPosition_;
144                Vector3 targetPosition_;
145                bool bHasTargetOrientation_;
146                Quaternion targetOrientation_;
147               
148            //----[/where-to-fly information]----
149            //----[protect information]----
150                WeakPtr<ControllableEntity> protect_;
151            //----[/protect information]----
152            //----[who-to-kill information]----
153                WeakPtr<ControllableEntity> target_;
154               
155                bool bHasPositionOfTarget_;
156                Vector3 positionOfTarget_;
157                bool bHasOrientationOfTarget_;
158                Quaternion orientationOfTarget_;
159            //----[/who-to-kill information]----
160
161
162            //----["Private" variables]----
163                FormationMode::Value formationMode_;
164
165                int attackRange_;
166                bool bLookAtTarget_;       
167                bool bShooting_;
168                int maneuverCounter_;
169                int tolerance_; 
170                bool bFirstTick_; 
171           
172            //----[/"Private" variables]----   
173           
174    };
175}
176
177#endif /* _CommonController_H__ */
Note: See TracBrowser for help on using the repository browser.