Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2010, 8:55:13 AM (14 years ago)
Author:
dafrick
Message:

Merged presentation3 branch into trunk.

Location:
code/trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/objects/triggers/CheckPoint.cc

    r5929 r7163  
    3838    CreateFactory(CheckPoint);
    3939
    40     CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
     40    CheckPoint::CheckPoint(BaseObject* creator)
     41        : DistanceTrigger(creator)
     42        , RadarViewable(creator, static_cast<WorldEntity*>(this))
    4143    {
    4244        RegisterObject(CheckPoint);
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc

    • Property svn:eol-style set to native
    r6906 r7163  
    4040namespace orxonox
    4141{
    42    
     42
    4343    CreateFactory(DistanceMultiTrigger);
    4444
    4545    /**
    4646    @brief
    47         Default Constructor. Registers the object and initializes default values. 
     47        Default Constructor. Registers the object and initializes default values.
    4848    */
    4949    DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator)
    5050    {
    5151        RegisterObject(DistanceMultiTrigger);
    52        
     52
    5353        this->distance_ = 100.0f;
    5454        this->targetName_ = BLANKSTRING;
     
    9898                continue;
    9999            }
    100            
     100
    101101            Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
    102102            // If the object is no longer in range.
     
    154154                if(this->singleTargetMode_)
    155155                    entity = entity->getParent();
    156                
     156
    157157                // If no queue has been created, yet.
    158158                if(queue == NULL)
     
    166166            }
    167167        }
    168        
     168
    169169        return queue;
    170170    }
    171    
     171
    172172}
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h

    • Property svn:eol-style set to native
    r6906 r7163  
    5656    class _ObjectsExport DistanceMultiTrigger : public MultiTrigger
    5757    {
    58        
     58
    5959        public:
    6060            DistanceMultiTrigger(BaseObject* creator); //!< Default Constructor. Registers the object and initializes default values.
    6161            ~DistanceMultiTrigger(); //!< Destructor.
    62            
     62
    6363            void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML.
    6464
     
    7575            inline const std::string& getTargetName(void)
    7676                { return this->targetName_; }
    77            
     77
    7878            /**
    7979            @brief Set the distance at which the DistanceMultiTrigger triggers.
     
    8888            inline float getDistance() const
    8989                { return this->distance_; }
    90                
     90
    9191        protected:
    9292            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.
     
    106106            inline bool removeFromRange(WorldEntity* entity)
    107107                { WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second; bool erased = this->range_.erase(entity) > 0; if(erased) delete weakptr; return erased; }
    108                
     108
    109109        private:
    110110            float distance_; //!< The distance at which the DistanceMultiTrigger triggers.
    111111            std::string targetName_; //!< The target name, used in singleTargetMode.
    112112            bool singleTargetMode_; //!< To indicate whe the MultiDistanceTrigger is in single-target-mode.
    113            
     113
    114114            std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
    115        
     115
    116116    };
    117    
     117
    118118}
    119119
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.cc

    r6906 r7163  
    136136          continue;
    137137      }
    138      
     138
    139139      Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
    140140      if (distanceVec.length() < this->distance_)
     
    155155      }
    156156    }
     157
    157158    return false;
    158159  }
  • code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.cc

    • Property svn:eol-style set to native
    r6906 r7163  
    3535
    3636    CreateFactory(DistanceTriggerBeacon);
    37    
     37
    3838    DistanceTriggerBeacon::DistanceTriggerBeacon(BaseObject* creator) : StaticEntity(creator)
    3939    {
    4040        RegisterObject(DistanceTriggerBeacon);
    4141    }
    42    
     42
    4343}
  • code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.h

    • Property svn:eol-style set to native
    r6906 r7163  
    3939    class _ObjectsExport DistanceTriggerBeacon : public StaticEntity
    4040    {
    41        
     41
    4242        public:
    4343
  • code/trunk/src/modules/objects/triggers/EventMultiTrigger.cc

    • Property svn:eol-style set to native
    r6864 r7163  
    5252    EventMultiTrigger::~EventMultiTrigger()
    5353    {
    54        
     54
    5555    }
    5656
     
    6161        this->setBroadcast(true);
    6262    }
    63    
     63
    6464    void EventMultiTrigger::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    6565    {
  • code/trunk/src/modules/objects/triggers/EventMultiTrigger.h

    • Property svn:eol-style set to native
    r6864 r7163  
    4444    class _ObjectsExport EventMultiTrigger : public MultiTrigger
    4545    {
    46        
     46
    4747        public:
    4848            EventMultiTrigger(BaseObject* creator);
  • code/trunk/src/modules/objects/triggers/MultiTrigger.cc

    • Property svn:eol-style set to native
    r6864 r7163  
    4747    /*static*/ const std::string MultiTrigger::or_s = "or";
    4848    /*static*/ const std::string MultiTrigger::xor_s = "xor";
    49    
     49
    5050    CreateFactory(MultiTrigger);
    5151
     
    6565        this->bSwitch_ = false;
    6666        this->bStayActive_ = false;
    67        
     67
    6868        this->remainingActivations_ = INF_s;
    6969        this->maxNumSimultaniousTriggerers_ = INF_s;
     
    7575
    7676        this->parentTrigger_ = NULL;
    77        
     77
    7878        this->targetMask_.exclude(Class(BaseObject));
    7979
    8080        this->setSyncMode(0x0);
    8181    }
    82    
     82
    8383    /**
    8484    @brief
     
    9595        }
    9696    }
    97    
     97
    9898    /**
    9999    @brief
     
    117117        //TODO: Maybe nicer with explicit subgroup, e.g. triggers
    118118        XMLPortObject(MultiTrigger, MultiTrigger, "", addTrigger, getTrigger, xmlelement, mode);
    119        
     119
    120120        COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") created." << std::endl;
    121121    }
    122    
     122
    123123
    124124    /**
     
    131131    {
    132132        // If this is the first tick.
    133         //TODO: Determine need for this, else kick it out. 
     133        //TODO: Determine need for this, else kick it out.
    134134        if(this->bFirstTick_)
    135135        {
     
    174174                    delete state;
    175175                }
    176                
     176
    177177                queue->pop();
    178178            }
     
    185185            MultiTriggerState* state;
    186186            float timeRemaining;
    187            
     187
    188188            // Go through all pending states.
    189189            for(int size = this->stateQueue_.size(); size >= 1; size--)
     
    212212                                this->triggered_.erase(state->originator);
    213213                            }
    214                            
     214
    215215                            bStateChanged = true;
    216216                        }
     
    229229
    230230                            bool bFire = true;
    231                            
     231
    232232                            // Add the originator to the objects activating this MultiTrigger.
    233233                            if(bActive == true)
     
    266266                                else
    267267                                    this->fire(bActive, state->originator);
    268                                
     268
    269269                                bStateChanged = true;
    270270                            }
     
    289289                        }
    290290                    }
    291                    
     291
    292292                    // Remove the state from the state queue.
    293293                    this->stateQueue_.pop_front();
     
    509509            return returnVal;
    510510        }
    511        
     511
    512512        return true;
    513513    }
    514    
     514
    515515    /**
    516516    @brief
     
    547547            return;
    548548        }
    549        
     549
    550550        MultiTriggerContainer* container = new MultiTriggerContainer(this, this, originator);
    551551        this->fireEvent(status, container);
     
    563563    {
    564564        ClassTreeMask& targetMask = this->getTargetMask();
    565        
     565
    566566        for(ClassTreeMaskObjectIterator it = targetMask.begin(); it != targetMask.end(); ++it)
    567567        {
     
    580580    {
    581581        assert(state);
    582        
     582
    583583        // If the originator is no target of this MultiTrigger.
    584584        if(!this->isTarget(state->originator))
    585585            return false;
    586        
     586
    587587        // Add it ot the state queue.
    588588        this->stateQueue_.push_back(std::pair<float, MultiTriggerState*>(this->delay_, state));
  • code/trunk/src/modules/objects/triggers/MultiTrigger.h

    • Property svn:eol-style set to native
    r6864 r7163  
    9494            MultiTrigger(BaseObject* creator); //!< Constructor. Registers the objects and initializes default values.
    9595            ~MultiTrigger(); //!< Destructor.
    96            
     96
    9797            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a MultiTrigger object through XML.
    9898            virtual void tick(float dt); //!< A method that is executed each tick.
    99            
     99
    100100            bool isActive(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is active for a given object.
    101101
     
    215215            void addTargets(const std::string& targets); //!< Add some target to the MultiTrigger.
    216216            void removeTargets(const std::string& targets); //!< Remove some target from the MultiTrigger.
    217            
     217
    218218            void addTrigger(MultiTrigger* trigger); //!< Adds a MultiTrigger as a sub-trigger to the trigger.
    219219            const MultiTrigger* getTrigger(unsigned int index) const; //!< Get the sub-trigger of this MultiTrigger at the given index.
    220            
     220
    221221        protected:
    222222            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.
    223223
    224224            void changeTriggered(BaseObject* originator = NULL); //!< This method can be called by any class inheriting from MultiTrigger to change it's triggered status for a specified originator.
    225            
     225
    226226            bool isModeTriggered(BaseObject* triggerer = NULL); //!< Checks whetherx the MultiTrigger is triggered concerning it's sub-triggers.
    227227            bool isTriggered(BaseObject* triggerer = NULL); //!< Get whether the MultiTrigger is triggered for a given object.
     
    236236            inline void addParentTrigger(MultiTrigger* parent)
    237237                { this->parentTrigger_ = parent; }
    238            
     238
    239239            /**
    240240            @brief Get the target mask used to identify the targets of this MultiTrigger.
     
    248248            //TODO: Check if something mus be done here.
    249249            virtual void notifyMaskUpdate(void) {}
    250            
     250
    251251        private:
    252252            static const int INF_s; //!< Magic number for infinity.
     
    257257
    258258            void subTrigggerActivityChanged(BaseObject* originator); //!< This method is called by any sub-trigger to advertise changes in it's state to it's parent-trigger.
    259            
     259
    260260            bool addState(MultiTriggerState* state); //!< Helper method. Adds a state to the state queue, where the state will wait to become active.
    261            
     261
    262262            bool checkAnd(BaseObject* triggerer); //!< Checks whether the sub-triggers amount to true for the 'and' mode for a given object.
    263263            bool checkOr(BaseObject* triggerer); //!< Checks whether the sub-triggers amount to true for the 'or' mode for a given object.
     
    276276            bool bSwitch_; //!< Bool for the switch-mode, if true the MultiTrigger behaves like a switch.
    277277            bool bStayActive_; //!< Bool for the stay-active-mode, if true the MultiTrigger stays active after its last activation.;
    278            
     278
    279279            int remainingActivations_; //!< The remaining activations of this MultiTrigger.
    280280            int maxNumSimultaniousTriggerers_; //!< The maximum number of objects simultaniously trigggering this MultiTrigger.
     
    287287            MultiTrigger* parentTrigger_;
    288288            std::set<MultiTrigger*> subTriggers_; //!< The sub-triggers of this MultiTrigger.
    289            
     289
    290290            std::set<BaseObject*> active_; //!< The set of all objects the MultiTrigger is active for.
    291291            std::set<BaseObject*> triggered_; //!< The set of all objects the MultiTrigger is triggered for.
    292292
    293293            std::deque< std::pair<float, MultiTriggerState*> > stateQueue_; //!< The queue of states waiting to become active.
    294            
     294
    295295            ClassTreeMask targetMask_; //!< The target mask, masking all objects that can trigger this MultiTrigger.
    296            
     296
    297297    };
    298298
  • code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc

    • Property svn:eol-style set to native
    r6859 r7163  
    4040
    4141    CreateUnloadableFactory(MultiTriggerContainer);
    42    
     42
    4343    /**
    4444    @brief
     
    7373    MultiTriggerContainer::~MultiTriggerContainer()
    7474    {
    75        
     75
    7676    }
    7777
  • code/trunk/src/modules/objects/triggers/MultiTriggerContainer.h

    • Property svn:eol-style set to native
    r6856 r7163  
    5050    class _ObjectsExport MultiTriggerContainer : public BaseObject
    5151    {
    52        
     52
    5353        public:
    5454            MultiTriggerContainer(BaseObject* creator); //!< Default constructor. Registers the object and creates an empty container.
     
    6868            inline BaseObject* getData(void)
    6969                { return this->data_; }
    70            
     70
    7171        private:
    7272            MultiTrigger* originator_; //!< The originator.
    7373            BaseObject* data_; //!< The data.
    7474    };
    75    
     75
    7676}
    7777
Note: See TracChangeset for help on using the changeset viewer.