Changeset 8493 for code/branches/dockingsystem2/src/modules/docking/Dock.cc
- Timestamp:
- May 16, 2011, 6:21:05 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/dockingsystem2/src/modules/docking/Dock.cc
r8434 r8493 57 57 { 58 58 RegisterObject(Dock); 59 COUT(0) << "Registering dock..." << std::endl;60 59 } 61 60 … … 70 69 71 70 XMLPortObject(Dock, DockingEffect, "effects", addEffect, getEffect, xmlelement, mode); 71 XMLPortObject(Dock, DockingAnimation, "animations", addAnimation, getAnimation, xmlelement, mode); 72 72 XMLPortEventSink(Dock, BaseObject, "execute", execute, xmlelement, mode); 73 74 COUT(0) << "Dock created.." << std::endl;75 73 } 76 74 … … 96 94 } 97 95 pawn = pTrigger->getTriggeringPlayer(); 98 } else { 96 } 97 else 98 { 99 99 COUT(2) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl; 100 100 return false; … … 110 110 if(player == NULL) 111 111 { 112 COUT(2) << "The PlayerInfo* is NULL." << std::endl; 113 return false; 114 } 115 116 COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl; 112 COUT(2) << "Docking::execute The PlayerInfo* is NULL." << std::endl; 113 return false; 114 } 117 115 118 116 if(bTriggered) … … 123 121 // Show docking dialog 124 122 GUIManager::showGUI("DockingDialog"); 125 //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);126 123 } 127 124 else … … 129 126 // Remove player from candidates list 130 127 candidates.erase(player); 131 132 //DockingEffect::invokeEffect(docking::RELEASE, player, effects_);133 128 } 134 129 … … 163 158 if(candidates.find(player) == candidates.end()) 164 159 { 165 COUT(0) << "Player is not a candidate!" << std::endl; 166 return false; 167 } 168 169 // Remove player from candidates, add to docked players and invoke docking effect 160 COUT(0) << "Dock::dock Player is not a candidate!" << std::endl; 161 return false; 162 } 163 170 164 candidates.erase(player); 171 165 docked.insert(player); 172 DockingEffect::invokeEffect(docking::ATTACH, player, effects); 166 167 if (animations.empty()) 168 return dockingAnimationFinished(player); 169 else 170 DockingAnimation::invokeAnimation(true, player, animations); 171 172 return true; 173 } 174 175 bool Dock::dockingAnimationFinished(PlayerInfo* player) 176 { 177 if(docked.find(player) == docked.end()) 178 { 179 COUT(0) << "Dock::dockingAnimationFinished Player is not currently docked." << std::endl; 180 return false; 181 } 182 183 DockingEffect::invokeEffect(true, player, effects); 173 184 return true; 174 185 } … … 179 190 if(docked.find(player) == docked.end()) 180 191 { 181 COUT(0) << "Player is not docked to this Dock." << std::endl; 182 return false; 183 } 184 185 // Remove player from docked, add to candidates and reverse DockingEffect 192 COUT(0) << "Dock::undock Player is not docked to this Dock." << std::endl; 193 return false; 194 } 195 186 196 docked.erase(player); 187 197 candidates.insert(player); 188 DockingEffect::invokeEffect(docking::RELEASE, player, effects); 198 199 DockingEffect::invokeEffect(false, player, effects); 200 201 if (animations.empty()) 202 return undockingAnimationFinished(player); 203 else 204 DockingAnimation::invokeAnimation(false, player, animations); 205 206 return true; 207 } 208 209 bool Dock::undockingAnimationFinished(PlayerInfo* player) { 210 COUT(0) << "Dock::undockingAnimationFinished executed" << std::endl; 189 211 return true; 190 212 } … … 226 248 } 227 249 228 const DockingEffect* Dock::getEffect(unsigned int index) const 229 { 230 int i = index; 250 const DockingEffect* Dock::getEffect(unsigned int i) const 251 { 231 252 for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) 232 253 { … … 237 258 return NULL; 238 259 } 260 261 bool Dock::addAnimation(DockingAnimation* animation) 262 { 263 assert(animation); 264 animation->setParent(this); 265 animations.push_back(animation); 266 return true; 267 } 268 269 const DockingAnimation* Dock::getAnimation(unsigned int i) const 270 { 271 for (std::list<DockingAnimation*>::const_iterator animation = this->animations.begin(); animation != this->animations.end(); ++animation) 272 { 273 if(i == 0) 274 return *animation; 275 i--; 276 } 277 return NULL; 278 } 239 279 }
Note: See TracChangeset
for help on using the changeset viewer.