Changeset 11190 for code/branches/plehmannFS16/src
- Timestamp:
- May 19, 2016, 5:34:38 PM (9 years ago)
- Location:
- code/branches/plehmannFS16/src/orxonox/controllers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.cc
r11187 r11190 130 130 }*/ 131 131 132 if(this->taskList_.size() != 0) 133 { 134 135 orxout() << this->scTime_ << endl; 136 137 if(this->taskList_.front().getStartTime() < this->scTime_) 138 { 139 activeTasks_.push_back(this->taskList_.front()); 140 this->taskList_.pop_front(); 132 if(!this->taskList_.empty()) 133 { 134 orxout() << scTime_ << endl; 135 136 orxout() << taskList_.size() << endl; 137 138 139 if(this->taskList_.front()->getStartTime() < this->scTime_) 140 { 141 activeTasks_.push_back(this->taskList_.front()); 142 this->taskList_.pop_front(); 141 143 } 142 144 } 143 145 else 144 146 { 145 //orxout() << "no tasks in taskList_" << endl; 146 } 147 148 for (std::vector<Task>::iterator it = activeTasks_.begin(); it != activeTasks_.end(); it++) 149 { 150 if( !(it->update(dt)) ) 151 { 152 activeTasks_.erase(it); 153 it--; // set back the iterator so we continue with the next element and not with the one after that 154 } 155 } 147 orxout() << "no tasks in taskList_" << endl; 148 } 149 150 std::vector<Task*>::iterator it = activeTasks_.begin(); 151 while (it != activeTasks_.end() ) 152 { 153 if( !((*it)->update(dt)) ) 154 { 155 (*(*it)).destroyLater(); 156 it = activeTasks_.erase(it); 157 } 158 else 159 { 160 it++; 161 } 162 163 } 164 156 165 157 166 … … 159 168 } 160 169 161 162 void NewScriptController::createAndAddTask(Task newTask)163 {164 //taskQueue_->push(newTask);165 }166 167 170 void NewScriptController::debugOut(float startTime) 168 171 { 169 DebugTask task = DebugTask(context_); 170 task.initialize(startTime); 172 173 DebugTask* task = new DebugTask(context_); 174 175 task->initialize(startTime); 176 177 bool inserted = false; 171 178 172 179 if(taskList_.empty()) 173 180 { 174 181 taskList_.push_front(task); 182 inserted = true; 175 183 } 176 184 177 185 else 178 186 { 179 for (std::list<Task >::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime180 { 181 orxout() << taskList_.empty()<< endl;182 183 if(task .getStartTime() < it->getStartTime() )187 for (std::list<Task*>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime 188 { 189 orxout() << "debugOutTask" << endl; 190 191 if(task->getStartTime() < (*it)->getStartTime() ) 184 192 { 185 193 taskList_.insert(it, task); 186 } 187 } 188 } 194 inserted = true; 195 break; 196 } 197 } 198 } 199 200 if (!inserted) 201 { 202 taskList_.push_back(task); 203 } 204 189 205 } 190 206 191 207 void NewScriptController::stringOut(float startTime, std::string output) 192 208 { 193 stringOutTask task = stringOutTask(context_); 194 task.initialize(startTime, output); 209 210 stringOutTask* task = new stringOutTask(context_); 211 212 task->initialize(startTime, output); 213 214 bool inserted = false; 195 215 196 216 if(taskList_.empty()) 197 217 { 198 218 taskList_.push_front(task); 219 inserted = true; 199 220 } 200 221 201 222 else 202 223 { 203 for (std::list<Task >::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime204 { 205 orxout() << taskList_.empty()<< endl;206 207 if(task .getStartTime() < it->getStartTime() )224 for (std::list<Task*>::iterator it = taskList_.begin(); it != taskList_.end(); it++) // insert sorted by starttime 225 { 226 orxout() << "stringOutTask" << endl; 227 228 if(task->getStartTime() < (*it)->getStartTime() ) 208 229 { 209 230 taskList_.insert(it, task); 210 } 211 } 212 } 231 inserted = true; 232 break; 233 } 234 } 235 } 236 237 if (!inserted) 238 { 239 taskList_.push_back(task); 240 } 241 213 242 } 214 243 -
code/branches/plehmannFS16/src/orxonox/controllers/NewScriptController.h
r11187 r11190 68 68 void printDebug() {orxout() << "fffff" << endl;} // tolua_export 69 69 70 71 void createAndAddTask(Task newTask);72 73 70 private: 74 71 // Information about the player that this ScriptController will … … 85 82 86 83 // List of events to walk through sorted by starting times 87 std::list<Task> taskList_; 88 84 std::list<Task*> taskList_; 89 85 90 86 //List of Tasks currently active 91 std::vector<Task > activeTasks_;87 std::vector<Task*> activeTasks_; 92 88 93 89 // Time since the creation of this ScriptController object -
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.cc
r11187 r11190 49 49 this->entity_ = this->player_->getControllableEntity(); 50 50 this->destination_ = destination; 51 this->velocity_ = velocity; 51 52 this->entity->setVelocity( Vector3(0,0,0) ) 52 53 } … … 55 56 { 56 57 58 float dl = this->velocity_ * dt; 57 59 60 58 61 /* Set the position to the correct place in the trajectory */ 59 62 this->entity_->setPosition( (1-dl)*startpos + dl * this->currentEvent.v1); -
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/MoveToTask.h
r11187 r11190 62 62 vector3 destination_; 63 63 64 float velocity_; 65 64 66 }; 65 67 } -
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/Task.cc
r11183 r11190 38 38 RegisterClass(Task); 39 39 40 Task::Task(Context* context) 40 Task::Task(Context* context) : BaseObject(context) 41 41 { 42 42 RegisterObject(Task); … … 49 49 } 50 50 51 bool Task::update(float dt)52 {53 SUPER(Task, tick, dt);54 }55 56 51 } -
code/branches/plehmannFS16/src/orxonox/controllers/scriptTasks/Task.h
r11183 r11190 32 32 #include "infos/PlayerInfo.h" 33 33 #include "tools/interfaces/Tickable.h" 34 #include "core/class/OrxonoxClass.h" 34 //#include "core/class/OrxonoxClass.h" 35 #include "core/BaseObject.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport Task : public OrxonoxClass{39 class _OrxonoxExport Task : public BaseObject { 39 40 40 41 public: … … 46 47 47 48 //important return true while the task is running and false to stop it!!! 48 virtual bool update(float dt) ;49 virtual bool update(float dt) {return false;} 49 50 50 51 float getStartTime()
Note: See TracChangeset
for help on using the changeset viewer.