Changeset 6475 for code/branches/pickup3/src/modules/pickup/PickupSpawner.h
- Timestamp:
- Mar 5, 2010, 6:26:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup3/src/modules/pickup/PickupSpawner.h
r6466 r6475 23 23 * Daniel 'Huty' Haggenmueller 24 24 * Co-authors: 25 * ...25 * Damian 'Mozork' Frick 26 26 * 27 27 */ … … 38 38 39 39 #include <string> 40 #include "interfaces/Pickupable.h" 40 41 #include "tools/Timer.h" 42 41 43 #include "tools/interfaces/Tickable.h" 42 44 #include "worldentities/StaticEntity.h" 43 #include "interfaces/Pickupable.h"44 45 45 46 namespace orxonox 46 47 { 47 48 /** 48 @brief PickupSpawner. 49 @author Daniel 'Huty' Haggenmueller 49 @brief 50 The PickupSpawner class is responsible for spawning pickups of a specific type. 51 Forthermore it can be specified how long the time interval between spawning two items is and how many pickups are spawned at maximum, amongst other things. 52 @author 53 Daniel 'Huty' Haggenmueller 54 Damian 'Mozork' Frick 50 55 */ 51 56 class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable 52 57 { 53 58 public: 54 //TODO: Add limit of items spawned here. 55 PickupSpawner(BaseObject* creator); 56 PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); 57 virtual ~PickupSpawner(); 59 PickupSpawner(BaseObject* creator); //!< Default Constructor. 60 PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); //!< Constructor. 61 virtual ~PickupSpawner(); //!< Destructor. 58 62 59 //virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).60 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML. 64 virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty). 61 65 virtual void tick(float dt); 62 66 63 67 /** 64 65 68 @brief Get the distance in which to trigger. 69 @return Returns the distance in which this gets triggered. 66 70 */ 67 71 inline float getTriggerDistance() const 68 72 { return this->triggerDistance_; } 69 73 /** 70 71 74 @brief Set the distance in which to trigger. 75 @param value The new distance in which to trigger. 72 76 */ 73 77 inline void setTriggerDistance(float value) … … 75 79 76 80 /** 77 78 81 @brief Get the time to respawn. 82 @returns Returns the time after which this gets re-actived. 79 83 */ 80 84 inline float getRespawnTime() const 81 85 { return this->respawnTime_; } 82 86 /** 83 84 87 @brief Set the time to respawn. 88 @param time New time after which this gets re-actived. 85 89 */ 86 90 inline void setRespawnTime(float time) … … 88 92 89 93 /** 90 91 94 @brief Get the maximum number of items that will be spawned by this PickupSpawner. 95 @return Returns the maximum number of items spawned by this PickupSpawner. 92 96 */ 93 97 inline int getMaxSpawnedItems(void) 94 98 { return this->maxSpawnedItems_; } 95 void setMaxSpawnedItems(int items); 99 void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items. 96 100 97 101 protected: 98 v irtual Pickupable* getPickup(void);102 void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns. 99 103 100 void setPickupable(Pickupable* pickup); 101 const Pickupable* getPickupable(void); 104 virtual Pickupable* getPickup(void); //!< Creates a new Pickupable. 102 105 103 void decrementSpawnsRemaining(void); 106 void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn. 107 const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner. 104 108 105 109 Pickupable* pickup_; //!< The pickup to be spawned. … … 108 112 void initialize(void); 109 113 110 void trigger(Pawn* pawn); 111 void respawnTimerCallback(); 114 void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough. 115 void respawnTimerCallback(); //!< Method called when the timer runs out. 112 116 113 int maxSpawnedItems_; 114 int spawnsRemaining_; 117 int maxSpawnedItems_; //!< Maximum number of items spawned by this PickupSpawner. 118 int spawnsRemaining_; //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs. 115 119 116 float triggerDistance_; 120 float triggerDistance_; //!< Distance in which this gets triggered. 117 121 118 /* Pickup animation */ 119 float tickSum_; //!< Adds up tick to use in sine movement 120 static const float bounceSpeed_s; //!< Speed of pickup to bounce up and down 121 static const float bounceDistance_s; //!< Distance the pickup bounces up and down 122 static const float rotationSpeed_s; //!< Rotation speed of pickup 122 float respawnTime_; //!< Time after which this gets re-actived. 123 Timer respawnTimer_; //!< Timer used for re-activating. 123 124 124 float respawnTime_; //!< Time after which this gets re-actived. 125 Timer respawnTimer_; //!< Timer used for re-activating. 126 127 static const int INF = -1; //!< Constant for infinity. 125 static const int INF = -1; //!< Constant for infinity. 128 126 }; 129 127 }
Note: See TracChangeset
for help on using the changeset viewer.