MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / setImageState

Method setImageState

Engine/source/T3D/shapeImage.cpp:2609–2863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2607}
2608
2609void ShapeBase::setImageState(U32 imageSlot, U32 newState, bool force)
2610{
2611 if (!mMountedImageList[imageSlot].dataBlock)
2612 return;
2613 MountedImage& image = mMountedImageList[imageSlot];
2614
2615
2616 // The client never enters the initial fire state on its own, but it
2617 // will continue to set that state...
2618 if (isGhost() && !force && newState == image.dataBlock->fireState) {
2619 if (image.state != &image.dataBlock->state[newState])
2620 return;
2621 }
2622
2623 // The client never enters the initial alternate fire state on its own, but it
2624 // will continue to set that state...
2625 if (isGhost() && !force && newState == image.dataBlock->altFireState) {
2626 if (image.state != &image.dataBlock->state[newState])
2627 return;
2628 }
2629
2630 // The client never enters the initial reload state on its own, but it
2631 // will continue to set that state...
2632 if (isGhost() && !force && newState == image.dataBlock->reloadState) {
2633 if (image.state != &image.dataBlock->state[newState])
2634 return;
2635 }
2636
2637 // Eject shell casing on every state change (client side only)
2638 ShapeBaseImageData::StateData& nextStateData = image.dataBlock->state[newState];
2639 if (isGhost() && nextStateData.ejectShell) {
2640 ejectShellCasing(imageSlot);
2641 }
2642
2643 // Shake camera on client.
2644 if (isGhost() && nextStateData.fire && image.dataBlock->shakeCamera) {
2645 shakeCamera(imageSlot);
2646 }
2647
2648 // Server must animate the shape if it is a firestate...
2649 if (isServerObject() && (image.dataBlock->state[newState].fire || image.dataBlock->state[newState].altFire))
2650 mShapeInstance->animate();
2651
2652 // Obtain the image's shape index for future use.
2653 U32 imageShapeIndex = getImageShapeIndex(image);
2654 image.lastShapeIndex = imageShapeIndex;
2655
2656 // If going back into the same state, just reset the timer
2657 // and invoke the script callback
2658 if (!force && image.state == &image.dataBlock->state[newState]) {
2659 image.delayTime = image.state->timeoutValue;
2660 if (image.state->script && !isGhost())
2661 scriptCallback(imageSlot, image.state->script);
2662
2663 // If this is a flash sequence, we need to select a new position for the
2664 // animation if we're returning to that state...
2665 F32 randomPos = Platform::getRandom();
2666 for (U32 i = 0; i < ShapeBaseImageData::MaxShapes; ++i)

Callers

nothing calls this directly

Calls 14

getVelocityFunction · 0.85
setPosMethod · 0.80
getSfxProfileMethod · 0.80
addSoundSourceMethod · 0.80
animateMethod · 0.45
setTimeScaleMethod · 0.45
isCyclicMethod · 0.45
getSequenceMethod · 0.45
getDescriptionMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected