Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 5, 2009, 5:02:25 PM (15 years ago)
Author:
landauf
Message:

More changes in the event-system: processEvent() is now locally executed in BaseObject. The event states (like activity, visibility, …) are now defined in XMLEventPort, a function which closely resembles XMLPort. This function is used to define event states and to parse event sources from XML.

Connected the main-state directly with the event-system. After a state was declared as the "main state", the Functor from the corresponding EventState-object is used to call the function. This reduces the redundancy of declaring event-states and main-states separately. Of course only boolean event-states (like activity or visibility) can be used as main-state, while memoryless states (like spawn in ParticleSpawner) and individual states which need the triggering object (like execute in QuestEffectBeacon) won't work.

Location:
code/branches/core5/src/modules
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/modules/objects/Attacher.cc

    r5738 r5879  
    5353    void Attacher::processEvent(Event& event)
    5454    {
    55         for (std::list<WorldEntity*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
    56             (*it)->fireEvent(event);
     55        if (this->target_)
     56            this->target_->processEvent(event);
    5757    }
    5858
     
    102102
    103103        for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
     104        {
    104105            if (it->getName() == this->targetname_)
     106            {
     107                this->target_ = *it;
    105108                this->attachToParent(*it);
     109            }
     110        }
    106111    }
    107112
  • code/branches/core5/src/modules/objects/triggers/EventTrigger.cc

    r5738 r5879  
    4747    }
    4848
    49     void EventTrigger::processEvent(Event& event)
     49    void EventTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    5050    {
    51         SUPER(EventTrigger, processEvent, event);
     51        SUPER(EventTrigger, XMLEventPort, xmlelement, mode);
    5252
    53         ORXONOX_SET_EVENT(EventTrigger, "trigger", trigger, event);
     53        XMLPortEventState(EventTrigger, BaseObject, "trigger", trigger, xmlelement, mode);
    5454    }
    5555
  • code/branches/core5/src/modules/objects/triggers/EventTrigger.h

    r5738 r5879  
    4141            virtual ~EventTrigger();
    4242
    43             virtual void processEvent(Event& event);
     43            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    4444
    4545            inline void trigger(bool bTriggered)
  • code/branches/core5/src/modules/questsystem/QuestEffectBeacon.cc

    r5738 r5879  
    7575        XMLPortObject(QuestEffectBeacon, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode);
    7676
     77        XMLPortEventState(QuestEffectBeacon, PlayerTrigger, "execute", execute, xmlelement, mode);
     78
    7779        COUT(3) << "New QuestEffectBeacon created." << std::endl;
    7880    }
    7981
    80     /**
    81     @brief
    82         Processes an event for this QuestEffectBeacon.
    83     */
    84     void QuestEffectBeacon::processEvent(Event& event)
    85     {
    86         SUPER(QuestEffectBeacon, processEvent, event);
    87 
    88         ORXONOX_SET_SUBCLASS_EVENT(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);
     82    void QuestEffectBeacon::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     83    {
     84        SUPER(QuestEffectBeacon, XMLEventPort, xmlelement, mode);
     85
     86        XMLPortEventState(QuestEffectBeacon, PlayerTrigger, "execute", execute, xmlelement, mode);
    8987    }
    9088
  • code/branches/core5/src/modules/questsystem/QuestEffectBeacon.h

    r5738 r5879  
    8686
    8787            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
    88 
    89             virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
     88            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    9089
    9190            bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
Note: See TracChangeset for help on using the changeset viewer.