| 1121 | } |
| 1122 | |
| 1123 | void RenderManager::rrSetObjectAnimationState(MovableGameEntity* curAnimatedObject, const std::string& animation, bool loop) |
| 1124 | { |
| 1125 | std::string objectName = curAnimatedObject->getOgreNamePrefix() |
| 1126 | + curAnimatedObject->getName(); |
| 1127 | if (!mSceneManager->hasEntity(objectName)) |
| 1128 | return; |
| 1129 | |
| 1130 | Ogre::Entity* objectEntity = mSceneManager->getEntity(objectName); |
| 1131 | |
| 1132 | // Can't animate entities without skeleton |
| 1133 | if (!objectEntity->hasSkeleton()) |
| 1134 | return; |
| 1135 | |
| 1136 | std::string anim = animation; |
| 1137 | |
| 1138 | // Handle the case where this entity does not have the requested animation. |
| 1139 | while (!objectEntity->getSkeleton()->hasAnimation(anim)) |
| 1140 | { |
| 1141 | // Try to change the unexisting animation to a close existing one. |
| 1142 | if (anim == EntityAnimation::sleep_anim) |
| 1143 | { |
| 1144 | anim = EntityAnimation::die_anim; |
| 1145 | continue; |
| 1146 | } |
| 1147 | else if (anim == EntityAnimation::die_anim) |
| 1148 | { |
| 1149 | anim = EntityAnimation::idle_anim; |
| 1150 | break; |
| 1151 | } |
| 1152 | |
| 1153 | if (anim == EntityAnimation::flee_anim) |
| 1154 | { |
| 1155 | anim = EntityAnimation::walk_anim; |
| 1156 | } |
| 1157 | else if (anim == EntityAnimation::dig_anim || anim == EntityAnimation::claim_anim) |
| 1158 | { |
| 1159 | anim = EntityAnimation::attack_anim; |
| 1160 | } |
| 1161 | else |
| 1162 | { |
| 1163 | anim = EntityAnimation::idle_anim; |
| 1164 | break; |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | if (!objectEntity->getSkeleton()->hasAnimation(anim)) |
| 1169 | return; |
| 1170 | |
| 1171 | Ogre::AnimationState* animState = setEntityAnimation(objectEntity, anim, loop); |
| 1172 | curAnimatedObject->setAnimationState(animState); |
| 1173 | } |
| 1174 | void RenderManager::rrMoveEntity(GameEntity* entity, const Ogre::Vector3& position) |
| 1175 | { |
| 1176 | if(entity->getEntityNode() == nullptr) |
no test coverage detected