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;
}
Example #2
0
void UUserWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime )
{
	// Update active movie scenes
	for( UUMGSequencePlayer* Player : ActiveSequencePlayers )
	{
		Player->Tick( InDeltaTime );
	}

	// The process of ticking the players above can stop them so we remove them after all players have ticked
	for( UUMGSequencePlayer* StoppedPlayer : StoppedSequencePlayers )
	{
		ActiveSequencePlayers.Remove( StoppedPlayer );	
	}

	StoppedSequencePlayers.Empty();

	if ( !bDesignTime )
	{
		UWorld* World = GetWorld();
		if ( World )
		{
			// Update any latent actions we have for this actor
			FLatentActionManager& LatentActionManager = World->GetLatentActionManager();
			LatentActionManager.ProcessLatentActions(this, InDeltaTime);
		}
	}

	Tick( MyGeometry, InDeltaTime );
}
	void AbortLatentActions(UActorComponent* OwnerOb, const UObject* Ob)
	{
		if (OwnerOb && !OwnerOb->HasAnyFlags(RF_BeginDestroyed) && OwnerOb->GetOwner())
		{
			UWorld* MyWorld = OwnerOb->GetOwner()->GetWorld();
			MyWorld->GetLatentActionManager().RemoveActionsForObject(Ob);
			MyWorld->GetTimerManager().ClearAllTimersForObject(Ob);
		}
	}
Example #4
0
void UUserWidget::TickActionsAndAnimation(const FGeometry& MyGeometry, float InDeltaTime)
{
	if ( IsDesignTime() )
	{
		return;
	}

	// Update active movie scenes
	for ( UUMGSequencePlayer* Player : ActiveSequencePlayers )
	{
		Player->Tick(InDeltaTime);
	}

	const bool bWasPlayingAnimation = IsPlayingAnimation();

	// The process of ticking the players above can stop them so we remove them after all players have ticked
	for ( UUMGSequencePlayer* StoppedPlayer : StoppedSequencePlayers )
	{
		ActiveSequencePlayers.RemoveSwap(StoppedPlayer);
	}

	StoppedSequencePlayers.Empty();

	// If we're no longer playing animations invalidate layout so that we recache the volatility of the widget.
	if ( bWasPlayingAnimation && IsPlayingAnimation() == false )
	{
		TSharedPtr<SWidget> CachedWidget = GetCachedWidget();
		if ( CachedWidget.IsValid() )
		{
			CachedWidget->Invalidate(EInvalidateWidget::LayoutAndVolatility);
		}
	}

	UWorld* World = GetWorld();
	if ( World )
	{
		// Update any latent actions we have for this actor
		FLatentActionManager& LatentActionManager = World->GetLatentActionManager();
		LatentActionManager.ProcessLatentActions(this, InDeltaTime);
	}
}