- Timestamp:
- Oct 24, 2015, 10:51:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/fabienHS15/src/orxonox/weaponsystem/Munition.cc
r9667 r10688 45 45 this->magazines_ = 10; 46 46 47 this->bUseSeparateMagazines_ = false; 48 this->bStackMunition_ = true; 47 this->deployment_ = DEPLOYMENT_STACK; 49 48 this->bAllowMunitionRefilling_ = true; 50 49 this->bAllowMultiMunitionRemovementUnderflow_ = true; 51 50 52 this->reloadTime_ = 0 ;51 this->reloadTime_ = 0.5f; 53 52 } 54 53 … … 61 60 Munition::Magazine* Munition::getMagazine(WeaponMode* user) const 62 61 { 63 if ( this->bUseSeparateMagazines_)62 if (deployment_ == DEPLOYMENT_SEPARATE) 64 63 { 65 64 // For separated magazines we definitively need a given user … … 87 86 if (magazine) 88 87 { 89 if ( this->bStackMunition_)88 if (deployment_ == DEPLOYMENT_STACK) 90 89 // With stacked munition every magazine contributes to the total amount 91 90 return this->maxMunitionPerMagazine_ * this->magazines_ + magazine->munition_; … … 109 108 unsigned int Munition::getNumMagazines() const 110 109 { 111 if ( this->bStackMunition_)110 if (deployment_ == DEPLOYMENT_STACK) 112 111 { 113 112 // If we stack munition and the current magazine is still full, it counts too … … 122 121 unsigned int Munition::getMaxMunition() const 123 122 { 124 if ( this->bStackMunition_)123 if (deployment_ == DEPLOYMENT_STACK) 125 124 return this->maxMunitionPerMagazine_ * this->maxMagazines_; 126 125 else … … 135 134 unsigned int munition = magazine->munition_; 136 135 137 // If we stack munition, we con't care about the current magazine - we just need enough munition in total138 if ( this->bStackMunition_)136 // If we stack munition, we don't care about the current magazine - we just need enough munition in total 137 if (deployment_ == DEPLOYMENT_STACK) 139 138 munition += this->maxMunitionPerMagazine_ * this->magazines_; 140 139 … … 169 168 { 170 169 // Not enough munition 171 if ( this->bStackMunition_)170 if (deployment_ == DEPLOYMENT_STACK) 172 171 { 173 172 // We stack munition, so just take what we can and then load the next magazine … … 199 198 { 200 199 // As long as we have enough magazines (and don't stack munition) we can reload 201 return (this->magazines_ > 0 && ! this->bStackMunition_);200 return (this->magazines_ > 0 && !deployment_ == DEPLOYMENT_STACK); 202 201 } 203 202 … … 207 206 if (magazine) 208 207 { 209 if ( this->bStackMunition_)208 if (deployment_ == DEPLOYMENT_STACK) 210 209 // With stacked munition, we never have to reload 211 210 return false; … … 231 230 232 231 // If we use separate magazines for each user, we definitively need a user given 233 if ( this->bUseSeparateMagazines_&& !user)232 if (deployment_ == DEPLOYMENT_SEPARATE && !user) 234 233 return false; 235 234 236 235 // If we don't use separate magazines, set user to 0 237 if (! this->bUseSeparateMagazines_)236 if (!deployment_ == DEPLOYMENT_SEPARATE) 238 237 user = 0; 239 238 … … 260 259 return false; 261 260 262 if ( this->bStackMunition_)261 if (deployment_ == DEPLOYMENT_STACK) 263 262 { 264 263 // If we stack munition, we can always add munition until we reach the limit … … 281 280 return false; 282 281 283 if ( this->bStackMunition_)282 if (deployment_ == DEPLOYMENT_STACK) 284 283 { 285 284 // Stacking munition means, if a magazine gets full, the munition adds to a new magazine … … 340 339 // TODO: 'amount' is not used 341 340 342 if ( this->bStackMunition_)341 if (deployment_ == DEPLOYMENT_STACK) 343 342 // If we stack munition, we can always add new magazines because they contribute directly to the munition 344 343 return (this->getNumMunition(0) < this->getMaxMunition()); … … 357 356 358 357 // If zero or less magazines are needed, we definitively don't need more magazines (unless we stack munition - then a magazine contributes directly to the munition) 359 if (needed_magazines <= 0 && ! this->bStackMunition_)358 if (needed_magazines <= 0 && !deployment_ == DEPLOYMENT_STACK) 360 359 return false; 361 360 … … 369 368 // We get more magazines than we need, so just add the needed amount 370 369 this->magazines_ += needed_magazines; 371 if ( this->bStackMunition_)370 if (deployment_ == DEPLOYMENT_STACK) 372 371 { 373 372 // We stack munition, so the additional amount contributes directly to the munition of the current magazine … … 383 382 bool Munition::canRemoveMagazines(unsigned int amount) const 384 383 { 385 if ( this->bStackMunition_)384 if (deployment_ == DEPLOYMENT_STACK) 386 385 { 387 386 if (this->magazines_ >= amount) … … 422 421 this->magazines_ -= amount; 423 422 } 424 else if ( this->bStackMunition_)423 else if (deployment_ == DEPLOYMENT_STACK) 425 424 { 426 425 // We don't have enough magazines, but we're stacking munition, so additionally remove the bullets from the current magazine … … 437 436 { 438 437 // If we use separate magazines, we need a user 439 if ( this->bUseSeparateMagazines_&& !user)438 if (deployment_ == DEPLOYMENT_SEPARATE && !user) 440 439 return false; 441 440 442 441 // If we don't use separate magazines, set user to 0 443 if (! this->bUseSeparateMagazines_)442 if (!deployment_ == DEPLOYMENT_SEPARATE) 444 443 user = 0; 445 444 … … 465 464 this->bLoaded_ = false; 466 465 467 if (bUseReloadTime && munition->reloadTime_ > 0 && !munition-> bStackMunition_)466 if (bUseReloadTime && munition->reloadTime_ > 0 && !munition->deployment_ == DEPLOYMENT_STACK) 468 467 { 469 468 const ExecutorPtr& executor = createExecutor(createFunctor(&Magazine::loaded, this));
Note: See TracChangeset
for help on using the changeset viewer.