[Orxonox-commit 2190] r6906 - in code/trunk: data/gui/scripts src/modules/objects src/modules/objects/triggers src/modules/questsystem

dafrick at orxonox.net dafrick at orxonox.net
Mon May 17 13:22:27 CEST 2010


Author: dafrick
Date: 2010-05-17 13:22:26 +0200 (Mon, 17 May 2010)
New Revision: 6906

Added:
   code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.cc
   code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.h
Modified:
   code/trunk/data/gui/scripts/PickupInventory.lua
   code/trunk/src/modules/objects/ObjectsPrereqs.h
   code/trunk/src/modules/objects/triggers/CMakeLists.txt
   code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
   code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
   code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
   code/trunk/src/modules/objects/triggers/DistanceTrigger.h
   code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
Log:
Added DistanceTriggerBeacon, which is a device which can be attached to objects to trigger a DistanceTrigger (both the (single) DistanceTrigger and DistanceMultiTrigger) based on the name of the DistanceTri$
Also some minor adjustements in QuestEffectBeacon: Removed some output and adjusted the outputlevel of some other output.
And started working on PickupInventory again (though no significant changes yet).


Modified: code/trunk/data/gui/scripts/PickupInventory.lua
===================================================================
--- code/trunk/data/gui/scripts/PickupInventory.lua	2010-05-15 16:12:13 UTC (rev 6905)
+++ code/trunk/data/gui/scripts/PickupInventory.lua	2010-05-17 11:22:26 UTC (rev 6906)
@@ -73,7 +73,7 @@
 function P.createCarrierBox(carrier, index)
 
     local name = "orxonox/PickupInventory/Carrier" .. index
-        
+    
     --Design parameters:
     local imageHeight = 50
     local textHeight = 30
@@ -86,13 +86,6 @@
     box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, 0)))
     box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -horizontalOffset), CEGUI.UDim(1, 0)))
     
-    offset = offset+textHeight
-    local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
-    title:setText(carrier:getCarrierName())
-    title:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, offset)))
-    title:setProperty("FrameEnabled", "set:False")
-    box:addChildWindow(title)
-    
     local numPickups = orxonox.PickupManager:getInstance():getNumPickups(carrier)
     for i=0,numPickups-1,1 do
         local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(i, carrier)

Modified: code/trunk/src/modules/objects/ObjectsPrereqs.h
===================================================================
--- code/trunk/src/modules/objects/ObjectsPrereqs.h	2010-05-15 16:12:13 UTC (rev 6905)
+++ code/trunk/src/modules/objects/ObjectsPrereqs.h	2010-05-17 11:22:26 UTC (rev 6906)
@@ -86,6 +86,7 @@
     class CheckPoint;
     class DistanceMultiTrigger;
     class DistanceTrigger;
+    class DistanceTriggerBeacon;
     class EventMultiTrigger;
     class EventTrigger;
     class MultiTrigger;

Modified: code/trunk/src/modules/objects/triggers/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/objects/triggers/CMakeLists.txt	2010-05-15 16:12:13 UTC (rev 6905)
+++ code/trunk/src/modules/objects/triggers/CMakeLists.txt	2010-05-17 11:22:26 UTC (rev 6906)
@@ -2,6 +2,7 @@
   CheckPoint.cc
   DistanceMultiTrigger.cc
   DistanceTrigger.cc
+  DistanceTriggerBeacon.cc
   EventMultiTrigger.cc
   EventTrigger.cc
   MultiTrigger.cc

Modified: code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc	2010-05-15 16:12:13 UTC (rev 6905)
+++ code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc	2010-05-17 11:22:26 UTC (rev 6906)
@@ -35,6 +35,7 @@
 
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
+#include "DistanceTriggerBeacon.h"
 
 namespace orxonox
 {
@@ -50,6 +51,8 @@
         RegisterObject(DistanceMultiTrigger);
         
         this->distance_ = 100.0f;
+        this->targetName_ = BLANKSTRING;
+        this->singleTargetMode_ = false;
     }
 
     /**
@@ -69,6 +72,7 @@
         SUPER(DistanceMultiTrigger, XMLPort, xmlelement, mode);
 
         XMLPortParam(DistanceMultiTrigger, "distance", setDistance, getDistance, xmlelement, mode);
+        XMLPortParam(DistanceMultiTrigger, "targetname", setTargetName, getTargetName, xmlelement, mode);
     }
 
     /**
@@ -127,6 +131,17 @@
             if (entity == NULL) //If the object is no WorldEntity or is already in range.
                 continue;
 
+            // If the DistanceMultiTrigger is in single-target-mode.
+            if(this->singleTargetMode_)
+            {
+                // If the object that is a target is no DistanceTriggerBeacon, then the DistanceMultiTrigger can't be in single-target-mode.
+                if(!(*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()))
+                    this->singleTargetMode_ = false;
+                // If the target name and the name of the DistancTriggreBeacon don't match.
+                else if(entity->getName().compare(this->targetName_) != 0)
+                    continue;
+            }
+
             Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
             // If the object is in range.
             if (distanceVec.length() <= this->distance_)
@@ -135,6 +150,10 @@
                 if(!this->addToRange(entity))
                     continue;
 
+                // Change the entity to the parent of the DistanceTriggerBeacon (if in single-target-mode), which is the entity to which the beacon is attached.
+                if(this->singleTargetMode_)
+                    entity = entity->getParent();
+                
                 // If no queue has been created, yet.
                 if(queue == NULL)
                     queue = new std::queue<MultiTriggerState*>();

Modified: code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h	2010-05-15 16:12:13 UTC (rev 6905)
+++ code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h	2010-05-17 11:22:26 UTC (rev 6906)
@@ -47,7 +47,7 @@
 
     /**
     @brief
-        The DistanceMultiTrigger is a trigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceMultiTrigger.
+        The DistanceMultiTrigger is a trigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceMultiTrigger. The object can be specified further by adding a DistanceTriggerBeacon (just attaching it) to the objects that can trigger this DistanceMultiTrigger and specify the name of the DistanceTriggerBeacon with the parameter targetname and only objects that hav a DistanceTriggerBeacon with that name attached will trigger the DistanceMultiTrigger.
     @see MultiTrigger.h
         For more information on MultiTriggers.
     @author
@@ -63,6 +63,19 @@
             void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML.
 
             /**
+            @brief Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger.
+            @param targename The name of the DistanceTriggerBeacon as a string.
+            */
+            inline void setTargetName(const std::string& targetname)
+                { if(targetname.compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
+            /**
+            @brief Get the target name of the DistanceTriggerbeacon, that triggers this DistanceMultiTrigger.
+            @return Returns the target name as a string.
+            */
+            inline const std::string& getTargetName(void)
+                { return this->targetName_; }
+            
+            /**
             @brief Set the distance at which the DistanceMultiTrigger triggers.
             @param distance The distance.
             */
@@ -95,6 +108,9 @@
                 
         private:
             float distance_; //!< The distance at which the DistanceMultiTrigger triggers.
+            std::string targetName_; //!< The target name, used in singleTargetMode.
+            bool singleTargetMode_; //!< To indicate whe the MultiDistanceTrigger is in single-target-mode.
+            
             std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
         
     };

Modified: code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTrigger.cc	2010-05-15 16:12:13 UTC (rev 6905)
+++ code/trunk/src/modules/objects/triggers/DistanceTrigger.cc	2010-05-17 11:22:26 UTC (rev 6906)
@@ -31,6 +31,7 @@
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "worldentities/pawns/Pawn.h"
+#include "DistanceTriggerBeacon.h"
 
 namespace orxonox
 {
@@ -42,6 +43,8 @@
 
     this->distance_ = 100;
     this->targetMask_.exclude(Class(BaseObject));
+    this->targetName_ = BLANKSTRING;
+    this->singleTargetMode_ = false;
     this->setForPlayer(false); //!< Normally hasn't just players as targets.
   }
 
@@ -54,7 +57,8 @@
     SUPER(DistanceTrigger, XMLPort, xmlelement, mode);
 
     XMLPortParam(DistanceTrigger, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(100.0f);
-    XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode).defaultValues("ControllableEntity");
+    XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode).defaultValues("Pawn");
+    XMLPortParam(DistanceTrigger, "targetname", setTargetName, getTargetName, xmlelement, mode);
   }
 
   void DistanceTrigger::addTarget(Ogre::Node* targetNode)
@@ -83,8 +87,9 @@
     Identifier* targetId = ClassByString(targets);
 
     //! Checks whether the target is (or is derived from) a ControllableEntity.
-    Identifier* controllableEntityId = Class(ControllableEntity);
-    if(targetId->isA(controllableEntityId))
+    Identifier* pawnId = Class(Pawn);
+    Identifier* distanceTriggerBeaconId = Class(DistanceTriggerBeacon);
+    if(targetId->isA(pawnId) || targetId->isA(distanceTriggerBeaconId))
     {
       this->setForPlayer(true);
     }
@@ -123,6 +128,14 @@
       if (!entity)
         continue;
 
+      if(this->singleTargetMode_)
+      {
+        if(!(*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()))
+          this->singleTargetMode_ = false;
+        else if(entity->getName().compare(this->targetName_) != 0)
+          continue;
+      }
+      
       Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
       if (distanceVec.length() < this->distance_)
       {
@@ -130,6 +143,10 @@
         // If the target is a player (resp. is a, or is derived from a, ControllableEntity) the triggeringPlayer is set to the target entity.
         if(this->isForPlayer())
         {
+
+          if(this->singleTargetMode_)
+            entity = entity->getParent();
+
           Pawn* player = orxonox_cast<Pawn*>(entity);
           this->setTriggeringPlayer(player);
         }

Modified: code/trunk/src/modules/objects/triggers/DistanceTrigger.h
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTrigger.h	2010-05-15 16:12:13 UTC (rev 6905)
+++ code/trunk/src/modules/objects/triggers/DistanceTrigger.h	2010-05-17 11:22:26 UTC (rev 6906)
@@ -51,6 +51,11 @@
       void removeTarget(Ogre::Node* targetNode);
       void removeTargets(const std::string& targets);
 
+      inline void setTargetName(const std::string& targetname)
+        { if(targetname.compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
+      inline const std::string& getTargetName(void)
+        { return this->targetName_; }
+
       inline void setDistance(float distance)
         { this->distance_ = distance; }
       inline float getDistance() const
@@ -66,7 +71,9 @@
 
     private:
       std::set<Ogre::Node*> targetSet_;
+      std::string targetName_;
       float distance_;
+      bool singleTargetMode_;
 
   };
 }

Added: code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.cc	                        (rev 0)
+++ code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.cc	2010-05-17 11:22:26 UTC (rev 6906)
@@ -0,0 +1,43 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+*/
+
+#include "DistanceTriggerBeacon.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+
+    CreateFactory(DistanceTriggerBeacon);
+    
+    DistanceTriggerBeacon::DistanceTriggerBeacon(BaseObject* creator) : StaticEntity(creator)
+    {
+        RegisterObject(DistanceTriggerBeacon);
+    }
+    
+}

Added: code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.h
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.h	                        (rev 0)
+++ code/trunk/src/modules/objects/triggers/DistanceTriggerBeacon.h	2010-05-17 11:22:26 UTC (rev 6906)
@@ -0,0 +1,51 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Damian 'Mozork' Frick
+ *   Co-authors:
+ *      ...
+ *
+*/
+
+#ifndef _DistanceTriggerBeacon_H__
+#define _DistanceTriggerBeacon_H__
+
+#include "objects/ObjectsPrereqs.h"
+#include "core/XMLPort.h"
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+
+    class _ObjectsExport DistanceTriggerBeacon : public StaticEntity
+    {
+        
+        public:
+
+            DistanceTriggerBeacon(BaseObject* creator);
+            ~DistanceTriggerBeacon() {}
+
+    };
+
+}
+
+#endif // _DistanceTriggerBeacon_H__

Modified: code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestEffectBeacon.cc	2010-05-15 16:12:13 UTC (rev 6905)
+++ code/trunk/src/modules/questsystem/QuestEffectBeacon.cc	2010-05-17 11:22:26 UTC (rev 6906)
@@ -98,16 +98,13 @@
     */
     bool QuestEffectBeacon::execute(bool b, BaseObject* trigger)
     {
-        //TODO: Remove debug output.
-        COUT(1) << "Debug: Calling execute on QuestEffectBeacon." << std::endl;
-        
         if(!b)
         {
             return false;
         }
         if(!(this->isActive())) //!< If the QuestEffectBeacon is inactive it cannot be executed.
         {
-            COUT(3) << "The QuestEffectBeacon is inactive." << std::endl;
+            COUT(4) << "The QuestEffectBeacon is inactive." << std::endl;
             return false;
         }
 




More information about the Orxonox-commit mailing list