[Orxonox-commit 3605] r8290 - in code/branches/portals: data/levels src/modules/portals

dafrick at orxonox.net dafrick at orxonox.net
Thu Apr 21 22:48:56 CEST 2011


Author: dafrick
Date: 2011-04-21 22:48:55 +0200 (Thu, 21 Apr 2011)
New Revision: 8290

Modified:
   code/branches/portals/data/levels/portals.oxw
   code/branches/portals/src/modules/portals/PortalEndPoint.cc
   code/branches/portals/src/modules/portals/PortalEndPoint.h
Log:
Moving the things done with the eventTemplate into the PortalEndPoint class.


Modified: code/branches/portals/data/levels/portals.oxw
===================================================================
--- code/branches/portals/data/levels/portals.oxw	2011-04-21 20:45:42 UTC (rev 8289)
+++ code/branches/portals/data/levels/portals.oxw	2011-04-21 20:48:55 UTC (rev 8290)
@@ -25,16 +25,6 @@
    skybox       = "Orxonox/skypanoramagen1"
   >
 
-    <Template name=portalEventTemplate>
-        <PortalEndPoint>
-            <events>
-                <execute>
-                    <EventListener event="portal" />
-                </execute>
-            </events>
-        </PortalEndPoint>
-    </Template>
-
     <Template name=portalDefault>
         <PortalEndPoint>
             <attached>
@@ -44,7 +34,7 @@
     </Template>
 
     <PortalEndPoint position="0,0,0" id="1" distance="40" target="MobileEntity" design="portalDefault" eventTemplate="portalEventTemplate" />
-    <PortalEndPoint position="-400,0,0" id="2" distance="40" lookat="0,100,0" target="MobileEntity" design="portalDefault" eventTemplate="portalEventTemplate" />
+    <PortalEndPoint position="-400,0,0" id="2" distance="40" lookat="0,100,0" target="MobileEntity" design="portalDefault" />
     <PortalLink fromID="1" toID="2" />
     <PortalLink fromID="2" toID="1" />
 

Modified: code/branches/portals/src/modules/portals/PortalEndPoint.cc
===================================================================
--- code/branches/portals/src/modules/portals/PortalEndPoint.cc	2011-04-21 20:45:42 UTC (rev 8289)
+++ code/branches/portals/src/modules/portals/PortalEndPoint.cc	2011-04-21 20:48:55 UTC (rev 8290)
@@ -8,6 +8,8 @@
 namespace orxonox
 {
     CreateFactory(PortalEndPoint);
+    
+    /*static*/ const std::string PortalEndPoint::EVENTFUNCTIONNAME = "execute";
 
     std::map<unsigned int, PortalEndPoint *> PortalEndPoint::idMap_s;
 
@@ -30,9 +32,11 @@
         XMLPortParam(PortalEndPoint, "id", setID, getID, xmlelement, mode);
         XMLPortParam(PortalEndPoint, "design", setTemplate, getTemplate, xmlelement, mode);
         XMLPortParamExtern(PortalEndPoint, DistanceMultiTrigger, this->trigger_, "distance", setDistance, getDistance, xmlelement, mode);
-        XMLPortParamLoadOnly(PortalEndPoint, "eventTemplate", setEventTemplate, xmlelement, mode);
         XMLPortParamLoadOnly(PortalEndPoint, "target", setTargets, xmlelement, mode).defaultValues("Pawn");
         
+        // Add the DistanceMultiTrigger as event source.
+        this->addEventSource(this->trigger_, EVENTFUNCTIONNAME);
+        
         if(mode == XMLPort::LoadObject)
         {
             PortalEndPoint::idMap_s[this->id_] = this;
@@ -43,7 +47,7 @@
     {
         SUPER(PortalEndPoint, XMLEventPort, xmlelement, mode);
         
-        XMLPortEventSink(PortalEndPoint, BaseObject, "execute", execute, xmlelement, mode);
+        XMLPortEventSink(PortalEndPoint, BaseObject, EVENTFUNCTIONNAME, execute, xmlelement, mode);
     }
 
     bool PortalEndPoint::execute(bool bTriggered, BaseObject* trigger)

Modified: code/branches/portals/src/modules/portals/PortalEndPoint.h
===================================================================
--- code/branches/portals/src/modules/portals/PortalEndPoint.h	2011-04-21 20:45:42 UTC (rev 8289)
+++ code/branches/portals/src/modules/portals/PortalEndPoint.h	2011-04-21 20:48:55 UTC (rev 8290)
@@ -48,14 +48,14 @@
             bool execute(bool bTriggered, BaseObject* trigger);
             void jumpOut(MobileEntity * entity);
         protected:
+            
         private:
+            static const std::string EVENTFUNCTIONNAME;
+            
             unsigned int id_;
             DistanceMultiTrigger * trigger_;
             std::string templateName_;
-            void setEventTemplate(const std::string & temp)
-            {
-                this->addTemplate(temp);
-            }
+
             std::set<MobileEntity *> recentlyJumpedOut_; //!< Entities which recently jumped out of this EndPoint, hence they shouldn't be pulled in again if the endpoint is the beginning of a link
     };
 




More information about the Orxonox-commit mailing list