Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/portals/PortalLink.cc @ 8619

Last change on this file since 8619 was 8457, checked in by FelixSchulthess, 14 years ago

merged portals branch into trunk

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#include "PortalLink.h"
2#include "core/XMLPort.h"
3#include "objects/triggers/MultiTriggerContainer.h"
4#include "worldentities/MobileEntity.h"
5
6namespace orxonox
7{
8    CreateFactory(PortalLink);
9
10    std::map<PortalEndPoint *, PortalEndPoint *> PortalLink::links_s;
11   
12    PortalLink::PortalLink(BaseObject* creator) : BaseObject(creator), fromID_(0), toID_(0), from_(0), to_(0)
13    {
14        RegisterObject(PortalLink);
15    }
16   
17    PortalLink::~PortalLink()
18    {
19    }
20   
21    void PortalLink::XMLPort(Element& xmlelement, XMLPort::Mode mode)
22    {
23        SUPER(PortalLink, XMLPort, xmlelement, mode);
24        XMLPortParam(PortalLink, "fromID", setFromID, getFromID, xmlelement, mode);
25        XMLPortParam(PortalLink, "toID", setToID, getToID, xmlelement, mode);
26
27        if(mode == XMLPort::LoadObject)
28        {
29            PortalEndPoint * from = PortalEndPoint::idMap_s[this->fromID_];
30            PortalEndPoint * to   = PortalEndPoint::idMap_s[this->toID_];
31            PortalLink::links_s[from] = to;
32        }
33    }
34
35    void PortalLink::use(MobileEntity* entity, PortalEndPoint * entrance)
36    {
37        if(entrance == 0)
38        {
39            // TODO COUT
40            return;
41        }
42       
43        std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoint = PortalLink::links_s.find(entrance);
44       
45        if(endpoint == PortalLink::links_s.end())  // entrance has no corresponding exit
46            return;
47       
48        endpoint->second->jumpOut(entity);
49    }
50
51
52}
Note: See TracBrowser for help on using the repository browser.