Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 30, 2008, 2:44:48 AM (16 years ago)
Author:
landauf
Message:

added two more graphical classes, ParticleEmitter and ParticleSpawner

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/core/BaseObject.cc

    r2063 r2065  
    3535#include "tinyxml/tinyxml.h"
    3636#include "CoreIncludes.h"
     37#include "EventIncludes.h"
    3738#include "XMLPort.h"
    3839#include "XMLFile.h"
     
    7980    BaseObject::~BaseObject()
    8081    {
     82        for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
     83            (*it)->eventListeners_.erase(this);
    8184    }
    8285
     
    184187    void BaseObject::addEvent(BaseObject* event, const std::string& sectionname)
    185188    {
    186         this->eventListeners_.insert(std::pair<std::string, BaseObject*>(sectionname, event));
     189        event->eventListeners_[this] = sectionname;
     190        this->events_.push_back(event);
    187191    }
    188192
     
    190194    {
    191195        unsigned int i = 0;
    192         for (std::set<std::pair<std::string, BaseObject*> >::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
     196        for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
    193197        {
    194198            if (i == index)
    195                 return (*it).second;
     199                return (*it);
    196200            ++i;
    197201        }
     
    230234        Event event(activate, this);
    231235
    232         for (std::set<std::pair<std::string, BaseObject*> >::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
    233         {
    234             event.sectionname_ = (*it).first;
    235             (*it).second->processEvent(event);
     236        for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
     237        {
     238            event.sectionname_ = it->second;
     239            it->first->processEvent(event);
    236240        }
    237241    }
Note: See TracChangeset for help on using the changeset viewer.