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 | * Daniel 'Huty' Haggenmueller |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | @file |
---|
31 | @brief Definition of PickupSpawner. |
---|
32 | */ |
---|
33 | |
---|
34 | #ifndef _PickupSpawner_H__ |
---|
35 | #define _PickupSpawner_H__ |
---|
36 | |
---|
37 | #include "OrxonoxPrereqs.h" |
---|
38 | |
---|
39 | #include "objects/Tickable.h" |
---|
40 | #include "objects/worldentities/StaticEntity.h" |
---|
41 | #include "tools/Timer.h" |
---|
42 | |
---|
43 | namespace orxonox |
---|
44 | { |
---|
45 | /** |
---|
46 | @brief PickupSpawner. |
---|
47 | @author Daniel 'Huty' Haggenmueller |
---|
48 | */ |
---|
49 | class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable |
---|
50 | { |
---|
51 | public: |
---|
52 | PickupSpawner(BaseObject* creator); |
---|
53 | virtual ~PickupSpawner(); |
---|
54 | |
---|
55 | virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty). |
---|
56 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML. |
---|
57 | virtual void tick(float dt); |
---|
58 | |
---|
59 | void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough. |
---|
60 | void respawnTimerCallback(); //!< Method called when the timer runs out. |
---|
61 | |
---|
62 | /** |
---|
63 | @brief Get the template name for the item to spawn. |
---|
64 | @return Returns the name of the template of the item to spawn. |
---|
65 | */ |
---|
66 | inline const std::string& getItemTemplateName() const |
---|
67 | { return this->itemTemplateName_; } |
---|
68 | void setItemTemplateName(const std::string& name); //!< Set the template name of the item to spawn. |
---|
69 | |
---|
70 | /** |
---|
71 | @brief Get the template for the item to spawn. |
---|
72 | @return Returns the template of the item to spawn. |
---|
73 | */ |
---|
74 | inline Template* getItemTemplate() const |
---|
75 | { return this->itemTemplate_; } |
---|
76 | |
---|
77 | /** |
---|
78 | @brief Get the distance in which to trigger. |
---|
79 | @return Returns the distance in which this gets triggered. |
---|
80 | */ |
---|
81 | inline float getTriggerDistance() const |
---|
82 | { return this->triggerDistance_; } |
---|
83 | /** |
---|
84 | @brief Set the distance in which to trigger. |
---|
85 | @param value The new distance in which to trigger. |
---|
86 | */ |
---|
87 | inline void setTriggerDistance(float value) |
---|
88 | { this->triggerDistance_ = value; } |
---|
89 | |
---|
90 | /** |
---|
91 | @brief Get the time to respawn. |
---|
92 | @returns Returns the time after which this gets re-actived. |
---|
93 | */ |
---|
94 | inline float getRespawnTime() const |
---|
95 | { return this->respawnTime_; } |
---|
96 | /** |
---|
97 | @brief Set the time to respawn. |
---|
98 | @param time New time after which this gets re-actived. |
---|
99 | */ |
---|
100 | inline void setRespawnTime(float time) |
---|
101 | { this->respawnTime_ = time; } |
---|
102 | private: |
---|
103 | std::string itemTemplateName_; //!< Template name of the item to spawn. |
---|
104 | Template* itemTemplate_; //!< Template of the item to spawn. |
---|
105 | |
---|
106 | float triggerDistance_; //!< Distance in which this gets triggered. |
---|
107 | |
---|
108 | /* Pickup animation */ |
---|
109 | float tickSum_; //!< Adds up tick to use in sine movement |
---|
110 | static const float bounceSpeed_s; //!< Speed of pickup to bounce up and down |
---|
111 | static const float bounceDistance_s; //!< Distance the pickup bounces up and down |
---|
112 | static const float rotationSpeed_s; //!< Rotation speed of pickup |
---|
113 | |
---|
114 | float respawnTime_; //!< Time after which this gets re-actived. |
---|
115 | Timer<PickupSpawner> respawnTimer_; //!< Timer used for re-activating. |
---|
116 | }; |
---|
117 | } |
---|
118 | |
---|
119 | #endif /* _PickupSpawner_H__ */ |
---|