Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2009, 8:20:07 PM (15 years ago)
Author:
rgrieder
Message:

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/Event.h

    r5781 r5929  
    3535namespace orxonox
    3636{
     37    /**
     38        @brief The Event struct contains information about a fired Event.
     39    */
    3740    struct _CoreExport Event
    3841    {
    39             Event(bool activate, BaseObject* originator) : activate_(activate), originator_(originator), castedOriginator_(0) {}
     42        Event(bool activate, BaseObject* originator, const std::string& name) : activate_(activate), originator_(originator), name_(name) {}
    4043
    41             bool        activate_;
    42             BaseObject* originator_;
    43             void*       castedOriginator_;
    44             std::string sectionname_;
     44        bool        activate_;   //!< True if this is an activating event (the event source was inactive before and just triggered the event) - false otherwise
     45        std::string statename_;  //!< The name of the state this event affects
     46        BaseObject* originator_; //!< The object which triggered this event
     47        std::string name_;       //!< The name of this event
    4548    };
    4649
    47     class _CoreExport EventContainer
     50    /**
     51        @brief The EventState contains information about an event state.
     52       
     53        An event state is a state of an object, which can be changed by events.
     54        Event states are changed through functions. Possible functions headers for set event states are:
     55         - memoryless state: function()
     56         - boolean state:    function(bool state)
     57         - individual state: function(bool state, SomeClass originator)
     58         
     59        Note that SomeClass may be any class deriving from BaseObject. You will not receive events from originators of other classes.
     60        The actual class for SomeClass must be specified as the second argument of the XMLPortEventState macro.
     61       
     62        The this pointer of the affected object is hidden in the functors, because the events are processed in the BaseObject, but some
     63        statefunctions may be from child-classes.
     64    */
     65    class _CoreExport EventState
    4866    {
    4967        public:
    50             EventContainer(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : bActive_(false), eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}
    51             virtual ~EventContainer();
     68            EventState(Functor* statefunction, Identifier* subclass) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass) {}
     69            virtual ~EventState();
    5270
    53             void process(BaseObject* object, const Event& event);
     71            void process(const Event& event, BaseObject* object);
     72           
     73            Functor* getFunctor() const
     74                { return this->statefunction_; }
    5475
    5576        private:
    56             bool bActive_;
    57             std::string eventname_;
    58             Executor* eventfunction_;
    59             Identifier* subclass_;
    60 
    61             int activeEvents_;
     77            bool        bProcessingEvent_;  //!< This becomes true while the container processes an event (used to prevent loops)
     78            int         activeEvents_;      //!< The number of events which affect this state and are currently active
     79            Functor*    statefunction_;     //!< A functor to set the state
     80            Identifier* subclass_;          //!< Originators must be an instance of this class (usually BaseObject, but some statefunctions allow a second argument with an originator of a specific class)
    6281    };
    6382}
Note: See TracChangeset for help on using the changeset viewer.