You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb: none #fyi: Laurent.Delayen, Thomas.Sarkanen [CL 11088765 by Lina Halper in Main branch]
64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimationDataSource.h"
|
|
|
|
bool UAnimationDataSourceRegistry::RegisterDataSource(const FName& InName, UObject* InDataSource)
|
|
{
|
|
ClearInvalidDataSource();
|
|
|
|
if (DataSources.Contains(InName))
|
|
{
|
|
return false;
|
|
}
|
|
DataSources.Add(InName, InDataSource);
|
|
return true;
|
|
}
|
|
|
|
bool UAnimationDataSourceRegistry::UnregisterDataSource(const FName& InName)
|
|
{
|
|
ClearInvalidDataSource();
|
|
return DataSources.Remove(InName) > 0;
|
|
}
|
|
|
|
bool UAnimationDataSourceRegistry::ContainsSource(const FName& InName) const
|
|
{
|
|
return DataSources.Contains(InName);
|
|
}
|
|
|
|
UObject* UAnimationDataSourceRegistry::RequestSource(const FName& InName, UClass* InExpectedClass) const
|
|
{
|
|
TWeakObjectPtr<UObject> const* DataSource = DataSources.Find(InName);
|
|
if (DataSource == nullptr)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
UObject* DataSourcePtr = DataSource->Get();
|
|
if (!DataSourcePtr)
|
|
{
|
|
return nullptr;
|
|
}
|
|
if (!DataSourcePtr->IsA(InExpectedClass))
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
return DataSourcePtr;
|
|
}
|
|
|
|
void UAnimationDataSourceRegistry::ClearInvalidDataSource()
|
|
{
|
|
TArray<FName> InvalidNames;
|
|
for (auto Iter = DataSources.CreateIterator(); Iter; ++Iter)
|
|
{
|
|
if (!Iter.Value().IsValid())
|
|
{
|
|
InvalidNames.Add(Iter.Key());
|
|
}
|
|
}
|
|
|
|
for (const FName& NameToRemove : InvalidNames)
|
|
{
|
|
DataSources.Remove(NameToRemove);
|
|
}
|
|
} |