Files
BusyRabbit/Plugins/UnrealSharp/Source/UnrealSharpCore/CSNamespace.h
wyatt 648386cd73 Lua向C#逻辑迁移 一期 #13
将整个插件代码上传
2025-10-26 21:48:39 +08:00

48 lines
1.2 KiB
C++

#pragma once
struct FCSNamespace
{
FCSNamespace(FName InNamespace = NAME_None) : Namespace(InNamespace)
{
}
// Get the namespace as a FName
FName GetFName() const { return Namespace; }
// Get the namespace as a string
FString GetName() const { return Namespace.ToString(); }
// Gets the name of the last part of the namespace. For example, if the namespace is "UnrealSharp.Core", this will return "Core".
FString GetLastNamespace() const;
bool GetParentNamespace(FCSNamespace& OutParent) const;
bool IsValid() const { return Namespace != NAME_None; }
UPackage* GetPackage() const;
UPackage* TryGetAsNativePackage() const
{
FString NativePackageName = FString::Printf(TEXT("/Script/%s"), *GetLastNamespace());
return FindPackage(nullptr, *NativePackageName);
}
FName GetPackageName() const { return *FString::Printf(TEXT("/Script/%s"), *Namespace.ToString()); }
static FCSNamespace Invalid() { return FCSNamespace(); }
bool operator == (const FCSNamespace& Other) const
{
return Namespace == Other.Namespace;
}
friend uint32 GetTypeHash(const FCSNamespace& InNamespace)
{
return GetTypeHash(InNamespace.Namespace);
}
private:
FName Namespace;
};