- Timestamp:
- Apr 12, 2010, 1:24:24 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r6640 r6683 45 45 this->target_ = 0; 46 46 this->team_ = -1;//new 47 this->state_ = 0;//new47 this->state_ = FREE;//new 48 48 this->bShooting_ = false; 49 49 this->bHasTargetPosition_ = false; … … 113 113 114 114 ArtificialController *controller = static_cast<ArtificialController*>(it->getController()); 115 if (controller && controller->getState() !=1)115 if (controller && controller->getState() != MASTER) 116 116 continue; 117 117 … … 121 121 //this->target_ = (*it); 122 122 //this->targetPosition_ = it->getPosition(); 123 this->state_ = -1;123 this->state_ = SLAVE; 124 124 125 125 } … … 127 127 128 128 //hasn't encountered any masters in range? -> become a master 129 if (state_!=-1) state_=1; // keep in mind: what happens when two masters encounter eache other? -> has to be evaluated in the for loop of within master mode in AIcontroller... 130 } 129 if (state_!=SLAVE) state_=MASTER; // keep in mind: what happens when two masters encounter eache other? -> has to be evaluated in the for loop of within master mode in AIcontroller... 130 } 131 132 void ArtificialController::commandSlaves() { 133 134 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it) 135 { 136 ArtificialController *controller = static_cast<ArtificialController*>(it->getController()); 137 if (controller && controller->getState() != MASTER) 138 continue; 139 140 controller->targetPosition_ = this->getControllableEntity()->getPosition(); 141 } 142 143 } 144 145 void ArtificialController::freeAllSlaves() 146 { 147 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it) 148 { 149 ArtificialController *controller = static_cast<ArtificialController*>(it->getController()); 150 if (controller && controller->getState() != MASTER) 151 continue; 152 153 controller->state_ = FREE; 154 } 155 156 } 157 131 158 132 159 void ArtificialController::setTargetPosition(const Vector3& target)
Note: See TracChangeset
for help on using the changeset viewer.