Files
Project-Reboot-3.0/Project Reboot 3.0/SoftObjectPtr.h
Milxnor 9be64d79ca Revert "alright im not so happy"
This reverts commit bd87832147.
2023-05-12 17:51:29 -04:00

60 lines
1.1 KiB
C++

#pragma once
#include "Object.h"
#include "PersistentObjectPtr.h"
#include "SoftObjectPath.h"
#include "AssetPtr.h"
#include "reboot.h"
struct FSoftObjectPtr : public TPersistentObjectPtr<FSoftObjectPath>
{
public:
};
template<class T = UObject>
struct TSoftObjectPtr
{
public:
FSoftObjectPtr SoftObjectPtr;
bool IsValid()
{
if (Engine_Version <= 416)
{
auto& AssetPtr = *(TAssetPtr<T>*)this;
return true;
}
else
{
return SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value;
}
}
T* Get(UClass* ClassToLoad = nullptr, bool bTryToLoad = false)
{
if (Engine_Version <= 416)
{
auto& AssetPtr = *(TAssetPtr<T>*)this;
return AssetPtr.Get();
}
else
{
if (SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value <= 0)
return nullptr;
if (bTryToLoad)
{
return LoadObject<T>(SoftObjectPtr.ObjectID.AssetPathName.ToString(), ClassToLoad);
}
return FindObject<T>(SoftObjectPtr.ObjectID.AssetPathName.ToString());
}
}
};
static inline int GetSoftObjectSize()
{
return Engine_Version == 416 ? sizeof(TAssetPtr<void>) : sizeof(TSoftObjectPtr<void>);
}