Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/portals/PortalEndPoint.h @ 8731

Last change on this file since 8731 was 8706, checked in by dafrick, 14 years ago

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

  • Property svn:eol-style set to native
File size: 5.1 KB
RevLine 
[8706]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Andreas Büchel
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30 *  @file PortalEndPoint.h
31 *  @brief Declaration of the PortalEndPoint class.
32 *  @ingroup Portals
33 */
34
[8177]35#ifndef _PortalEndPoint_H__
36#define _PortalEndPoint_H__
37
[8200]38#include "portals/PortalsPrereqs.h"
39
[8177]40#include <set>
41#include <string>
42#include <map>
43
[8200]44#include "worldentities/StaticEntity.h"
[8706]45#include "interfaces/RadarViewable.h"
[8177]46#include "graphics/Billboard.h"
[8200]47#include "objects/triggers/DistanceMultiTrigger.h"
[8243]48#include "core/EventIncludes.h"
[8706]49#include <ctime>
[8177]50
51namespace orxonox
52{
[8706]53    /**
54     @brief
55     A PortalEndPoint serves as portal entrance and/or exit.
56     
57     @ingroup Portals
58     */
59   
60    class _PortalsExport PortalEndPoint : public StaticEntity, public RadarViewable
[8177]61    {
62        public:
63            PortalEndPoint(BaseObject* creator);
64            virtual ~PortalEndPoint();
[8706]65           
[8177]66            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
[8706]67            virtual void changedActivity(void);
68           
[8457]69            inline void setTarget(const std::string & target)                 //!< add types which are allowed to activate the PortalEndPoint
[8706]70                { this->trigger_->addTarget(target); }
[8243]71           
72            void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
[8454]73            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
[8706]74            inline void setReenterDelay(unsigned int seconds)
75                { this->reenterDelay_ = seconds; }
76            inline unsigned int getReenterDelay()
77                { return this->reenterDelay_; }
[8177]78            inline void setID(unsigned int id)
[8706]79                { this->id_ = id; }
[8177]80           
81            inline unsigned int getID() const
[8706]82                { return this->id_; }
[8454]83           
84            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
[8243]85            inline void setTemplate(const std::string & name)
[8706]86                { this->templateName_ = name; this->addTemplate(name); }
[8454]87
88            /// \brief Get the name of the attached design template
[8243]89            inline const std::string & getTemplate()
[8706]90                { return this->templateName_; }
[8454]91
92            /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed
[8706]93                \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
94                \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
95            */
[8243]96            bool execute(bool bTriggered, BaseObject* trigger);
[8454]97
98            /*! \brief Let an Entity jump out of this portal no matter where it was before
99             * \param entity The Entity which should jump out of this portal */
[8243]100            void jumpOut(MobileEntity * entity);
[8706]101           
102            /** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint?
103                @return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise
104            */
105            bool letsEnter(MobileEntity* entity);
[8177]106        protected:
[8290]107           
[8177]108        private:
[8454]109            static const std::string EVENTFUNCTIONNAME; //!< = "execute"
[8290]110           
[8454]111            unsigned int id_;            //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints
112            DistanceMultiTrigger * trigger_;      //!< the DistanceMultiTrigger which notices near entities of the defined type
113            std::string templateName_;            //!< The name of the design template used for this endpoint
[8290]114
[8706]115            int reenterDelay_;
116            std::map<MobileEntity *, time_t> jumpOutTimes_;   //!< Stores the time at which a certain MobileEntity @ref jumpOut "jumped out" of this PortalEndPoint
117            std::set<MobileEntity *> recentlyJumpedOut_;   //!< Stores the entities witch recently jumped out of this PortalEndPoint and haven't left the activation radius yet. This is needed in order to prevent them from beeing pulled into the PortalEndPoint they have just come out of.
[8177]118    };
119
120}
121
122#endif /* _Portals_H__ */
Note: See TracBrowser for help on using the repository browser.