- Timestamp:
- Oct 31, 2015, 4:07:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc
r10729 r10731 39 39 this->setFormationMode(WALL); 40 40 41 bIsDivisionLeader_ = false;42 41 this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this))); 43 42 this->myWingman_ = 0; 44 43 this->myDivisionLeader_ = 0; 44 this->rank_ = SECTIONLEADER; 45 45 46 46 orxout(internal_error) << this << "Was created" << endl; … … 52 52 53 53 } 54 55 void SectionController::tick(float dt) 56 { 57 if (!this->isActive()) 58 return; 59 60 if (this->bHasTargetPosition_) 61 { 62 this->moveToTargetPosition(); 63 } 64 65 66 SUPER(SectionController, tick, dt); 67 } 68 69 void SectionController::action() 70 { 71 //this->target_ = this->sectionTarget_; 72 if (!myDivisionLeader_) 73 { 74 LeaderController* newDivisionLeader = findNewDivisionLeader(); 75 this->myDivisionLeader_ = newDivisionLeader; 76 if (newDivisionLeader) 77 orxout(internal_error) << "new DivisionLeader set" << endl; 78 79 } 80 setTargetPositionOfWingman(); 81 82 } 83 54 84 void SectionController::setTargetPositionOfWingman() 55 85 { … … 85 115 86 116 } 87 88 117 LeaderController* SectionController::findNewDivisionLeader() 89 118 { … … 98 127 { 99 128 //0ptr or not DivisionController? 100 if (!(it) || !( it)->bIsDivisionLeader_|| !(it->getControllableEntity()))129 if (!(it) || !((it)->getRank() == DIVISIONLEADER) || !(it->getControllableEntity())) 101 130 continue; 102 131 //same team? … … 126 155 127 156 } 157 bool SectionController::setWingman(CommonController* cwingman) 158 { 159 WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman); 128 160 129 void SectionController::action() 130 { 131 //this->target_ = this->sectionTarget_; 132 if (!myDivisionLeader_) 161 if (!this->myWingman_) 133 162 { 134 LeaderController* newDivisionLeader = findNewDivisionLeader(); 135 this->myDivisionLeader_ = newDivisionLeader; 136 if (newDivisionLeader) 137 orxout(internal_error) << "new DivisionLeader set" << endl; 138 163 this->myWingman_ = wingman; 164 return true; 139 165 } 140 setTargetPositionOfWingman(); 141 142 } 143 /* 144 Wingmen and Leaders attack target_, which is a member variable of their classes. 145 Wingmen's target_ is set to sectionTarget_, which is a member variable of SectionController class, unless 146 Wingman covers Leader's rear. 147 Leader's target_ must always equal sectionTarget_. 148 if section has a target, its Leader shoots at it, but doesn't follow. 149 Every section is a part of division. Division consisting of one Section is still a division. 150 Division's leader's target_ must always equal divisionTarget_, which is a member variable of DivisionController. 151 Division leader ONLY can follow target_ while in formation flight. 152 If Division doesn't have a target, Division Leader stays in place, unless it has a waypoint. 153 Division Leader's sectionTarget_ must equal divisionTarget_, 154 but the other section, that is not a leading section, can attack any target that is near divisonTarget_ 155 156 */ 157 158 void SectionController::tick(float dt) 159 { 160 if (!this->isActive()) 161 return; 162 163 if (this->bHasTargetPosition_) 166 else 164 167 { 165 this->moveToTargetPosition();168 return false; 166 169 } 167 168 169 SUPER(SectionController, tick, dt);170 170 } 171 171 172 bool SectionController::hasWingman() 173 { 174 if (this->myWingman_) 175 return true; 176 else 177 return false; 178 } 172 179 173 180 void SectionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Note: See TracChangeset
for help on using the changeset viewer.