Leviathan  0.8.0.0
Leviathan game engine
Leviathan::AnimationTimeAdder Class Reference

Handles updating time of Ogre animations. More...

#include <Systems.h>

Public Member Functions

DLLEXPORT void Run (GameWorld &world, std::unordered_map< ObjectID, Animated *> &index, int tick, int timeintick)
 

Detailed Description

Handles updating time of Ogre animations.

Todo:
This needs to be replaced with an animation system

Definition at line 121 of file Systems.h.

Member Function Documentation

◆ Run()

DLLEXPORT void AnimationTimeAdder::Run ( GameWorld world,
std::unordered_map< ObjectID, Animated *> &  index,
int  tick,
int  timeintick 
)

Definition at line 239 of file Systems.cpp.

241 {
242  float timeNow = (tick * TICKSPEED + timeintick) / 1000.f;
243 
244  const float passed = timeNow - LastSeconds;
245 
246  LastSeconds = timeNow;
247 
248  for(auto iter = index.begin(); iter != index.end(); ++iter) {
249 
250  Animated& animated = *iter->second;
251 
252  if(!animated.Animation)
253  continue;
254 
255  // auto skeleton = animated.GraphicalObject->getSkeletonInstance();
256 
257  // if(!skeleton) {
258 
259  // LOG_WARNING("Animated (entity id: " + std::to_string(iter->first) +
260  // ") has an Item that has no skeleton instance");
261  // continue;
262  // }
263 
264  if(animated.Marked) {
265  animated.Marked = false;
266 
267  LOG_WRITE("TODO: animation activation");
268 
269  // // Apply all properties and stop not playing animations
270  // for(const auto& animation : animated.Animations) {
271 
272  // try {
273 
274  // // Documentation says that this throws if not found
275  // Ogre::SkeletonAnimation* ogreAnim =
276  // skeleton->getAnimation(animation.Name);
277 
278  // ogreAnim->setEnabled(true);
279  // ogreAnim->setLoop(animation.Loop);
280 
281  // } catch(const Ogre::Exception& e) {
282 
283  // LOG_WARNING("Animated (entity id: " + std::to_string(iter->first) +
284  // ") has no animation named: " + animation.ReadableName +
285  // ", exception: " + e.what());
286  // }
287  // }
288 
289  // // Then disable
290  // for(const auto& ogreAnimation : skeleton->getAnimations()) {
291 
292  // bool found = false;
293 
294  // for(const auto& animation : animated.Animations) {
295 
296  // if(animation.Name == ogreAnimation.getName()) {
297  // found = true;
298  // break;
299  // }
300  // }
301 
302  // if(!found) {
303 
304  // skeleton->getAnimation(ogreAnimation.getName())->setEnabled(false);
305  // }
306  // }
307  }
308 
309  // // Update animation time
310  // for(const auto& animation : animated.Animations) {
311 
312  // if(animation.Paused)
313  // return;
314 
315  // try {
316 
317  // // Documentation says that this throws if not found
318  // Ogre::SkeletonAnimation* ogreAnim = skeleton->getAnimation(animation.Name);
319  // ogreAnim->addTime(passed * animation.SpeedFactor);
320 
321  // } catch(const Ogre::Exception& e) {
322 
323  // LOG_WARNING("Animated (entity id: " + std::to_string(iter->first) +
324  // ") has no animation named (in update): " +
325  // animation.ReadableName +
326  // ", exception: " + e.what());
327  // }
328  // }
329  }
330 }
bs::HAnimation Animation
Created animation component for this entity.
Definition: Components.h:300
constexpr auto TICKSPEED
Number of milliseconds between engine and world ticks.
Definition: Define.h:22
#define LOG_WRITE(x)
Definition: Define.h:91
Entity plays animations on an Ogre::Item.
Definition: Components.h:291

The documentation for this class was generated from the following files: