Esempio n. 1
0
void UAbilityTask::EndTask()
{
	if (!IsPendingKill())
	{
		OnDestroy(false);
	}
}
Esempio n. 2
0
void AMech_RPGCharacter::BeginPlay() {
	Super::BeginPlay();
	GetCharacterMovement()->SetAvoidanceEnabled(true);
	if (IsPendingKill()) {
		return;
	}

	if (!UseLoadout) {
		//CreatePresetRole(StartingRole());
	}
	else {
		SetupWithLoadout();
	}

	if (abilities.Num() > 0) {
		SetCurrentAbility(abilities[0]);
	}

	//SetUpGroup();
	SetUpWidgets();

	if (OnPostBeginPlay.IsBound()) {
		OnPostBeginPlay.Broadcast(this);
	}
}
Esempio n. 3
0
void APawn::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	
	if (!IsPendingKill())
	{
		GetWorld()->AddPawn( this );

		// Automatically add Controller to AI Pawns if we are allowed to.
		if (AutoPossessPlayer == EAutoReceiveInput::Disabled)
		{
			if (AutoPossessAI != EAutoPossessAI::Disabled && Controller == NULL && GetNetMode() != NM_Client)
			{
				const bool bPlacedInWorld = (GetWorld()->bStartup);
				if ((AutoPossessAI == EAutoPossessAI::PlacedInWorldOrSpawned) ||
					(AutoPossessAI == EAutoPossessAI::PlacedInWorld && bPlacedInWorld) ||
					(AutoPossessAI == EAutoPossessAI::Spawned && !bPlacedInWorld))
				{
					SpawnDefaultController();
				}
			}
		}

		// update movement component's nav agent values
		UpdateNavAgent();
	}
}
void ABaseCharacter::SetRagdollPhysics()
{
	USkeletalMeshComponent* Mesh3P = GetMesh();
	if (Mesh3P)
	{
		Mesh3P->SetCollisionProfileName(TEXT("Ragdoll"));
	}
	SetActorEnableCollision(true);

	if (!IsPendingKill() || Mesh3P || Mesh3P->GetPhysicsAsset())
	{
		Mesh3P->SetAllBodiesSimulatePhysics(true);
		Mesh3P->SetSimulatePhysics(true);
		Mesh3P->WakeAllRigidBodies();
		Mesh3P->bBlendPhysics = true;

		SetLifeSpan(TimeAfterDeathBeforeDestroy);
	}
	else
	{
		// Immediately hide the pawn
		TurnOff();
		SetActorHiddenInGame(true);
		SetLifeSpan(1.0f);
	}

	UCharacterMovementComponent* CharacterComp = Cast<UCharacterMovementComponent>(GetMovementComponent());
	if (CharacterComp)
	{
		CharacterComp->StopMovementImmediately();
		CharacterComp->DisableMovement();
		CharacterComp->SetComponentTickEnabled(false);
	}
}
void UActorComponent::DoDeferredRenderUpdates_Concurrent()
{
	checkf(!HasAnyFlags(RF_Unreachable), TEXT("%s"), *GetFullName());
	checkf(!IsTemplate(), TEXT("%s"), *GetFullName());
	checkf(!IsPendingKill(), TEXT("%s"), *GetFullName());

	if(!IsRegistered())
	{
		UE_LOG(LogActorComponent, Log, TEXT("UpdateComponent: (%s) Not registered, Aborting."), *GetPathName());
		return;
	}

	if(bRenderStateDirty)
	{
		SCOPE_CYCLE_COUNTER(STAT_PostTickComponentRecreate);
		RecreateRenderState_Concurrent();
		checkf(!bRenderStateDirty, TEXT("Failed to route CreateRenderState_Concurrent (%s)"), *GetFullName());
	}
	else
	{
		SCOPE_CYCLE_COUNTER(STAT_PostTickComponentLW);
		if(bRenderTransformDirty)
		{
			// Update the component's transform if the actor has been moved since it was last updated.
			SendRenderTransform_Concurrent();
		}

		if(bRenderDynamicDataDirty)
		{
			SendRenderDynamicData_Concurrent();
		}
	}
}
void UPawnActionsComponent::DescribeSelfToVisLog(FVisualLogEntry* Snapshot) const
{
    static const FString Category = TEXT("PawnActions");

    if (IsPendingKill())
    {
        return;
    }

    for (int32 PriorityIndex = 0; PriorityIndex < ActionStacks.Num(); ++PriorityIndex)
    {
        const UPawnAction* Action = ActionStacks[PriorityIndex].GetTop();
        if (Action == NULL)
        {
            continue;
        }

        FVisualLogStatusCategory StatusCategory;
        StatusCategory.Category = Category + TEXT(": ") + GetPriorityName(PriorityIndex);

        while (Action)
        {
            StatusCategory.Add(Action->GetName(), Action->GetStateDescription());
            Action = Action->GetParentAction();
        }

        Snapshot->Status.Add(StatusCategory);
    }
}
Esempio n. 7
0
void ANavigationData::PostInitProperties()
{
	Super::PostInitProperties();

	if (IsPendingKill() == true)
	{
		return;
	}

	if (HasAnyFlags(RF_ClassDefaultObject))
	{
		if (RuntimeGeneration == ERuntimeGenerationType::LegacyGeneration)
		{
			RuntimeGeneration = bRebuildAtRuntime_DEPRECATED ? ERuntimeGenerationType::Dynamic : ERuntimeGenerationType::Static;
		}
	}
	else
	{
		bNetLoadOnClient = (*GEngine->NavigationSystemClass != nullptr) && (GEngine->NavigationSystemClass->GetDefaultObject<UNavigationSystem>()->ShouldLoadNavigationOnClient(this));

		UWorld* WorldOuter = GetWorld();
		
		if (WorldOuter != NULL && WorldOuter->GetNavigationSystem() != NULL)
		{
			WorldOuter->GetNavigationSystem()->RequestRegistration(this);
		}

		RenderingComp = ConstructRenderingComponent();
	}
}
Esempio n. 8
0
void ACharacter::PostInitializeComponents()
{
    Super::PostInitializeComponents();

    if (!IsPendingKill())
    {
        if (Mesh)
        {
            BaseTranslationOffset = Mesh->RelativeLocation;
            BaseRotationOffset = Mesh->RelativeRotation.Quaternion();

            // force animation tick after movement component updates
            if (Mesh->PrimaryComponentTick.bCanEverTick && CharacterMovement)
            {
                Mesh->PrimaryComponentTick.AddPrerequisite(CharacterMovement, CharacterMovement->PrimaryComponentTick);
            }
        }

        if (CharacterMovement && CapsuleComponent)
        {
            CharacterMovement->UpdateNavAgent(*CapsuleComponent);
        }

        if (Controller == NULL && GetNetMode() != NM_Client)
        {
            if (CharacterMovement && CharacterMovement->bRunPhysicsWithNoController)
            {
                CharacterMovement->SetDefaultMovementMode();
            }
        }
    }
}
void AGameplayDebuggerReplicator::DrawDebugDataDelegate(class UCanvas* Canvas, class APlayerController* PC)
{
#if ENABLED_GAMEPLAY_DEBUGGER
	if (GetWorld() == nullptr || IsPendingKill() || Canvas == nullptr || Canvas->IsPendingKill())
	{
		return;
	}

	if (!LocalPlayerOwner || !IsActorTickEnabled())
	{
		return;
	}

	if (Canvas->SceneView != nullptr && !Canvas->SceneView->bIsGameView)
	{
		return;
	}

	if (GetWorld()->bPlayersOnly && Role == ROLE_Authority)
	{
		for (FConstPawnIterator Iterator = GetWorld()->GetPawnIterator(); Iterator; ++Iterator)
		{
			AActor* NewTarget = Cast<AActor>(*Iterator);
			if (NewTarget->IsSelected() && GetSelectedActorToDebug() != NewTarget)
			{
				ServerSetActorToDebug(NewTarget);
			}
		}
	}
	DrawDebugData(Canvas, PC);
#endif
}
void UAbilityTask_WaitTargetData::RegisterTargetDataCallbacks()
{
	if (!ensure(IsPendingKill() == false))
	{
		return;
	}

	check(TargetClass);
	check(Ability);

	const AGameplayAbilityTargetActor* CDO = CastChecked<AGameplayAbilityTargetActor>(TargetClass->GetDefaultObject());

	const bool bIsLocallyControlled = Ability->GetCurrentActorInfo()->IsLocallyControlled();
	const bool bShouldProduceTargetDataOnServer = CDO->ShouldProduceTargetDataOnServer;

	// If not locally controlled (server for remote client), see if TargetData was already sent
	// else register callback for when it does get here.
	if (!bIsLocallyControlled)
	{
		// Register with the TargetData callbacks if we are expecting client to send them
		if (!bShouldProduceTargetDataOnServer)
		{
			FGameplayAbilitySpecHandle	SpecHandle = GetAbilitySpecHandle();
			FPredictionKey ActivationPredictionKey = GetActivationPredictionKey();

			//Since multifire is supported, we still need to hook up the callbacks
			AbilitySystemComponent->AbilityTargetDataSetDelegate(SpecHandle, ActivationPredictionKey ).AddUObject(this, &UAbilityTask_WaitTargetData::OnTargetDataReplicatedCallback);
			AbilitySystemComponent->AbilityTargetDataCancelledDelegate(SpecHandle, ActivationPredictionKey ).AddUObject(this, &UAbilityTask_WaitTargetData::OnTargetDataReplicatedCancelledCallback);

			AbilitySystemComponent->CallReplicatedTargetDataDelegatesIfSet(SpecHandle, ActivationPredictionKey );

			SetWaitingOnRemotePlayerData();
		}
	}
}
Esempio n. 11
0
void UActorComponent::ConsolidatedPostEditChange(const FPropertyChangedEvent& PropertyChangedEvent)
{
	FComponentReregisterContext* ReregisterContext = nullptr;
	if(EditReregisterContexts.RemoveAndCopyValue(this, ReregisterContext))
	{
		delete ReregisterContext;

		AActor* MyOwner = GetOwner();
		if ( MyOwner && !MyOwner->IsTemplate() && PropertyChangedEvent.ChangeType != EPropertyChangeType::Interactive )
		{
			MyOwner->RerunConstructionScripts();
		}
	}
	else
	{
		// This means there are likely some stale elements left in there now, strip them out
		for (auto It(EditReregisterContexts.CreateIterator()); It; ++It)
		{
			if (!It.Key().IsValid())
			{
				It.RemoveCurrent();
			}
		}
	}

	// The component or its outer could be pending kill when calling PostEditChange when applying a transaction.
	// Don't do do a full recreate in this situation, and instead simply detach.
	if( IsPendingKill() )
	{
		// @todo UE4 james should this call UnregisterComponent instead to remove itself from the RegisteredComponents array on the owner?
		ExecuteUnregisterEvents();
		World = NULL;
	}
}
Esempio n. 12
0
void UAbilityTask::AbilityEnded()
{
	if (!IsPendingKill())
	{
		OnDestroy(true);
	}
}
Esempio n. 13
0
void APlayerStart::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	if ( !IsPendingKill()  && GetWorld()->GetAuthGameMode() )
	{
		GetWorld()->GetAuthGameMode()->AddPlayerStart(this);
	}
}
Esempio n. 14
0
void UActorComponent::RegisterComponentWithWorld(UWorld* InWorld)
{
	checkf(!HasAnyFlags(RF_Unreachable), TEXT("%s"), *GetFullName());

	if(IsPendingKill())
	{
		UE_LOG(LogActorComponent, Log, TEXT("RegisterComponentWithWorld: (%s) Trying to register component with IsPendingKill() == true. Aborting."), *GetPathName());
		return;
	}

	// If the component was already registered, do nothing
	if(IsRegistered())
	{
		UE_LOG(LogActorComponent, Log, TEXT("RegisterComponentWithWorld: (%s) Already registered. Aborting."), *GetPathName());
		return;
	}

	if(InWorld == NULL)
	{
		//UE_LOG(LogActorComponent, Log, TEXT("RegisterComponentWithWorld: (%s) NULL InWorld specified. Aborting."), *GetPathName());
		return;
	}

	// If not registered, should not have a scene
	checkf(World == NULL, TEXT("%s"), *GetFullName());

	// Follow outer chain to see if we can find an Actor
	AActor* Owner = GetOwner();

	ensureMsgf(Owner == NULL || Owner == GetOuter(), TEXT("Component %s is owned by %s by has an Outer of %s."), *GetName(), *Owner->GetName(), *GetOuter()->GetName());

	if ((Owner != NULL) && Owner->GetClass()->HasAnyClassFlags(CLASS_NewerVersionExists))
	{
		UE_LOG(LogActorComponent, Log, TEXT("RegisterComponentWithWorld: Owner belongs to a DEADCLASS"));
		return;
	}

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	// Can only register with an Actor if we are created within one
	if(Owner != NULL)
	{
		checkf(!Owner->HasAnyFlags(RF_Unreachable), TEXT("%s"), *GetFullName());
		// can happen with undo because the owner will be restored "next"
		//checkf(!Owner->IsPendingKill(), TEXT("%s"), *GetFullName());

		if(InWorld != GetOwner()->GetWorld())
		{
			// The only time you should specify a scene that is not GetOwner()->GetWorld() is when you don't have an Actor
			UE_LOG(LogActorComponent, Log, TEXT("RegisterComponentWithWorld: (%s) Specifying a world, but an Owner Actor found, and InWorld is not GetOwner()->GetWorld()"), *GetPathName());
		}
	}
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)

	World = InWorld;

	ExecuteRegisterEvents();
	RegisterAllComponentTickFunctions(true);
}
Esempio n. 15
0
void AAIController::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	if (bWantsPlayerState && !IsPendingKill() && (GetNetMode() != NM_Client))
	{
		InitPlayerState();
	}
}
Esempio n. 16
0
void AGroupActor::PostEditUndo()
{
	Super::PostEditUndo();

	if (IsPendingKill())
	{
		GetWorld()->ActiveGroupActors.RemoveSwap(this);
	}
}
Esempio n. 17
0
// Called when this enemy no longer has any health. [15/7/2016 Matthew Woolley]
void ARoadFeverEnemy::Die()
{
	// If this enemy isn't already being killed. [15/7/2016 Matthew Woolley]
	if ( !IsPendingKill() && EnemyHealth <= 0 )
	{
		// Kill it. [15/7/2016 Matthew Woolley]
		Destroy();
	}
}
Esempio n. 18
0
void AController::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	if ( !IsPendingKill() )
	{
		GetWorld()->AddController( this );
	}
}
class UNetConnection* AGameplayDebuggerReplicator::GetNetConnection() const
{
#if ENABLED_GAMEPLAY_DEBUGGER
	if (LocalPlayerOwner && LocalPlayerOwner->IsPendingKill() == false && IsPendingKill() == false)
	{
		return LocalPlayerOwner->GetNetConnection();
	}
#endif
	return nullptr;
}
class UNetConnection* AGameplayDebuggingReplicator::GetNetConnection() const
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	if (LocalPlayerOwner && LocalPlayerOwner->IsPendingKill() == false && IsPendingKill() == false)
	{
		return LocalPlayerOwner->GetNetConnection();
	}
#endif
	return NULL;
}
Esempio n. 21
0
void ALevelScriptActor::PostDuplicate(bool bDuplicateForPIE)
{
	ULevelScriptBlueprint* MyBlueprint = Cast<ULevelScriptBlueprint>(GetClass()->ClassGeneratedBy);
	if (MyBlueprint && !GIsDuplicatingClassForReinstancing && !IsPendingKill())
	{
		MyBlueprint->SetObjectBeingDebugged(this);
	}

	Super::PostDuplicate(bDuplicateForPIE);
}
Esempio n. 22
0
void UPrimitiveComponent::SetConstraintMode(EDOFMode::Type ConstraintMode)
{
	FBodyInstance * RootBI = GetBodyInstance(NAME_None, false);

	if (RootBI == NULL || IsPendingKill())
	{
		return;
	}

	RootBI->SetDOFLock(ConstraintMode);
}
Esempio n. 23
0
bool UGameplayAbility::IsActive() const
{
	// Only Instanced-Per-Actor abilities persist between activations
	if (GetInstancingPolicy() == EGameplayAbilityInstancingPolicy::InstancedPerActor)
	{
		return bIsActive;
	}

	// Non-instanced and Instanced-Per-Execution abilities are by definition active unless they are pending kill
	return !IsPendingKill();
}
void UGameplayTask::EndTask()
{
	UE_VLOG(GetGameplayTasksComponent(), LogGameplayTasks, Verbose
		, TEXT("%s EndTask called, current State: %s")
		, *GetName(), *GetTaskStateName());

	if (TaskState != EGameplayTaskState::Finished && !IsPendingKill())
	{
		OnDestroy(false);
	}
}
void UGameplayTask::TaskOwnerEnded()
{
    UE_VLOG(GetGameplayTasksComponent(), LogGameplayTasks, Verbose
            , TEXT("%s TaskOwnerEnded called, current State: %s")
            , *GetName(), *GetTaskStateName());

    if (TaskState != EGameplayTaskState::Finished && !IsPendingKill())
    {
        bOwnerFinished = true;
        OnDestroy(true);
    }
}
void UGameplayTask::OnDestroy(bool bInOwnerFinished)
{
    ensure(TaskState != EGameplayTaskState::Finished && !IsPendingKill());
    TaskState = EGameplayTaskState::Finished;

    if (TasksComponent.IsValid())
    {
        TasksComponent->OnGameplayTaskDeactivated(*this);
    }

    MarkPendingKill();
}
bool AVehiclePawn::CanDie() const
{
	if ( bIsDying										// already dying
		|| IsPendingKill()								// already destroyed
		|| Role != ROLE_Authority						// not authority
		|| GetWorld()->GetAuthGameMode() == NULL
		|| GetWorld()->GetAuthGameMode()->GetMatchState() == MatchState::LeavingMap)	// level transition occurring
	{
		return false;
	}

	return true;
}
Esempio n. 28
0
void AShooterPickup::PickupOnTouch(class AShooterCharacter* Pawn)
{
	if (bIsActive && Pawn && Pawn->IsAlive() && !IsPendingKill())
	{
		if (CanBePickedUp(Pawn))
		{
			GivePickupTo(Pawn);
			PickedUpBy = Pawn;

			if (!IsPendingKill())
			{
				bIsActive = false;
				OnPickedUp();

				if (RespawnTime > 0.0f)
				{
					GetWorldTimerManager().SetTimer(TimerHandle_RespawnPickup, this, &AShooterPickup::RespawnPickup, RespawnTime, false);
				}
			}
		}
	}
}
Esempio n. 29
0
bool ANimModCharacter::CanDie(float KillingDamage, FDamageEvent const& DamageEvent, AController* Killer, AActor* DamageCauser) const
{
	if (bIsDying										// already dying
		|| IsPendingKill()								// already destroyed
		|| Role != ROLE_Authority						// not authority
		|| GetWorld()->GetAuthGameMode() == NULL
		|| GetWorld()->GetAuthGameMode()->GetMatchState() == MatchState::LeavingMap)	// level transition occurring
	{
		return false;
	}

	return true;
}
Esempio n. 30
0
void UGame::Shutdown()
{
	if ( IsPendingKill() )
	{
		return;
	}

	OnShutdown();

	ObjectTree->Dispose();

	MarkPendingKill();
}