Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

gani check in before a major change

File size: 7.3 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>
[10719]41
[10759]42
[10719]43namespace orxonox
44{
[10759]45
46    namespace FormationMode
47    {
48        enum Value
49        {
[10826]50            FINGER4, DIAMOND, WALL
[10759]51        };
52    }
53    namespace Rank
54    {
55        enum Value
56        { 
57            NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN
58        };
59
60    }
[10805]61    namespace Action
62    { 
63        enum Value
64        {
65            FLY, FIGHT, PROTECT
66        };
67    }
[10826]68 
[10761]69
[10843]70    class _OrxonoxExport CommonController : public Controller, public Tickable
[10719]71    {
[10796]72
[10719]73        public:
[10803]74            static const float hardcoded_projectile_speed = 750;
75            static const float ACTION_INTERVAL = 1.0f;
[10729]76
[10731]77            CommonController(Context* context);
78            virtual ~CommonController();
79
[10840]80            virtual void tick(float dt); 
81
[10832]82            //----[XML data]----
83                virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
84                //----[Action data]----
85                    Action::Value getAction ();
86                    void setAction (Action::Value action);
87                    void setAction (Action::Value action, ControllableEntity* target);
88                    void setAction (Action::Value action, const Vector3& target);
89                    void setAction (Action::Value action, const Vector3& target,  const Quaternion& orient );
90                    void setActionXML( std::string val);
91                    std::string getActionXML();
92                //----[/Action data]----
93                //----[Formation data]----
94                    virtual void setFormationModeXML(std::string val);
95                    virtual std::string getFormationModeXML();
96                    virtual void setFormationMode(FormationMode::Value val)
97                        { this->formationMode_ = val; }
98                    inline FormationMode::Value getFormationMode() const
99                        { return this->formationMode_; }
100                //----[/Formation data]----
101                //----[Rank data]----
102                    virtual void setRank(Rank::Value val)
103                        { this->rank_ = val; }
104                    inline Rank::Value getRank() const
105                        { return this->rank_; }
106                //----[/Rank data]----
[10838]107                //----[Protect data]----
108                    void setProtectXML( std::string val );
109                    std::string getProtectXML ();
110                    void setProtect (ControllableEntity* protect);
111                    ControllableEntity* getProtect ();
112                //----[/Protect data]----
[10832]113            //----[/XML data]----
[10731]114
[10832]115            //----[Interaction with other Controllers]----
116                virtual bool setWingman(CommonController* wingman);
117                virtual bool hasWingman();       
[10731]118
[10832]119                void setPositionOfTarget(const Vector3& target);
120                void setOrientationOfTarget(const Quaternion& orient);
[10759]121
[10832]122                void setTarget(ControllableEntity* target);
123                ControllableEntity* getTarget();
124                bool hasTarget();
[10759]125
[10832]126                void setTargetPosition(const Vector3& target);
127                void setTargetOrientation(const Quaternion& orient);
128                void setTargetOrientation(ControllableEntity* target);
129            //----[/Interaction with other Controllers]----
[10725]130
[10832]131            //----[Helper functions]----
132                float randomInRange(float a, float b);
133                static float distance(ControllableEntity* entity1, ControllableEntity* entity2);
[10838]134                static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt);
[10832]135                static bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) ;
[10731]136
[10832]137                float squaredDistanceToTarget() const;
138                bool isLookingAtTarget(float angle) const;
139            //----[/Helper functions]----
[10731]140
[10719]141        protected:
[10832]142            //----[Flying functionality]----
143                void stopMoving();
[10789]144
[10832]145                void moveToPoint(const Vector3& relativeTargetPosition, float angleRoll);
146                bool moveAndRoll(float dt);
[10719]147
[10832]148                void moveToPosition(const Vector3& target, float dt);
149                void moveToTargetPosition(float dt);
[10725]150
[10832]151                void copyOrientation(const Quaternion& orient, float dt);
152                void copyTargetOrientation(float dt);
[10725]153
[10832]154                void lookAtTarget(float dt);
155                void stopLookingAtTarget();
156                void startLookingAtTarget();
[10737]157
[10832]158                bool bLookAtTarget_;       
159            //----[/Flying functionality]----
160           
161            //----[Fighting functionality]----
162                void maneuver();
163                void dodge(Vector3& thisPosition, Vector3& diffUnit);
164                void aimAtTarget();           
165                bool canFire();
166                void doFire();
167                void setClosestTarget();
[10725]168
[10832]169                bool bShooting_;
170                int maneuverCounter_;         
171            //----[/Fighting functionality]----           
172           
173            //----[where-to-fly information]----
174                bool bHasTargetPosition_;
175                Vector3 targetPosition_;
176                bool bHasTargetOrientation_;
177                Quaternion targetOrientation_;
[10838]178               
179                Vector3 destination_;
180                bool bHasDestination;
[10832]181            //----[/where-to-fly information]----
[10838]182            //----[protect information]----
183                WeakPtr<ControllableEntity> protect_;
184            //----[/protect information]----
[10832]185            //----[who-to-kill information]----
186                WeakPtr<ControllableEntity> target_;
[10838]187                WeakPtr<ControllableEntity> enemy_;
[10805]188
[10832]189                bool bHasPositionOfTarget_;
190                Vector3 positionOfTarget_;
191                bool bHasOrientationOfTarget_;
192                Quaternion orientationOfTarget_;
193            //----[/who-to-kill information]----
[10805]194
[10832]195            //----["Private" variables]----
196                FormationMode::Value formationMode_;
197                Rank::Value rank_;
[10840]198                std::string protectName_;
[10832]199                Action::Value action_;
200            //----[/"Private" variables]----               
[10719]201    };
202}
203
204#endif /* _CommonController_H__ */
Note: See TracBrowser for help on using the repository browser.