CBattleAnimation.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "StdInc.h"
  2. #include "CBattleAnimation.h"
  3. #include "CBattleInterface.h"
  4. #include "../../lib/BattleState.h"
  5. #include "CSpellEffectAnimation.h"
  6. #include "CReverseAnimation.h"
  7. void CBattleAnimation::endAnim()
  8. {
  9. for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
  10. {
  11. if(it->first == this)
  12. {
  13. it->first = NULL;
  14. }
  15. }
  16. }
  17. bool CBattleAnimation::isEarliest(bool perStackConcurrency)
  18. {
  19. int lowestMoveID = owner->animIDhelper + 5;
  20. CBattleStackAnimation * thAnim = dynamic_cast<CBattleStackAnimation *>(this);
  21. CSpellEffectAnimation * thSen = dynamic_cast<CSpellEffectAnimation *>(this);
  22. for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
  23. {
  24. CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(it->first);
  25. CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(it->first);
  26. if(perStackConcurrency && stAnim && thAnim && stAnim->stack->ID != thAnim->stack->ID)
  27. continue;
  28. if(sen && thSen && sen != thSen && perStackConcurrency)
  29. continue;
  30. CReverseAnimation * revAnim = dynamic_cast<CReverseAnimation *>(stAnim);
  31. if(revAnim && thAnim && stAnim && stAnim->stack->ID == thAnim->stack->ID && revAnim->priority)
  32. return false;
  33. if(it->first)
  34. vstd::amin(lowestMoveID, it->first->ID);
  35. }
  36. return (ID == lowestMoveID) || (lowestMoveID == (owner->animIDhelper + 5));
  37. }
  38. CBattleAnimation::CBattleAnimation(CBattleInterface * _owner)
  39. : owner(_owner), ID(_owner->animIDhelper++)
  40. {}