Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutoriallevel/src/modules/objects/triggers/DistanceTrigger.h @ 7826

Last change on this file since 7826 was 7601, checked in by dafrick, 14 years ago

Adding all classes in modules/objects to Objects module (in doxygen).
Created TriggerBase which is the base class of Trigger and MultiTrigger and now provides the shared functionality and data.
Updated some of the documentation in MultiTrigger and Script.

  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
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:
25 *      Damian 'Mozork' Frick
26 *
27 */
28
29/**
30    @file DistanceTrigger.h
31    @brief Definition of the DistanceTrigger class.
32    @ingroup NormalTrigger
33*/
34
35#ifndef _DistanceTrigger_H__
36#define _DistanceTrigger_H__
37
38#include "objects/ObjectsPrereqs.h"
39
40#include <set>
41#include "core/ClassTreeMask.h"
42#include "Trigger.h"
43#include "interfaces/PlayerTrigger.h"
44
45namespace orxonox
46{
47
48  /**
49  @brief
50
51  @author
52    Benjamin Knecht
53  @author
54    Damian 'Mozork' Frick
55
56  @ingroup NormalTrigger
57  */
58  class _ObjectsExport DistanceTrigger : public Trigger, public PlayerTrigger
59  {
60    public:
61      DistanceTrigger(BaseObject* creator);
62      virtual ~DistanceTrigger();
63
64      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
65
66      void addTarget(Ogre::Node* targetNode);
67      void addTargets(const std::string& targets);
68      void removeTarget(Ogre::Node* targetNode);
69      void removeTargets(const std::string& targets);
70
71      inline void setTargetName(const std::string& targetname)
72        { if(targetname.compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
73      inline const std::string& getTargetName(void)
74        { return this->targetName_; }
75
76      inline void setDistance(float distance)
77        { this->distance_ = distance; }
78      inline float getDistance() const
79        { return this->distance_; }
80
81      bool checkDistance();
82
83    protected:
84      virtual bool isTriggered(TriggerMode::Value mode);
85      virtual void notifyMaskUpdate() {}
86
87      ClassTreeMask targetMask_;
88
89    private:
90      std::set<Ogre::Node*> targetSet_;
91      std::string targetName_;
92      float distance_;
93      bool singleTargetMode_;
94
95  };
96}
97
98#endif /* _DistanceTrigger_H__ */
Note: See TracBrowser for help on using the repository browser.