Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 20, 2011, 11:27:45 PM (13 years ago)
Author:
dafrick
Message:

Some cleanup…

Location:
code/trunk/src/modules/portals
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/portals/PortalEndPoint.cc

    r8706 r8767  
    2828
    2929#include "PortalEndPoint.h"
     30
     31#include <ctime>
     32
     33#include "core/CoreIncludes.h"
    3034#include "core/XMLPort.h"
     35
     36#include "worldentities/MobileEntity.h"
     37
    3138#include "objects/triggers/MultiTriggerContainer.h"
     39
    3240#include "portals/PortalLink.h"
    33 #include "worldentities/MobileEntity.h"
    34 #include <ctime>
    3541
    3642namespace orxonox
    3743{
    3844    CreateFactory(PortalEndPoint);
    39    
     45
    4046    /*static*/ const std::string PortalEndPoint::EVENTFUNCTIONNAME = "execute";
    4147
     
    4551    {
    4652        RegisterObject(PortalEndPoint);
    47        
     53
    4854        this->trigger_ = new DistanceMultiTrigger(this);
    4955        this->trigger_->setName("portal");
    50         this->attach(trigger_);
     56        this->attach(this->trigger_);
    5157
    5258        this->setRadarObjectColour(ColourValue::White);
     
    5460        this->setRadarVisibility(true);
    5561    }
    56    
     62
    5763    PortalEndPoint::~PortalEndPoint()
    5864    {
     
    6470    {
    6571        SUPER(PortalEndPoint, XMLPort, xmlelement, mode);
    66        
     72
    6773        XMLPortParam(PortalEndPoint, "id", setID, getID, xmlelement, mode);
    6874        XMLPortParam(PortalEndPoint, "design", setTemplate, getTemplate, xmlelement, mode);
     
    7076        XMLPortParamExtern(PortalEndPoint, DistanceMultiTrigger, this->trigger_, "distance", setDistance, getDistance, xmlelement, mode);
    7177        XMLPortParamLoadOnly(PortalEndPoint, "target", setTarget, xmlelement, mode).defaultValues("Pawn");
    72        
     78
    7379        // Add the DistanceMultiTrigger as event source.
    7480        this->addEventSource(this->trigger_, EVENTFUNCTIONNAME);
    75        
     81
    7682        if(mode == XMLPort::LoadObject)
    7783        {
     
    8389    {
    8490        SUPER(PortalEndPoint, XMLEventPort, xmlelement, mode);
    85        
     91
    8692        XMLPortEventSink(PortalEndPoint, BaseObject, EVENTFUNCTIONNAME, execute, xmlelement, mode);
    8793    }
     
    9197        if(!this->isActive())
    9298            return true;
    93        
     99
    94100        MultiTriggerContainer * cont = orxonox_cast<MultiTriggerContainer *>(trigger);
    95101        if(cont == 0)
    96102            return true;
    97        
     103
    98104        DistanceMultiTrigger * originatingTrigger = orxonox_cast<DistanceMultiTrigger *>(cont->getOriginator());
    99105        if(originatingTrigger == 0)
     
    101107            return true;
    102108        }
    103        
     109
    104110        MobileEntity * entity = orxonox_cast<MobileEntity *>(cont->getData());
    105111        if(entity == 0)
    106112            return true;
    107        
     113
    108114        if(bTriggered)
    109115        {
     
    117123            this->recentlyJumpedOut_.erase(entity);
    118124        }
    119        
     125
    120126        return true;
    121127    }
     
    124130    {
    125131        SUPER(PortalEndPoint, changedActivity);
    126        
     132
    127133        this->setRadarVisibility(this->isActive());
    128134    }
  • code/trunk/src/modules/portals/PortalEndPoint.h

    r8706 r8767  
    3838#include "portals/PortalsPrereqs.h"
    3939
     40#include <map>
    4041#include <set>
    4142#include <string>
    42 #include <map>
     43
     44#include "core/EventIncludes.h"
    4345
    4446#include "worldentities/StaticEntity.h"
    4547#include "interfaces/RadarViewable.h"
    46 #include "graphics/Billboard.h"
    4748#include "objects/triggers/DistanceMultiTrigger.h"
    48 #include "core/EventIncludes.h"
    49 #include <ctime>
    5049
    5150namespace orxonox
     
    5453     @brief
    5554     A PortalEndPoint serves as portal entrance and/or exit.
    56      
     55
    5756     @ingroup Portals
    5857     */
    59    
     58
    6059    class _PortalsExport PortalEndPoint : public StaticEntity, public RadarViewable
    6160    {
     
    6362            PortalEndPoint(BaseObject* creator);
    6463            virtual ~PortalEndPoint();
    65            
     64
    6665            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    6766            virtual void changedActivity(void);
    68            
     67
    6968            inline void setTarget(const std::string & target)                 //!< add types which are allowed to activate the PortalEndPoint
    7069                { this->trigger_->addTarget(target); }
    71            
     70
    7271            void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    7372            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
     
    7877            inline void setID(unsigned int id)
    7978                { this->id_ = id; }
    80            
     79
    8180            inline unsigned int getID() const
    8281                { return this->id_; }
    83            
     82
    8483            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
    8584            inline void setTemplate(const std::string & name)
     
    9998             * \param entity The Entity which should jump out of this portal */
    10099            void jumpOut(MobileEntity * entity);
    101            
     100
    102101            /** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint?
    103102                @return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise
     
    105104            bool letsEnter(MobileEntity* entity);
    106105        protected:
    107            
     106
    108107        private:
    109108            static const std::string EVENTFUNCTIONNAME; //!< = "execute"
    110            
     109
    111110            unsigned int id_;            //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints
    112111            DistanceMultiTrigger * trigger_;      //!< the DistanceMultiTrigger which notices near entities of the defined type
  • code/trunk/src/modules/portals/PortalLink.cc

    r8706 r8767  
    2828
    2929#include "PortalLink.h"
     30
     31#include "core/CoreIncludes.h"
    3032#include "core/XMLPort.h"
    31 #include "objects/triggers/MultiTriggerContainer.h"
     33
    3234#include "worldentities/MobileEntity.h"
    3335
     
    3739
    3840    std::map<PortalEndPoint *, PortalEndPoint *> PortalLink::links_s;
    39    
     41
    4042    PortalLink::PortalLink(BaseObject* creator) : BaseObject(creator), fromID_(0), toID_(0), from_(0), to_(0)
    4143    {
    4244        RegisterObject(PortalLink);
    4345    }
    44    
     46
    4547    PortalLink::~PortalLink()
    4648    {
    47        
     49
    4850    }
    49    
     51
    5052    void PortalLink::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5153    {
     
    5456        XMLPortParam(PortalLink, "toID", setToID, getToID, xmlelement, mode);
    5557
     58        // Beware: This means, that the PortalEndPoints must exist before the PortalLink is created.
    5659        if(mode == XMLPort::LoadObject)
    5760        {
     
    6568    {
    6669        if(entrance == 0)
    67         {
    6870            return;
    69         }
    70        
     71
    7172        std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoints = PortalLink::links_s.find(entrance);
    72        
    7373        if(endpoints == PortalLink::links_s.end())  // entrance has no corresponding exit
    7474            return;
  • code/trunk/src/modules/portals/PortalLink.h

    r8706 r8767  
    3737
    3838#include "portals/PortalsPrereqs.h"
    39 #include "tools/interfaces/Tickable.h"
    40 #include "core/BaseObject.h"
    41 #include "PortalEndPoint.h"
    42 #include "objects/eventsystem/EventListener.h"
    4339
    4440#include <map>
     41
     42#include "PortalEndPoint.h"
     43
     44#include "core/BaseObject.h"
    4545
    4646namespace orxonox
     
    5757            virtual ~PortalLink();
    5858            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     59
    5960            inline void setFromID(unsigned int from)    //!< set the ID of the PortalEndPoint which should act as the entrance of this link
    60             {
    61                 this->fromID_ = from;
    62             }
     61                { this->fromID_ = from; }
    6362            inline unsigned int getFromID(unsigned int) const
    64             {
    65                 return this->fromID_;
    66             }
     63                { return this->fromID_; }
    6764            inline void setToID(unsigned int to)     //!< set the ID of the PortalEndPoint which should act as the exit of this link
    68             {
    69                 this->toID_ = to;
    70             }
     65                { this->toID_ = to; }
    7166            inline unsigned int getToID(unsigned int) const
    72             {
    73                 return this->toID_;
    74             }
     67                { return this->toID_; }
    7568            /*! \brief Let an entity enter a certain PortalEndPoint
    7669                \param entity pointer to the entity which is entering a PortalEndPoint
Note: See TracChangeset for help on using the changeset viewer.