Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6906 for code/trunk


Ignore:
Timestamp:
May 17, 2010, 1:22:26 PM (14 years ago)
Author:
dafrick
Message:

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).

Location:
code/trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/gui/scripts/PickupInventory.lua

    r6750 r6906  
    7474
    7575    local name = "orxonox/PickupInventory/Carrier" .. index
    76        
     76   
    7777    --Design parameters:
    7878    local imageHeight = 50
     
    8686    box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, 0)))
    8787    box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -horizontalOffset), CEGUI.UDim(1, 0)))
    88    
    89     offset = offset+textHeight
    90     local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
    91     title:setText(carrier:getCarrierName())
    92     title:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, offset)))
    93     title:setProperty("FrameEnabled", "set:False")
    94     box:addChildWindow(title)
    9588   
    9689    local numPickups = orxonox.PickupManager:getInstance():getNumPickups(carrier)
  • code/trunk/src/modules/objects/ObjectsPrereqs.h

    r6864 r6906  
    8787    class DistanceMultiTrigger;
    8888    class DistanceTrigger;
     89    class DistanceTriggerBeacon;
    8990    class EventMultiTrigger;
    9091    class EventTrigger;
  • code/trunk/src/modules/objects/triggers/CMakeLists.txt

    r6864 r6906  
    33  DistanceMultiTrigger.cc
    44  DistanceTrigger.cc
     5  DistanceTriggerBeacon.cc
    56  EventMultiTrigger.cc
    67  EventTrigger.cc
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc

    r6864 r6906  
    3636#include "core/CoreIncludes.h"
    3737#include "core/XMLPort.h"
     38#include "DistanceTriggerBeacon.h"
    3839
    3940namespace orxonox
     
    5152       
    5253        this->distance_ = 100.0f;
     54        this->targetName_ = BLANKSTRING;
     55        this->singleTargetMode_ = false;
    5356    }
    5457
     
    7073
    7174        XMLPortParam(DistanceMultiTrigger, "distance", setDistance, getDistance, xmlelement, mode);
     75        XMLPortParam(DistanceMultiTrigger, "targetname", setTargetName, getTargetName, xmlelement, mode);
    7276    }
    7377
     
    128132                continue;
    129133
     134            // If the DistanceMultiTrigger is in single-target-mode.
     135            if(this->singleTargetMode_)
     136            {
     137                // If the object that is a target is no DistanceTriggerBeacon, then the DistanceMultiTrigger can't be in single-target-mode.
     138                if(!(*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()))
     139                    this->singleTargetMode_ = false;
     140                // If the target name and the name of the DistancTriggreBeacon don't match.
     141                else if(entity->getName().compare(this->targetName_) != 0)
     142                    continue;
     143            }
     144
    130145            Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
    131146            // If the object is in range.
     
    136151                    continue;
    137152
     153                // Change the entity to the parent of the DistanceTriggerBeacon (if in single-target-mode), which is the entity to which the beacon is attached.
     154                if(this->singleTargetMode_)
     155                    entity = entity->getParent();
     156               
    138157                // If no queue has been created, yet.
    139158                if(queue == NULL)
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h

    r6864 r6906  
    4848    /**
    4949    @brief
    50         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.
     50        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.
    5151    @see MultiTrigger.h
    5252        For more information on MultiTriggers.
     
    6363            void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML.
    6464
     65            /**
     66            @brief Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger.
     67            @param targename The name of the DistanceTriggerBeacon as a string.
     68            */
     69            inline void setTargetName(const std::string& targetname)
     70                { if(targetname.compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
     71            /**
     72            @brief Get the target name of the DistanceTriggerbeacon, that triggers this DistanceMultiTrigger.
     73            @return Returns the target name as a string.
     74            */
     75            inline const std::string& getTargetName(void)
     76                { return this->targetName_; }
     77           
    6578            /**
    6679            @brief Set the distance at which the DistanceMultiTrigger triggers.
     
    96109        private:
    97110            float distance_; //!< The distance at which the DistanceMultiTrigger triggers.
     111            std::string targetName_; //!< The target name, used in singleTargetMode.
     112            bool singleTargetMode_; //!< To indicate whe the MultiDistanceTrigger is in single-target-mode.
     113           
    98114            std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
    99115       
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.cc

    r6417 r6906  
    3232#include "core/XMLPort.h"
    3333#include "worldentities/pawns/Pawn.h"
     34#include "DistanceTriggerBeacon.h"
    3435
    3536namespace orxonox
     
    4344    this->distance_ = 100;
    4445    this->targetMask_.exclude(Class(BaseObject));
     46    this->targetName_ = BLANKSTRING;
     47    this->singleTargetMode_ = false;
    4548    this->setForPlayer(false); //!< Normally hasn't just players as targets.
    4649  }
     
    5558
    5659    XMLPortParam(DistanceTrigger, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(100.0f);
    57     XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode).defaultValues("ControllableEntity");
     60    XMLPortParamLoadOnly(DistanceTrigger, "target", addTargets, xmlelement, mode).defaultValues("Pawn");
     61    XMLPortParam(DistanceTrigger, "targetname", setTargetName, getTargetName, xmlelement, mode);
    5862  }
    5963
     
    8488
    8589    //! Checks whether the target is (or is derived from) a ControllableEntity.
    86     Identifier* controllableEntityId = Class(ControllableEntity);
    87     if(targetId->isA(controllableEntityId))
     90    Identifier* pawnId = Class(Pawn);
     91    Identifier* distanceTriggerBeaconId = Class(DistanceTriggerBeacon);
     92    if(targetId->isA(pawnId) || targetId->isA(distanceTriggerBeaconId))
    8893    {
    8994      this->setForPlayer(true);
     
    124129        continue;
    125130
     131      if(this->singleTargetMode_)
     132      {
     133        if(!(*it)->isA(ClassIdentifier<DistanceTriggerBeacon>::getIdentifier()))
     134          this->singleTargetMode_ = false;
     135        else if(entity->getName().compare(this->targetName_) != 0)
     136          continue;
     137      }
     138     
    126139      Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
    127140      if (distanceVec.length() < this->distance_)
     
    131144        if(this->isForPlayer())
    132145        {
     146
     147          if(this->singleTargetMode_)
     148            entity = entity->getParent();
     149
    133150          Pawn* player = orxonox_cast<Pawn*>(entity);
    134151          this->setTriggeringPlayer(player);
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.h

    r5781 r6906  
    5252      void removeTargets(const std::string& targets);
    5353
     54      inline void setTargetName(const std::string& targetname)
     55        { if(targetname.compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
     56      inline const std::string& getTargetName(void)
     57        { return this->targetName_; }
     58
    5459      inline void setDistance(float distance)
    5560        { this->distance_ = distance; }
     
    6772    private:
    6873      std::set<Ogre::Node*> targetSet_;
     74      std::string targetName_;
    6975      float distance_;
     76      bool singleTargetMode_;
    7077
    7178  };
  • code/trunk/src/modules/questsystem/QuestEffectBeacon.cc

    r6859 r6906  
    9999    bool QuestEffectBeacon::execute(bool b, BaseObject* trigger)
    100100    {
    101         //TODO: Remove debug output.
    102         COUT(1) << "Debug: Calling execute on QuestEffectBeacon." << std::endl;
    103        
    104101        if(!b)
    105102        {
     
    108105        if(!(this->isActive())) //!< If the QuestEffectBeacon is inactive it cannot be executed.
    109106        {
    110             COUT(3) << "The QuestEffectBeacon is inactive." << std::endl;
     107            COUT(4) << "The QuestEffectBeacon is inactive." << std::endl;
    111108            return false;
    112109        }
Note: See TracChangeset for help on using the changeset viewer.