Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation/src/modules/portals/PortalEndPoint.h @ 8605

Last change on this file since 8605 was 8605, checked in by dafrick, 13 years ago

Merging portals2 branch into presentation branch.

  • Property svn:executable set to *
File size: 5.1 KB
Line 
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
35#ifndef _PortalEndPoint_H__
36#define _PortalEndPoint_H__
37
38#include "portals/PortalsPrereqs.h"
39
40#include <set>
41#include <string>
42#include <map>
43
44#include "worldentities/StaticEntity.h"
45#include "graphics/Billboard.h"
46#include "objects/triggers/DistanceMultiTrigger.h"
47#include "core/EventIncludes.h"
48#include <ctime>
49
50namespace orxonox
51{
52    /**
53     @brief
54     A PortalEndPoint serves as portal entrance and/or exit.
55     
56     @ingroup Portals
57     */
58   
59    class _PortalsExport PortalEndPoint : public StaticEntity
60    {
61        public:
62            PortalEndPoint(BaseObject* creator);
63            virtual ~PortalEndPoint();
64            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
65            inline void setTarget(const std::string & target)                 //!< add types which are allowed to activate the PortalEndPoint
66            {
67                this->trigger_->addTarget(target);
68            }
69           
70            void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
71            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
72            inline void setReenterDelay(unsigned int seconds)
73            {
74                this->reenterDelay_ = seconds;
75            }
76            inline unsigned int getReenterDelay()
77            {
78                return this->reenterDelay_;
79            }
80            inline void setID(unsigned int id)
81            {
82                this->id_ = id;
83            }
84           
85            inline unsigned int getID() const
86            {
87                return this->id_;
88            }
89           
90            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
91            inline void setTemplate(const std::string & name)
92            {
93                this->templateName_ = name;
94                this->addTemplate(name);
95            }
96
97            /// \brief Get the name of the attached design template
98            inline const std::string & getTemplate()
99            {
100                return this->templateName_;
101            }
102
103            /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed
104                \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
105                \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
106            */
107            bool execute(bool bTriggered, BaseObject* trigger);
108
109            /*! \brief Let an Entity jump out of this portal no matter where it was before
110             * \param entity The Entity which should jump out of this portal */
111            void jumpOut(MobileEntity * entity);
112           
113            /** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint?
114                @return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise
115            */
116            bool letsEnter(MobileEntity* entity);
117        protected:
118           
119        private:
120            static const std::string EVENTFUNCTIONNAME; //!< = "execute"
121           
122            unsigned int id_;            //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints
123            DistanceMultiTrigger * trigger_;      //!< the DistanceMultiTrigger which notices near entities of the defined type
124            std::string templateName_;            //!< The name of the design template used for this endpoint
125
126            int reenterDelay_;
127            std::map<MobileEntity *, time_t> jumpOutTimes_;   //!< Stores the time at which a certain MobileEntity @ref jumpOut "jumped out" of this PortalEndPoint
128            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.
129    };
130
131}
132
133#endif /* _Portals_H__ */
Note: See TracBrowser for help on using the repository browser.