Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h @ 11479

Last change on this file since 11479 was 11204, checked in by plehmann, 9 years ago

implemented the update function of MoveToTask. but it does not yet work right. it might be more a problem of the controllerDirector than the task.

File size: 4.0 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 *      Paul Lehmann
24 *   Co-authors:
25 *      ...
26 *
27 *
28 *
29 */
30
31#ifndef _NewScriptController_H__
32#define _NewScriptController_H__
33
34#include "scriptTasks/DebugTask.h"
35#include "scriptTasks/stringOutTask.h"
36#include "scriptTasks/MoveToTask.h"
37#include "scriptTasks/Task.h"
38#include "OrxonoxPrereqs.h"                 /* die ganzen tolua, kopiert aus Dock.h*/
39#include "ArtificialController.h"
40#include "core/EventIncludes.h"
41
42
43
44namespace orxonox  // tolua_export
45{  // tolua_export
46
47    /**
48    @brief
49
50    A scriptController to carry out tasks on an entity.
51    The tasks are provided as a lua script.
52    The commands which are exported to lua have to create the specified task, initialze it and add it to the TaskList.
53
54    Important add the export comment after functions that need to be accessed from the lua script.
55
56    @todo
57
58    take away the human controller and put it back into place when this controller is deleted.
59    This is probably better done in the controller director class.
60
61    remove the startTimes of the tasks so that the lua script is just carried out one task after the other.
62    to avoid problems when to tasks are carried out simultainiously.
63
64    also the velocity while the controller is taking control is kept and hinders the tasks.
65
66    the moveToTask does not work right.
67    */
68
69    class _OrxonoxExport NewScriptController // tolua_export
70       : public ArtificialController, public Tickable
71    {  // tolua_export
72        public:
73            NewScriptController(Context* context);
74            virtual ~NewScriptController() { }
75
76            void takeControl(int ctrlid);
77            void setPlayer(PlayerInfo* player) { this->player_ = player; }
78           
79            virtual void tick(float dt) override;
80
81            // LUA interface
82
83            void debugOut(float startTime);// tolua_export
84
85            void stringOut(float startTime, std::string output);// tolua_export
86
87            void moveTo(float startTime, float x, float y, float z, float velocity);// tolua_export
88
89            static NewScriptController* getNewScriptController();// tolua_export
90
91            int getID() { return ctrlid_; }// tolua_export
92
93            void printDebug() {orxout() << "fffff" << endl;} // tolua_export
94
95        private:
96            // Information about the player that this ScriptController will
97            // control
98            // - Player pointer
99            PlayerInfo* player_;
100
101            // - Entity pointer, this is for convenience and will be the same as
102            //   player_->getControllableEntity()
103            ControllableEntity* entity_;
104
105            // Controller ID, defaults to 0 and is set using takeControl()
106            int ctrlid_;
107
108            // List of events to walk through sorted by starting times
109            std::list<Task*> taskList_;
110
111            //List of Tasks currently active
112            std::vector<Task*> activeTasks_;
113
114            // Time since the creation of this ScriptController object
115            float scTime_; 
116
117
118            // context of the Controller to create the tasks
119            Context* context_;
120
121
122    };// tolua_export
123} // tolua_export
124
125#endif /* _NewScriptController_H__ */
Note: See TracBrowser for help on using the repository browser.