Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h @ 10879

Last change on this file since 10879 was 10877, checked in by gania, 9 years ago

CommonController now has static methods only. Replace with a namespace?

File size: 4.3 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 _ActionpointController_H__
30#define _ActionpointController_H__
31
32#include "controllers/FightingController.h"
33#include "tools/Timer.h"
34#include "tools/interfaces/Tickable.h"
35
36namespace orxonox
37{
38    namespace Action
39    { 
40        enum Value
41        {
42            NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK
43        };
44       
45    }
46   
47    struct Point {
48        Action::Value action;
49        std::string name;
50        Vector3 position;
51        bool inLoop;
52    } ;
53
54    class _OrxonoxExport ActionpointController : public FightingController, public Tickable
55    {
56        public:
57            //----[language demanded functions]----           
58                ActionpointController(Context* context);
59                virtual ~ActionpointController();
60            //----[language demanded functions]----           
61                virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);         
62               
63            virtual void tick(float dt); 
64            void addActionpoint(WorldEntity* waypoint);
65            WorldEntity* getActionpoint(unsigned int index) const;           
66            virtual void stayNearProtect();
67            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
68            virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
69            Action::Value getAction ();
70            std::string getActionName();
71
72            void setAction (Action::Value action);
73            void setAction (Action::Value action, ControllableEntity* target);
74            void setAction (Action::Value action, const Vector3& target);
75            void setAction (Action::Value action, const Vector3& target,  const Quaternion& orient );
76
77            virtual bool setWingman(ActionpointController* wingman)
78                { return false; }
79            virtual bool hasWingman()
80                { return true; }
81            virtual bool setFollower(ActionpointController* myFollower)
82                { return false; }
83            virtual bool hasFollower()
84                { return true; }
85
86        protected:
87            void startAttackingEnemiesThatAreClose();
88
89            //----[Actionpoint information]----
90                Action::Value action_;
91                std::string protectName_;
92                std::string targetName_;
93                std::vector<WeakPtr<WorldEntity> > actionpoints_;
94                float squaredaccuracy_;
95                std::vector<Point > parsedActionpoints_;
96                std::vector<Point > loopActionpoints_;
97                bool bInLoop_;
98                bool bLoop_;   
99                bool bEndLoop_; 
100                bool bTakenOver_; 
101            //----[/Actionpoint information]----
102                void setProtect (ControllableEntity* protect);
103                ControllableEntity* getProtect (); 
104                WeakPtr<ControllableEntity> protect_;     
105
106                void setClosestTarget();
107                Pawn* closestTarget();
108            //----[Actionpoint methods]----
109                void executeActionpoint();
110                void nextActionpoint();
111                void fillLoop();
112                void fillLoopReversed();
113                void moveBackToTop();
114            //----[Actionpoint methods]----         
115                bool bFirstTick_; 
116
117        private:
118           
119    };
120}
121
122#endif /* _ActionpointController_H__ */
Note: See TracBrowser for help on using the repository browser.