Changeset 6859
- Timestamp:
- May 6, 2010, 2:56:39 PM (15 years ago)
- Location:
- code/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/Event.cc
r6800 r6859 59 59 this->bProcessingEvent_ = true; 60 60 61 COUT(4) << "Processing event (EventState) : originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << ", object: " << object->getIdentifier()->getName() << " (&" << object << ")" << " , subclass: " << this->subclass_->getName() << ", (?): " << event.originator_->isA(this->subclass_) << "." << std::endl;61 COUT(4) << "Processing event (EventState) : originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << ", object: " << object->getIdentifier()->getName() << " (&" << object << ")" << "." << std::endl; 62 62 63 63 // check if the originator is an instance of the requested class -
code/trunk/src/modules/objects/triggers/MultiTrigger.cc
r6857 r6859 71 71 this->bInvertMode_ = false; 72 72 this->mode_ = MultiTriggerMode::EventTriggerAND; 73 74 this->parentTrigger_ = NULL; 73 75 74 76 this->targetMask_.exclude(Class(BaseObject)); … … 165 167 } 166 168 else 169 { 170 COUT(1) << "BUH" << std::endl; 167 171 delete state; 172 } 168 173 169 174 queue->pop(); … … 259 264 // Print some debug output if the state has changed. 260 265 if(bStateChanged) 266 { 261 267 COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: " << state->originator->getIdentifier()->getName() << " (&" << state->originator << "), active: " << bActive << ", triggered: " << state->bTriggered << "." << std::endl; 268 if(this->parentTrigger_ != NULL) 269 this->parentTrigger_->activityChanged(state->originator); 270 } 262 271 263 272 // If the MultiTrigger has exceeded its amount of activations and it doesn't stay active, it has to be destroyed, … … 386 395 if (this != trigger && trigger != NULL) 387 396 this->subTriggers_.insert(trigger); 397 trigger->addParentTrigger(this); 388 398 } 389 399 … … 423 433 std::queue<MultiTriggerState*>* MultiTrigger::letTrigger(void) 424 434 { 425 // Goes through all sub-triggers and gets the objects triggering them. 426 std::set<BaseObject*>* triggerers = new std::set<BaseObject*>(); 427 std::set<BaseObject*>::iterator objIt; 428 for(std::set<MultiTrigger*>::iterator it = this->subTriggers_.begin(); it != this->subTriggers_.end(); it ++) 429 { 430 std::set<BaseObject*> set = (*it)->getActive(); 431 for(objIt = set.begin(); objIt != set.end(); objIt++) 432 { 433 triggerers->insert(*objIt); 434 } 435 } 436 437 // Goes through all the triggerers of this trigger. 438 for(objIt = this->active_.begin(); objIt != this->active_.end(); objIt++) 439 { 440 triggerers->insert(*objIt); 441 } 442 443 // If no objects are triggering this MultiTrigger or the sub-triggers. 444 if(triggerers->size() == 0) 445 return NULL; 446 447 // Create a state for each object triggering this MultiTrigger or any of the sub-triggers and append it to the queue. 448 std::queue<MultiTriggerState*>* queue = new std::queue<MultiTriggerState*>(); 449 MultiTriggerState* state = NULL; 450 for(std::set<BaseObject*>::iterator it = triggerers->begin(); it != triggerers->end(); it++) 451 { 452 state = new MultiTriggerState; 453 state->bTriggered = true; 454 state->originator = *it; 455 queue->push(state); 456 } 457 delete triggerers; 458 459 return queue; 435 return NULL; 436 } 437 438 void MultiTrigger::activityChanged(BaseObject* originator) 439 { 440 MultiTriggerState* state = new MultiTriggerState; 441 state->bTriggered = (this->isTriggered(originator) & this->isModeTriggered(originator)) ^ this->bInvertMode_; 442 state->originator = originator; 443 this->addState(state); 460 444 } 461 445 -
code/trunk/src/modules/objects/triggers/MultiTrigger.h
r6857 r6859 207 207 protected: 208 208 virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at. 209 210 void activityChanged(BaseObject* originator); 209 211 210 212 bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whetherx the MultiTrigger is triggered concerning it's sub-triggers. … … 213 215 void fire(bool status, BaseObject* originator = NULL); //!< Helper method. Creates an event for the given status and originator and fires it. 214 216 217 /** 218 @brief Adds the parent of a MultiTrigger. 219 @param parent A pointer to the parent MultiTrigger. 220 */ 221 inline void addParentTrigger(MultiTrigger* parent) 222 { this->parentTrigger_ = parent; } 223 215 224 /** 216 225 @brief Get the target mask used to identify the targets of this MultiTrigger. … … 257 266 MultiTriggerMode::Value mode_; //!< The mode of the MultiTrigger. 258 267 268 MultiTrigger* parentTrigger_; 259 269 std::set<MultiTrigger*> subTriggers_; //!< The sub-triggers of this MultiTrigger. 260 270 -
code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc
r6856 r6859 38 38 namespace orxonox 39 39 { 40 41 CreateUnloadableFactory(MultiTriggerContainer); 40 42 41 43 /** -
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r6800 r6859 76 76 XMLPortObject(QuestEffectBeacon, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode); 77 77 78 XMLPortEventS tate(QuestEffectBeacon, BaseObject, "execute", execute, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers.78 XMLPortEventSink(QuestEffectBeacon, BaseObject, "execute", execute, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers. 79 79 80 80 COUT(3) << "New QuestEffectBeacon created." << std::endl;
Note: See TracChangeset
for help on using the changeset viewer.