Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged portals branch into trunk

  • Property svn:executable set to *
File size: 1.5 KB
RevLine 
[8177]1#include "PortalLink.h"
2#include "core/XMLPort.h"
[8198]3#include "objects/triggers/MultiTriggerContainer.h"
[8243]4#include "worldentities/MobileEntity.h"
[8177]5
6namespace orxonox
7{
8    CreateFactory(PortalLink);
[8243]9
10    std::map<PortalEndPoint *, PortalEndPoint *> PortalLink::links_s;
[8177]11   
[8243]12    PortalLink::PortalLink(BaseObject* creator) : BaseObject(creator), fromID_(0), toID_(0), from_(0), to_(0)
[8177]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        {
[8243]29            PortalEndPoint * from = PortalEndPoint::idMap_s[this->fromID_];
30            PortalEndPoint * to   = PortalEndPoint::idMap_s[this->toID_];
31            PortalLink::links_s[from] = to;
[8177]32        }
33    }
[8243]34
35    void PortalLink::use(MobileEntity* entity, PortalEndPoint * entrance)
[8177]36    {
[8243]37        if(entrance == 0)
[8198]38        {
[8243]39            // TODO COUT
[8198]40            return;
41        }
[8243]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
[8198]46            return;
[8243]47       
48        endpoint->second->jumpOut(entity);
[8177]49    }
[8198]50
[8243]51
[8200]52}
Note: See TracBrowser for help on using the repository browser.