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 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | @file Trigger.h |
---|
31 | @brief Definition of the Trigger class. |
---|
32 | @ingroup NormalTrigger |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef _Trigger_H__ |
---|
36 | #define _Trigger_H__ |
---|
37 | |
---|
38 | #include "objects/ObjectsPrereqs.h" |
---|
39 | |
---|
40 | #include <set> |
---|
41 | #include <queue> |
---|
42 | |
---|
43 | #include "tools/BillboardSet.h" |
---|
44 | |
---|
45 | #include "TriggerBase.h" |
---|
46 | |
---|
47 | namespace orxonox |
---|
48 | { |
---|
49 | |
---|
50 | /** |
---|
51 | @brief |
---|
52 | |
---|
53 | @author |
---|
54 | Benjamin Knecht |
---|
55 | |
---|
56 | @ingroup NormalTrigger |
---|
57 | */ |
---|
58 | class _ObjectsExport Trigger : public TriggerBase |
---|
59 | { |
---|
60 | public: |
---|
61 | Trigger(BaseObject* creator); |
---|
62 | virtual ~Trigger(); |
---|
63 | |
---|
64 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
65 | virtual void tick(float dt); |
---|
66 | |
---|
67 | inline bool isActive(void) const |
---|
68 | { return this->bActive_; } |
---|
69 | |
---|
70 | inline void setVisible(bool visibility) |
---|
71 | { this->debugBillboard_.setVisible(visibility); } |
---|
72 | |
---|
73 | void delayChanged(void); |
---|
74 | |
---|
75 | bool switchState(); |
---|
76 | |
---|
77 | static void debugFlares(bool bVisible); |
---|
78 | virtual void changedVisibility(); |
---|
79 | |
---|
80 | protected: |
---|
81 | inline bool isTriggered() { return this->isTriggered(this->mode_); } |
---|
82 | virtual bool isTriggered(TriggerMode::Value mode); |
---|
83 | virtual void triggered(bool bIsTriggered); |
---|
84 | |
---|
85 | private: |
---|
86 | bool checkAnd(); |
---|
87 | bool checkOr(); |
---|
88 | bool checkXor(); |
---|
89 | void setBillboardColour(const ColourValue& colour); |
---|
90 | void storeState(); |
---|
91 | |
---|
92 | bool bActive_; |
---|
93 | bool bTriggered_; |
---|
94 | |
---|
95 | char latestState_; |
---|
96 | float remainingTime_; |
---|
97 | float timeSinceLastEvent_; |
---|
98 | |
---|
99 | // bool bUpdating_; |
---|
100 | BillboardSet debugBillboard_; |
---|
101 | |
---|
102 | std::queue<std::pair<float, char> > stateChanges_; |
---|
103 | }; |
---|
104 | |
---|
105 | } |
---|
106 | |
---|
107 | #endif /* _Trigger_H__ */ |
---|