Changeset 7540
- Timestamp:
- Oct 14, 2010, 11:20:16 AM (14 years ago)
- Location:
- code/trunk/src/modules/pickup
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/PickupManager.h
r7533 r7540 164 164 PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation. 165 165 166 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking @ref oroxnox::PickupIdentifier "PickupIdentifiers" (representing types of @ref orxonox::Pickupable "Pickupables") and @ref orxonox::PickupRepresentation "PickupRepresentations".167 std::map<uint32_t, PickupRepresentation*> representationsNetworked_; //!< Map linking the @ref orxonox::PickupRepresentation "PickupRepresentation's" objectId to the @ref orxonox::PickupRepresentation "PickupRepresentation"itself. It is used for networking purposes.166 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types of Pickupables) and PickupRepresentations. 167 std::map<uint32_t, PickupRepresentation*> representationsNetworked_; //!< Map linking the PickupRepresentation's objectId to the PickupRepresentation itself. It is used for networking purposes. 168 168 169 std::map<uint32_t, PickupInventoryContainer*> pickupInventoryContainers_; //!< Map linking a number identifying a @ref orxonox::Pickupable "Pickupable" to a @ref orxonox::PickupInventoryContainer "PickupInventoryContainer", which contains all necessary information about that @ref orxonox::Pickupable "Pickupable".169 std::map<uint32_t, PickupInventoryContainer*> pickupInventoryContainers_; //!< Map linking a number identifying a Pickupable to a PickupInventoryContainer, which contains all necessary information about that Pickupable. 170 170 std::map<uint32_t, PickupInventoryContainer*>::iterator pickupsIterator_; //!< An iterator pointing to the current Pickupable in pickupsList_. 171 171 172 std::map<uint32_t, WeakPtr<Pickupable>*> pickups_; //!< Map linking a number identifying a @ref orxonox::Pickupable "Pickupable" to a weak pointer of a @ref orxonox::Pickupable "Pickupable".173 std::map<Pickupable*, uint32_t> indexes_;//!< Map linking @ref orxonox::Pickupable "Pickupable"to the number identifying it.172 std::map<uint32_t, WeakPtr<Pickupable>*> pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable. 173 std::map<Pickupable*, uint32_t> indexes_;//!< Map linking Pickupable to the number identifying it. 174 174 175 175 void updateGUI(void); //!< Updates the PickupInventory GUI. -
code/trunk/src/modules/pickup/PickupRepresentation.cc
r7533 r7540 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/GameMode.h" 38 #include "util/StringUtils.h" 39 38 40 #include "graphics/Billboard.h" 39 #include "util/StringUtils.h" 41 40 42 #include "PickupManager.h" 41 43 … … 55 57 56 58 this->initialize(); 57 this->setSyncMode(0x0); 59 this->setSyncMode(0x0); // The default PickupRperesentation created by each PickupManager is not synchronised, since it only exists locally. 58 60 } 59 61 … … 69 71 this->registerVariables(); 70 72 71 PickupManager::getInstance().registerRepresentation(this); // !<Registers the PickupRepresentation with the PickupManager.73 PickupManager::getInstance().registerRepresentation(this); // Registers the PickupRepresentation with the PickupManager. 72 74 } 73 75 … … 107 109 } 108 110 111 /** 112 @brief 113 Registers the variables that need to be synchornised. 114 */ 109 115 void PickupRepresentation::registerVariables(void) 110 116 { … … 131 137 if(GameMode::isMaster()) 132 138 { 133 PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents. 139 // Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents. 140 PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); 134 141 } 135 142 … … 156 163 { 157 164 COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl; 158 // !<If neither spawnerRepresentation nor spawnerTemplate was specified165 // If neither spawnerRepresentation nor spawnerTemplate was specified 159 166 return this->getDefaultSpawnerRepresentation(spawner); 160 167 } … … 180 187 Returns a pointer to the StaticEntity. 181 188 */ 182 //TODO: Possibility to define default representation through XML .189 //TODO: Possibility to define default representation through XML? 183 190 StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner) 184 191 { -
code/trunk/src/modules/pickup/PickupRepresentation.h
r7539 r7540 42 42 #include "pickup/PickupIdentifier.h" 43 43 #include "worldentities/StaticEntity.h" 44 44 45 #include "PickupSpawner.h" 45 46 … … 52 53 /** 53 54 @brief 54 The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like. 55 They are created through XML and are registered with the PickupManager. 55 The PickupRepresentation class represents a specific pickup type (identified by its @ref orxonox::PickupIdentififer "PickupIdentifier"). It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like. 56 They are created through XML and are registered with the @ref orxonox::PickupManager "PickupManager". 57 58 Creating a PickupRepresentation in XML could look as follows: 59 @code 60 <PickupRepresentation 61 name = "My awesome Pickup" 62 description = "This is the most awesome Pickup ever to exist." 63 spawnerTemplate = "awesomePickupRepresentation" 64 inventoryRepresentation = "AwesomePickup" 65 > 66 <pickup> 67 <SomePickup /> 68 </pickup> 69 </PickupRepresentation> 70 @endcode 71 As you might have noticed, there is a parameter called <em>spawnerTemplate</em> and also another parameter called <em>inventoryRepresentation</em>. Let's first explain the second one, <em>inventoryRepresentation</em>. 72 - The <b>inventoryRepresentation</b> specifies the image that is displayed in the PickupInventory for the specific type of @ref orxonox::Pickupable "Pickupable". More technically, it is the name of an image located in the <code>PickupInventory.imageset</code>, which in turn is located in <code>data_extern/gui/imagesets/</code>. 73 - The <b>spawnerTemplate</b> specifies how the type of @ref orxonox::Pickupable "Pickupable" (or more precisely the @ref orxonox::PickupSpawner "PickupSpawner", that spawns that type of @ref orxonox::Pickupable "Pickupable") is displayed ingame. It is a @ref orxnox::Template "Template" defined in XML. The <em>spawnerTemplate</em> can be specified as follows (keep in mind, that the template needs to have been specified before the definition of the PickupRepresentation that uses it). 74 @code 75 <Template name="awesomePickupRepresentation"> 76 <PickupRepresentation> 77 <spawner-representation> 78 <StaticEntity> 79 <attached> 80 <!-- Here you can put all the objects which define the look of the spawner. --> 81 </attached> 82 </StaticEntity> 83 </spawner-representation> 84 </PickupRepresentation> 85 </Template> 86 @endcode 87 88 For the purpose of them working over the network, they are synchronised. 56 89 57 90 @author … … 69 102 virtual ~PickupRepresentation(); //!< Destructor. 70 103 71 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 104 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupRepresentation object through XML. 72 105 73 106 /** … … 152 185 StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner. 153 186 154 void registerVariables(void); //!< Register some variables for synchronisation.187 void registerVariables(void); //!< Registers the variables that need to be synchronised. 155 188 156 189 std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation. -
code/trunk/src/modules/pickup/PickupSpawner.cc
r7493 r7540 106 106 { 107 107 this->triggerDistance_ = 10; 108 this->respawnTime_ = 0; 108 this->respawnTime_ = 0; //TODO: Smart? Shouldn't we have a better mechanism to prevent unwanted multiple pickups? 109 109 this->maxSpawnedItems_ = INF; 110 110 this->spawnsRemaining_ = INF; -
code/trunk/src/modules/pickup/PickupSpawner.h
r7494 r7540 39 39 40 40 #include <string> 41 42 #include "tools/Timer.h" 43 41 44 #include "interfaces/Pickupable.h" 42 #include "tools/Timer.h"43 45 44 46 #include "tools/interfaces/Tickable.h" … … 49 51 /** 50 52 @brief 51 The PickupSpawner class is responsible for spawning pickups of a specific type. 52 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. 53 The PickupSpawner class is responsible for spawning @ref orxonox::Pickupable "Pickupables" of a specific type. 54 Furthermore it can be specified how long the time interval between spawning two items is and how many @ref orxonox::Pickupable "Pickupables" are spawned at maximum, amongst other things. The parameters that can be used to further specify the behaviour of the PickupSpawner are: 55 - The <b>triggerDistance</b> can be used to specify how far away an entity has to be to still trigger the PickupSPawner (and thus receive a @ref orxonox::Pickupable "Pickupable" form it). The default is 10. 56 - The <b>respawnTime</b> is the time in seconds that passes until the PickupSpawner is enabled again, after having spawned a @ref orxonox::Pickupable "Pickupable". The default is 0. 57 - The <b>maxSpawnedItems</b> is the number of @ref orxonox::Pickupable "Pickupables" that are spawned by this PickupSpawner at the most. The default is -1, which denotes infinity. 58 59 A PickupSpawner is created in XML, which can be done in the following fashion: 60 @code 61 <PickupSpawner position="-100,0,-100" respawnTime="30" maxSpawnedItems="10"> 62 <pickup> 63 <SomePickup > 64 </pickup> 65 </PickupSpawner> 66 @endcode 67 As we can see, since the PickupSpawner is a StaticEntity, it also has spatial coordinates. We can also see, that the type of @ref orxonox::Pickupable "Pickupable" which is spawned hast to be specified as well. 53 68 54 69 @author … … 56 71 @author 57 72 Damian 'Mozork' Frick 73 74 @ingroup Pickup 58 75 */ 59 76 class _PickupExport PickupSpawner : public StaticEntity, public Tickable … … 66 83 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML. 67 84 virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty). 68 virtual void tick(float dt); 85 virtual void tick(float dt); //!< Tick, checks if any Pawn is close enough to trigger. 69 86 70 87 /**
Note: See TracChangeset
for help on using the changeset viewer.