[11165] | 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 | * |
---|
[11204] | 27 | * |
---|
| 28 | * |
---|
[11165] | 29 | */ |
---|
| 30 | |
---|
| 31 | #ifndef _NewScriptController_H__ |
---|
| 32 | #define _NewScriptController_H__ |
---|
| 33 | |
---|
[11183] | 34 | #include "scriptTasks/DebugTask.h" |
---|
| 35 | #include "scriptTasks/stringOutTask.h" |
---|
[11204] | 36 | #include "scriptTasks/MoveToTask.h" |
---|
[11183] | 37 | #include "scriptTasks/Task.h" |
---|
[11165] | 38 | #include "OrxonoxPrereqs.h" /* die ganzen tolua, kopiert aus Dock.h*/ |
---|
| 39 | #include "ArtificialController.h" |
---|
| 40 | #include "core/EventIncludes.h" |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | namespace orxonox // tolua_export |
---|
| 45 | { // tolua_export |
---|
| 46 | |
---|
[11204] | 47 | /** |
---|
| 48 | @brief |
---|
[11165] | 49 | |
---|
[11204] | 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. |
---|
[11165] | 53 | |
---|
[11204] | 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 | |
---|
[11165] | 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 | |
---|
[11178] | 83 | void debugOut(float startTime);// tolua_export |
---|
[11167] | 84 | |
---|
[11178] | 85 | void stringOut(float startTime, std::string output);// tolua_export |
---|
| 86 | |
---|
[11204] | 87 | void moveTo(float startTime, float x, float y, float z, float velocity);// tolua_export |
---|
| 88 | |
---|
[11172] | 89 | static NewScriptController* getNewScriptController();// tolua_export |
---|
[11167] | 90 | |
---|
[11172] | 91 | int getID() { return ctrlid_; }// tolua_export |
---|
[11167] | 92 | |
---|
[11178] | 93 | void printDebug() {orxout() << "fffff" << endl;} // tolua_export |
---|
[11167] | 94 | |
---|
[11165] | 95 | private: |
---|
[11167] | 96 | // Information about the player that this ScriptController will |
---|
| 97 | // control |
---|
| 98 | // - Player pointer |
---|
[11165] | 99 | PlayerInfo* player_; |
---|
| 100 | |
---|
[11167] | 101 | // - Entity pointer, this is for convenience and will be the same as |
---|
| 102 | // player_->getControllableEntity() |
---|
[11165] | 103 | ControllableEntity* entity_; |
---|
| 104 | |
---|
[11167] | 105 | // Controller ID, defaults to 0 and is set using takeControl() |
---|
| 106 | int ctrlid_; |
---|
| 107 | |
---|
[11183] | 108 | // List of events to walk through sorted by starting times |
---|
[11190] | 109 | std::list<Task*> taskList_; |
---|
[11165] | 110 | |
---|
[11167] | 111 | //List of Tasks currently active |
---|
[11190] | 112 | std::vector<Task*> activeTasks_; |
---|
[11165] | 113 | |
---|
[11167] | 114 | // Time since the creation of this ScriptController object |
---|
[11165] | 115 | float scTime_; |
---|
| 116 | |
---|
| 117 | |
---|
[11178] | 118 | // context of the Controller to create the tasks |
---|
| 119 | Context* context_; |
---|
[11172] | 120 | |
---|
| 121 | |
---|
[11165] | 122 | };// tolua_export |
---|
| 123 | } // tolua_export |
---|
| 124 | |
---|
| 125 | #endif /* _NewScriptController_H__ */ |
---|