- Timestamp:
- Apr 26, 2010, 5:02:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r6696 r6795 51 51 this->bHasTargetPosition_ = false; 52 52 this->targetPosition_ = Vector3::ZERO; 53 //this->slaves_ = new std::list<ArtificialController*>; 53 54 54 55 this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this)); … … 100 101 if(myMaster_) 101 102 { 102 myMaster_->slaves .remove(this);103 myMaster_->slaves_.remove(this); 103 104 } 104 105 } … … 132 133 if (static_cast<ControllableEntity*>(*it) != this->getControllableEntity()) //&& it->getPosition().squaredDistance(this->getControllableEntity()->getPosition()) < 1000 133 134 { 134 if(controller->slaves .size() > 9) continue;135 if(controller->slaves_.size() > 9) continue; 135 136 136 137 this->freeAllSlaves(); 137 this->slaves .clear();138 this->slaves_.clear(); 138 139 this->state_ = SLAVE; 139 140 140 141 this->myMaster_ = controller; 141 controller->slaves .push_back(this);142 controller->slaves_.push_back(this); 142 143 143 144 break; … … 152 153 void ArtificialController::commandSlaves() { 153 154 154 for(std::list<ArtificialController*>::iterator it = slaves .begin(); it != slaves.end(); it++)155 for(std::list<ArtificialController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++) 155 156 { 156 157 (*it)->setTargetPosition(this->getControllableEntity()->getPosition()); … … 173 174 } 174 175 176 // binds slaves to new Master within formation 177 void ArtificialController::setNewMasterWithinFormation() 178 { 179 COUT(0) << "~setNewMasterWithinFormation 1" << std::endl; 180 if (this->slaves_.empty()) 181 return; 182 COUT(0) << "~setNewMasterWithinFormation 1b" << std::endl; 183 184 ArtificialController *newMaster = this->slaves_.back(); 185 COUT(0) << "~setNewMasterWithinFormation 2" << std::endl; 186 this->slaves_.pop_back(); 187 COUT(0) << "~setNewMasterWithinFormation 3" << std::endl; 188 if(!newMaster) return; 189 COUT(0) << "~setNewMasterWithinFormation 4" << std::endl; 190 newMaster->state_ = MASTER; 191 newMaster->slaves_ = this->slaves_; 192 //this->slaves_.clear(); 193 194 this->state_ = SLAVE; 195 this->myMaster_ = newMaster; 196 197 COUT(0) << "~setNewMasterWithinFormation 5" << std::endl; 198 for(std::list<ArtificialController*>::iterator it = newMaster->slaves_.begin(); it != newMaster->slaves_.end(); it++) 199 { 200 COUT(0) << "~setNewMasterWithinFormation 6" << std::endl; 201 (*it)->myMaster_ = newMaster; 202 } 203 COUT(0) << "~setNewMasterWithinFormation 7" << std::endl; 204 205 } 206 175 207 void ArtificialController::freeAllSlaves() 176 208 { 177 209 178 210 179 for(std::list<ArtificialController*>::iterator it = slaves .begin(); it != slaves.end(); it++)211 for(std::list<ArtificialController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++) 180 212 { 181 213 (*it)->state_ = FREE;
Note: See TracChangeset
for help on using the changeset viewer.