Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 12, 2008, 3:32:33 PM (16 years ago)
Author:
dafrick
Message:

Even more trigger stuff. Sorry for the spam…

Location:
code/branches/questsystem2/src/orxonox/objects
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem2/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r2195 r2196  
    6363        XMLPortParam(QuestEffectBeacon, "times", setTimes, getTimes, xmlelement, mode);
    6464        XMLPortObject(QuestEffectBeacon, QuestEffect, "", addEffect, getEffect, xmlelement, mode);
    65         XMLPortObject(QuestEffectBeacon, Trigger, "", addTrigger, getTrigger, xmlelement, mode);
     65        XMLPortObject(QuestEffectBeacon, PlayerTrigger, "", addTrigger, getTrigger, xmlelement, mode);
    6666    }
    6767   
     
    187187    }
    188188
    189     const Trigger* QuestEffectBeacon::getTrigger(unsigned int index) const
     189    const PlayerTrigger* QuestEffectBeacon::getTrigger(unsigned int index) const
    190190    {
    191191        if(index == 0)
  • code/branches/questsystem2/src/orxonox/objects/quest/QuestEffectBeacon.h

    r2195 r2196  
    8585           
    8686            const QuestEffect* getEffect(unsigned int index) const;
    87             const Trigger* getTrigger(unsigned int index) const;
     87            const PlayerTrigger* getTrigger(unsigned int index) const;
    8888   
    8989    };
  • code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    r2193 r2196  
    4545    this->distance_ = 100;
    4646    this->targetMask_.exclude(Class(BaseObject));
    47     this->player_ = NULL;
     47    this->setForPlayer(false);
    4848  }
    4949
     
    8383  void DistanceTrigger::addTargets(const std::string& targets)
    8484  {
     85 
     86    if(targets == "ControllableEntity")
     87    {
     88        this->setForPlayer(true);
     89    }
     90 
    8591    Identifier* targetId = ClassByString(targets);
    8692    if (!targetId)
     
    119125      if (distanceVec.length() < this->distance_)
    120126      {
    121         this->player_ = dynamic_cast<ControllableEntity*>(entity);
     127        if(this->isForPlayer())
     128        {
     129            ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity);
     130            this->setTriggeringPlayer(player);
     131        }
     132       
    122133        return true;
    123134      }
    124135    }
    125136    return false;
    126 
    127   }
    128  
    129   ControllableEntity* DistanceTrigger::getTriggeringPlayer(void) const
    130   {
    131     return this->player_;
    132137  }
    133138
  • code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

    r2193 r2196  
    5858      inline float getDistance() const
    5959        { return this->distance_; }
    60        
    61         virtual ControllableEntity* getTriggeringPlayer(void) const;
    6260
    6361      bool checkDistance();
     
    7169      float distance_;
    7270     
    73       ControllableEntity* player_;
    74      
    7571  };
    7672}
  • code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/PlayerTrigger.cc

    r2194 r2196  
    3636    {
    3737        RegisterObject(PlayerTrigger);
     38       
     39        this->player_ = NULL;
     40        this->isForPlayer_ = true;
    3841    }
    3942   
  • code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h

    r2194 r2196  
    4848            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4949           
    50             virtual ControllableEntity* getTriggeringPlayer(void) const = 0;
     50            inline ControllableEntity* getTriggeringPlayer(void) const
     51                { return this->player_; }
    5152           
    5253        protected:
    5354            virtual bool isTriggered(TriggerMode mode) = 0;
     55           
     56            inline void setTriggeringPlayer(ControllableEntity* player)
     57               { this->player_ = player; }
     58            inline bool isForPlayer(void) const
     59               { return this->isForPlayer_; }
     60            inline void setForPlayer(bool isForPlayer)
     61               { this->isForPlayer_ = isForPlayer; }
     62           
     63        private:
     64            ControllableEntity* player_;
     65            bool isForPlayer_;
    5466       
    5567    };
Note: See TracChangeset for help on using the changeset viewer.