Changeset 11167
- Timestamp:
- Apr 14, 2016, 4:03:16 PM (9 years ago)
- Location:
- code/branches/plehmannFS16
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/plehmannFS16/data/gui/scripts/testscript.lua
r11152 r11167 18 18 19 19 -- Get a local pointer to a scriptcontroller 20 local ctrl = orxonox. ScriptController:getScriptController()20 local ctrl = orxonox.NewScriptController:getNewScriptController() 21 21 22 22 -- If it worked, call its "movetoposition" function 23 23 if ctrl ~= nil then 24 24 25 ctrl:eventScheduler("mal", xl,yl,zl, xl,yl,zl, 10) 25 26 ctrl:debugOut() 27 --ctrl:eventScheduler("mal", xl,yl,zl, xl,yl,zl, 10) 26 28 -- ctrl:eventScheduler("ral", xl, yl, zl, 3, 3000, 0, math.pi) 27 29 -- ctrl:eventScheduler("idle", 1) -
code/branches/plehmannFS16/src/orxonox/controllers/CMakeLists.txt
r11165 r11167 5 5 ArtificialController.cc 6 6 AIController.cc 7 ScriptController.cc7 8 8 WaypointController.cc 9 9 WaypointPatrolController.cc -
code/branches/plehmannFS16/src/orxonox/controllers/ControllerDirector.cc
r11071 r11167 6 6 7 7 #include "ControllerDirector.h" 8 #include " ScriptController.h"8 #include "NewScriptController.h" 9 9 #include "core/CoreIncludes.h" 10 10 … … 64 64 { 65 65 /* Output a message confirming that the function was called */ 66 orxout( verbose)<<"test takecontrol."<< endl;66 orxout()<<"test takecontrol."<< endl; 67 67 68 68 /* First, we set up a new controller to attach to the unit that … … 74 74 { 75 75 /* Create a scriptcontroller object */ 76 ScriptController *newctrl = newScriptController(this->context_);76 NewScriptController *newctrl = new NewScriptController(this->context_); 77 77 78 78 /* Make the player we were given its slave */ … … 112 112 this->player_ = nullptr; 113 113 114 orxout( verbose) << "Preparation to take Control!" << endl;114 orxout() << "Preparation to take Control!" << endl; 115 115 116 116 // Check whether it is a player trigger and extract pawn from it … … 125 125 else 126 126 { 127 orxout( verbose) << "ControllerDirector::preparationToTakeControl "127 orxout() << "ControllerDirector::preparationToTakeControl " 128 128 << "Not a player trigger, can't extract pawn from it.." << endl; 129 129 return false; -
code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.cc
r11165 r11167 39 39 RegisterClass(DebugTask); 40 40 41 DebugTask::DebugTask( ) : isRunning_(false)41 DebugTask::DebugTask(Context* context) : isRunning_(false) 42 42 { 43 43 RegisterObject(DebugTask); 44 44 } 45 DebugTask::DebugTask(float startTime) : isRunning_(false) 45 46 DebugTask::Tick(float dt) 46 47 { 47 RegisterObject(DebugTask); 48 startTime_ = startTime;48 49 orxout() << "*" << endl; 49 50 } 50 51 51 52 53 54 52 } -
code/branches/plehmannFS16/src/orxonox/controllers/DebugTask.h
r11165 r11167 39 39 { 40 40 public: 41 DebugTask(); 42 DebugTask(float startTime) 41 DebugTask(Context* context); 43 42 virtual ~Task(); 43 44 //this function needs to be called otherwise the task is never carriedout 45 initialize() 44 46 45 47 virtual void tick(float dt) override; -
code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc
r11165 r11167 61 61 62 62 63 / * Set default values for all variables */64 / * - pointers to zero */63 // Set default values for all variables 64 // - pointers to zero 65 65 this->player_ = nullptr; 66 66 this->entity_ = nullptr; 67 67 68 / * - times */68 // - times 69 69 this->scTime_ = 0.0f; 70 71 //taskList_->push(new DebugTask); 70 72 71 73 } 72 74 75 76 73 77 void NewScriptController::takeControl(int ctrlid) 74 78 { 75 / * Output some debugging information */79 // Output some debugging information 76 80 orxout(verbose) << "NewScriptController: Taking control" << endl; 77 81 orxout(verbose) << "This-pointer: " << this << endl; 78 82 79 83 80 / * Store the entity pointer in a private variable */84 // Store the entity pointer in a private variable 81 85 this->entity_ = this->player_->getControllableEntity(); 82 86 assert(this->entity_); 87 88 this->ctrlid_ = ctrlid; 89 if (ctrlid_ == 0) 90 { 91 ctrlid_ = 1; 92 } 83 93 84 / *Add the controller here to this entity. Apparently this still leaves85 *any preexisting human controllers in place.86 */94 // Add the controller here to this entity. Apparently this still leaves 95 // any preexisting human controllers in place. 96 87 97 this->entity_->setDestroyWhenPlayerLeft(false); 88 98 this->player_->stopTemporaryControl(); … … 98 108 void NewScriptController::tick(float dt) 99 109 { 100 / * Call the tick function of the classes we derive from */101 SUPER( ScriptController, tick, dt);110 // Call the tick function of the classes we derive from 111 SUPER(NewScriptController, tick, dt); 102 112 103 /* If this controller has no entity entry, do nothing */ 113 /* 114 // If this controller has no entity entry, do nothing 104 115 if( !(this->entity_) ) return; 105 116 106 / * See if time has come for the next event to be run */117 // See if time has come for the next event to be run 107 118 if(this->taskList_->size() > 0 && this->taskList_->front().getStartTime() <= scTime_) 108 { / * Execute the next event on the list */119 { // Execute the next event on the list 109 120 activeTasks_->push_back(taskList_->front()); 110 121 taskList_->pop(); 111 122 } 112 123 113 / * Update the local timers in this object */124 // Update the local timers in this object 114 125 scTime_ += dt; 115 126 116 / * tick active tasks and delete completed tasks */127 // tick active tasks and delete completed tasks 117 128 for(std::vector<Task>::iterator it = activeTasks_->begin(); it != activeTasks_->end(); it++) 118 129 { … … 125 136 126 137 } 127 138 */ 128 139 } 129 140 … … 134 145 } 135 146 147 void NewScriptController::debugOut() 148 { 149 orxout() << "NewScriptController: Taking control" << endl; 150 } 151 152 NewScriptController* NewScriptController::getNewScriptController() 153 { 154 /* Output a message that confirms this function was called */ 155 orxout() << "Great success!" << std::endl; 156 157 /* Debugging: print all the scriptcontroller object pointers */ 158 for(NewScriptController* controller : ObjectList<NewScriptController>()) 159 { orxout() << "Have object in list: " << controller << endl; } 160 161 /* Find the first one with a nonzero ID */ 162 for(NewScriptController* controller : ObjectList<NewScriptController>()) 163 { 164 // TODO: do some selection here. Currently just returns the first one 165 if( controller->getID() > 0 ) 166 { orxout() << "Controller to return: " << controller << endl; 167 return controller; 168 } 169 170 } 171 return nullptr; 172 } 136 173 137 174 } -
code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h
r11165 r11167 57 57 // tolua_begin 58 58 59 void debugOut(); 60 61 static NewScriptController* getNewScriptController(); 62 63 int getID() { return ctrlid_; } 64 65 //tolua_end 66 59 67 void createAndAddTask(Task newTask); 60 68 61 69 private: 62 / *Information about the player that this ScriptController will63 * control */64 / * - Player pointer */70 // Information about the player that this ScriptController will 71 // control 72 // - Player pointer 65 73 PlayerInfo* player_; 66 74 67 /* - Entity pointer, this is for convenience and will be the same as 68 * player_->getControllableEntity() 69 */ 75 // - Entity pointer, this is for convenience and will be the same as 76 // player_->getControllableEntity() 70 77 ControllableEntity* entity_; 71 78 72 /* List of events to walk through */ 79 // Controller ID, defaults to 0 and is set using takeControl() 80 int ctrlid_; 81 82 // List of events to walk through 73 83 std::queue<Task>* taskList_; 74 84 75 85 76 / *List of Tasks currently active */86 //List of Tasks currently active 77 87 std::vector<Task>* activeTasks_; 78 88 79 / * Time since the creation of this ScriptController object */89 // Time since the creation of this ScriptController object 80 90 float scTime_; 81 91 -
code/branches/plehmannFS16/src/orxonox/controllers/ScriptController.h
r11152 r11167 36 36 37 37 38 namespace orxonox // tolua_export39 { // tolua_export38 namespace orxonox 39 { 40 40 41 41 /** Structure to describe a single event */ … … 61 61 }; 62 62 63 class _OrxonoxExport ScriptController // tolua_export63 class _OrxonoxExport ScriptController 64 64 : public ArtificialController, public Tickable 65 { // tolua_export65 { 66 66 public: 67 67 ScriptController(Context* context); … … 73 73 virtual void tick(float dt) override; 74 74 75 // LUA interface 76 // tolua_begin 75 77 76 void eventScheduler(std::string instruction = "", 78 77 float x1 = 0, float y1 = 0, float z1 = 0, … … 84 83 int getID() { return ctrlid_; } 85 84 86 // tolua_end85 87 86 const Vector3& getPosition(); 88 87 … … 146 145 void rotX(float dl); 147 146 148 }; // tolua_export149 } // tolua_export147 }; 148 } 150 149 151 150 #endif /* _ScriptController_H__ */ -
code/branches/plehmannFS16/src/orxonox/controllers/Task.cc
r11165 r11167 31 31 32 32 #include "infos/PlayerInfo.h" 33 #include "controllers/ArtificialController.h"33 //#include "controllers/ArtificialController.h" 34 34 #include "tools/interfaces/Tickable.h" 35 35 … … 39 39 RegisterClass(Task); 40 40 41 Task::Task( ) : isRunning_(false)41 Task::Task(Context* context) : isRunning_(false) 42 42 { 43 43 RegisterObject(Task); 44 startTime_ = -1; 45 } 46 Task::~Task() 47 { 48 49 } 50 /* 51 Task::initialize(float startTime) 52 { 53 startTime_ = startTime; 54 } 55 */ 56 void Task::tick(float dt) 57 { 58 44 59 } 45 60 46 47 48 61 } -
code/branches/plehmannFS16/src/orxonox/controllers/Task.h
r11165 r11167 31 31 32 32 #include "infos/PlayerInfo.h" 33 #include "controllers/ArtificialController.h"33 //#include "controllers/ArtificialController.h" 34 34 #include "tools/interfaces/Tickable.h" 35 35 … … 39 39 { 40 40 public: 41 Task( );41 Task(Context* context); 42 42 virtual ~Task(); 43 44 //this function needs to be called otherwise the task is never carriedout 45 //initialize(); 43 46 44 47 virtual void tick(float dt) override;
Note: See TracChangeset
for help on using the changeset viewer.