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