- Timestamp:
- Apr 14, 2016, 4:03:16 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.