Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2010, 11:52:07 PM (14 years ago)
Author:
dafrick
Message:

Started documenting, also changed some of the implementation to avoid possible bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/objects/triggers/MultiTrigger.h

    r6851 r6853  
    4343namespace orxonox
    4444{
    45    
     45
     46    //! The different modes the MultiTrigger can be in.
    4647    namespace MultiTriggerMode
    4748    {
     
    5354        };
    5455    }
    55    
     56
     57    //! Struct to handle MultiTrigger states internally.
    5658    struct MultiTriggerState
    5759    {
     
    6466    @brief
    6567        The MultiTrigger class implements a trigger that has a distinct state for each object triggering it.
     68        In more detail: A Trigger is an object that can either be active or inactive, whith a specified behaviour how to switch between the two. A MultiTrigger generalizes that behaviour for multiple objects trigggering the trigger. A MultiTrigger can be active or inactive for any object triggering it, with the state for each object being completely independent of the state for other objects. Each time a switch occurs an Event is fired with as the originator a MultiTriggerContainer, containig a pointer to the pointer that caused the Event and a pointer to the object that caused the trigger to change it's activity.
     69
     70        MultiTriggers also allow for additional complexity which can be added trough the choice of the parameters explained (briefly) below:
     71        But first you must understand a small implementational detail. There is a distinction between the MultiTrigger being triggered (there is the state 'triggered' for that) and the MultiTrigger being active (for that is the state 'activity'). From the outside only the activity is visible. The state 'triggered' tells us whether the trigger is actually triggered, but it could pretend (for some reason, some of which we will see shortly) to be triggered (or to the outside, active), while it in fact isn't. The standard behaviour is, that the cativity changes, when the MultiTrigger transits from being triggered to not being triggered or the other way around.
     72        The parameters are:
     73            'delay':                    The delay is the time that the trigger waits until it reacts (i.e. changes it's state) to the triggering condition being fulfilled.
     74            'switch':                   Switch is a bool, if true the MultiTrigger is in switch-mode, meaning, that the activity changes only when the trigger is triggered , this means, that now the activity only changes, when the trigger changes from not being triggered to being triggered but not the other way around. The default is false.
     75            'stayactive':               Stay active is also a bool, if true the MultiTrigger stays active after it has been activated as many times as specified by the parameter activations. The default is -1, which is infinity.
     76            'activations':              The number of activations until the trigger can't be triggered anymore. The default is -1, which is infinity.
     77            'invert':                   Invert is a bool, if true the trigger is in invert-mode, meaning, that if the triggering condition is fulfilled the MultiTrigger will have the state not triggered and and if the condition is not fulfilled it will have the state triggered. In short it just inverts the behaviour of the MultiTrigger. The default is false.
     78            'simultaniousTriggerers':   The number of simultanious triggerers limits the number of object that are allowed to trigger the MultiTrigger at the same time. Or a little more precisely, the number of distinct objects the MultiTrigger has 'triggered' states for, at each point in time.
     79            'mode':                     The mode describes how the MultiTrigger acts in relation to all the MultiTriggers, that are appended to it. There are 3 modes: 'and', meaning that the MultiTrigger can only be triggered if all the appended MultiTriggers are active. 'or', meaning that the MultiTrigger can only triggered if at least one of the appendend MultiTriggers is active. And 'xor', meaning that the MultiTrigger can only be triggered if one and only one appended MultiTrigger is active. Notice, that I wrote 'can only be active', that implies, that there is an addtitional condition to the activity of the MultiTrigger and that is the fulfillment of the triggering condition (the MultiTrigger itself doesn't have one, but all derived classes should). Also bear in mind, that the activity of a MultiTrigger is still coupled to the object that triggered it. The default is 'and'.
     80            'target':                   The target describes the kind of objects that are allowed to trigger this MultiTrigger. The default is 'ControllableEntity'.
     81            Also there is the possibility of appending MultiTriggers to the MultiTrigger just by adding them as subobjects in the XML description of your MultiTrigger.
     82
     83    @author
     84        Damian 'Mozork' Frick
    6685    */
    6786    class _ObjectsExport MultiTrigger : public StaticEntity, public Tickable
    6887    {
    6988        public:
    70             MultiTrigger(BaseObject* creator);
    71             ~MultiTrigger();
     89            MultiTrigger(BaseObject* creator); //!< Constructor. Registers the objects and initializes default values.
     90            ~MultiTrigger(); //!< Destructor.
    7291           
    73             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    74             virtual void tick(float dt);
     92            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a MultiTrigger object through XML.
     93            virtual void tick(float dt); //!< A method that is executed each tick.
    7594           
    7695            bool isActive(BaseObject* triggerer = NULL);
Note: See TracChangeset for help on using the changeset viewer.