| 116 | } |
| 117 | |
| 118 | bool NpcAnimationHandler::playAnimationTrans(const std::string& anim) |
| 119 | { |
| 120 | Handle::AnimationHandle transAni; |
| 121 | Components::AnimHandler& h = getAnimHandler(); |
| 122 | Logic::ModelVisual* model = getController().getModelVisual(); |
| 123 | |
| 124 | if (!model) |
| 125 | return false; |
| 126 | |
| 127 | // Try to find a matching transition-file |
| 128 | if (h.getActiveAnimationPtr()) |
| 129 | { |
| 130 | // Strip the "s_" from the animation names |
| 131 | std::string activeName = h.getActiveAnimationPtr()->m_Name.substr(2); |
| 132 | std::string queryName = anim.substr(2); |
| 133 | |
| 134 | // Build potential transition animation name |
| 135 | std::string transAniName = "T_" + activeName + "_2_" + queryName; |
| 136 | |
| 137 | // Try to find it in the global library |
| 138 | transAni = getAnimLib().getAnimation(h.getMeshLibName(), h.getOverlay(), transAniName); |
| 139 | } |
| 140 | |
| 141 | if (transAni.isValid()) |
| 142 | { |
| 143 | model->playAnimation(transAni); |
| 144 | return true; |
| 145 | } |
| 146 | else |
| 147 | { |
| 148 | // Try to fallback to target animation |
| 149 | Handle::AnimationHandle fallbackAni = getAnimLib().getAnimation(h.getMeshLibName(), h.getOverlay(), anim); |
| 150 | |
| 151 | // Cancel if the animation really doesn't exist |
| 152 | if(!fallbackAni.isValid()) |
| 153 | return false; |
| 154 | |
| 155 | model->playAnimation(fallbackAni); |
| 156 | return true; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | bool NpcAnimationHandler::isAnimationActive(Handle::AnimationHandle anim) |
| 161 | { |
nothing calls this directly
no test coverage detected