Add network replication support for in-built object/asset reference holders

This commit is contained in:
Wojtek Figat
2023-07-03 13:06:08 +02:00
parent 9d640656e6
commit 544eb03f7e
3 changed files with 56 additions and 0 deletions

View File

@@ -159,6 +159,34 @@ public:
Read(ptr);
v = ptr;
}
template<typename T>
FORCE_INLINE void Read(SoftObjectReference<T>& v)
{
uint32 id[4];
ReadBytes(id, sizeof(id));
v.Set(*(Guid*)id);
}
template<typename T>
FORCE_INLINE void Read(AssetReference<T>& v)
{
uint32 id[4];
ReadBytes(id, sizeof(id));
v = (T*)::LoadAsset(*(Guid*)id, T::TypeInitializer);
}
template<typename T>
FORCE_INLINE void Read(WeakAssetReference<T>& v)
{
uint32 id[4];
ReadBytes(id, sizeof(id));
v = (T*)::LoadAsset(*(Guid*)id, T::TypeInitializer);
}
template<typename T>
FORCE_INLINE void Read(SoftAssetReference<T>& v)
{
uint32 id[4];
ReadBytes(id, sizeof(id));
v.Set(*(Guid*)id);
}
/// <summary>
/// Read data array

View File

@@ -17,6 +17,14 @@ class ISerializable;
class ScriptingObject;
template<typename T>
class ScriptingObjectReference;
template<typename T>
class SoftObjectReference;
template<typename T>
class AssetReference;
template<typename T>
class WeakAssetReference;
template<typename T>
class SoftAssetReference;
/// <summary>
/// Base class for all data streams (memory streams, file streams etc.)

View File

@@ -176,6 +176,26 @@ public:
{
Write(v.Get());
}
template<typename T>
FORCE_INLINE void Write(const SoftObjectReference<T>& v)
{
Write(v.Get());
}
template<typename T>
FORCE_INLINE void Write(const AssetReference<T>& v)
{
Write(v.Get());
}
template<typename T>
FORCE_INLINE void Write(const WeakAssetReference<T>& v)
{
Write(v.Get());
}
template<typename T>
FORCE_INLINE void Write(const SoftAssetReference<T>& v)
{
Write(v.Get());
}
template<typename T, typename AllocationType = HeapAllocation>
void Write(const Array<T, AllocationType>& data)