[1383] | 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 | #ifndef _Trigger_H__ |
---|
| 30 | #define _Trigger_H__ |
---|
| 31 | |
---|
[1541] | 32 | #include <set> |
---|
[1693] | 33 | #include <queue> |
---|
[1383] | 34 | |
---|
| 35 | #include "OrxonoxPrereqs.h" |
---|
| 36 | |
---|
| 37 | #include "WorldEntity.h" |
---|
[1693] | 38 | |
---|
[1550] | 39 | #include "../tools/BillboardSet.h" |
---|
[1383] | 40 | |
---|
| 41 | namespace orxonox { |
---|
| 42 | |
---|
| 43 | enum TriggerMode |
---|
| 44 | { |
---|
[1671] | 45 | TM_EventTriggerAND, |
---|
| 46 | TM_EventTriggerOR, |
---|
| 47 | TM_EventTriggerXOR, |
---|
[1383] | 48 | }; |
---|
| 49 | |
---|
| 50 | class _OrxonoxExport Trigger : public WorldEntity |
---|
| 51 | { |
---|
| 52 | public: |
---|
| 53 | Trigger(); |
---|
| 54 | ~Trigger(); |
---|
| 55 | |
---|
[1693] | 56 | inline bool isTriggered() { return this->isTriggered(this->mode_); } |
---|
| 57 | virtual bool isTriggered(TriggerMode mode); |
---|
[1383] | 58 | void addTrigger(Trigger* trig); |
---|
[1693] | 59 | void setVisibility(bool bVisible); |
---|
| 60 | void setDelay(float delay); |
---|
| 61 | bool switchState(); |
---|
[1550] | 62 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[1383] | 63 | inline TriggerMode getMode() { return mode_; } |
---|
| 64 | inline void setMode(TriggerMode mode) { this->mode_ = mode; } |
---|
[1671] | 65 | void tick(float dt); |
---|
[1383] | 66 | |
---|
| 67 | private: |
---|
[1693] | 68 | void init(); |
---|
[1541] | 69 | bool checkAnd(); |
---|
| 70 | bool checkOr(); |
---|
[1671] | 71 | bool checkXor(); |
---|
[1693] | 72 | void setBillboardColour(ColourValue colour); |
---|
[1541] | 73 | |
---|
| 74 | private: |
---|
[1671] | 75 | std::set<Trigger*> children_; |
---|
[1693] | 76 | std::queue<std::pair<float,char> > stateChanges_; |
---|
| 77 | float remainingTime_; |
---|
| 78 | float timeSinceLastEvent_; |
---|
[1383] | 79 | TriggerMode mode_; |
---|
[1550] | 80 | bool bActive_; |
---|
[1693] | 81 | bool bInvertMode_; |
---|
| 82 | bool bTriggered_; |
---|
| 83 | bool bUpdating_; |
---|
[1550] | 84 | BillboardSet debugBillboard_; |
---|
[1693] | 85 | float delay_; |
---|
| 86 | char latestState_; |
---|
[1383] | 87 | }; |
---|
| 88 | |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | #endif /* _Trigger_H__ */ |
---|