| 2580 | } |
| 2581 | |
| 2582 | void ShapeBase::setImageState(U32 imageSlot, U32 newState,bool force) |
| 2583 | { |
| 2584 | if (!mMountedImageList[imageSlot].dataBlock) |
| 2585 | return; |
| 2586 | MountedImage& image = mMountedImageList[imageSlot]; |
| 2587 | |
| 2588 | |
| 2589 | // The client never enters the initial fire state on its own, but it |
| 2590 | // will continue to set that state... |
| 2591 | if (isGhost() && !force && newState == image.dataBlock->fireState) { |
| 2592 | if (image.state != &image.dataBlock->state[newState]) |
| 2593 | return; |
| 2594 | } |
| 2595 | |
| 2596 | // The client never enters the initial alternate fire state on its own, but it |
| 2597 | // will continue to set that state... |
| 2598 | if (isGhost() && !force && newState == image.dataBlock->altFireState) { |
| 2599 | if (image.state != &image.dataBlock->state[newState]) |
| 2600 | return; |
| 2601 | } |
| 2602 | |
| 2603 | // The client never enters the initial reload state on its own, but it |
| 2604 | // will continue to set that state... |
| 2605 | if (isGhost() && !force && newState == image.dataBlock->reloadState) { |
| 2606 | if (image.state != &image.dataBlock->state[newState]) |
| 2607 | return; |
| 2608 | } |
| 2609 | |
| 2610 | // Eject shell casing on every state change (client side only) |
| 2611 | ShapeBaseImageData::StateData& nextStateData = image.dataBlock->state[newState]; |
| 2612 | if (isGhost() && nextStateData.ejectShell) { |
| 2613 | ejectShellCasing( imageSlot ); |
| 2614 | } |
| 2615 | |
| 2616 | // Shake camera on client. |
| 2617 | if (isGhost() && nextStateData.fire && image.dataBlock->shakeCamera) { |
| 2618 | shakeCamera( imageSlot ); |
| 2619 | } |
| 2620 | |
| 2621 | // Server must animate the shape if it is a firestate... |
| 2622 | if (isServerObject() && (image.dataBlock->state[newState].fire || image.dataBlock->state[newState].altFire)) |
| 2623 | mShapeInstance->animate(); |
| 2624 | |
| 2625 | // Obtain the image's shape index for future use. |
| 2626 | U32 imageShapeIndex = getImageShapeIndex(image); |
| 2627 | image.lastShapeIndex = imageShapeIndex; |
| 2628 | |
| 2629 | // If going back into the same state, just reset the timer |
| 2630 | // and invoke the script callback |
| 2631 | if (!force && image.state == &image.dataBlock->state[newState]) { |
| 2632 | image.delayTime = image.state->timeoutValue; |
| 2633 | if (image.state->script && !isGhost()) |
| 2634 | scriptCallback(imageSlot,image.state->script); |
| 2635 | |
| 2636 | // If this is a flash sequence, we need to select a new position for the |
| 2637 | // animation if we're returning to that state... |
| 2638 | F32 randomPos = Platform::getRandom(); |
| 2639 | for (U32 i=0; i<ShapeBaseImageData::MaxShapes; ++i) |
nothing calls this directly
no test coverage detected