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