Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

modified newScriptController to prevent memory leacks caused by tasks

File size: 3.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#ifndef _NewScriptController_H__
30#define _NewScriptController_H__
31
32#include "scriptTasks/DebugTask.h"
33#include "scriptTasks/stringOutTask.h"
34#include "scriptTasks/Task.h"
35#include "OrxonoxPrereqs.h"                 /* die ganzen tolua, kopiert aus Dock.h*/
36#include "ArtificialController.h"
37#include "core/EventIncludes.h"
38
39
40
41namespace orxonox  // tolua_export
42{  // tolua_export
43
44
45
46    class _OrxonoxExport NewScriptController // tolua_export
47       : public ArtificialController, public Tickable
48    {  // tolua_export
49        public:
50            NewScriptController(Context* context);
51            virtual ~NewScriptController() { }
52
53            void takeControl(int ctrlid);
54            void setPlayer(PlayerInfo* player) { this->player_ = player; }
55           
56            virtual void tick(float dt) override;
57
58            // LUA interface
59
60            void debugOut(float startTime);// tolua_export
61
62            void stringOut(float startTime, std::string output);// tolua_export
63
64            static NewScriptController* getNewScriptController();// tolua_export
65
66            int getID() { return ctrlid_; }// tolua_export
67
68            void printDebug() {orxout() << "fffff" << endl;} // tolua_export
69
70        private:
71            // Information about the player that this ScriptController will
72            // control
73            // - Player pointer
74            PlayerInfo* player_;
75
76            // - Entity pointer, this is for convenience and will be the same as
77            //   player_->getControllableEntity()
78            ControllableEntity* entity_;
79
80            // Controller ID, defaults to 0 and is set using takeControl()
81            int ctrlid_;
82
83            // List of events to walk through sorted by starting times
84            std::list<Task*> taskList_;
85
86            //List of Tasks currently active
87            std::vector<Task*> activeTasks_;
88
89            // Time since the creation of this ScriptController object
90            float scTime_; 
91
92
93            // context of the Controller to create the tasks
94            Context* context_;
95
96
97    };// tolua_export
98} // tolua_export
99
100#endif /* _NewScriptController_H__ */
Note: See TracBrowser for help on using the repository browser.