Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/dockingsystem2/src/modules/objects/triggers/DistanceTrigger.h @ 8474

Last change on this file since 8474 was 8206, checked in by dafrick, 14 years ago

Extending DistanceTrigger (both the normal and the MultiTrigger version). DistanceTriggerBeacons, can now also be used to exclude specific objects from triggering a DistanceTrigger.
Beware: The syntax for the DistanceTrigger, used with a DistanceTriggerBeacon has changed.
It was: <DistanceTrigger target="DistanceTriggerBeacon" targetname="someBeacon" />
And is now: <DistanceTrigger target="WhateverTargetYouWantYourTriggerToReactTo" beaconMode="identify" targetname="someBeacon" />
Consult the documentation in DistanceMultiTrigger for it's specific usage, the DistanceTrigger works analogously.

  • Property svn:eol-style set to native
File size: 3.6 KB
RevLine 
[1693]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Benjamin Knecht
24 *   Co-authors:
[7301]25 *      Damian 'Mozork' Frick
[1693]26 *
27 */
28
[7601]29/**
30    @file DistanceTrigger.h
31    @brief Definition of the DistanceTrigger class.
32    @ingroup NormalTrigger
33*/
34
[1693]35#ifndef _DistanceTrigger_H__
36#define _DistanceTrigger_H__
37
[5730]38#include "objects/ObjectsPrereqs.h"
[1693]39
40#include <set>
41#include "core/ClassTreeMask.h"
[5727]42#include "Trigger.h"
43#include "interfaces/PlayerTrigger.h"
[1693]44
[2071]45namespace orxonox
46{
[8206]47   
48  /**
49  @brief
50      Enum for the beacon mode of the DistanceTrigger.
51     
52  @ingroup NormalTrigger
53  */
54  namespace distanceTriggerBeaconMode
55  {
56      enum Value {
57          off,
58          identify,
59          exclude
60      };
61  }
[7601]62
63  /**
64  @brief
65
66  @author
67    Benjamin Knecht
68  @author
69    Damian 'Mozork' Frick
70
71  @ingroup NormalTrigger
72  */
[5730]73  class _ObjectsExport DistanceTrigger : public Trigger, public PlayerTrigger
[1693]74  {
75    public:
[2019]76      DistanceTrigger(BaseObject* creator);
[2071]77      virtual ~DistanceTrigger();
[2029]78
79      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
80
[1693]81      void addTarget(Ogre::Node* targetNode);
[2029]82      void addTargets(const std::string& targets);
[1693]83      void removeTarget(Ogre::Node* targetNode);
[1969]84      void removeTargets(const std::string& targets);
[2029]85
86      inline void setDistance(float distance)
87        { this->distance_ = distance; }
88      inline float getDistance() const
89        { return this->distance_; }
[8206]90       
91      void setBeaconModeDirect(distanceTriggerBeaconMode::Value mode); //!< Set the beacon mode.
92      /**
93      @brief Get the beacon mode.
94      @return Returns the mode as an enum.
95      */
96      inline distanceTriggerBeaconMode::Value getBeaconModeDirect(void) const
97        { return this->beaconMode_; }
98      void setBeaconMode(const std::string& mode); //!< Set the beacon mode.
99      const std::string& getBeaconMode(void) const; //!< Get the beacon mode.
100           
101      inline void setTargetName(const std::string& targetname)
102        { this->targetName_ = targetname; }
103      inline const std::string& getTargetName(void)
104        { return this->targetName_; }
[2029]105
[1693]106      bool checkDistance();
107
[1851]108    protected:
[3280]109      virtual bool isTriggered(TriggerMode::Value mode);
[3033]110      virtual void notifyMaskUpdate() {}
[1851]111
[3033]112      ClassTreeMask targetMask_;
113
[1693]114    private:
[8206]115      //! Strings for the beacon modes.
116      static const std::string beaconModeOff_s;
117      static const std::string beaconModeIdentify_s;
118      static const std::string beaconModeExlcude_s;
119           
[1693]120      std::set<Ogre::Node*> targetSet_;
[8206]121     
122      distanceTriggerBeaconMode::Value beaconMode_;
[6906]123      std::string targetName_;
[8206]124      ClassTreeMask* beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
125     
[1693]126      float distance_;
[5727]127
[1693]128  };
129}
130
[2071]131#endif /* _DistanceTrigger_H__ */
Note: See TracBrowser for help on using the repository browser.