Exemplo n.º 1
0
void AFunctionalTest::FinishTest(TEnumAsByte<EFunctionalTestResult::Type> TestResult, const FString& Message)
{
	const static UEnum* FTestResultTypeEnum = FindObject<UEnum>( NULL, TEXT("FunctionalTesting.FunctionalTest.EFunctionalTestResult") );
	
	bIsRunning = false;
	SetActorTickEnabled(false);

	OnTestFinished.Broadcast();

	AActor** ActorToDestroy = AutoDestroyActors.GetTypedData();

	for (int32 ActorIndex = 0; ActorIndex < AutoDestroyActors.Num(); ++ActorIndex, ++ActorToDestroy)
	{
		if (*ActorToDestroy != NULL)
		{
			// will be removed next frame
			(*ActorToDestroy)->SetLifeSpan( 0.01f );
		}
	}

	const FText ResultText = FTestResultTypeEnum->GetEnumText( TestResult.GetValue() );
	const FString OutMessage = FString::Printf(TEXT("%s> Result: %s> %s")
		, *GetActorLabel()
		, *ResultText.ToString()
		, Message.IsEmpty() == false ? *Message : TEXT("Test finished") );

	AutoDestroyActors.Reset();

	EMessageSeverity::Type MessageLogSeverity = EMessageSeverity::Info;
	
	switch (TestResult.GetValue())
	{
		case EFunctionalTestResult::Invalid:
		case EFunctionalTestResult::Error:
			UE_VLOG(this, LogFunctionalTest, Error, TEXT("%s"), *OutMessage);
			MessageLogSeverity = EMessageSeverity::Error;
			break;
		case EFunctionalTestResult::Running:
			UE_VLOG(this, LogFunctionalTest, Warning, TEXT("%s"), *OutMessage);
			MessageLogSeverity = EMessageSeverity::Warning;
			break;
		case EFunctionalTestResult::Failed:
			UE_VLOG(this, LogFunctionalTest, Error, TEXT("%s"), *OutMessage);
			MessageLogSeverity = EMessageSeverity::Error;
			break;
		default:
			UE_VLOG(this, LogFunctionalTest, Log, TEXT("%s"), *OutMessage);
			break;
	}

	FMessageLog("FunctionalTestingLog").Message(MessageLogSeverity, FText::FromString(GetActorLabel()))
		->AddToken( FTextToken::Create( ResultText ) )
		->AddToken( FTextToken::Create( Message.IsEmpty() == false ? FText::FromString(Message) : NSLOCTEXT("FunctionalTest", "FinishedTest", "Test finished") ) );

	TestFinishedObserver.ExecuteIfBound(this);
}
Exemplo n.º 2
0
//@todo add "warning" level here
void AFunctionalTest::LogMessage(const FString& Message)
{
	UFunctionalTestingManager::AddLogItem(FText::FromString(Message));
	UE_VLOG(this, LogFunctionalTest, Log
		, TEXT("%s> %s")
		, *GetActorLabel(), *Message);
}
Exemplo n.º 3
0
void AFunctionalTest::SetTimeLimit(float InTimeLimit, TEnumAsByte<EFunctionalTestResult::Type> InResult)
{
	if (InTimeLimit < 0.f)
	{
		UE_VLOG(this, LogFunctionalTest, Warning
			, TEXT("%s> Trying to set TimeLimit to less than 0. Falling back to 0 (infinite).")
			, *GetActorLabel());

		InTimeLimit = 0.f;
	}
	TimeLimit = InTimeLimit;

	if (InResult == EFunctionalTestResult::Invalid)
	{
		UE_VLOG(this, LogFunctionalTest, Warning
			, TEXT("%s> Trying to set test Result to \'Invalid\'. Falling back to \'Failed\'")
			, *GetActorLabel());

		InResult == EFunctionalTestResult::Failed;
	}
	TimesUpResult = InResult;
}
Exemplo n.º 4
0
FString AAmbientSound::GetInternalSoundCueName()
{
	FString CueName;
#if WITH_EDITOR
	CueName = GetActorLabel();
#endif
	if (CueName.Len() == 0)
	{
		CueName = GetName();
	}
	CueName += TEXT("_SoundCue");

	return CueName;
}
Exemplo n.º 5
0
//@todo add "warning" level here
void AFunctionalTest::LogMessage(const FString& Message)
{
	UE_VLOG(this, LogFunctionalTest, Warning
		, TEXT("%s> %s")
		, *GetActorLabel(), *Message);
}
Exemplo n.º 6
0
void AActor::SetActorLabelInternal( const FString& NewActorLabelDirty, bool bMakeGloballyUniqueFName, bool bMarkDirty )
{
	// Clean up the incoming string a bit
	FString NewActorLabel = NewActorLabelDirty;
	NewActorLabel.Trim();
	NewActorLabel.TrimTrailing();


	// First, update the actor label
	{
		// Has anything changed?
		if( FCString::Strcmp( *NewActorLabel, *GetActorLabel() ) != 0 )
		{
			// Store new label
			Modify( bMarkDirty );
			ActorLabel = NewActorLabel;
		}
	}


	// Next, update the actor's name
	{
		// Generate an object name for the actor's label
		const FName OldActorName = GetFName();
		FName NewActorName = MakeObjectNameFromDisplayLabel( GetActorLabel(), OldActorName );

		// Has anything changed?
		if( OldActorName != NewActorName )
		{
			// Try to rename the object
			UObject* NewOuter = NULL;		// Outer won't be changing
			ERenameFlags RenFlags = bMakeGloballyUniqueFName ? (REN_DontCreateRedirectors | REN_ForceGlobalUnique) : REN_DontCreateRedirectors;
			bool bCanRename = Rename( *NewActorName.ToString(), NewOuter, REN_Test | REN_DoNotDirty | REN_NonTransactional | RenFlags );
			if( bCanRename )
			{
				// NOTE: Will assert internally if rename fails
				const bool bWasRenamed = Rename( *NewActorName.ToString(), NewOuter, RenFlags );
			}
			else
			{
				// Unable to rename the object.  Use a unique object name variant.
				NewActorName = MakeUniqueObjectName( bMakeGloballyUniqueFName ? ANY_PACKAGE : GetOuter(), GetClass(), NewActorName );

				bCanRename = Rename( *NewActorName.ToString(), NewOuter, REN_Test | REN_DoNotDirty | REN_NonTransactional | RenFlags );
				if( bCanRename )
				{
					// NOTE: Will assert internally if rename fails
					const bool bWasRenamed = Rename( *NewActorName.ToString(), NewOuter, RenFlags );
				}
				else
				{
					// Unable to rename the object.  Oh well, not a big deal.
				}
			}
		}
	}

	FPropertyChangedEvent PropertyEvent( FindField<UProperty>( AActor::StaticClass(), "ActorLabel" ) );
	PostEditChangeProperty(PropertyEvent);

	FCoreDelegates::OnActorLabelChanged.Broadcast(this);
}
Exemplo n.º 7
0
void AFunctionalTest::FinishTest(TEnumAsByte<EFunctionalTestResult::Type> TestResult, const FString& Message)
{
	const static UEnum* FTestResultTypeEnum = FindObject<UEnum>( NULL, TEXT("FunctionalTesting.FunctionalTest.EFunctionalTestResult") );
	
	if (bIsRunning == false)
	{
		// ignore
		return;
	}

	Result = TestResult;

	bIsRunning = false;
	SetActorTickEnabled(false);

	OnTestFinished.Broadcast();

	AActor** ActorToDestroy = AutoDestroyActors.GetData();

	for (int32 ActorIndex = 0; ActorIndex < AutoDestroyActors.Num(); ++ActorIndex, ++ActorToDestroy)
	{
		if (*ActorToDestroy != NULL)
		{
			// will be removed next frame
			(*ActorToDestroy)->SetLifeSpan( 0.01f );
		}
	}

	const FText ResultText = FTestResultTypeEnum->GetEnumText( TestResult.GetValue() );
	const FString OutMessage = FString::Printf(TEXT("%s %s: \"%s\'")
		, *GetActorLabel()
		, *ResultText.ToString()
		, Message.IsEmpty() == false ? *Message : TEXT("Test finished") );
	const FString AdditionalDetails = GetAdditionalTestFinishedMessage(TestResult) + FString::Printf(TEXT(", time %.2fs"), TotalTime);

	AutoDestroyActors.Reset();
		
	switch (TestResult.GetValue())
	{
		case EFunctionalTestResult::Invalid:
		case EFunctionalTestResult::Error:
		case EFunctionalTestResult::Failed:
			UE_VLOG(this, LogFunctionalTest, Error, TEXT("%s"), *OutMessage);
			UFunctionalTestingManager::AddError(FText::FromString(OutMessage));
			break;

		case EFunctionalTestResult::Running:
			UE_VLOG(this, LogFunctionalTest, Warning, TEXT("%s"), *OutMessage);
			UFunctionalTestingManager::AddWarning(FText::FromString(OutMessage));
			break;
		
		default:
			UE_VLOG(this, LogFunctionalTest, Log, TEXT("%s"), *OutMessage);
			UFunctionalTestingManager::AddLogItem(FText::FromString(OutMessage));
			break;
	}
	
	if (AdditionalDetails.IsEmpty() == false)
	{
		UFunctionalTestingManager::AddLogItem(FText::FromString(AdditionalDetails));
	}

	TestFinishedObserver.ExecuteIfBound(this);
}
void AMMO_Character::AttemptToLockOn()
{
	if (bIsDead)return;
	if (bMantineeHasControl)return;

	// Part 1 of 2: Set / Unset LockOn Target

	if (!LockedTarget)
	{
		TArray<AMMO_Mob_Character*> Enemies;
		for (TActorIterator<AMMO_Mob_Character> ActorItr(GetWorld()); ActorItr; ++ActorItr)
		{
			if(!ActorItr->bIsDead)
			Enemies.Add(*ActorItr);
		}

		int32 Index = -1;
		float Distance = 100000000;
		for (size_t i = 0; i < Enemies.Num(); i++)
		{
			if (FVector::Dist(GetActorLocation(), Enemies[i]->GetActorLocation()) <= PingAreaForLockOn)
			{
				if (FVector::Dist(GetActorLocation(), Enemies[i]->GetActorLocation()) < Distance)
				{
					if (!Enemies[i]->bIsDead && !Enemies[i]->MonsterAnimInstance->bHasDied )
					{
						Distance = FVector::Dist(GetActorLocation(), Enemies[i]->GetActorLocation());
						Index = i;
					}
				}
			}
		}

		if (Index != -1)
		{
			if (bIsInFocusMode)
			{
				bIsInFocusMode = false;
			}

			LockedTarget = Cast<AActor>(Enemies[Index]);
		}
		else
		{
			LockedTarget = nullptr;
		}
	}
	else
	{
		Cast<AMMO_Mob_Character>(LockedTarget)->MyLockOnWidget->PlayersLockedOn[LockOnID]=-1;
		LockedTarget = nullptr;
	}


	// Part 2 of 2: Activate and Deactivate as well as set some helper variables for Rotation of Actor and Camera.

	if (LockedTarget)
	{
		LastKnownRotation = FRotator((LockedTarget->GetActorLocation() - LockOnCam->GetComponentLocation()).Rotation());
		
		Cast<AMMO_Mob_Character>(LockedTarget)->MyLockOnWidget->PlayersLockedOn[LockOnID] = LockOnID;

		SetActorRotation(LastKnownRotation);
		Player_SkeletalMeshComponent->SetWorldRotation(LastKnownRotation);
		
		LockOnCam->Activate();
		MainCam->Deactivate();

		LockOnCam->SetRelativeLocation(FVector(-300, 0, 120));
		LockOnCam->SetRelativeRotation(FRotator(-22.5f, 0, 0));
	}
	else
	{
		GLog->Log(GetActorLabel());

		LockOnCam->Deactivate();
		MainCam->Activate();
	}
}