Changeset 9318
- Timestamp:
- Jul 18, 2012, 10:36:24 PM (12 years ago)
- Location:
- code/branches/presentation2012merge
- Files:
-
- 3 deleted
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/data/gui/scripts/PickupInventory.lua
r9297 r9318 108 108 109 109 function P.createPickupEntry(index, pickup) 110 local representation = orxonox.PickupManager:getInstance():get PickupRepresentation(pickup.pickup)110 local representation = orxonox.PickupManager:getInstance():getRepresentation(pickup.representationName) 111 111 112 112 local name = "orxonox/PickupInventory/Box/Pickup" .. index … … 193 193 function P.createDetailsWindow(pickupIndex) 194 194 local pickup = P.pickupsList[pickupIndex] 195 local representation = orxonox.PickupManager:getInstance():get PickupRepresentation(pickup.pickup)195 local representation = orxonox.PickupManager:getInstance():getRepresentation(pickup.representationName) 196 196 197 197 local index = P.getNewDetailNumber() -
code/branches/presentation2012merge/data/levels/includes/pickups.oxi
r9269 r9318 3 3 4 4 <PickupRepresentation 5 name = "smallshieldpickup" 5 6 pickupName = "Small Shield Pickup" 6 7 pickupDescription = "Gives you a small-sized shield for 30 seconds." 7 8 inventoryRepresentation = "SmallShield" 8 9 spawnerTemplate = "smallshieldpickupRepresentation" 9 > 10 <pickup> 11 <ShieldPickup template=smallshieldpickup /> 12 </pickup> 13 </PickupRepresentation> 14 15 <PickupRepresentation 10 /> 11 12 <PickupRepresentation 13 name = "mediumshieldpickup" 16 14 pickupName = "Medium Shield Pickup" 17 15 pickupDescription = "Gives you a medium-sized shield for 30 seconds." 18 16 inventoryRepresentation = "MediumShield" 19 17 spawnerTemplate = "mediumshieldpickupRepresentation" 20 > 21 <pickup> 22 <ShieldPickup template=mediumshieldpickup /> 23 </pickup> 24 </PickupRepresentation> 25 26 <PickupRepresentation 18 /> 19 20 <PickupRepresentation 21 name = "hugeshieldpickup" 27 22 pickupName = "Huge Shield Pickup" 28 23 pickupDescription = "Gives you a big shield for 60 seconds." 29 24 inventoryRepresentation = "HugeShield" 30 25 spawnerTemplate = "hugeshieldpickupRepresentation" 31 > 32 <pickup> 33 <ShieldPickup template=hugeshieldpickup /> 34 </pickup> 35 </PickupRepresentation> 26 /> 36 27 37 28 <!-- Health pickups --> 38 29 39 30 <PickupRepresentation 31 name = "smallhealthpickup" 40 32 pickupName = "Small Health Boost" 41 33 pickupDescription = "Adds a small amout of health to the ship." 42 34 inventoryRepresentation = "SmallHealth" 43 35 spawnerTemplate = "smallhealthpickupRepresentation" 44 > 45 <pickup> 46 <HealthPickup template=smallhealthpickup /> 47 </pickup> 48 </PickupRepresentation> 49 50 <PickupRepresentation 36 /> 37 38 <PickupRepresentation 39 name = "mediumhealthpickup" 51 40 pickupName = "Medium Health Boost" 52 41 pickupDescription = "Adds a medium amout of health to the ship." 53 42 spawnerTemplate = "mediumhealthpickupRepresentation" 54 43 inventoryRepresentation = "MediumHealth" 55 > 56 <pickup> 57 <HealthPickup template=mediumhealthpickup /> 58 </pickup> 59 </PickupRepresentation> 60 61 <PickupRepresentation 44 /> 45 46 <PickupRepresentation 47 name = "hugehealthpickup" 62 48 pickupName = "Huge Health Boost" 63 49 pickupDescription = "Adds a huge amout of health to the ship." 64 50 spawnerTemplate = "hugehealthpickupRepresentation" 65 51 inventoryRepresentation = "HugeHealth" 66 > 67 <pickup> 68 <HealthPickup template=hugehealthpickup /> 69 </pickup> 70 </PickupRepresentation> 71 72 <PickupRepresentation 52 /> 53 54 <PickupRepresentation 55 name = "crazyhealthpickup" 73 56 pickupName = "Crazy Madness Health Boost" 74 57 pickupDescription = "Adds a crazy amout of health to the ship." 75 58 spawnerTemplate = "crazyhealthpickupRepresentation" 76 59 inventoryRepresentation = "CrazyMadnessHealth" 77 > 78 <pickup> 79 <HealthPickup template=crazyhealthpickup /> 80 </pickup> 81 </PickupRepresentation> 60 /> 82 61 83 62 <!-- Meta pickups --> 84 63 85 64 <PickupRepresentation 65 name = "use" 86 66 pickupName = "Use Pickup" 87 67 pickupDescription = "Uses all pickups you have." 88 68 spawnerTemplate = "usepickupRepresentation" 89 69 inventoryRepresentation = "usePickup" 90 > 91 <pickup> 92 <MetaPickup metaType="use" /> 93 </pickup> 94 </PickupRepresentation> 95 96 <PickupRepresentation 70 /> 71 72 <PickupRepresentation 73 name = "drop" 97 74 pickupName = "Drop Pickup" 98 75 pickupDescription = "Drops all pickups you have." 99 76 spawnerTemplate = "droppickupRepresentation" 100 77 inventoryRepresentation = "dropPickup" 101 > 102 <pickup> 103 <MetaPickup metaType="drop" /> 104 </pickup> 105 </PickupRepresentation> 78 /> 106 79 107 80 <!-- Speed pickups --> 108 81 109 82 <PickupRepresentation 83 name = "smallspeedpickup" 110 84 pickupName = "Small Speed Boost" 111 85 pickupDescription = "Multiplies Speed of the Ship by a small amount." 112 86 spawnerTemplate = "smallspeedpickupRepresentation" 113 87 inventoryRepresentation = "SmallSpeed" 114 > 115 <pickup> 116 <SpeedPickup template=smallspeedpickup /> 117 </pickup> 118 </PickupRepresentation> 119 120 <PickupRepresentation 88 /> 89 90 <PickupRepresentation 91 name = "mediumspeedpickup" 121 92 pickupName = "Medium Speed Boost" 122 93 pickupDescription = "Multiplies Speed of the Ship by a bigger amount." 123 94 spawnerTemplate = "mediumspeedpickupRepresentation" 124 95 inventoryRepresentation = "MediumSpeed" 125 > 126 <pickup> 127 <SpeedPickup template=mediumspeedpickup /> 128 </pickup> 129 </PickupRepresentation> 130 131 <PickupRepresentation 96 /> 97 98 <PickupRepresentation 99 name = "hugespeedpickup" 132 100 pickupName = "Huge Speed Boost" 133 101 pickupDescription = "Multiplies Speed of the Ship by a huge amount." 134 102 spawnerTemplate = "hugespeedpickupRepresentation" 135 103 inventoryRepresentation = "HugeSpeed" 136 > 137 <pickup> 138 <SpeedPickup template=hugespeedpickup /> 139 </pickup> 140 </PickupRepresentation> 141 142 <PickupRepresentation 104 /> 105 106 <PickupRepresentation 107 name = "smalljumppickup" 143 108 pickupName = "Small Jump Boost" 144 109 pickupDescription = "Boosts the Ship with a massive amount for a very short time." 145 110 spawnerTemplate = "smalljumppickupRepresentation" 146 111 inventoryRepresentation = "SmallSpeed" 147 > 148 <pickup> 149 <SpeedPickup template=smalljumppickup /> 150 </pickup> 151 </PickupRepresentation> 112 /> 152 113 153 114 <!-- Invisible pickups --> 154 115 155 116 <PickupRepresentation 117 name = "smallinvisiblepickup" 156 118 pickupName = "Small Invisibility" 157 119 pickupDescription = "Makes you invisible for 5 seconds." 158 120 spawnerTemplate = "smallinvisiblepickupRepresentation" 159 121 inventoryRepresentation = "SmallInvisible" 160 > 161 <pickup> 162 <InvisiblePickup template=smallinvisiblepickup /> 163 </pickup> 164 </PickupRepresentation> 165 166 <PickupRepresentation 122 /> 123 124 <PickupRepresentation 125 name = "mediuminvisiblepickup" 167 126 pickupName = "Medium Invisibility" 168 127 pickupDescription = "Makes you invisible for 10 seconds." 169 128 spawnerTemplate = "mediuminvisiblepickupRepresentation" 170 129 inventoryRepresentation = "MediumInvisible" 171 > 172 <pickup> 173 <InvisiblePickup template=mediuminvisiblepickup /> 174 </pickup> 175 </PickupRepresentation> 176 177 <PickupRepresentation 130 /> 131 132 <PickupRepresentation 133 name = "hugeinvisiblepickup" 178 134 pickupName = "Huge Invisibility" 179 135 pickupDescription = "Makes you invisible for 20 seconds." 180 136 spawnerTemplate = "hugeinvisiblepickupRepresentation" 181 137 inventoryRepresentation = "HugeInvisible" 182 > 183 <pickup> 184 <InvisiblePickup template=hugeinvisiblepickup /> 185 </pickup> 186 </PickupRepresentation> 138 /> 187 139 188 140 <!-- Pickup Collection pickups --> 189 141 190 142 <PickupRepresentation 143 name = "triplehealthspeedinvisibilitypickup" 191 144 pickupName = "Tri Pickup" 192 145 pickupDescription = "Adds health, speed and invisibility." 193 146 spawnerTemplate = "triplehealthspeedinvisibilitypickupRepresentation" 194 > 195 <pickup> 196 <PickupCollection template=triplehealthspeedinvisibilitypickup /> 197 </pickup> 198 </PickupRepresentation> 147 /> 199 148 200 149 <!-- Drone Pickup --> 201 150 202 151 <PickupRepresentation 152 name = "dronepickup" 203 153 pickupName = "Drone Pickup" 204 154 pickupDescription = "Adds a Drone to the Player's Spaceship" 205 155 spawnerTemplate = "dronepickupRepresentation" 206 > 207 <pickup> 208 <DronePickup template=dronepickup /> 209 </pickup> 210 </PickupRepresentation> 156 /> 211 157 212 158 <!-- DamageBoost Pickup --> 213 159 214 160 <PickupRepresentation 161 name = "smalldamageboostpickup" 215 162 pickupName = "Small DamageBoost Pickup" 216 163 pickupDescription = "Multiplies the ship damage with 2." 217 164 spawnerTemplate = "smalldamageboostpickupRepresentation" 218 165 inventoryRepresentation = "SmallDamageBoost" 219 > 220 <pickup> 221 <DamageBoostPickup template=smalldamageboostpickup /> 222 </pickup> 223 </PickupRepresentation> 224 225 <PickupRepresentation 166 /> 167 168 <PickupRepresentation 169 name = "mediumdamageboostpickup" 226 170 pickupName = "Medium DamageBoost Pickup" 227 171 pickupDescription = "Multiplies the ship damage with 5." 228 172 spawnerTemplate = "mediumdamageboostpickupRepresentation" 229 173 inventoryRepresentation = "MediumDamageBoost" 230 > 231 <pickup> 232 <DamageBoostPickup template=mediumdamageboostpickup /> 233 </pickup> 234 </PickupRepresentation> 235 236 <PickupRepresentation 174 /> 175 176 <PickupRepresentation 177 name = "largedamageboostpickup" 237 178 pickupName = "Large DamageBoost Pickup" 238 179 pickupDescription = "Multiplies the ship damage with 7." 239 180 spawnerTemplate = "largedamageboostpickupRepresentation" 240 181 inventoryRepresentation = "LargeDamageBoost" 241 > 242 <pickup> 243 <DamageBoostPickup template=largedamageboostpickup /> 244 </pickup> 245 </PickupRepresentation> 182 /> 246 183 247 184 <!-- Shrink Pickup --> 248 185 249 186 <PickupRepresentation 187 name = "smallshrinkpickup" 250 188 pickupName = "Small Shrink" 251 189 pickupDescription = "Shrinks the Ship by a bit" 252 190 spawnerTemplate = "smallshrinkpickupRepresentation" 253 191 inventoryRepresentation = "SmallShrink" 254 > 255 <pickup> 256 <ShrinkPickup template=smallshrinkpickup /> 257 </pickup> 258 </PickupRepresentation> 259 260 <PickupRepresentation 192 /> 193 194 <PickupRepresentation 195 name = "mediumshrinkpickup" 261 196 pickupName = "Medium Shrink" 262 197 pickupDescription = "Shrinks the Ship" 263 198 spawnerTemplate = "mediumshrinkpickupRepresentation" 264 199 inventoryRepresentation = "MediumShrink" 265 > 266 <pickup> 267 <ShrinkPickup template=mediumshrinkpickup /> 268 </pickup> 269 </PickupRepresentation> 270 271 <PickupRepresentation 200 /> 201 202 <PickupRepresentation 203 name = "hugeshrinkpickup" 272 204 pickupName = "Huge Shrink" 273 205 pickupDescription = "Shrinks the Ship considerably" 274 206 spawnerTemplate = "hugeshrinkpickupRepresentation" 275 207 inventoryRepresentation = "HugeShrink" 276 > 277 <pickup> 278 <ShrinkPickup template=hugeshrinkpickup /> 279 </pickup> 280 </PickupRepresentation> 281 208 /> -
code/branches/presentation2012merge/data/levels/pickups.oxw
r9291 r9318 131 131 <PickupSpawner position="-25,75,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10"> 132 132 <pickup> 133 <MetaPickup metaType="use" />133 <MetaPickup representation="use" metaType="use" /> 134 134 </pickup> 135 135 </PickupSpawner> … … 137 137 <PickupSpawner position="0,75,-125" triggerDistance="10" respawnTime="5" maxSpawnedItems="10"> 138 138 <pickup> 139 <MetaPickup metaType="drop" />139 <MetaPickup representation="drop" metaType="drop" /> 140 140 </pickup> 141 141 </PickupSpawner> … … 194 194 <!-- PickupRepresentation for the pickup below, since it is not a standard pickup provided by pickups.oxi --> 195 195 <PickupRepresentation 196 name = "MediumHealth" 196 197 pickupName = "Medium Health Pack" 197 198 pickupDescription = "Once used adds a medium amout of health to the ship." 198 199 spawnerTemplate = "mediumhealthpickupRepresentation" 199 200 inventoryRepresentation = "MediumHealth" 200 > 201 <pickup> 202 <HealthPickup health=500 activationType=immediate healthRate=10 durationType=continuous /> 203 </pickup> 204 </PickupRepresentation> 201 /> 205 202 206 203 <PickupSpawner position="-50,0,-125" respawnTime="60" triggerDistance="20" maxSpawnedItems="5"> 207 204 <pickup> 208 <HealthPickup health=500 activationType=immediate healthRate=10 durationType=continuous />205 <HealthPickup representation="MediumHealth" health=500 activationType=immediate healthRate=10 durationType=continuous /> 209 206 </pickup> 210 207 </PickupSpawner> -
code/branches/presentation2012merge/data/levels/presentation09b.oxw
r9316 r9318 102 102 <!-- PickupRepresentation for the pickup below, since it is not a standard pickup provided by pickups.oxi --> 103 103 <PickupRepresentation 104 name = "MediumHealth" 104 105 pickupName = "Medium Health Pack" 105 106 pickupDescription = "Once used adds a medium amout of health to the ship." 106 107 spawnerTemplate = "mediumhealthpickupRepresentation" 107 108 inventoryRepresentation = "MediumHealth" 108 > 109 <pickup> 110 <HealthPickup health=100 activationType="onUse" durationType="once" /> 111 </pickup> 112 </PickupRepresentation> 109 /> 113 110 114 111 <PickupSpawner position="-4150,2750,1550" respawnTime="60" triggerDistance="20" maxSpawnedItems="5"> 115 112 <pickup> 116 <HealthPickup health=100 activationType=onUse durationType=once />113 <HealthPickup representation="MediumHealth" health=100 activationType=onUse durationType=once /> 117 114 </pickup> 118 115 </PickupSpawner> -
code/branches/presentation2012merge/data/levels/presentationFS10.oxw
r9016 r9318 148 148 <!-- PickupRepresentation for the pickup below, since it is not a standard pickup provided by pickups.oxi --> 149 149 <PickupRepresentation 150 name = "MediumHealth" 150 151 pickupName = "Medium Health Pack" 151 152 pickupDescription = "Once used adds a medium amout of health to the ship." 152 153 spawnerTemplate = "mediumhealthpickupRepresentation" 153 154 inventoryRepresentation = "MediumHealth" 154 > 155 <pickup> 156 <HealthPickup health=50 activationType="onUse" durationType="once" /> 157 </pickup> 158 </PickupRepresentation> 155 /> 159 156 160 157 <PickupSpawner position="25,-75,-500" respawnTime="60" triggerDistance="20" maxSpawnedItems="5"> 161 158 <pickup> 162 <HealthPickup health=50 activationType=onUse durationType=once />159 <HealthPickup representation="MediumHealth" health=50 activationType=onUse durationType=once /> 163 160 </pickup> 164 161 </PickupSpawner> -
code/branches/presentation2012merge/data/levels/presentationHS09.oxw
r9316 r9318 105 105 <!-- PickupRepresentation for the pickup below, since it is not a standard pickup provided by pickups.oxi --> 106 106 <PickupRepresentation 107 name = "MediumHealth" 107 108 pickupName = "Medium Health Pack" 108 109 pickupDescription = "Once used adds a medium amout of health to the ship." 109 110 spawnerTemplate = "mediumhealthpickupRepresentation" 110 111 inventoryRepresentation = "MediumHealth" 111 > 112 <pickup> 113 <HealthPickup health=100 activationType="onUse" durationType="once" /> 114 </pickup> 115 </PickupRepresentation> 112 /> 116 113 117 114 <PickupSpawner position="-4150,2750,1550" respawnTime="60" triggerDistance="20" maxSpawnedItems="5"> 118 115 <pickup> 119 <HealthPickup health=100 activationType=onUse durationType=once />116 <HealthPickup representation="MediumHealth" health=100 activationType=onUse durationType=once /> 120 117 </pickup> 121 118 </PickupSpawner> -
code/branches/presentation2012merge/data/levels/templates/pickupRepresentationTemplates.oxt
r9303 r9318 19 19 <Template name=smallshieldpickup> 20 20 <ShieldPickup 21 representation = "smallshieldpickup" 21 22 duration = 10 22 23 shieldabsorption = 0.7 … … 45 46 <Template name=mediumshieldpickup> 46 47 <ShieldPickup 48 representation = "mediumshieldpickup" 47 49 duration = 30 48 50 shieldabsorption = 0.8 … … 72 74 <Template name=hugeshieldpickup> 73 75 <ShieldPickup 76 representation = "hugeshieldpickup" 74 77 duration = 60 75 78 shieldabsorption = 0.95 … … 100 103 <Template name=smallhealthpickup> 101 104 <HealthPickup 105 representation = "smallhealthpickup" 102 106 health = 10 103 107 healthType = "limited" … … 125 129 <Template name=mediumhealthpickup> 126 130 <HealthPickup 131 representation = "mediumhealthpickup" 127 132 health = 50 128 133 healthType = "limited" … … 150 155 <Template name=hugehealthpickup> 151 156 <HealthPickup 157 representation = "hugehealthpickup" 152 158 health = 100 153 159 healthType = "limited" … … 175 181 <Template name=crazyhealthpickup> 176 182 <HealthPickup 183 representation = "crazyhealthpickup" 177 184 health = 1000 178 185 healthType = "permanent" … … 236 243 <Template name=smalldamageboostpickup> 237 244 <DamageBoostPickup 245 representation = "smalldamageboostpickup" 238 246 duration = 10.0 239 247 damageMultiplier = 2.0 … … 261 269 <Template name=mediumdamageboostpickup> 262 270 <DamageBoostPickup 271 representation = "mediumdamageboostpickup" 263 272 duration = 10.0 264 273 damageMultiplier = 5.0 … … 286 295 <Template name=largedamageboostpickup> 287 296 <DamageBoostPickup 297 representation = "largedamageboostpickup" 288 298 duration = 10.0 289 299 damageMultiplier = 7.0 … … 314 324 <Template name=smallspeedpickup> 315 325 <SpeedPickup 326 representation = "smallspeedpickup" 316 327 duration = 10.0 317 328 speedAdd = 0.0 … … 340 351 <Template name=mediumspeedpickup> 341 352 <SpeedPickup 353 representation = "mediumspeedpickup" 342 354 duration = 10.0 343 355 speedAdd = 0.0 … … 366 378 <Template name=hugespeedpickup> 367 379 <SpeedPickup 380 representation = "hugespeedpickup" 368 381 duration = 10.0 369 382 speedAdd = 0.0 … … 392 405 <Template name=smalljumppickup> 393 406 <SpeedPickup 407 representation = "smalljumppickup" 394 408 duration = 0.7 395 409 speedAdd = 5000.0 … … 420 434 <Template name=smallinvisiblepickup> 421 435 <InvisiblePickup 436 representation = "smallinvisiblepickup" 422 437 duration = 5.0 423 438 activaionType = "immediate" … … 444 459 <Template name=mediuminvisiblepickup> 445 460 <InvisiblePickup 461 representation = "mediuminvisiblepickup" 446 462 duration = 10.0 447 463 activaionType = "immediate" … … 468 484 <Template name=hugeinvisiblepickup> 469 485 <InvisiblePickup 486 representation = "hugeinvisiblepickup" 470 487 duration = 20.0 471 488 activaionType = "immediate" … … 492 509 <Template name=smallshrinkpickup> 493 510 <ShrinkPickup 511 representation = "smallshrinkpickup" 494 512 duration = 10.0 495 513 shrinkFactor = 2.5 … … 517 535 <Template name=mediumshrinkpickup> 518 536 <ShrinkPickup 537 representation = "mediumshrinkpickup" 519 538 duration = 30.0 520 539 shrinkFactor = 5.0 … … 542 561 <Template name=hugeshrinkpickup> 543 562 <ShrinkPickup 563 representation = "hugeshrinkpickup" 544 564 duration = 60.0 545 565 shrinkFactor = 10.0 … … 570 590 571 591 <Template name=triplehealthspeedinvisibilitypickup> 572 <PickupCollection> 592 <PickupCollection 593 representation = "triplehealthspeedinvisibilitypickup" 594 > 573 595 <pickupables> 574 596 <HealthPickup template=mediumhealthpickup /> … … 630 652 631 653 <Template name=dronepickup> 632 <DronePickup droneTemplate=droneTemplate />633 </Template> 634 654 <DronePickup representation=dronepickup droneTemplate=droneTemplate /> 655 </Template> 656 -
code/branches/presentation2012merge/src/modules/pickup/CMakeLists.txt
r7163 r9318 4 4 Pickup.cc 5 5 PickupCollection.cc 6 PickupCollectionIdentifier.cc7 6 PickupManager.cc 8 7 PickupRepresentation.cc -
code/branches/presentation2012merge/src/modules/pickup/Pickup.cc
r9313 r9318 36 36 #include "core/CoreIncludes.h" 37 37 #include "util/StringUtils.h" 38 39 #include "pickup/PickupIdentifier.h"40 38 41 39 #include "DroppedPickup.h" … … 86 84 /** 87 85 @brief 88 Initializes the PickupIdentififer of this Pickup.89 */90 void Pickup::initializeIdentifier(void)91 {92 this->pickupIdentifier_->addParameter("activationType", this->getActivationType());93 this->pickupIdentifier_->addParameter("durationType", this->getDurationType());94 }95 96 /**97 @brief98 86 Method for creating a Pickup object through XML. 99 87 */ … … 102 90 SUPER(Pickup, XMLPort, xmlelement, mode); 103 91 92 XMLPortParam(Pickup, "representation", setRepresentationName, getRepresentationName, xmlelement, mode); 104 93 XMLPortParam(Pickup, "activationType", setActivationTypeAsString, getActivationTypeAsString, xmlelement, mode); 105 94 XMLPortParam(Pickup, "durationType", setDurationTypeAsString, getDurationTypeAsString, xmlelement, mode); 106 107 this->initializeIdentifier();108 95 } 109 96 … … 206 193 207 194 Pickup* pickup = orxonox_cast<Pickup*>(item); 195 pickup->setRepresentationName(this->getRepresentationName()); 208 196 pickup->setActivationType(this->getActivationType()); 209 197 pickup->setDurationType(this->getDurationType()); 210 211 pickup->initializeIdentifier();212 198 } 213 199 -
code/branches/presentation2012merge/src/modules/pickup/Pickup.h
r9313 r9318 105 105 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 106 106 107 virtual const std::string& getRepresentationName() const 108 { return this->representationName_; } 109 107 110 /** 108 111 @brief Get the activation type of the Pickup. … … 150 153 151 154 protected: 152 v oid initializeIdentifier(void);155 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 153 156 154 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 157 /** 158 @brief Sets the representation name which refers to the name of the PickupRepresentation that is used to represent this pickup. 159 */ 160 inline void setRepresentationName(const std::string& name) 161 { this->representationName_ = name; } 155 162 156 163 /** … … 173 180 void initialize(void); //!< Initializes the member variables. 174 181 182 std::string representationName_; //!< The name of the associated PickupRepresentation. 175 183 pickupActivationType::Value activationType_; //!< The activation type of the Pickup. 176 184 pickupDurationType::Value durationType_; //!< The duration type of the Pickup. -
code/branches/presentation2012merge/src/modules/pickup/PickupCollection.cc
r9296 r9318 39 39 #include "CollectiblePickup.h" 40 40 #include "DroppedPickup.h" 41 #include "PickupCollectionIdentifier.h"42 41 43 42 #include "PickupCollection.h" … … 54 53 The creator of the object. 55 54 */ 56 PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator) , pickupCollectionIdentifier_(NULL)55 PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator) 57 56 { 58 57 RegisterObject(PickupCollection); 59 58 60 this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this);61 59 this->processingUsed_ = false; 62 60 this->processingPickedUp_ = false; … … 76 74 } 77 75 this->pickups_.clear(); 78 79 if(this->pickupCollectionIdentifier_ != NULL)80 this->pickupCollectionIdentifier_->destroy();81 76 } 82 77 … … 89 84 SUPER(PickupCollection, XMLPort, xmlelement, mode); 90 85 86 XMLPortParam(PickupCollection, "representation", setRepresentationName, getRepresentationName, xmlelement, mode); 91 87 XMLPortObject(PickupCollection, CollectiblePickup, "pickupables", addPickupable, getPickupable, xmlelement, mode); 92 88 } … … 217 213 218 214 PickupCollection* pickup = orxonox_cast<PickupCollection*>(item); 215 pickup->setRepresentationName(this->getRepresentationName()); 219 216 // Clone all Pickupables this PickupCollection consist of. 220 217 for(std::list<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); ++it) … … 243 240 244 241 return true; 245 }246 247 /**248 @brief249 Get the PickupIdentifier of this PickupCollection.250 This is in fact the PickupCollectionIdentifier.251 @return252 Returns a pointer to the PickupIdentifier of this PickupCollection.253 */254 const PickupIdentifier* PickupCollection::getPickupIdentifier(void) const255 {256 return this->pickupCollectionIdentifier_;257 242 } 258 243 -
code/branches/presentation2012merge/src/modules/pickup/PickupCollection.h
r9295 r9318 50 50 The PickupCollection combines different @ref orxonox::Pickupable "Pickupables" (more precisely @ref orxonox::CollectiblePickup "CollectiblePickups") to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one @ref orxonox::Pickupable "Pickupable". 51 51 52 To differentiate between different types of @ref orxonox::PickupCollection "PickupCollections" (just as we differentiate between different types of @ref orxonox::Pickupable "Pickupables") we define a new identifyer called the @ref orxonox::PickupCollectionIdentifier "PickupCollectionIdentifier" which has pretty much the same properties as the @ref orxonox::PickupIdentifier "PickupIdentifier" but extende to @ref orxonox::PickupCollection "PickupCollections".53 54 52 A PickupCollection can be created in XML as follows: 55 53 @code … … 85 83 virtual bool isTarget(const PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection. 86 84 87 virtual const PickupIdentifier* getPickupIdentifier(void) const; //!< Get the PickupIdentifier of this PickupCollection. 85 inline void setRepresentationName(const std::string& name) 86 { this->representationName_ = name; } 87 virtual const std::string& getRepresentationName() const 88 { return this->representationName_; } 88 89 89 90 bool addPickupable(CollectiblePickup* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection. … … 101 102 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 102 103 103 PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves.104 105 104 private: 106 105 void changedUsedAction(void); //!< Helper method. … … 108 107 void pickupsChanged(void); //!< Helper method. 109 108 109 std::string representationName_; //!< The name of the associated PickupRepresentation. 110 110 std::list<CollectiblePickup*> pickups_; //!< The list of the pointers of all the Pickupables this PickupCollection consists of. They are weak pointers to facilitate testing, whether the pointers are still valid. 111 111 -
code/branches/presentation2012merge/src/modules/pickup/PickupManager.cc
r8858 r9318 87 87 88 88 this->representations_.clear(); 89 this->representationsNetworked_.clear();90 89 91 90 // Destroying all the PickupInventoryContainers that are still there. … … 106 105 /** 107 106 @brief 108 Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents, on the server (or in standalone mode). 109 For every type of Pickupable (uniquely identified by a PickupIdentifier) there can be one (and just one) PickupRepresentation registered. 110 @param identifier 111 The PickupIdentifier identifying the Pickupable. 107 Registers a PickupRepresentation. 108 @param name 109 The representation's name. 112 110 @param representation 113 111 A pointer to the PickupRepresentation. … … 115 113 Returns true if successful and false if not. 116 114 */ 117 bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 118 { 119 assert(identifier); 115 bool PickupManager::registerRepresentation(const std::string& name, PickupRepresentation* representation) 116 { 120 117 assert(representation); 121 118 122 119 // If the list is not empty and Pickupable already has a Representation registered. 123 if(!this->representations_.empty() && this->representations_.find( identifier) != this->representations_.end())120 if(!this->representations_.empty() && this->representations_.find(name) != this->representations_.end()) 124 121 return false; 125 122 126 this->representations_[ identifier] = representation;123 this->representations_[name] = representation; 127 124 128 125 orxout(verbose, context::pickups) << "PickupRepresentation &" << representation << " registered with the PickupManager." << endl; … … 132 129 /** 133 130 @brief 134 Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents, on the server (or in standalone mode). 135 @param identifier 136 The PickupIdentifier identifying the Pickupable. 137 @param representation 138 A pointer to the PickupRepresentation. 131 Unegisters a PickupRepresentation. 132 @param name 133 The representation's name. 139 134 @return 140 135 Returns true if successful and false if not. 141 136 */ 142 bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation) 143 { 144 assert(identifier); 145 assert(representation); 146 147 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier); 137 bool PickupManager::unregisterRepresentation(const std::string& name) 138 { 139 std::map<std::string, PickupRepresentation*>::iterator it = this->representations_.find(name); 148 140 if(it == this->representations_.end()) // If the Pickupable is not registered in the first place. 149 141 return false; … … 151 143 this->representations_.erase(it); 152 144 153 orxout(verbose, context::pickups) << "PickupRepresentation &" << representation<< " unregistered with the PickupManager." << endl;145 orxout(verbose, context::pickups) << "PickupRepresentation &" << name << " unregistered with the PickupManager." << endl; 154 146 return true; 155 147 } … … 157 149 /** 158 150 @brief 159 Registers a PickupRepresentation on the host it was created. 160 @param representation 161 A pointer to the PickupRepresentation. 162 @return 163 Returns true if successful, false if not. 164 */ 165 bool PickupManager::registerRepresentation(PickupRepresentation* representation) 166 { 167 assert(representation); 168 169 // If the list is not empty and PickupRepresentation is already registered. 170 if(!this->representationsNetworked_.empty() && this->representationsNetworked_.find(representation->getObjectID()) != this->representationsNetworked_.end()) 171 return false; 172 173 this->representationsNetworked_[representation->getObjectID()] = representation; 174 return true; 175 } 176 177 /** 178 @brief 179 Unregisters a PickupRepresentation on the host it is being destroyed (which is the same host on which it was created). 180 @param representation 181 A pointer to the Pickuprepresentation. 182 @return 183 Returns true if successful, false if not. 184 */ 185 bool PickupManager::unregisterRepresentation(PickupRepresentation* representation) 186 { 187 assert(representation); 188 189 std::map<uint32_t, PickupRepresentation*>::iterator it = this->representationsNetworked_.find(representation->getObjectID()); 190 if(it == this->representationsNetworked_.end()) // If the Pickupable is not registered in the first place. 191 return false; 192 193 this->representationsNetworked_.erase(it); 194 return true; 195 } 196 197 /** 198 @brief 199 Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. 200 @param identifier 201 The PickupIdentifier. 151 Get the PickupRepresentation with the given name. 152 @param name 153 The name of the PickupRepresentation. 202 154 @return 203 155 Returns a pointer to the PickupRepresentation. 204 156 */ 205 PickupRepresentation* PickupManager::getRepresentation(const PickupIdentifier* identifier)206 { 207 std::map< const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);208 if(it == this->representations_.end()) // If there is no PickupRepresentation associated with the input PickupIdentifier.157 PickupRepresentation* PickupManager::getRepresentation(const std::string& name) 158 { 159 std::map<std::string, PickupRepresentation*>::iterator it = this->representations_.find(name); 160 if(it == this->representations_.end()) // If there is no PickupRepresentation associated with the input name. 209 161 { 210 162 orxout(verbose, context::pickups) << "PickupManager::getRepresentation() returned default representation." << endl; … … 353 305 { 354 306 // If there is no PickupRepresentation registered the default representation is used. 355 if(this->representations_.find(pickup->get PickupIdentifier()) == this->representations_.end())356 PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pick edUp);307 if(this->representations_.find(pickup->getRepresentationName()) == this->representations_.end()) 308 PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickup->getRepresentationName(), pickedUp); 357 309 else 358 PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->representations_[pickup->get PickupIdentifier()]->getObjectID(), pickedUp);310 PickupManager::pickupChangedPickedUpNetwork(index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickup->getRepresentationName(), pickedUp); 359 311 } 360 312 // If the concerned host is somewhere in the network, we call pickupChangedPickedUpNetwork() on its PickupManager. … … 362 314 { 363 315 // If there is no PickupRepresentation registered the default representation is used. 364 if(this->representations_.find(pickup->get PickupIdentifier()) == this->representations_.end())316 if(this->representations_.find(pickup->getRepresentationName()) == this->representations_.end()) 365 317 { 366 318 callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp); … … 368 320 else 369 321 { 370 callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->get PickupIdentifier()]->getObjectID(), pickedUp);322 callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp); 371 323 } 372 324 } … … 388 340 The pickedUp status the Pickupable changed to. 389 341 */ 390 /*static*/ void PickupManager::pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, bool pickedUp)342 /*static*/ void PickupManager::pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, const std::string& representationName, bool pickedUp) 391 343 { 392 344 PickupManager& manager = PickupManager::getInstance(); // Get the PickupManager singleton on this host. … … 402 354 container->unusable = false; 403 355 container->representationObjectId = representationObjectId; 356 container->representationName = representationName; 404 357 // Insert the container into the pickupInventoryContainers_ list. 405 358 manager.pickupInventoryContainers_.insert(std::pair<uint32_t, PickupInventoryContainer*>(pickup, container)); … … 417 370 manager.updateGUI(); // Tell the PickupInventory that something has changed. 418 371 } 419 }420 421 /**422 @brief423 Get the PickupRepresentation of an input Pickupable.424 This method spares us the hassle to export the PickupIdentifier class to lua.425 @param pickup426 The number identifying the Pickupable whose PickupRepresentation should be returned.427 @return428 Returns the PickupRepresentation of the input Pickupable or NULL if an error occurred.429 */430 orxonox::PickupRepresentation* PickupManager::getPickupRepresentation(uint32_t pickup)431 {432 // Clear and rebuild the representationsNetworked_ list.433 //TODO: Better solution?434 this->representationsNetworked_.clear();435 for(ObjectList<PickupRepresentation>::iterator it = ObjectList<PickupRepresentation>::begin(); it != ObjectList<PickupRepresentation>::end(); ++it)436 this->representationsNetworked_[it->getObjectID()] = *it;437 438 // Get the container belonging to the input pickup, if not found return the default representation.439 std::map<uint32_t, PickupInventoryContainer*>::iterator it = this->pickupInventoryContainers_.find(pickup);440 if(it == this->pickupInventoryContainers_.end())441 return this->defaultRepresentation_;442 443 // Get the PickupRepresentation of the input pickup (through the objecId of the representation stored in the PickupInventoryContainer belonging to the pickup), if not found return the default representation.444 std::map<uint32_t, PickupRepresentation*>::iterator it2 = this->representationsNetworked_.find(it->second->representationObjectId);445 if(it2 == this->representationsNetworked_.end())446 return this->defaultRepresentation_;447 448 return it2->second;449 372 } 450 373 -
code/branches/presentation2012merge/src/modules/pickup/PickupManager.h
r8706 r9318 41 41 #include "core/WeakPtr.h" 42 42 43 #include "pickup/PickupIdentifier.h"44 45 43 #include "PickupRepresentation.h" 46 44 … … 67 65 bool unusable; //!< Whether the @ref orxonox::Pickupable "Pickupable" is droppable. 68 66 uint32_t representationObjectId; //!< The objectId of the @ref orxonox::PickupRepresentation "PickupRepresentation" that represents the @ref orxonox::Pickupable "Pickupable". 67 std::string representationName; //!< The name of the associated PickupRepresentation 69 68 }; 70 69 // tolua_end … … 74 73 The PickupManager class manages @ref orxonox::Pickupable "Pickupables". 75 74 76 It has in essence two tasks to fulfill. Firstly it must link @ref orxonox::Pickupable "Pickupables" (through their @ref orxonox::PickupIdentifier "PickupIdentifiers") to theirrespective @ref orxonox::PickupRepresentation "PickupRepresentations". Secondly it manages the PickupInventory. (The PickupInventory is the GUI that displays @ref orxonox::Pickupable "Pickupables" for the covenience of the user.)75 It has in essence two tasks to fulfill. Firstly it must link @ref orxonox::Pickupable "Pickupables" (through their representation-name attribute) to the respective @ref orxonox::PickupRepresentation "PickupRepresentations". Secondly it manages the PickupInventory. (The PickupInventory is the GUI that displays @ref orxonox::Pickupable "Pickupables" for the covenience of the user.) 77 76 78 77 @section PickupManagerTechnicalDetails Technical details … … 86 85 87 86 Firstly there are a number of lists (where by list I really mean any kind of ordered data structure) kept. 88 - The @ref orxonox::PickupManager::representations_ "representations_" list links @ref orxonox::PickupRepresentation "PickupRepresentations" with @ref orxonox::PickupIdentifier "PickupIdentifiers" and can be used to get the @ref orxonox::PickupRepresentation "PickupRepresentation" for a given @ref orxonox::Pickupable "Pickupable". It is only populated on the server (or in standalone mode). Each @ref orxonox::PickupRepresentation "PickupRepresentation" that is generated through XML registers itself with the PickupManager and is thereby added to the list. 89 - The @ref orxonox::PickupManager::representationsNetworked_ "representationsNetworked_" list is the networked (hence the name) equivalent to the @ref orxonox::PickupManager::representations_ "representations_" list. It links an objectId of a @ref orxonox::PickupRepresentation "PickupRepresentation" to a @ref orxonox::PickupRepresentation "PickupRepresentation". This list is maintained on all hosts, each representation registers itself (in its constructor) with the PickupManager. Since the representations are synchronised they are created on each host. The "same" instance on each host is identified by the same objectId and that is why we store the representations with the objectId as key. We can then use this list to get a @ref orxonox::PickupRepresentation "PickupRepresentation" for a specific @ref orxonox::Pickupable "Pickupable" (or more precisely a number identifiying that particular pickup, but we'll see that, when we look at the next list) on a client to be used in the PickupInventory. 87 - The @ref orxonox::PickupManager::representations_ "representations_" list links @ref orxonox::PickupRepresentation "PickupRepresentations" with its name and can be used to get the @ref orxonox::PickupRepresentation "PickupRepresentation" for a given @ref orxonox::Pickupable "Pickupable". It is only populated on the server (or in standalone mode). Each @ref orxonox::PickupRepresentation "PickupRepresentation" that is generated through XML registers itself with the PickupManager and is thereby added to the list. 90 88 - The @ref orxonox::PickupManager::pickupInventoryContainers_ "pickupInventoryContainers_" list links a number identifying a @ref orxonox::Pickupable "Pickupable" to a data structure (the @ref orxonox::PickupInventoryContainer "PickupInventoryContainer"), which contains all necessary information about that @ref orxonox::Pickupable "Pickupable". This list is maintained on all hosts, a new container is inserted when a @ref orxonox::Pickupable "Pickupable" is picked up, but only if it has been picked up by the repsective host. This list is then used by the PickupInventory to access the required information and to get the correct @ref orxonox::PickupRepresentation "PickupRepresentation". 91 89 - The @ref orxonox::PickupManager::pickups_ "pickups_" list links a number identifiying a @ref orxonox::Pickupable "Pickupable" to a (weak pointer to a) @ref orxonox::Pickupable "Pickupable". It is only maintained by the server (or in standalone mode), to be able to use, unuse and drop @ref orxonox::Pickupable "Pickupables" through the PickupInventory. Since @ref orxonox::Pickupable "Pickupables" only exist on the server a client that wants to change a pickups status has so send a request over the network (with the number identifying the pickup) to the server and then the server facilitates the change, using this list to map from the identifyer to the actual @ref orxonox::Pickupable "Pickupable". … … 114 112 static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export 115 113 116 bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.117 bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.114 bool registerRepresentation(const std::string& name, PickupRepresentation* representation); 115 bool unregisterRepresentation(const std::string& name); 118 116 119 bool registerRepresentation(PickupRepresentation* representation); //!< Registers a PickupRepresentation on the host it was created. 120 bool unregisterRepresentation(PickupRepresentation* representation); //!< Unregisters a PickupRepresentation on the host it is being destroyed. 121 122 PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier. 117 PickupRepresentation* getRepresentation(const std::string& name); // tolua_export 123 118 124 119 virtual void pickupChangedUsed(Pickupable* pickup, bool used); //!< Is called by the PickupListener to notify the PickupManager, that the input Pickupable has transited to the input used state. 125 120 static void pickupChangedUsedNetwork(uint32_t pickup, bool inUse, bool usable, bool unusable); //!< Helper method to react to the change in the used status of a Pickupable. 126 121 virtual void pickupChangedPickedUp(Pickupable* pickup, bool pickedUp); //!< Is called by the PickupListener to notify the PickupManager, that the input Pickupable has transited to the input pickedUp state. 127 static void pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, bool pickedUp); //!< Helper method to react to the change in the pickedUp status of a Pickupable.122 static void pickupChangedPickedUpNetwork(uint32_t pickup, bool usable, uint32_t representationObjectId, const std::string& representationName, bool pickedUp); //!< Helper method to react to the change in the pickedUp status of a Pickupable. 128 123 129 124 // Methods to be used by the PickupInventory. 130 125 public: 131 126 // tolua_begin 132 orxonox::PickupRepresentation* getPickupRepresentation(uint32_t pickup); //!< Get the PickupRepresentation of an input indentifier for Pickupable.133 134 127 int getNumPickups(void); //!< Get the number of pickups currently picked up by the player. 135 128 /** … … 163 156 PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation. 164 157 165 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types of Pickupables) and PickupRepresentations. 166 std::map<uint32_t, PickupRepresentation*> representationsNetworked_; //!< Map linking the PickupRepresentation's objectId to the PickupRepresentation itself. It is used for networking purposes. 158 std::map<std::string, PickupRepresentation*> representations_; //!< Map linking PickupRepresentations and their names. 167 159 168 160 std::map<uint32_t, PickupInventoryContainer*> pickupInventoryContainers_; //!< Map linking a number identifying a Pickupable to a PickupInventoryContainer, which contains all necessary information about that Pickupable. -
code/branches/presentation2012merge/src/modules/pickup/PickupPrereqs.h
r9269 r9318 73 73 class Pickup; 74 74 class PickupCollection; 75 class PickupCollectionIdentifier;76 75 class PickupManager; 77 76 class PickupRepresentation; -
code/branches/presentation2012merge/src/modules/pickup/PickupRepresentation.cc
r9302 r9318 52 52 This is primarily for use of the PickupManager in creating a default PickupRepresentation. 53 53 */ 54 PickupRepresentation::PickupRepresentation() : BaseObject(NULL), Synchronisable(NULL), spawnerRepresentation_(NULL) , pickup_(NULL)54 PickupRepresentation::PickupRepresentation() : BaseObject(NULL), Synchronisable(NULL), spawnerRepresentation_(NULL) 55 55 { 56 56 RegisterObject(PickupRepresentation); … … 64 64 Default Constructor. Registers the object and initializes its member variables. 65 65 */ 66 PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), Synchronisable(creator), spawnerRepresentation_(NULL) , pickup_(NULL)66 PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), Synchronisable(creator), spawnerRepresentation_(NULL) 67 67 { 68 68 RegisterObject(PickupRepresentation); … … 70 70 this->initialize(); 71 71 this->registerVariables(); 72 73 PickupManager::getInstance().registerRepresentation(this); // Registers the PickupRepresentation with the PickupManager.74 72 } 75 73 … … 84 82 85 83 if(this->isInitialized()) 86 { 87 if(GameMode::isMaster() && this->pickup_ != NULL) 88 { 89 PickupManager::getInstance().unregisterRepresentation(this->pickup_->getPickupIdentifier(), this); 90 } 91 PickupManager::getInstance().unregisterRepresentation(this); 92 } 84 PickupManager::getInstance().unregisterRepresentation(this->getName()); 93 85 } 94 86 … … 128 120 XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode); 129 121 XMLPortParam(PickupRepresentation, "inventoryRepresentation", setInventoryRepresentation, getInventoryRepresentation, xmlelement, mode); 130 XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode);131 122 XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode); 132 133 if(GameMode::isMaster())134 {135 // Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.136 PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this);137 }138 139 if(this->spawnerRepresentation_ != NULL)140 this->spawnerRepresentation_->setVisible(false);141 123 142 124 orxout(verbose, context::pickups) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << endl; … … 172 154 } 173 155 156 void PickupRepresentation::changedName() 157 { 158 // Registers the PickupRepresentation with the PickupManager. 159 PickupManager::getInstance().unregisterRepresentation(this->getOldName()); 160 PickupManager::getInstance().registerRepresentation(this->getName(), this); 161 } 162 163 void PickupRepresentation::setSpawnerRepresentation(StaticEntity* representation) 164 { 165 this->spawnerRepresentation_ = representation; 166 if(this->spawnerRepresentation_ != NULL) 167 this->spawnerRepresentation_->setVisible(false); 168 } 169 174 170 /** 175 171 @brief -
code/branches/presentation2012merge/src/modules/pickup/PickupRepresentation.h
r9302 r9318 41 41 42 42 #include "interfaces/Pickupable.h" 43 #include "pickup/PickupIdentifier.h"44 43 #include "worldentities/StaticEntity.h" 45 44 … … 54 53 /** 55 54 @brief 56 The PickupRepresentation class represents a specific pickup type (identified by its @ref orxonox::PickupIdentifier "PickupIdentifier"). It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like.55 The PickupRepresentation class represents a specific pickup type. It defines the information displayed in the GUI (PickupInventory) and how @ref orxonox::PickupSpawner "PickupSpawners" that spawn the pickup type look like. 57 56 They are created through XML and are registered with the @ref orxonox::PickupManager "PickupManager". 58 57 … … 64 63 spawnerTemplate = "awesomePickupRepresentation" 65 64 inventoryRepresentation = "AwesomePickup" 66 > 67 <pickup> 68 <SomePickup /> 69 </pickup> 70 </PickupRepresentation> 65 /> 71 66 @endcode 72 67 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>. … … 133 128 */ 134 129 inline const std::string& getInventoryRepresentation(void) const { return this->inventoryRepresentation_; } // tolua_export 135 /** 136 @brief Get the Pickupable represented by this PickupRepresentation. 137 @param index The index. 138 @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL. 139 */ 140 inline const Pickupable* getPickup(unsigned int index) const 141 { if(index == 0) return this->pickup_; return NULL; } 130 131 virtual void changedName(); 142 132 143 133 StaticEntity* createSpawnerRepresentation(PickupSpawner* spawner); //!< Create a spawnerRepresentation for a specific PickupSpawner. … … 168 158 @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation. 169 159 */ 170 inline void setSpawnerRepresentation(StaticEntity* representation)171 { this->spawnerRepresentation_ = representation; } 160 void setSpawnerRepresentation(StaticEntity* representation); 161 172 162 /** 173 163 @brief Set the image representing the pickup in the PickupInventory. … … 176 166 inline void setInventoryRepresentation(const std::string& image) 177 167 { this->inventoryRepresentation_ = image; } 178 /**179 @brief Set the Pickupable that is represented by this PickupRepresentation.180 @param pickup A pointer to the Pickupable.181 */182 inline void setPickup(Pickupable* pickup)183 { this->pickup_ = pickup; }184 168 185 169 private: … … 195 179 std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. 196 180 197 Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.198 199 181 }; // tolua_export 200 182 -
code/branches/presentation2012merge/src/modules/pickup/PickupSpawner.cc
r9302 r9318 95 95 else 96 96 { 97 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->get PickupIdentifier());97 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getRepresentationName()); 98 98 this->attach(representation->createSpawnerRepresentation(this)); 99 99 this->setActive(true); … … 149 149 else 150 150 { 151 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->get PickupIdentifier());151 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getRepresentationName()); 152 152 this->attach(representation->createSpawnerRepresentation(this)); 153 153 this->setActive(true); -
code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc
r9305 r9318 38 38 #include "core/XMLPort.h" 39 39 40 #include "pickup/PickupIdentifier.h"41 40 #include "worldentities/pawns/SpaceShip.h" 42 41 … … 78 77 /** 79 78 @brief 80 Initializes the PickupIdentifier of this pickup.81 */82 void DamageBoostPickup::initializeIdentifier(void)83 {84 this->pickupIdentifier_->addParameter("duration", this->getDuration());85 this->pickupIdentifier_->addParameter("damageMultiplier", this->getDamageMultiplier());86 }87 88 /**89 @brief90 79 Method for creating a DamageBoostPickup object through XML. 91 80 */ … … 96 85 XMLPortParam(DamageBoostPickup, "duration", setDuration, getDuration, xmlelement, mode); 97 86 XMLPortParam(DamageBoostPickup, "damageMultiplier", setDamageMultiplier, getDamageMultiplier, xmlelement, mode); 98 99 this->initializeIdentifier();100 87 } 101 88 … … 196 183 pickup->setDuration(this->getDuration()); 197 184 pickup->setDamageMultiplier(this->getDamageMultiplier()); 198 pickup->initializeIdentifier();199 185 } 200 186 -
code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.h
r9272 r9318 79 79 80 80 protected: 81 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.82 81 void setDamageMultiplier(float damageMultiplier); //!< Sets the DamageMultiplier according to the XML. 83 82 -
code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc
r9313 r9318 39 39 40 40 #include "controllers/DroneController.h" 41 #include "pickup/PickupIdentifier.h"42 41 #include "worldentities/Drone.h" 43 42 #include "worldentities/pawns/Pawn.h" … … 81 80 /** 82 81 @brief 83 Initializes the PickupIdentifier of this pickup.84 */85 void DronePickup::initializeIdentifier(void)86 {87 this->pickupIdentifier_->addParameter("droneTemplate", this->getDroneTemplate());88 }89 90 /**91 @brief92 82 Method for creating a DronePickup object through XML. 93 83 */ … … 96 86 SUPER(DronePickup, XMLPort, xmlelement, mode); 97 87 XMLPortParam(DronePickup, "droneTemplate", setDroneTemplate, getDroneTemplate, xmlelement, mode); 98 99 this->initializeIdentifier();100 88 } 101 89 … … 198 186 DronePickup* pickup = orxonox_cast<DronePickup*>(item); 199 187 pickup->setDroneTemplate(this->getDroneTemplate()); 200 201 pickup->initializeIdentifier();202 188 } 203 189 } -
code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.h
r9312 r9318 75 75 76 76 protected: 77 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.78 79 77 void setDroneTemplate(const std::string& templatename); //!< Set the droneTemplate. 80 78 -
code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc
r9312 r9318 38 38 #include "core/XMLPort.h" 39 39 40 #include "pickup/PickupIdentifier.h"41 40 #include "worldentities/pawns/Pawn.h" 42 41 … … 87 86 /** 88 87 @brief 89 Initializes the PickupIdentifier of this pickup.90 */91 void HealthPickup::initializeIdentifier(void)92 {93 this->pickupIdentifier_->addParameter("health", this->getHealth());94 this->pickupIdentifier_->addParameter("healthType", this->getHealthType());95 this->pickupIdentifier_->addParameter("healthRate", this->getHealthRate());96 }97 98 /**99 @brief100 88 Method for creating a HealthPickup object through XML. 101 89 */ … … 110 98 if(!this->isContinuous()) 111 99 this->setHealthRate(0.0f); // TODO: this logic should be inside tick(), not in XMLPort 112 113 this->initializeIdentifier();114 100 } 115 101 … … 277 263 pickup->setHealthRate(this->getHealthRate()); 278 264 pickup->setHealthType(this->getHealthType()); 279 280 pickup->initializeIdentifier();281 265 } 282 266 -
code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.h
r9312 r9318 121 121 122 122 protected: 123 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.124 125 123 void setHealth(float health); //!< Sets the health. 126 124 void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous. -
code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.cc
r9305 r9318 40 40 #include "core/XMLPort.h" 41 41 42 #include "pickup/PickupIdentifier.h"43 42 #include "worldentities/pawns/Pawn.h" 44 43 … … 79 78 /** 80 79 @brief 81 Initializes the PickupIdentifier of this pickup.82 */83 void InvisiblePickup::initializeIdentifier(void)84 {85 this->pickupIdentifier_->addParameter("duration", this->getDuration());86 }87 88 /**89 @brief90 80 Method for creating a HealthPickup object through XML. 91 81 */ … … 94 84 SUPER(InvisiblePickup, XMLPort, xmlelement, mode); 95 85 XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode); 96 97 this->initializeIdentifier();98 86 } 99 87 … … 157 145 InvisiblePickup* pickup = orxonox_cast<InvisiblePickup*>(item); 158 146 pickup->setDuration(this->getDuration()); 159 pickup->initializeIdentifier();160 147 } 161 148 -
code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.h
r7547 r9318 72 72 InvisiblePickup(BaseObject* creator); //!< Constructor. 73 73 virtual ~InvisiblePickup(); //!< Destructor. 74 74 75 75 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML. 76 76 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. … … 91 91 92 92 protected: 93 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.94 95 93 bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again. 96 94 void setDuration(float duration); //!< Sets the time the InvisibilityPickup will last. -
code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc
r9313 r9318 36 36 37 37 #include "interfaces/PickupCarrier.h" 38 #include "pickup/PickupIdentifier.h"39 38 #include "worldentities/pawns/Pawn.h" 40 39 … … 86 85 /** 87 86 @brief 88 Helper method to initialize the PickupIdentifier.89 */90 void MetaPickup::initializeIdentifier(void)91 {92 this->pickupIdentifier_->addParameter("metaType", this->getMetaType());93 }94 95 /**96 @brief97 87 Method for creating a MetaPickup object through XML. 98 88 */ … … 102 92 103 93 XMLPortParam(MetaPickup, "metaType", setMetaTypeAsString, getMetaTypeAsString, xmlelement, mode); 104 105 this->initializeIdentifier();106 94 } 107 95 … … 172 160 MetaPickup* pickup = orxonox_cast<MetaPickup*>(item); 173 161 pickup->setMetaType(this->getMetaType()); 174 175 pickup->initializeIdentifier();176 162 } 177 163 -
code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.h
r9312 r9318 106 106 107 107 protected: 108 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.109 110 108 /** 111 109 @brief Set the meta type of the MetaPickup. -
code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.cc
r9305 r9318 38 38 #include "core/XMLPort.h" 39 39 40 #include "pickup/PickupIdentifier.h"41 40 #include "worldentities/pawns/Pawn.h" 42 41 … … 80 79 /** 81 80 @brief 82 Initializes the PickupIdentifier of this pickup.83 */84 void ShieldPickup::initializeIdentifier(void)85 {86 this->pickupIdentifier_->addParameter("duration", this->getDuration());87 this->pickupIdentifier_->addParameter("ShieldHealth", this->getShieldHealth());88 this->pickupIdentifier_->addParameter("ShieldAbsorption", this->getShieldAbsorption());89 }90 91 /**92 @brief93 81 Method for creating a ShieldPickup object through XML. 94 82 */ … … 100 88 XMLPortParam(ShieldPickup, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode); 101 89 XMLPortParam(ShieldPickup, "duration", setDuration, getDuration, xmlelement, mode); 102 103 this->initializeIdentifier();104 90 } 105 91 … … 188 174 pickup->setShieldAbsorption(this->getShieldAbsorption()); 189 175 pickup->setShieldHealth(this->getShieldHealth()); 190 pickup->initializeIdentifier();191 176 } 192 177 -
code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.h
r7547 r9318 104 104 105 105 protected: 106 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.107 106 void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires. 108 107 -
code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.cc
r9305 r9318 40 40 #include "core/XMLPort.h" 41 41 42 #include "pickup/PickupIdentifier.h"43 42 #include "worldentities/pawns/Pawn.h" 44 43 … … 81 80 } 82 81 83 void ShrinkPickup::initializeIdentifier(void)84 {85 this->pickupIdentifier_->addParameter("shrinkFactor", this->getShrinkFactor());86 this->pickupIdentifier_->addParameter("duration", this->getDuration());87 this->pickupIdentifier_->addParameter("shrinkDuration", this->getShrinkDuration());88 }89 90 82 /** 91 83 @brief … … 99 91 XMLPortParam(ShrinkPickup, "duration", setDuration, getDuration, xmlelement, mode); 100 92 XMLPortParam(ShrinkPickup, "shrinkDuration", setShrinkDuration, getShrinkDuration, xmlelement, mode); 101 102 this->initializeIdentifier();103 93 } 104 94 … … 321 311 pickup->setDuration(this->getDuration()); 322 312 pickup->setShrinkDuration(this->getShrinkDuration()); 323 324 pickup->initializeIdentifier();325 313 } 326 314 } -
code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.h
r8858 r9318 119 119 { if(speed <= 0.0f) { orxout(internal_warning, context::pickups) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkDuration_ = speed; } 120 120 121 protected:122 void initializeIdentifier(void);123 124 121 private: 125 122 void initialize(void); … … 135 132 float currentFactor_; //!< The shrink factor that is currently applied. 136 133 float timeRemainig_; //!< The remaining shrink time. 137 134 138 135 Pawn* carrierToPawnHelper(void); 139 136 Timer durationTimer_; -
code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.cc
r9305 r9318 38 38 #include "core/XMLPort.h" 39 39 40 #include "pickup/PickupIdentifier.h"41 40 #include "worldentities/pawns/SpaceShip.h" 42 41 … … 80 79 /** 81 80 @brief 82 Initializes the PickupIdentifier of this pickup.83 */84 void SpeedPickup::initializeIdentifier(void)85 {86 this->pickupIdentifier_->addParameter("duration", this->getDuration());87 this->pickupIdentifier_->addParameter("speedAdd", this->getSpeedAdd());88 this->pickupIdentifier_->addParameter("speedMultiply", this->getSpeedMultiply());89 }90 91 /**92 @brief93 81 Method for creating a SpeedPickup object through XML. 94 82 */ … … 100 88 XMLPortParam(SpeedPickup, "speedAdd", setSpeedAdd, getSpeedAdd, xmlelement, mode); 101 89 XMLPortParam(SpeedPickup, "speedMultiply", setSpeedMultiply, getSpeedMultiply, xmlelement, mode); 102 103 this->initializeIdentifier();104 90 } 105 91 … … 189 175 pickup->setSpeedAdd(this->getSpeedAdd()); 190 176 pickup->setSpeedMultiply(this->getSpeedMultiply()); 191 192 pickup->initializeIdentifier();193 177 } 194 178 -
code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.h
r9269 r9318 103 103 104 104 protected: 105 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.106 105 void pickupTimerCallback(void); //!< Function that gets called when timer ends. 107 106 -
code/branches/presentation2012merge/src/orxonox/CMakeLists.txt
r8858 r9318 50 50 ADD_SUBDIRECTORY(items) 51 51 ADD_SUBDIRECTORY(overlays) 52 ADD_SUBDIRECTORY(pickup)53 52 ADD_SUBDIRECTORY(sound) 54 53 ADD_SUBDIRECTORY(weaponsystem) -
code/branches/presentation2012merge/src/orxonox/OrxonoxPrereqs.h
r9286 r9318 151 151 class OrxonoxOverlay; 152 152 class OverlayGroup; 153 154 // pickup155 class PickupIdentifier;156 153 157 154 //sound -
code/branches/presentation2012merge/src/orxonox/interfaces/Pickupable.cc
r9293 r9318 39 39 40 40 #include "infos/PlayerInfo.h" 41 #include "pickup/PickupIdentifier.h"42 41 #include "worldentities/pawns/Pawn.h" 43 42 … … 52 51 Constructor. Registers the objects and initializes its member variables. 53 52 */ 54 Pickupable::Pickupable() : pickupIdentifier_(NULL),used_(false), pickedUp_(false)53 Pickupable::Pickupable() : used_(false), pickedUp_(false) 55 54 { 56 55 RegisterRootObject(Pickupable); … … 58 57 this->carrier_ = NULL; 59 58 60 this->pickupIdentifier_ = new PickupIdentifier(this);61 59 this->beingDestroyed_ = false; 62 60 this->enabled_ = true; … … 69 67 Pickupable::~Pickupable() 70 68 { 71 if(this->pickupIdentifier_ != NULL)72 {73 orxout(verbose, context::pickups) << "Pickupable (&" << this << ") destroyed." << endl;74 this->pickupIdentifier_->destroy();75 }76 69 } 77 70 -
code/branches/presentation2012merge/src/orxonox/interfaces/Pickupable.h
r9293 r9318 53 53 Pickups (@ref orxonox::Pickupable "Pickupables") are objects that (quite unsurprisingly) can be picked up. Additionally they can be used and unused (transition from used to not used), and also dropped. 54 54 55 A class of Pickups can incorporate many different types of pickups (see @ref orxonox::PickupIdentifier "PickupIdentifier"), each type is uniquely defined by a @ref orxonox::PickupIdentifier "PickupIdentifier". Each pickup has such an identifier identiying its type. This means that two pickups of the same type have identifiers which are equal.56 57 55 @author 58 56 Damian 'Mozork' Frick … … 70 68 virtual ~Pickupable(); //!< Default destructor. 71 69 70 //! @brief Returns the representation name which refers to the name of the PickupRepresentation that is used to represent this pickup. 71 virtual const std::string& getRepresentationName() const = 0; 72 72 73 /** 73 74 @brief Get whether the Pickupable is currently in use or not. … … 144 145 virtual void clone(OrxonoxClass*& item) {} 145 146 146 /**147 @brief Get the PickupIdentifier of this Pickupable.148 @return Returns a pointer to the PickupIdentifier of this Pickupable.149 */150 virtual const PickupIdentifier* getPickupIdentifier(void) const151 { return this->pickupIdentifier_; }152 153 147 bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input. 154 148 bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up. … … 158 152 159 153 protected: 160 /**161 @brief Helper method to initialize the PickupIdentifier.162 */163 void initializeIdentifier(void) {}164 165 154 virtual void preDestroy(void); //!< A method that is called by OrxonoxClass::destroy() before the object is actually destroyed. 166 155 virtual void destroyPickup(void); //!< Destroys a Pickupable. … … 187 176 */ 188 177 virtual bool createSpawner(void) = 0; 189 190 PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable.191 178 192 179 private:
Note: See TracChangeset
for help on using the changeset viewer.