@@ -100,7 +100,11 @@ AttachEffectClass::~AttachEffectClass()
100100 if (it != AttachEffectClass::Array.end ())
101101 AttachEffectClass::Array.erase (it);
102102
103- this ->KillAnim ();
103+ if (this ->Animation )
104+ {
105+ this ->Animation ->UnInit ();
106+ this ->Animation = nullptr ;
107+ }
104108
105109 if (this ->Invoker )
106110 TechnoExt::ExtMap.Find (this ->Invoker )->AttachedEffectInvokerCount --;
@@ -250,8 +254,6 @@ void AttachEffectClass::AI()
250254
251255 if (!this ->Animation && this ->CanShowAnim ())
252256 this ->CreateAnim ();
253-
254- this ->AnimCheck ();
255257}
256258
257259void AttachEffectClass::AI_Temporal ()
@@ -286,12 +288,10 @@ void AttachEffectClass::AI_Temporal()
286288 break ;
287289 }
288290 }
289-
290- this ->AnimCheck ();
291291 }
292292}
293293
294- void AttachEffectClass::AnimCheck ()
294+ void AttachEffectClass::UpdateAnimLogic ()
295295{
296296 if (this ->Type ->Animation_HideIfAttachedWith .size () > 0 )
297297 {
@@ -319,7 +319,7 @@ void AttachEffectClass::AnimCheck()
319319
320320 for (auto const & drawOffset : this ->Type ->Animation_DrawOffsets )
321321 {
322- if (drawOffset.RequiredTypes .size () < 1 || pTechnoExt->HasAttachedEffects (drawOffset.RequiredTypes , false , false , nullptr , nullptr , nullptr , nullptr ))
322+ if (drawOffset.RequiredTypes .size () < 1 || pTechnoExt->HasAttachedEffects (drawOffset.RequiredTypes , false , false , nullptr , nullptr , nullptr , nullptr , true ))
323323 pAnimExt->AEDrawOffset += drawOffset.Offset ;
324324 }
325325 }
@@ -431,6 +431,7 @@ void AttachEffectClass::CreateAnim()
431431
432432 pAnim->RemainingIterations = 0xFFu ;
433433 this ->Animation = pAnim;
434+ TechnoExt::ExtMap.Find (this ->Techno )->UpdateAEAnimLogic ();
434435 }
435436}
436437
@@ -440,8 +441,13 @@ void AttachEffectClass::KillAnim()
440441 {
441442 this ->Animation ->UnInit ();
442443 this ->Animation = nullptr ;
444+ TechnoExt::ExtMap.Find (this ->Techno )->UpdateAEAnimLogic ();
443445 }
444446}
447+ bool AttachEffectClass::HasAnim ()
448+ {
449+ return this ->Animation != nullptr ;
450+ }
445451
446452void AttachEffectClass::UpdateCumulativeAnim ()
447453{
@@ -802,6 +808,8 @@ AttachEffectClass* AttachEffectClass::CreateAndAttach(AttachEffectTypeClass* pTy
802808 if (!currentTypeCount && pType->Cumulative && pType->CumulativeAnimations .size () > 0 )
803809 pAE->HasCumulativeAnim = true ;
804810
811+ TechnoExt::ExtMap.Find (pTarget)->UpdateAEAnimLogic ();
812+
805813 return pAE;
806814 }
807815
@@ -882,7 +890,11 @@ int AttachEffectClass::DetachTypes(TechnoClass* pTarget, AEAttachInfoTypeClass c
882890 }
883891
884892 if (detachedCount > 0 )
885- TechnoExt::ExtMap.Find (pTarget)->RecalculateStatMultipliers ();
893+ {
894+ auto const pExt = TechnoExt::ExtMap.Find (pTarget);
895+ pExt->RecalculateStatMultipliers ();
896+ pExt->UpdateAEAnimLogic ();
897+ }
886898
887899 if (markForRedraw)
888900 pTarget->MarkForRedraw ();
@@ -985,6 +997,7 @@ int AttachEffectClass::RemoveAllOfType(AttachEffectTypeClass* pType, TechnoClass
985997// / <param name="pTarget">Target techno.</param>
986998void AttachEffectClass::TransferAttachedEffects (TechnoClass* pSource, TechnoClass* pTarget)
987999{
1000+ int transferCount = 0 ;
9881001 const auto pSourceExt = TechnoExt::ExtMap.Find (pSource);
9891002 const auto pTargetExt = TechnoExt::ExtMap.Find (pTarget);
9901003 std::vector<std::unique_ptr<AttachEffectClass>>::iterator it;
@@ -1035,8 +1048,15 @@ void AttachEffectClass::TransferAttachedEffects(TechnoClass* pSource, TechnoClas
10351048 pAE->Duration = attachEffect->Duration ;
10361049 }
10371050
1051+ transferCount++;
10381052 it = pSourceExt->AttachedEffects .erase (it);
10391053 }
1054+
1055+ if (transferCount)
1056+ {
1057+ pSourceExt->UpdateAEAnimLogic ();
1058+ pTargetExt->UpdateAEAnimLogic ();
1059+ }
10401060}
10411061
10421062#pragma endregion
0 commit comments