diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp index 1e1f81e09..f894b7417 100644 --- a/Source/Engine/Content/Content.cpp +++ b/Source/Engine/Content/Content.cpp @@ -2,6 +2,8 @@ #include "Content.h" #include "JsonAsset.h" +#include "SceneReference.h" +#include "Engine/Serialization/Serialization.h" #include "Cache/AssetsCache.h" #include "Storage/ContentStorageManager.h" #include "Storage/JsonStorageProxy.h" @@ -39,6 +41,16 @@ String AssetInfo::ToString() const return String::Format(TEXT("ID: {0}, TypeName: {1}, Path: \'{2}\'"), ID, TypeName, Path); } +void FLAXENGINE_API Serialization::Serialize(ISerializable::SerializeStream& stream, const SceneReference& v, const void* otherObj) +{ + Serialize(stream, v.ID, otherObj); +} + +void FLAXENGINE_API Serialization::Deserialize(ISerializable::DeserializeStream& stream, SceneReference& v, ISerializeModifier* modifier) +{ + Deserialize(stream, v.ID, modifier); +} + namespace { // Assets diff --git a/Source/Engine/Content/SceneReference.h b/Source/Engine/Content/SceneReference.h index c1e405f4e..50b24955d 100644 --- a/Source/Engine/Content/SceneReference.h +++ b/Source/Engine/Content/SceneReference.h @@ -1,8 +1,9 @@ -// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. +// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Types/Guid.h" +#include "Engine/Core/ISerializable.h" /// /// Represents the reference to the scene asset. Stores the unique ID of the scene to reference. Can be used to load the selected scene. @@ -15,4 +16,37 @@ API_STRUCT(NoDefault) struct FLAXENGINE_API SceneReference /// The identifier of the scene asset (and the scene object). /// API_FIELD() Guid ID; + + FORCE_INLINE bool operator==(const SceneReference& other) const + { + return ID == other.ID; + } + + FORCE_INLINE bool operator!=(const SceneReference& other) const + { + return ID != other.ID; + } }; + +template<> +struct TIsPODType +{ + enum { Value = true }; +}; + +inline uint32 GetHash(const SceneReference& key) +{ + return GetHash(key.ID); +} + +// @formatter:off +namespace Serialization +{ + inline bool ShouldSerialize(const SceneReference& v, const void* otherObj) + { + return !otherObj || v != *(SceneReference*)otherObj; + } + void FLAXENGINE_API Serialize(ISerializable::SerializeStream& stream, const SceneReference& v, const void* otherObj); + void FLAXENGINE_API Deserialize(ISerializable::DeserializeStream& stream, SceneReference& v, ISerializeModifier* modifier); +} +// @formatter:on