void AGameplayCueNotify_Actor::SetOwner( AActor* InNewOwner ) { // Remove our old delegate ClearOwnerDestroyedDelegate(); Super::SetOwner(InNewOwner); if (AActor* NewOwner = GetOwner()) { NewOwner->OnDestroyed.AddDynamic(this, &AGameplayCueNotify_Actor::OnOwnerDestroyed); } }
bool AGameplayCueNotify_Actor::Recycle() { bHasHandledOnActiveEvent = false; bHasHandledWhileActiveEvent = false; bHasHandledOnRemoveEvent = false; ClearOwnerDestroyedDelegate(); if (FinishTimerHandle.IsValid()) { FinishTimerHandle.Invalidate(); } // End timeline components TInlineComponentArray<UTimelineComponent*> TimelineComponents(this); for (UTimelineComponent* Timeline : TimelineComponents) { if (Timeline) { // May be too spammy, but want to call visibility to this. Maybe make this editor only? if (Timeline->IsPlaying()) { ABILITY_LOG(Warning, TEXT("GameplayCueNotify_Actor %s had active timelines when it was recycled."), *GetName()); } Timeline->SetPlaybackPosition(0.f, false, false); Timeline->Stop(); } } UWorld* MyWorld = GetWorld(); if (MyWorld) { // Note, ::Recycle is called on CDOs too, so that even "new" GCs start off in a recycled state. // So, its ok if there is no valid world here, just skip the stuff that has to do with worlds. if (MyWorld->GetLatentActionManager().GetNumActionsForObject(this)) { // May be too spammy, but want ot call visibility to this. Maybe make this editor only? ABILITY_LOG(Warning, TEXT("GameplayCueNotify_Actor %s has active latent actions (Delays, etc) when it was recycled."), *GetName()); } // End latent actions MyWorld->GetLatentActionManager().RemoveActionsForObject(this); // End all timers MyWorld->GetTimerManager().ClearAllTimersForObject(this); } // Clear owner, hide, detach from parent SetOwner(nullptr); SetActorHiddenInGame(true); DetachRootComponentFromParent(); return true; }
bool AGameplayCueNotify_Actor::Recycle() { bHasHandledOnActiveEvent = false; bHasHandledWhileActiveEvent = false; bHasHandledOnRemoveEvent = false; ClearOwnerDestroyedDelegate(); if (FinishTimerHandle.IsValid()) { GetWorld()->GetTimerManager().ClearTimer(FinishTimerHandle); FinishTimerHandle.Invalidate(); } return false; }