Example #1
0
void AStealthArea::CalculateVisibility(AGameCharacter* calculatingUnit, TArray<AGameCharacter*>& sightList, TArray<AGameCharacter*>& availableUnits)
{
	if (!IsValid(calculatingUnit))
		return;

	//first get visible units on the outside based on increased radial area
	TArray<AActor*> ignoreList;
	for (AGameCharacter* gc : availableUnits)
		ignoreList.AddUnique(gc);

	for (AGameCharacter* gc : availableUnits)
	{
		if (occupyingUnits.Contains(gc)) //don't account for units in this area yet
			continue;

		if (gc->GetTeamIndex() == calculatingUnit->GetTeamIndex())
		{
			sightList.AddUnique(gc);
			continue;
		}

		FVector start = GetActorLocation();
		FVector end = gc->GetActorLocation();

		if ((start - end).SizeSquared2D() <= FMath::Square(calculatingUnit->sightRadius * 1.15f))
		{
			FHitResult hit;
			FCollisionQueryParams collisionParams;

			TArray<AActor*> ignoredActors = ignoreList;
			ignoredActors.Remove(gc);

			collisionParams.AddIgnoredActors(ignoredActors);
			collisionParams.AddIgnoredActor(this);

			GetWorld()->LineTraceSingleByChannel(hit, start, end, ECC_Visibility, collisionParams);

			if (hit.GetActor() == gc)
			{
				if (!IsValid(gc->currentStealthArea))
					sightList.AddUnique(gc);
			}
		}
	}

	//finally add all of the units that are currently in the area
	for (AGameCharacter* gc : occupyingUnits)
	{
		if (IsValid(gc))
			sightList.AddUnique(gc);
		else
			sightList.Remove(gc);
	}
}
bool FAssetFixUpRedirectors::CheckOutReferencingPackages(TArray<FRedirectorRefs>& RedirectorsToFix, TArray<UPackage*>& InOutReferencingPackagesToSave) const
{
	// Prompt to check out all successfully loaded packages
	bool bUserAcceptedCheckout = true;

	if ( InOutReferencingPackagesToSave.Num() > 0 )
	{
		if ( ISourceControlModule::Get().IsEnabled() )
		{
			TArray<UPackage*> PackagesCheckedOutOrMadeWritable;
			TArray<UPackage*> PackagesNotNeedingCheckout;
			bUserAcceptedCheckout = FEditorFileUtils::PromptToCheckoutPackages( false, InOutReferencingPackagesToSave, &PackagesCheckedOutOrMadeWritable, &PackagesNotNeedingCheckout );
			if ( bUserAcceptedCheckout )
			{
				TArray<UPackage*> PackagesThatCouldNotBeCheckedOut = InOutReferencingPackagesToSave;

				for ( auto PackageIt = PackagesCheckedOutOrMadeWritable.CreateConstIterator(); PackageIt; ++PackageIt )
				{
					PackagesThatCouldNotBeCheckedOut.Remove(*PackageIt);
				}

				for ( auto PackageIt = PackagesNotNeedingCheckout.CreateConstIterator(); PackageIt; ++PackageIt )
				{
					PackagesThatCouldNotBeCheckedOut.Remove(*PackageIt);
				}

				for ( auto PackageIt = PackagesThatCouldNotBeCheckedOut.CreateConstIterator(); PackageIt; ++PackageIt )
				{
					const FName NonCheckedOutPackageName = (*PackageIt)->GetFName();

					for ( auto RedirectorRefsIt = RedirectorsToFix.CreateIterator(); RedirectorRefsIt; ++RedirectorRefsIt )
					{
						FRedirectorRefs& RedirectorRefs = *RedirectorRefsIt;
						if ( RedirectorRefs.ReferencingPackageNames.Contains(NonCheckedOutPackageName) )
						{
							// We did not check out at least one of the packages we needed to. This redirector can not be fixed up.
							RedirectorRefs.FailureReason = FText::Format(LOCTEXT("RedirectorFixupFailed_NotCheckedOut", "Referencing package {0} was not checked out"), FText::FromName(NonCheckedOutPackageName));
							RedirectorRefs.bRedirectorValidForFixup = false;
						}
					}

					InOutReferencingPackagesToSave.Remove(*PackageIt);
				}
			}
		}
	}

	return bUserAcceptedCheckout;
}
Example #3
0
	void Unbind(UJavascriptDelegate* DelegateObject)
	{
		static FName NAME_Fire("Fire");

		if (WeakObject.IsValid())
		{
			if (auto p = Cast<UMulticastDelegateProperty>(Property))
			{
				FScriptDelegate Delegate;
				Delegate.BindUFunction(DelegateObject, NAME_Fire);

				auto Target = p->GetPropertyValuePtr_InContainer(WeakObject.Get());
				Target->Remove(Delegate);
			}
			else if (auto p = Cast<UDelegateProperty>(Property))
			{
				auto Target = p->GetPropertyValuePtr_InContainer(WeakObject.Get());
				Target->Clear();
			}
		}

		DelegateObject->JavascriptDelegate = nullptr;
		DelegateObject->RemoveFromRoot();
		DelegateObjects.Remove(DelegateObject);

		if (!bAbandoned)
		{
			functions.Remove(DelegateObject->UniqueId);
		}
	}
void FSlateWindowHelper::ArrangeWindowToFront( TArray< TSharedRef<SWindow> >& Windows, const TSharedRef<SWindow>& WindowToBringToFront )
{
	Windows.Remove(WindowToBringToFront);

	if ((Windows.Num() == 0) || WindowToBringToFront->IsTopmostWindow())
	{
		Windows.Add(WindowToBringToFront);
	}
	else
	{
		bool PerformedInsert = false;

		for (int WindowIndex = Windows.Num() - 1; WindowIndex >= 0; --WindowIndex)
		{
			if (!Windows[WindowIndex]->IsTopmostWindow())
			{
				Windows.Insert(WindowToBringToFront, WindowIndex + 1);
				PerformedInsert = true;

				break;
			}
		}

		if (!PerformedInsert)
		{
			Windows.Insert(WindowToBringToFront, 0);
		}
	}
}
void FProfilerClientManager::Track( const TArray<ISessionInstanceInfoPtr>& Instances )
{
#if STATS
	if (MessageEndpoint.IsValid() && ActiveSessionId.IsValid())
	{
		TArray<FGuid> ActiveInstances;
		Connections.GenerateKeyArray(ActiveInstances);

		for (int32 i = 0; i < Instances.Num(); ++i)
		{
			if (Connections.Find(Instances[i]->GetInstanceId()) == nullptr)
			{
				Track(Instances[i]->GetInstanceId());
			}
			else
			{
				ActiveInstances.Remove(Instances[i]->GetInstanceId());
			}
		}

		for (int32 i = 0; i < ActiveInstances.Num(); ++i)
		{
			Untrack(ActiveInstances[i]);
		}
	}
#endif
}
void FPathContextMenu::ExecuteSCCOpenForAdd()
{
	ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();

	// Get a list of package names in the selected paths
	TArray<FString> PackageNames;
	GetPackageNamesInSelectedPaths(PackageNames);

	TArray<FString> PackagesToAdd;
	TArray<UPackage*> PackagesToSave;
	for ( auto PackageIt = PackageNames.CreateConstIterator(); PackageIt; ++PackageIt )
	{
		FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(SourceControlHelpers::PackageFilename(*PackageIt), EStateCacheUsage::Use);
		if ( SourceControlState.IsValid() && !SourceControlState->IsSourceControlled() )
		{
			PackagesToAdd.Add(*PackageIt);

			// Make sure the file actually exists on disk before adding it
			FString Filename;
			if ( !FPackageName::DoesPackageExist(*PackageIt, NULL, &Filename) )
			{
				UPackage* Package = FindPackage(NULL, **PackageIt);
				if ( Package )
				{
					PackagesToSave.Add(Package);
				}
			}
		}
	}

	if ( PackagesToAdd.Num() > 0 )
	{
		// If any of the packages are new, save them now
		if ( PackagesToSave.Num() > 0 )
		{
			const bool bCheckDirty = false;
			const bool bPromptToSave = false;
			TArray<UPackage*> FailedPackages;
			const FEditorFileUtils::EPromptReturnCode Return = FEditorFileUtils::PromptForCheckoutAndSave(PackagesToSave, bCheckDirty, bPromptToSave, &FailedPackages);
			if(FailedPackages.Num() > 0)
			{
				// don't try and add files that failed to save - remove them from the list
				for(auto FailedPackageIt = FailedPackages.CreateConstIterator(); FailedPackageIt; FailedPackageIt++)
				{
					PackagesToAdd.Remove((*FailedPackageIt)->GetName());
				}
			}
		}

		if ( PackagesToAdd.Num() > 0 )
		{
			SourceControlProvider.Execute(ISourceControlOperation::Create<FMarkForAdd>(), SourceControlHelpers::PackageFilenames(PackagesToAdd));
		}
	}
}
void FSlateWindowHelper::RemoveWindowFromList( TArray<TSharedRef<SWindow>>& Windows, const TSharedRef<SWindow>& WindowToRemove )
{
	int32 NumRemoved = Windows.Remove(WindowToRemove);

	if (NumRemoved == 0)
	{
		for (int32 ChildIndex=0; ChildIndex < Windows.Num(); ++ChildIndex)
		{
			RemoveWindowFromList(Windows[ChildIndex]->GetChildWindows(), WindowToRemove) ;
		}	
	}
}
Example #8
0
void AGroupActor::RemoveSubGroupsFromArray(TArray<AGroupActor*>& GroupArray)
{
	for(int32 GroupIndex=0; GroupIndex<GroupArray.Num(); ++GroupIndex)
	{
		AGroupActor* GroupToCheck = GroupArray[GroupIndex];
		if(GroupHasParentInArray(GroupToCheck, GroupArray))
		{
			GroupArray.Remove(GroupToCheck);
			--GroupIndex;
		}
	}
}
Example #9
0
	// This will remove a previously inserted mount point
	void RemoveMountPoint(const FString& RootPath, const FString& ContentPath)
	{
		// Make sure the content path is stored as a relative path, consistent with the other paths we have
		FString RelativeContentPath = IFileManager::Get().ConvertToRelativePath(*ContentPath);

		// Make sure the path ends in a trailing path separator.  We are expecting that in the InternalFilenameToLongPackageName code.
		if (!RelativeContentPath.EndsWith(TEXT("/")))
		{
			RelativeContentPath += TEXT("/");
		}

		if ( MountPointRootPaths.Remove(RootPath) > 0 )
		{
			FPathPair Pair(RootPath, RelativeContentPath);
			ContentRootToPath.Remove(Pair);
			ContentPathToRoot.Remove(Pair);
			MountPointRootPaths.Remove(RootPath);

			// Let subscribers know that a new content path was mounted
			FPackageName::OnContentPathDismounted().Broadcast( RootPath, ContentPath );
		}
	}
Example #10
0
void NUTNet::MarkUnitTestWorldForCleanup(UWorld* CleanupWorld, bool bImmediate/*=false*/)
{
	UnitTestWorlds.Remove(CleanupWorld);
	PendingUnitWorldCleanup.Add(CleanupWorld);

	if (!bImmediate)
	{
		GEngine->DeferredCommands.AddUnique(TEXT("CleanupUnitTestWorlds"));
	}
	else
	{
		CleanupUnitTestWorlds();
	}
}
Example #11
0
void ASensor::OnEndOverlap(class AActor* otherActor) {
	inMotionRange.Remove(otherActor); /* Remove otherActor from motion tracking */
	//UE_LOG(LogNet, Log, TEXT("%s: Someone left (%s)"), *(this->GetName()), *(otherActor->GetName()));
	if (!active) return;
	fbb.Clear();
	UnrealCoojaMsg::MessageBuilder msg(fbb);

	msg.add_id(ID);
	msg.add_type(UnrealCoojaMsg::MsgType_PIR);
	//msg.add_pir()
	auto mloc = msg.Finish();
	fbb.Finish(mloc);

	int sent = 0;
	bool successful = socket->SendTo(fbb.GetBufferPointer(), fbb.GetSize(),
										 sent, *addr);
  active = false;
	//UE_LOG(LogNet, Log, TEXT("Send to %s: %i-%i"), *(addr->ToString(true)), successful, sent);
}
	/**
	 * Checks whether the file was completed during last install attempt and adds it to FilesCompleted if so
	 * @param Filename    The filename to check
	 */
	void CheckFile( const FString& Filename )
	{
		// If we had resume data, check file size is correct
		if( bHasResumeData && FilesStarted.Contains( Filename ) )
		{
			const FString FullFilename = StagingDir / Filename;
			const int64 DiskFileSize = IFileManager::Get().FileSize( *FullFilename );
			const int64 CompleteFileSize = BuildManifest->GetFileSize( Filename );
			if( DiskFileSize == CompleteFileSize )
			{
				FilesCompleted.Add( Filename );
			}
			// Sanity check, if file is larger than we expect, that's bad
			else if( DiskFileSize > CompleteFileSize )
			{
				FilesStarted.Remove( Filename );
			}
		}
	}
	static void CleanAndSanitizeStruct(UUserDefinedStruct* StructToClean)
	{
		check(StructToClean);

		if (auto EditorData = Cast<UUserDefinedStructEditorData>(StructToClean->EditorData))
		{
			EditorData->CleanDefaultInstance();
		}

		const FString TransientString = FString::Printf(TEXT("TRASHSTRUCT_%s"), *StructToClean->GetName());
		const FName TransientName = MakeUniqueObjectName(GetTransientPackage(), UUserDefinedStruct::StaticClass(), FName(*TransientString));
		UUserDefinedStruct* TransientStruct = NewObject<UUserDefinedStruct>(GetTransientPackage(), TransientName, RF_Public | RF_Transient);

		TArray<UObject*> SubObjects;
		GetObjectsWithOuter(StructToClean, SubObjects, true);
		SubObjects.Remove(StructToClean->EditorData);
		for( auto SubObjIt = SubObjects.CreateIterator(); SubObjIt; ++SubObjIt )
		{
			UObject* CurrSubObj = *SubObjIt;
			CurrSubObj->Rename(NULL, TransientStruct, REN_DontCreateRedirectors);
			if( UProperty* Prop = Cast<UProperty>(CurrSubObj) )
			{
				FKismetCompilerUtilities::InvalidatePropertyExport(Prop);
			}
			else
			{
				FLinkerLoad::InvalidateExport(CurrSubObj);
			}
		}

		StructToClean->SetSuperStruct(NULL);
		StructToClean->Children = NULL;
		StructToClean->Script.Empty();
		StructToClean->MinAlignment = 0;
		StructToClean->RefLink = NULL;
		StructToClean->PropertyLink = NULL;
		StructToClean->DestructorLink = NULL;
		StructToClean->ScriptObjectReferences.Empty();
		StructToClean->PropertyLink = NULL;
		StructToClean->ErrorMessage.Empty();
	}
Example #14
0
void FProjectManager::GetEnabledPlugins(TArray<FString>& OutPluginNames) const
{
	// Get the default list of plugin names
	GetDefaultEnabledPlugins(OutPluginNames, true);

	// Modify that with the list of plugins in the project file
	const FProjectDescriptor *Project = GetCurrentProject();
	if(Project != NULL)
	{
		for(const FPluginReferenceDescriptor& Plugin: Project->Plugins)
		{
			if(Plugin.IsEnabledForPlatform(FPlatformMisc::GetUBTPlatform()))
			{
				OutPluginNames.AddUnique(Plugin.Name);
			}
			else
			{
				OutPluginNames.Remove(Plugin.Name);
			}
		}
	}
}
void UDeviceProfileManager::InitializeCVarsForActiveDeviceProfile()
{
	// Find the device profile selector module used in this instance
	FString DeviceProfileSelectionModule;
	GConfig->GetString( TEXT("DeviceProfileManager"), TEXT("DeviceProfileSelectionModule"), DeviceProfileSelectionModule, GEngineIni );

	FString SelectedPlatformDeviceProfileName = GetActiveProfileName();
	UE_LOG(LogInit, Log, TEXT("Applying CVar settings loaded from the selected device profile: [%s]"), *SelectedPlatformDeviceProfileName);

	// Load the device profile config
	FConfigCacheIni::LoadGlobalIniFile(DeviceProfileFileName, TEXT("DeviceProfiles"));

	TArray< FString > AvailableProfiles;
	GConfig->GetSectionNames( DeviceProfileFileName, AvailableProfiles );

	// Look up the ini for this tree as we are far too early to use the UObject system
	AvailableProfiles.Remove( TEXT( "DeviceProfiles" ) );

	// Next we need to create a hierarchy of CVars from the Selected Device Profile, to it's eldest parent
	TMap<FString, FString> CVarsAlreadySetList;
	
	// For each device profile, starting with the selected and working our way up the BaseProfileName tree,
	// Find all CVars and set them 
	FString BaseDeviceProfileName = SelectedPlatformDeviceProfileName;
	bool bReachedEndOfTree = BaseDeviceProfileName.IsEmpty();
	while( bReachedEndOfTree == false ) 
	{
		FString CurrentSectionName = FString::Printf( TEXT("%s %s"), *BaseDeviceProfileName, *UDeviceProfile::StaticClass()->GetName() );
		
		// Check the profile was available.
		bool bProfileExists = AvailableProfiles.Contains( CurrentSectionName );
		if( bProfileExists )
		{
			TArray< FString > CurrentProfilesCVars;
			GConfig->GetArray( *CurrentSectionName, TEXT("CVars"), CurrentProfilesCVars, DeviceProfileFileName );

			// Iterate over the profile and make sure we do not have duplicate CVars
			{
				TMap< FString, FString > ValidCVars;
				for( TArray< FString >::TConstIterator CVarIt(CurrentProfilesCVars); CVarIt; ++CVarIt )
				{
					FString CVarKey, CVarValue;
					if( (*CVarIt).Split( TEXT("="), &CVarKey, &CVarValue ) )
					{
						if( ValidCVars.Find( CVarKey ) )
						{
							ValidCVars.Remove( CVarKey );
						}

						ValidCVars.Add( CVarKey, CVarValue );
					}
				}
				
				// Empty the current list, and replace with the processed CVars. This removes duplicates
				CurrentProfilesCVars.Empty();

				for( TMap< FString, FString >::TConstIterator ProcessedCVarIt(ValidCVars); ProcessedCVarIt; ++ProcessedCVarIt )
				{
					CurrentProfilesCVars.Add( FString::Printf( TEXT("%s=%s"), *ProcessedCVarIt.Key(), *ProcessedCVarIt.Value() ) );
				}

			}

			// Iterate over this profiles cvars and set them if they haven't been already.
			for( TArray< FString >::TConstIterator CVarIt(CurrentProfilesCVars); CVarIt; ++CVarIt )
			{
				FString CVarKey, CVarValue;
				if( (*CVarIt).Split( TEXT("="), &CVarKey, &CVarValue ) )
				{
					if( !CVarsAlreadySetList.Find( CVarKey ) )
					{
						IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(*CVarKey);
						if( CVar )
						{
							UE_LOG(LogInit, Log, TEXT("Setting Device Profile CVar: [[%s:%s]]"), *CVarKey, *CVarValue);
							CVar->Set( *CVarValue, ECVF_SetByDeviceProfile);
							CVarsAlreadySetList.Add( CVarKey, CVarValue );
						}
						else
						{
							UE_LOG(LogInit, Warning, TEXT("Failed to find a registered CVar that matches the key: [%s]"), *CVarKey);
						}
					}
				}
			}

			// Get the next device profile name, to look for CVars in, along the tree
			FString NextBaseDeviceProfileName;
			if( GConfig->GetString( *CurrentSectionName, TEXT("BaseProfileName"), NextBaseDeviceProfileName, DeviceProfileFileName ) )
			{
				BaseDeviceProfileName = NextBaseDeviceProfileName;
			}
			else
			{
				BaseDeviceProfileName.Empty();
			}
		}
		
		// Check if we have inevitably reached the end of the device profile tree.
		bReachedEndOfTree = !bProfileExists || BaseDeviceProfileName.IsEmpty();
	}
}
Example #16
0
void UKUIInterfaceElement::CalculateAlignLocation( TArray<UKUIInterfaceElement*>& arAlignStack )
{
	if ( HasValidAlignLocation() )
		return;

	// Avoid recursive layout dependencies.
	if ( arAlignStack.Contains( this ) )
		return;

	if ( GetContainer() != NULL && GetContainer()->IsChildsLayoutManaged( this ) )
	{
		//SetAlignLocation( FVector2D::ZeroVector );

		// Caused circular layout dependencies.
		//if ( !GetContainer()->HasValidLayout() )
			//GetContainer()->DoLayout();

		return;
	}

	UKUIInterfaceElement* oAlignedTo = GetAlignedTo();

	if ( oAlignedTo == NULL )
		oAlignedTo = GetContainer();

	if ( oAlignedTo == NULL )
	{
		SetAlignLocation( FVector2D::ZeroVector );
		return;
	}

	arAlignStack.Add( this );

	if ( !oAlignedTo->HasValidAlignLocation() )
		oAlignedTo->CalculateAlignLocation( arAlignStack );

	const FVector2D v2Size = GetSize() + GetMarginSize();
	FVector2D v2AlignLocation = FVector2D::ZeroVector;
	FVector2D v2AlignSize = FVector2D::ZeroVector;
	FVector2D v2AlignRenderLocation = FVector2D::ZeroVector;

	// If we're aligned to something in this container, use local space
	if ( oAlignedTo->GetContainer() == GetContainer() )	
	{
		v2AlignRenderLocation = oAlignedTo->GetRenderLocation() - oAlignedTo->GetMarginOffset();
		v2AlignSize = oAlignedTo->GetSize() + oAlignedTo->GetMarginSize();
	}

	// If we're aligned to something outside our container, use its screen location
	else if ( oAlignedTo != GetContainer() )
	{
		v2AlignRenderLocation = oAlignedTo->GetScreenLocation() - oAlignedTo->GetMarginOffset();
		v2AlignSize = oAlignedTo->GetSize() + oAlignedTo->GetMarginSize();
	}

	// We're aligned to the container, so use 0, 0
	else
	{
		v2AlignRenderLocation = FVector2D::ZeroVector;
		v2AlignSize = oAlignedTo->GetSize();
	}

	v2AlignLocation = CalculateAlignLocation( 
		v2AlignRenderLocation, 
		v2AlignSize, 
		v2Size
	);

	// If we're aligned to something outside of our container, move the align location back into local space.
	if ( oAlignedTo != GetContainer() && oAlignedTo->GetContainer() != GetContainer() )
		v2AlignLocation += oAlignedTo->GetScreenLocation() - GetContainer()->GetScreenLocation();

	arAlignStack.Remove( this );
	SetAlignLocation( v2AlignLocation );
}
Example #17
0
	void GenerateOutput(UWorld* InWorld, int32 Depth, bool bShowDefault, bool bShowScript)
	{
		auto PrintLogTimes = GPrintLogTimes;

		// Create log file
		
		const FString PathName = *(FPaths::GameLogDir() + TEXT("RefInfo/"));
		IFileManager::Get().MakeDirectory(*PathName);
		const FString Filename = FString::Printf(TEXT("Output-%s.txt"), *FDateTime::Now().ToString(TEXT("%m.%d-%H.%M.%S")));
		const FString FilenameFull = PathName + Filename;
		FOutputDeviceFile FileAr(*FilenameFull);
		
		FileAr.SetSuppressEventTag(true);
		GPrintLogTimes = ELogTimes::None;

		// Set up our ignore lists

		IgnoreClasses.Empty();
		IgnorePackages.Empty();

		IgnoreClasses.Add(ULevel::StaticClass());
		IgnoreClasses.Add(UWorld::StaticClass());

		// Load the asset registry module
		FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));

		TArray<FAssetData> AssetData;
		FARFilter Filter;
		Filter.PackagePaths.Add(FName(TEXT("/Engine/EngineResources")));
		Filter.PackagePaths.Add(FName(TEXT("/Engine/EngineFonts")));
		Filter.PackagePaths.Add(FName(TEXT("/Engine/EngineMaterials")));
		Filter.PackagePaths.Add(FName(TEXT("/Engine/EditorResources")));
		Filter.PackagePaths.Add(FName(TEXT("/Engine/EditorMaterials")));

		AssetRegistryModule.Get().GetAssets(Filter, AssetData);

		for (int32 AssetIdx = 0; AssetIdx < AssetData.Num(); ++AssetIdx)
		{
			IgnorePackages.Add(FindObject<UPackage>(NULL, *AssetData[AssetIdx].PackageName.ToString(), true));
		}

		IgnorePackages.Add(GetTransientPackage());

		// Bug?  At this point IgnorePackages often has a handful of null entries, which, completely throws off the filtering process
		IgnorePackages.Remove(NULL);

		// Generate reference info

		BuildAssetList(InWorld, Depth, bShowDefault, bShowScript);

		// Output reference info

		OutputTree(FileAr);

		OutputDetails(FileAr);

		FileAr.TearDown();

		GPrintLogTimes = PrintLogTimes;

		// Display "completed" popup

		FString AbsPath = FilenameFull;
		FPaths::ConvertRelativePathToFull(AbsPath);
		FFormatNamedArguments Args;
		Args.Add( TEXT("AbsolutePath"), FText::FromString( AbsPath ) );
		FNotificationInfo Info( FText::Format( NSLOCTEXT("UnrealEd", "ReferenceInfoSavedNotification", "Reference info was successfully saved to: {AbsolutePath}"), Args ) );
		Info.ExpireDuration = 3.0f;
		FSlateNotificationManager::Get().AddNotification(Info);
	}
bool FDesktopPlatformBase::EnumerateProjectsKnownByEngine(const FString &Identifier, bool bIncludeNativeProjects, TArray<FString> &OutProjectFileNames)
{
	// Get the engine root directory
	FString RootDir;
	if (!GetEngineRootDirFromIdentifier(Identifier, RootDir))
	{
		return false;
	}

	FString GameAgnosticConfigDir = GetEngineSavedConfigDirectory(Identifier);

	if (GameAgnosticConfigDir.Len() == 0)
	{
		return false;
	}

	// Find all the created project directories. Start with the default project creation path.
	TArray<FString> SearchDirectories;
	SearchDirectories.AddUnique(GetDefaultProjectCreationPath());

	// Load the config file
	FConfigFile GameAgnosticConfig;
	FConfigCacheIni::LoadExternalIniFile(GameAgnosticConfig, TEXT("EditorSettings"), NULL, *GameAgnosticConfigDir, false);

	// Find the editor game-agnostic settings
	FConfigSection* Section = GameAgnosticConfig.Find(TEXT("/Script/UnrealEd.EditorSettings"));

	if (Section == NULL)
	{
		FConfigCacheIni::LoadExternalIniFile(GameAgnosticConfig, TEXT("EditorGameAgnostic"), NULL, *GameAgnosticConfigDir, false);
		Section = GameAgnosticConfig.Find(TEXT("/Script/UnrealEd.EditorGameAgnosticSettings"));
	}

	if(Section != NULL)
	{
		// Add in every path that the user has ever created a project file. This is to catch new projects showing up in the user's project folders
		TArray<FString> AdditionalDirectories;
		Section->MultiFind(TEXT("CreatedProjectPaths"), AdditionalDirectories);
		for(int Idx = 0; Idx < AdditionalDirectories.Num(); Idx++)
		{
			FPaths::NormalizeDirectoryName(AdditionalDirectories[Idx]);
			SearchDirectories.AddUnique(AdditionalDirectories[Idx]);
		}

		// Also add in all the recently opened projects
		TArray<FString> RecentlyOpenedFiles;
		Section->MultiFind(TEXT("RecentlyOpenedProjectFiles"), RecentlyOpenedFiles);
		for(int Idx = 0; Idx < RecentlyOpenedFiles.Num(); Idx++)
		{
			FPaths::NormalizeFilename(RecentlyOpenedFiles[Idx]);
			OutProjectFileNames.AddUnique(RecentlyOpenedFiles[Idx]);
		}		
	}

	// Find all the other projects that are in the search directories
	for(int Idx = 0; Idx < SearchDirectories.Num(); Idx++)
	{
		TArray<FString> ProjectFolders;
		IFileManager::Get().FindFiles(ProjectFolders, *(SearchDirectories[Idx] / TEXT("*")), false, true);

		for(int32 FolderIdx = 0; FolderIdx < ProjectFolders.Num(); FolderIdx++)
		{
			TArray<FString> ProjectFiles;
			IFileManager::Get().FindFiles(ProjectFiles, *(SearchDirectories[Idx] / ProjectFolders[FolderIdx] / TEXT("*.uproject")), true, false);

			for(int32 FileIdx = 0; FileIdx < ProjectFiles.Num(); FileIdx++)
			{
				OutProjectFileNames.AddUnique(SearchDirectories[Idx] / ProjectFolders[FolderIdx] / ProjectFiles[FileIdx]);
			}
		}
	}

	// Find all the native projects, and either add or remove them from the list depending on whether we want native projects
	const FUProjectDictionary &Dictionary = GetCachedProjectDictionary(RootDir);
	if(bIncludeNativeProjects)
	{
		TArray<FString> NativeProjectPaths = Dictionary.GetProjectPaths();
		for(int Idx = 0; Idx < NativeProjectPaths.Num(); Idx++)
		{
			if(!NativeProjectPaths[Idx].Contains(TEXT("/Templates/")))
			{
				OutProjectFileNames.AddUnique(NativeProjectPaths[Idx]);
			}
		}
	}
	else
	{
		TArray<FString> NativeProjectPaths = Dictionary.GetProjectPaths();
		for(int Idx = 0; Idx < NativeProjectPaths.Num(); Idx++)
		{
			OutProjectFileNames.Remove(NativeProjectPaths[Idx]);
		}
	}

	return true;
}
void ADEPRECATED_VolumeAdaptiveBuilder::BuildNAVNetwork()
{	
	NavGraph.nodes = TMap<UDoNNavigationVolumeComponent*, TArray<UDoNNavigationVolumeComponent*>>();
	
	for (auto Iter(NAVVolumeComponents.CreateIterator()); Iter; Iter++)
	{
		if (!Iter)
			continue;

		UDoNNavigationVolumeComponent* volume = (*Iter);		
		TArray<UPrimitiveComponent*> neighboringVolumeComponents;	

		volume->UpdateBounds(); // GetBoxExtrema functions return outdated values unless this is called after a volume has grown to desired size
		volume->CanNavigate = true;
		volume->ShapeColor = FColor::Green;		

		FVector originalBoxExtent = volume->GetUnscaledBoxExtent();		
		volume->SetBoxExtent(FVector(originalBoxExtent.X + XBaseUnit / 2, originalBoxExtent.Y + YBaseUnit / 2, originalBoxExtent.Z + ZBaseUnit/2));		
		UKismetSystemLibrary::ComponentOverlapComponents_NEW(volume, volume->GetComponentTransform(), NAVOverlapQuery, UDoNNavigationVolumeComponent::StaticClass(), ActorsToIgnoreForCollision, neighboringVolumeComponents);
		volume->SetBoxExtent(originalBoxExtent);		

		neighboringVolumeComponents.Remove(volume);
		volume->UpdateBounds();

		TArray<UDoNNavigationVolumeComponent*> neighbors;
		for (UPrimitiveComponent* neighbor : neighboringVolumeComponents)
		{
			neighbor->UpdateBounds();
			
			bool overlapsX = VolumesOverlapAxis2(volume->Bounds.GetBoxExtrema(0).X, volume->Bounds.GetBoxExtrema(1).X, neighbor->Bounds.GetBoxExtrema(0).X, neighbor->Bounds.GetBoxExtrema(1).X);
			bool overlapsY = VolumesOverlapAxis2(volume->Bounds.GetBoxExtrema(0).Y, volume->Bounds.GetBoxExtrema(1).Y, neighbor->Bounds.GetBoxExtrema(0).Y, neighbor->Bounds.GetBoxExtrema(1).Y);
			bool overlapsZ = VolumesOverlapAxis2(volume->Bounds.GetBoxExtrema(0).Z, volume->Bounds.GetBoxExtrema(1).Z, neighbor->Bounds.GetBoxExtrema(0).Z, neighbor->Bounds.GetBoxExtrema(1).Z);
			bool pathExists = (overlapsX && overlapsY) || (overlapsY && overlapsZ) || (overlapsZ && overlapsX);
			if (!pathExists)
				continue;				

			neighbors.Add(Cast<UDoNNavigationVolumeComponent>(neighbor));

			if (DisplayNAVNeighborGraph)
			{
				DrawDebugPoint(GetWorld(), volume->GetComponentLocation(), 10.f, FColor::Blue, true);
				DrawDebugLine(GetWorld(), volume->GetComponentLocation(), neighbor->GetComponentLocation(), FColor::Red, true, -1.f, 0, 4.f);
				
				/*if (volume->X == 88 && volume->Y == 169 && volume->Z == 7)
				{					
					volume->ShapeColor = FColor::Red;
					Cast<UDoNNavigationVolumeComponent>(neighbor)->ShapeColor = FColor::Blue;
				}*/

				volume->SetVisibility(true);
				neighbor->SetVisibility(true);
				
			}
		}			

		NavGraph.nodes.Add((*Iter), neighbors);

		// [Old code] Special workaround for persisting UObject volumes onto a UMAP. Not applicable for pixel builders ATM
		FNAVMapContainer NAVMapContainer;
		NAVMapContainer.volume = volume;
		NAVMapContainer.neighbors = neighbors;
		NavGraph_GCSafe.Add(NAVMapContainer);		
	}
}
bool ADEPRECATED_VolumeAdaptiveBuilder::GrowNAVVolumeByIndex(UDoNNavigationVolumeComponent* volume, int32 XGrowth, int32 YGrowth, int32 ZGrowth)
{	
	bool infantVolume = XGrowth == 1 && ZGrowth == 1 && YGrowth == 1;

	float xBoxExtent = (XGrowth * XBaseUnit + (XGrowth - 1)*OffsetThickness) / 2;
	float yBoxExtent = (YGrowth * YBaseUnit + (YGrowth - 1)*OffsetThickness) / 2;
	float zBoxExtent = (ZGrowth * ZBaseUnit + (ZGrowth - 1)*OffsetThickness) / 2;

	float x = xBoxExtent + (XBaseUnit + OffsetThickness) * volume->X + GetActorLocation().X;
	float y = yBoxExtent + (YBaseUnit + OffsetThickness) * volume->Y + GetActorLocation().Y;	
	float z = zBoxExtent + (ZBaseUnit + OffsetThickness) * (volume->Z + 1 - ZGrowth) + GetActorLocation().Z;
	
	FVector originalWorldLocation = volume->GetComponentLocation();
	FVector originalBoxExtent = volume->GetUnscaledBoxExtent();		
	volume->SetWorldLocation(FVector(x, y, z));
	volume->SetBoxExtent(FVector(xBoxExtent, yBoxExtent, zBoxExtent));

	TArray<UPrimitiveComponent*> obstacles;	
	UKismetSystemLibrary::ComponentOverlapComponents_NEW(volume, volume->GetComponentTransform(), ObstacleList, NULL, ActorsToIgnoreForCollision, obstacles);

	if (obstacles.Num() > 0)
	{
		if (infantVolume)
		{
			/*volume->CanNavigate = false;volume->ShapeColor = FColor::Red;*/
			NAVVolumeComponents.Remove(volume);
			volume->DestroyComponent();

			return false;
		}
		else
		{
			volume->SetWorldLocation(originalWorldLocation);
			volume->SetBoxExtent(originalBoxExtent);
		}

		return false;
	}
	else
	{
		TArray<UPrimitiveComponent*> neighboringVolumeComponents;		
		UKismetSystemLibrary::ComponentOverlapComponents_NEW(volume, volume->GetComponentTransform(), NAVOverlapQuery, UDoNNavigationVolumeComponent::StaticClass(), ActorsToIgnoreForCollision, neighboringVolumeComponents);
		neighboringVolumeComponents.Remove(volume);		

		if (neighboringVolumeComponents.Num() > 0)
		{
			if (infantVolume)
			{
				// Seed has landed on existing volume, destroy it immediately
				NAVVolumeComponents.Remove(volume);
				volume->DestroyComponent();

				return false;
			}
			else
			{
				volume->SetWorldLocation(originalWorldLocation);
				volume->SetBoxExtent(originalBoxExtent);
			}

			return false;
		}
		else
		{
			volume->UpdateBounds();
			return true;
		}
			
	}
	
}
Example #21
0
/** Get array of UProperties that corresponds to columns in the table */
TArray<UProperty*> UDataTable::GetTablePropertyArray(const TArray<const TCHAR*>& Cells, UStruct* InRowStruct, TArray<FString>& OutProblems)
{
    TArray<UProperty*> ColumnProps;

    // Get list of all expected properties from the struct
    TArray<FName> ExpectedPropNames = DataTableUtils::GetStructPropertyNames(InRowStruct);

    // Need at least 2 columns, first column is skipped, will contain row names
    if(Cells.Num() > 1)
    {
        ColumnProps.AddZeroed( Cells.Num() );

        // first element always NULL - as first column is row names

        for (int32 ColIdx = 1; ColIdx < Cells.Num(); ++ColIdx)
        {
            const TCHAR* ColumnValue = Cells[ColIdx];

            FName PropName = DataTableUtils::MakeValidName(ColumnValue);
            if(PropName == NAME_None)
            {
                OutProblems.Add(FString::Printf(TEXT("Missing name for column %d."), ColIdx));
            }
            else
            {
                UProperty* ColumnProp = FindField<UProperty>(InRowStruct, PropName);

                for (TFieldIterator<UProperty> It(InRowStruct); It && !ColumnProp; ++It)
                {
                    const auto DisplayName = DataTableUtils::GetPropertyDisplayName(*It, FString());
                    ColumnProp = (!DisplayName.IsEmpty() && DisplayName == ColumnValue) ? *It : NULL;
                }

                // Didn't find a property with this name, problem..
                if(ColumnProp == NULL)
                {
                    OutProblems.Add(FString::Printf(TEXT("Cannot find Property for column '%s' in struct '%s'."), *PropName.ToString(), *InRowStruct->GetName()));
                }
                // Found one!
                else
                {
                    // Check we don't have this property already
                    if(ColumnProps.Contains(ColumnProp))
                    {
                        OutProblems.Add(FString::Printf(TEXT("Duplicate column '%s'."), *ColumnProp->GetName()));
                    }
                    // Check we support this property type
                    else if( !DataTableUtils::IsSupportedTableProperty(ColumnProp) )
                    {
                        OutProblems.Add(FString::Printf(TEXT("Unsupported Property type for struct member '%s'."), *ColumnProp->GetName()));
                    }
                    // Looks good, add to array
                    else
                    {
                        ColumnProps[ColIdx] = ColumnProp;
                    }

                    // Track that we found this one
                    ExpectedPropNames.Remove(ColumnProp->GetFName());
                }
            }
        }
    }

    // Generate warning for any properties in struct we are not filling in
    for(int32 PropIdx=0; PropIdx < ExpectedPropNames.Num(); PropIdx++)
    {
        const UProperty* const ColumnProp = FindField<UProperty>(InRowStruct, ExpectedPropNames[PropIdx]);
        const FString DisplayName = DataTableUtils::GetPropertyDisplayName(ColumnProp, ExpectedPropNames[PropIdx].ToString());
        OutProblems.Add(FString::Printf(TEXT("Expected column '%s' not found in input."), *DisplayName));
    }

    return ColumnProps;
}
void FStreamingWaveData::BeginPendingRequests(const TArray<uint32>& IndicesToLoad, const TArray<uint32>& IndicesToFree)
{
	if (UE_LOG_ACTIVE(LogAudio, Log) && IndicesToLoad.Num() > 0)
	{
		FString LogString = FString::Printf(TEXT("Requesting ASync load of chunk(s) %d"), IndicesToLoad[0]);
		for (int32 Index = 1; Index < IndicesToLoad.Num(); ++Index)
		{
			LogString += FString::Printf(TEXT(", %d"), IndicesToLoad[Index]);
		}
		LogString += FString::Printf(TEXT(" from SoundWave'%s'"), *SoundWave->GetName());
		UE_LOG(LogAudio, Log, TEXT("%s"), *LogString);
	}

	// Mark Chunks for removal in case they can be reused
	TArray<uint32> FreeChunkIndices;
	for (auto Index : IndicesToFree)
	{
		for (int32 ChunkIndex = 0; ChunkIndex < LoadedChunks.Num(); ++ChunkIndex)
		{
			if (LoadedChunks[ChunkIndex].Index == Index)
			{
				FreeChunkIndices.AddUnique(ChunkIndex);
				break;
			}
		}
	}

	if (IndicesToLoad.Num() > 0)
	{
		PendingChunkChangeRequestStatus.Set(AudioState_InProgress_Loading);

		// Set off all IO Requests
		for (auto Index : IndicesToLoad)
		{
			const FStreamedAudioChunk& Chunk = SoundWave->RunningPlatformData->Chunks[Index];
			int32 ChunkSize = Chunk.DataSize;

			FLoadedAudioChunk* ChunkStorage = NULL;

			for (auto FreeIndex : FreeChunkIndices)
			{
				if (LoadedChunks[FreeIndex].MemorySize >= ChunkSize)
				{
					FreeChunkIndices.Remove(FreeIndex);
					ChunkStorage = &LoadedChunks[FreeIndex];
					ChunkStorage->DataSize = ChunkSize;
					ChunkStorage->Index = Index;
					break;
				}
			}
			if (ChunkStorage == NULL)
			{
				ChunkStorage = AddNewLoadedChunk(ChunkSize);
				ChunkStorage->Index = Index;
			}

			// Pass the request on to the async io manager after increasing the request count. The request count 
			// has been pre-incremented before fielding the update request so we don't have to worry about file
			// I/O immediately completing and the game thread kicking off again before this function
			// returns.
			PendingChunkChangeRequestStatus.Increment();

			EAsyncIOPriority AsyncIOPriority = CurrentRequest.bPrioritiseRequest ? AIOP_BelowNormal : AIOP_Low;

			// Load and decompress async.
#if WITH_EDITORONLY_DATA
			if (Chunk.DerivedDataKey.IsEmpty() == false)
			{
				FAsyncStreamDerivedChunkTask* Task = new(PendingAsyncStreamDerivedChunkTasks)FAsyncStreamDerivedChunkTask(
					Chunk.DerivedDataKey,
					ChunkStorage->Data,
					ChunkSize,
					&PendingChunkChangeRequestStatus
					);
				Task->StartBackgroundTask();
			}
			else
#endif // #if WITH_EDITORONLY_DATA
			{
				check(Chunk.BulkData.GetFilename().Len());
				if (Chunk.BulkData.IsStoredCompressedOnDisk())
				{
					IORequestIndices.AddUnique(FIOSystem::Get().LoadCompressedData(
						Chunk.BulkData.GetFilename(),						// filename
						Chunk.BulkData.GetBulkDataOffsetInFile(),			// offset
						Chunk.BulkData.GetBulkDataSizeOnDisk(),				// compressed size
						Chunk.BulkData.GetBulkDataSize(),					// uncompressed size
						ChunkStorage->Data,									// dest pointer
						Chunk.BulkData.GetDecompressionFlags(),				// compressed data format
						&PendingChunkChangeRequestStatus,					// counter to decrement
						AsyncIOPriority										// priority
						)
						);
				}
				// Load async.
				else
				{
					IORequestIndices.AddUnique(FIOSystem::Get().LoadData(
						Chunk.BulkData.GetFilename(),						// filename
						Chunk.BulkData.GetBulkDataOffsetInFile(),			// offset
						Chunk.BulkData.GetBulkDataSize(),					// size
						ChunkStorage->Data,									// dest pointer
						&PendingChunkChangeRequestStatus,					// counter to decrement
						AsyncIOPriority										// priority
						)
						);
				}
				check(IORequestIndices[IORequestIndices.Num() - 1]);
			}
		}

		// Decrement the state to AudioState_InProgress_Loading + NumChunksCurrentLoading - 1.
		PendingChunkChangeRequestStatus.Decrement();
	}
	else
	{
		// Skip straight to finalisation
		PendingChunkChangeRequestStatus.Set(AudioState_ReadyFor_Finalization);
	}

	// Ensure indices are in order so we can step through backwards
	FreeChunkIndices.Sort();

	for (int32 FreeIndex = FreeChunkIndices.Num() - 1; FreeIndex >= 0; --FreeIndex)
	{
		FreeLoadedChunk(LoadedChunks[FreeChunkIndices[FreeIndex]]);
		LoadedChunks.RemoveAt(FreeChunkIndices[FreeIndex]);
	}
}