Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 19, 2008, 11:50:03 AM (16 years ago)
Author:
dafrick
Message:

Some tweaks and solved some bugs…

Location:
code/branches/questsystem2/src/orxonox/objects/worldentities/triggers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    r2209 r2221  
    3535#include "core/XMLPort.h"
    3636
     37#include "orxonox/objects/worldentities/ControllableEntity.h"
     38
    3739namespace orxonox
    3840{
     
    4547    this->distance_ = 100;
    4648    this->targetMask_.exclude(Class(BaseObject));
    47     this->setForPlayer(false);
     49    this->setForPlayer(false); //!< Normally hasn't just ControllableEntities as targets.
    4850  }
    4951
     
    8385  void DistanceTrigger::addTargets(const std::string& targets)
    8486  {
    85  
    86     if(targets == "ControllableEntity")
     87    Identifier* targetId = ClassByString(targets);
     88   
     89    //! Checks whether the target is (or is derived from) a ControllableEntity.
     90    Identifier* controllableEntityId = Class(ControllableEntity);
     91    if(targetId->isA(controllableEntityId))
    8792    {
    88         this->setForPlayer(true);
     93      this->setForPlayer(true);
    8994    }
    90  
    91     Identifier* targetId = ClassByString(targets);
     95   
    9296    if (!targetId)
    9397    {
     
    125129      if (distanceVec.length() < this->distance_)
    126130      {
     131       
     132        //! If the target is a player (resp. is a, or is derived from a, ControllableEntity) the triggeringPlayer is set to the target entity.
    127133        if(this->isForPlayer())
    128134        {
    129             ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity);
    130             this->setTriggeringPlayer(player);
     135          ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity);
     136          this->setTriggeringPlayer(player);
    131137        }
    132138       
  • code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/PlayerTrigger.cc

    r2196 r2221  
    2727 */
    2828
     29/**
     30    @file PlayerTrigger.cc
     31    @brief
     32        Implementation of the PlayerTrigger class.
     33*/
     34
     35#include "OrxonoxStableHeaders.h"
     36#include "PlayerTrigger.h"
     37
    2938#include "core/CoreIncludes.h"
    30 
    31 #include "PlayerTrigger.h"
    3239
    3340namespace orxonox {
    3441
     42    /**
     43    @brief
     44        Constructor. Registers the object and initializes defaults.
     45    */
    3546    PlayerTrigger::PlayerTrigger(BaseObject* creator) : Trigger(creator)
    3647    {
     
    4152    }
    4253   
    43    
     54    /**
     55    @brief
     56        Destructor.
     57    */
    4458    PlayerTrigger::~PlayerTrigger()
    4559    {
    4660    }
    4761
     62    /**
     63    @brief
     64        Method for creating a QuestEffectBeacon object through XML.
     65    */
    4866    void PlayerTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    4967    {
  • code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h

    r2196 r2221  
    2626 *
    2727 */
    28  
     28
     29/**
     30    @file PlayerTrigger.h
     31    @brief
     32        Definition of the PlayerTrigger class.
     33*/
     34
    2935#ifndef _PlayerTrigger_H__
    3036#define _PlayerTrigger_H__
     37
     38#include "OrxonoxPrereqs.h"
    3139
    3240#include "Trigger.h"
     
    3644    /**
    3745    @brief
    38        
     46        A PlayerTrigger is a trigger which is normally triggered by ControllableEntities and can as such return a pointer to the ControllableEntity which triggered it.
    3947    @author
    4048        Damian 'Mozork' Frick
     
    4654            virtual ~PlayerTrigger();
    4755           
    48             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     56            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PlayerTrigger object through XML.
    4957           
     58            /**
     59            @brief Returns the player that triggered the PlayerTrigger.
     60            @return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger.
     61            */
    5062            inline ControllableEntity* getTriggeringPlayer(void) const
    5163                { return this->player_; }
     64           
     65            /**
     66            @brief Checks whether the PlayerTrigger normally returns a ControllableEntity.
     67            @return Returns true if the PlayerTrigger normally returns a ControllableEntity.
     68            */
     69            inline bool isForPlayer(void) const
     70               { return this->isForPlayer_; }
    5271           
    5372        protected:
    5473            virtual bool isTriggered(TriggerMode mode) = 0;
    5574           
     75            /**
     76            @brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger.
     77            @param player A pointer to the ControllableEntity that triggered the PlayerTrigger.
     78            */
    5679            inline void setTriggeringPlayer(ControllableEntity* player)
    5780               { this->player_ = player; }
    58             inline bool isForPlayer(void) const
    59                { return this->isForPlayer_; }
     81
     82            /**
     83            @brief Set whether the PlayerTrigger normally is triggered by ControllableEntities.
     84            @param isForPlayer Should be true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities, false if not.
     85            */
    6086            inline void setForPlayer(bool isForPlayer)
    6187               { this->isForPlayer_ = isForPlayer; }
    6288           
    6389        private:
    64             ControllableEntity* player_;
    65             bool isForPlayer_;
     90            ControllableEntity* player_; //!< The player that triggered the PlayerTrigger.
     91            bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities.
    6692       
    6793    };
Note: See TracChangeset for help on using the changeset viewer.