Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4884 in orxonox.OLD


Ignore:
Timestamp:
Jul 18, 2005, 3:26:03 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: saver implementation of state-variables.
this step makes the execute function very big, and as such is not the best idea, maybe i will split up the checks in the execute-functions so one has a better insight into what is happening in weapon.
For this maybe a wrapper around fire/reload… functions will be written, that calls them within a fireWeapon/reloadWeapon function

Location:
orxonox/branches/weaponSystem/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/weaponSystem/src/lib/sound/sound_engine.cc

    r4883 r4884  
    138138  alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
    139139  alSourcePlay(this->sourceID);
    140 //  printf("playing sound\n");
     140
     141  if (unlikely(this->buffer != NULL))
     142    alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    141143}
    142144
  • orxonox/branches/weaponSystem/src/world_entities/weapons/test_gun.cc

    r4883 r4884  
    153153{
    154154  this->energyLoaded -= this->minCharge;
    155   if (this->soundBuffers[WA_SHOOT] != NULL)
    156     this->soundSource->play(this->soundBuffers[WA_SHOOT]);
    157 
    158 
    159155  Projectile* pj =  new TestBullet(this);//dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS));
    160156//  weaponSource->play();
  • orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.cc

    r4883 r4884  
    9191  if (action >= WA_ACTION_COUNT)
    9292    return;
    93   else
     93  else if (soundFile != NULL)
    9494  {
    9595    this->soundBuffers[action] = (SoundBuffer*)ResourceManager::getInstance()->load(soundFile, WAV);
     
    102102      PRINTF(4)("failed to load sound %s to %s\n", soundFile, actionToChar(action));
    103103    }
    104 
    105   }
     104  }
     105  else
     106    this->soundBuffers[action] = NULL;
    106107}
    107108
     
    136137      //if (likely(this->currentState != WS_INACTIVE))
    137138      {
    138         if (this->minCharge < this->energyLoaded)
     139        if (this->minCharge <= this->energyLoaded)
    139140        {
     141          if (this->soundBuffers[WA_SHOOT] != NULL)
     142            this->soundSource->play(this->soundBuffers[WA_SHOOT]);
    140143          this->fire();
    141144          this->requestedAction = WA_NONE;
     
    151154      if ( this->currentState != WS_INACTIVE && this->energyLoaded >= this->minCharge)
    152155      {
     156        if (this->soundBuffers[WA_CHARGE] != NULL)
     157         this->soundSource->play(this->soundBuffers[WA_CHARGE]);
    153158        this->charge();
    154159        this->requestedAction = WA_NONE;
     
    163168      //if (this->currentState != WS_INACTIVE && this->energy + this->energyLoaded >= this->minCharge)
    164169      {
     170        if (this->soundBuffers[WA_RELOAD] != NULL)
     171          this->soundSource->play(this->soundBuffers[WA_RELOAD]);
     172
    165173        this->reload();
    166174        this->requestedAction = WA_NONE;
     
    170178      if (this->currentState != WS_INACTIVE)
    171179      {
     180        if (this->soundBuffers[WA_DEACTIVATE] != NULL)
     181          this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]);
     182
    172183        this->deactivate();
    173184        this->requestedAction = WA_NONE;
     
    177188      if (this->currentState == WS_INACTIVE)
    178189      {
     190        if (this->soundBuffers[WA_ACTIVATE] != NULL)
     191          this->soundSource->play(this->soundBuffers[WA_ACTIVATE]);
     192
    179193        this->activate();
    180194        this->requestedAction = WA_NONE;
  • orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.h

    r4883 r4884  
    147147    // PHASES //
    148148    ////////////
     149  private:
    149150    WeaponState          currentState;                     //!< The State the weapon is in.
    150151    WeaponAction         requestedAction;                  //!< An action to try to Engage after the currentState ends.
     
    157158    bool                 hideInactive;                    //!< Hides the Weapon if it is inactive
    158159
    159   private:
    160160    bool                 active;                          //!< states wheter the weapon is enabled or not
    161161    Projectile*          projectile;                      //!< the projectile used for this weapon
Note: See TracChangeset for help on using the changeset viewer.