Changeset 4895 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons/weapon.cc
- Timestamp:
- Jul 19, 2005, 6:27:06 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4894 r4895 129 129 130 130 /** 131 * creates an Animation3D for a certain State.132 * @param state what state should the Animation be created for133 * @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). 135 135 * 136 136 * This function does only generate the Animation Object, and if set it will … … 138 138 * What this does not do, is set keyframes, you have to operate on the returned animation. 139 139 */ 140 Animation3D* Weapon:: createAnimation(WeaponState state, PNode* node)141 { 142 if (state >= WS_STATE_COUNT || node == NULL)140 Animation3D* Weapon::getAnimation(WeaponState state, PNode* node) 141 { 142 if (state >= WS_STATE_COUNT) // if the state is not known 143 143 return NULL; 144 144 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]; 151 157 } 152 158 … … 156 162 // GAME ACTION // 157 163 ///////////////// 158 159 164 /** 160 165 * request an action that should be executed, … … 241 246 bool Weapon::activateW() 242 247 { 243 244 if (this->currentState == WS_INACTIVE) 248 // if (this->currentState == WS_INACTIVE) 245 249 { 246 250 // play Sound … … 250 254 this->animation[WS_ACTIVATING]->replay(); 251 255 // activate 252 PRINTF( 5)("Activating the Weapon %s\n", this->getName());256 PRINTF(4)("Activating the Weapon %s\n", this->getName()); 253 257 this->activate(); 254 // setting up for next action255 this->requestedAction = WA_NONE;258 this->active = true; 259 // setting up for next action 256 260 this->stateDuration = this->times[WA_ACTIVATE] + this->stateDuration; 257 261 } 262 this->requestedAction = WA_NONE; 258 263 } 259 264 … … 275 280 // deactivate 276 281 this->deactivate(); 282 this->active = false; 277 283 // setting up for next action 278 this->requestedAction = WA_NONE;279 284 this->stateDuration = this->times[WA_DEACTIVATE] + this->stateDuration; 280 285 } 281 286 this->requestedAction = WA_NONE; 282 287 } 283 288 … … 414 419 // HELPER FUNCTIONS // 415 420 ////////////////////// 416 // inclass417 /**418 * checks if the next Action given is valid419 * @returns if the Action that comes next is valid420 * @todo more checks421 */422 bool Weapon::nextActionValid() const423 {424 if (this->currentState == WS_INACTIVE)425 {426 return (this->requestedAction == WA_ACTIVATE || this->requestedAction == WA_NONE);427 }428 else429 return true;430 431 }432 433 434 421 /** 435 422 * 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.