| 1784 | //---------------------------------------------------------------------------- |
| 1785 | |
| 1786 | bool Player::onNewDataBlock( GameBaseData *dptr, bool reload ) |
| 1787 | { |
| 1788 | PlayerData* prevData = mDataBlock; |
| 1789 | mDataBlock = dynamic_cast<PlayerData*>(dptr); |
| 1790 | if ( !mDataBlock || !Parent::onNewDataBlock( dptr, reload ) ) |
| 1791 | return false; |
| 1792 | |
| 1793 | // Player requires a shape instance. |
| 1794 | if ( mShapeInstance == NULL ) |
| 1795 | return false; |
| 1796 | |
| 1797 | // Initialize arm thread, preserve arm sequence from last datablock. |
| 1798 | // Arm animation can be from last datablock, or sent from the server. |
| 1799 | U32 prevAction = mArmAnimation.action; |
| 1800 | mArmAnimation.action = PlayerData::NullAnimation; |
| 1801 | if (mDataBlock->lookAction) { |
| 1802 | mArmAnimation.thread = mShapeInstance->addThread(); |
| 1803 | mShapeInstance->setTimeScale(mArmAnimation.thread,0); |
| 1804 | if (prevData) { |
| 1805 | if (prevAction != prevData->lookAction && prevAction != PlayerData::NullAnimation) |
| 1806 | setArmThread(prevData->actionList[prevAction].name); |
| 1807 | prevAction = PlayerData::NullAnimation; |
| 1808 | } |
| 1809 | if (mArmAnimation.action == PlayerData::NullAnimation) { |
| 1810 | mArmAnimation.action = (prevAction != PlayerData::NullAnimation)? |
| 1811 | prevAction: mDataBlock->lookAction; |
| 1812 | mShapeInstance->setSequence(mArmAnimation.thread, |
| 1813 | mDataBlock->actionList[mArmAnimation.action].sequence,0); |
| 1814 | } |
| 1815 | } |
| 1816 | else |
| 1817 | mArmAnimation.thread = 0; |
| 1818 | |
| 1819 | // Initialize head look thread |
| 1820 | TSShape const* shape = mShapeInstance->getShape(); |
| 1821 | S32 headSeq = shape->findSequence("head"); |
| 1822 | if (headSeq != -1) { |
| 1823 | mHeadVThread = mShapeInstance->addThread(); |
| 1824 | mShapeInstance->setSequence(mHeadVThread,headSeq,0); |
| 1825 | mShapeInstance->setTimeScale(mHeadVThread,0); |
| 1826 | } |
| 1827 | else |
| 1828 | mHeadVThread = 0; |
| 1829 | |
| 1830 | headSeq = shape->findSequence("headside"); |
| 1831 | if (headSeq != -1) { |
| 1832 | mHeadHThread = mShapeInstance->addThread(); |
| 1833 | mShapeInstance->setSequence(mHeadHThread,headSeq,0); |
| 1834 | mShapeInstance->setTimeScale(mHeadHThread,0); |
| 1835 | } |
| 1836 | else |
| 1837 | mHeadHThread = 0; |
| 1838 | |
| 1839 | // Create Recoil thread if any recoil sequences are specified. |
| 1840 | // Note that the server player does not play this animation. |
| 1841 | mRecoilThread = 0; |
| 1842 | if (isGhost()) |
| 1843 | for (U32 s = 0; s < PlayerData::NumRecoilSequences; s++) |
no test coverage detected