Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 23, 2008, 10:40:38 PM (16 years ago)
Author:
rgrieder
Message:

merged revisions 2260 - 2508 from trunk to buggy.
I'm sorry that I have to commit every merge. But otherwise I get tons of conflicts I have to solve ten times over.
Note: did not merge deletion of src/util/testing, tortoise wasn't very friendly with that.

Location:
code/branches/bugger
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/bugger

  • code/branches/bugger/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    r2171 r2530  
    3535#include "core/XMLPort.h"
    3636
     37#include "orxonox/objects/worldentities/ControllableEntity.h"
     38
    3739namespace orxonox
    3840{
    3941  CreateFactory(DistanceTrigger);
    4042
    41   DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator)
     43  DistanceTrigger::DistanceTrigger(BaseObject* creator) : PlayerTrigger(creator)
    4244  {
    4345    RegisterObject(DistanceTrigger);
     
    4547    this->distance_ = 100;
    4648    this->targetMask_.exclude(Class(BaseObject));
     49    this->setForPlayer(false); //!< Normally hasn't just ControllableEntities as targets.
    4750  }
    4851
     
    8386  {
    8487    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))
     92    {
     93      this->setForPlayer(true);
     94    }
     95   
    8596    if (!targetId)
    8697    {
     
    117128      Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition();
    118129      if (distanceVec.length() < this->distance_)
     130      {
     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.
     133        if(this->isForPlayer())
     134        {
     135          ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity);
     136          this->setTriggeringPlayer(player);
     137        }
     138       
    119139        return true;
     140      }
    120141    }
    121142    return false;
    122 
    123143  }
    124144
     
    126146  {
    127147    if (Trigger::isTriggered(mode))
     148    {
    128149      return checkDistance();
     150    }
    129151    else
    130152      return false;
Note: See TracChangeset for help on using the changeset viewer.