Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 19, 2005, 6:27:06 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: messed things up a bit, try fixing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4894 r4895  
    129129
    130130/**
    131  * creates an Animation3D for a certain State.
    132  * @param state what state should the Animation be created for
    133  * @param node the node this Animation should apply to.
    134  * @returns The created animation.Animation(), NULL on error.
     131 * creates/returns an Animation3D for a certain State.
     132 * @param state what State should the Animation be created/returned for
     133 * @param node the node this Animation should apply to. (NULL is fine if the animation was already created)
     134 * @returns The created animation.Animation(), NULL on error (or if the animation does not yet exist).
    135135 *
    136136 * This function does only generate the Animation Object, and if set it will
     
    138138 * What this does not do, is set keyframes, you have to operate on the returned animation.
    139139 */
    140 Animation3D* Weapon::createAnimation(WeaponState state, PNode* node)
    141 {
    142   if (state >= WS_STATE_COUNT || node == NULL)
     140Animation3D* Weapon::getAnimation(WeaponState state, PNode* node)
     141{
     142  if (state >= WS_STATE_COUNT) // if the state is not known
    143143    return NULL;
    144144
    145   if (unlikely(this->animation[state] != NULL))
    146   {
    147     delete this->animation[state];
    148     this->animation[state] = NULL;
    149   }
    150   return this->animation[state] = new Animation3D(node);
     145  if (unlikely(this->animation[state] == NULL)) // if the animation does not exist yet create it.
     146  {
     147    if (likely(node != NULL))
     148      return this->animation[state] = new Animation3D(node);
     149    else
     150    {
     151      PRINTF(2)("Node not defined for the Creation of the 3D-animation of state %s\n", stateToChar(state));
     152      return NULL;
     153    }
     154  }
     155  else
     156    return this->animation[state];
    151157}
    152158
     
    156162// GAME ACTION //
    157163/////////////////
    158 
    159164/**
    160165 * request an action that should be executed,
     
    241246bool Weapon::activateW()
    242247{
    243 
    244   if (this->currentState == WS_INACTIVE)
     248//  if (this->currentState == WS_INACTIVE)
    245249  {
    246250        // play Sound
     
    250254      this->animation[WS_ACTIVATING]->replay();
    251255        // activate
    252     PRINTF(5)("Activating the Weapon %s\n", this->getName());
     256    PRINTF(4)("Activating the Weapon %s\n", this->getName());
    253257    this->activate();
    254         // setting up for next action
    255     this->requestedAction = WA_NONE;
     258    this->active = true;
     259    // setting up for next action
    256260    this->stateDuration = this->times[WA_ACTIVATE] + this->stateDuration;
    257261  }
     262  this->requestedAction = WA_NONE;
    258263}
    259264
     
    275280        // deactivate
    276281    this->deactivate();
     282    this->active = false;
    277283        // setting up for next action
    278     this->requestedAction = WA_NONE;
    279284    this->stateDuration = this->times[WA_DEACTIVATE] + this->stateDuration;
    280285  }
    281 
     286  this->requestedAction = WA_NONE;
    282287}
    283288
     
    414419// HELPER FUNCTIONS //
    415420//////////////////////
    416 // inclass
    417 /**
    418  * checks if the next Action given is valid
    419  * @returns if the Action that comes next is valid
    420  * @todo more checks
    421  */
    422 bool Weapon::nextActionValid() const
    423 {
    424   if (this->currentState == WS_INACTIVE)
    425   {
    426     return (this->requestedAction == WA_ACTIVATE || this->requestedAction == WA_NONE);
    427   }
    428   else
    429     return true;
    430 
    431 }
    432 
    433 
    434421/**
    435422 * checks wether all the Weapons functions are valid, and if it is possible to go to action with it.
Note: See TracChangeset for help on using the changeset viewer.