October3d55/M/BlobSerialization/Source/BlobSerializationEditor/Private/BlobSerializationTests.h

123 lines
2.4 KiB
C++

// Copyright (c) Samuel Kahn (samuel@kahncode.com). All Rights Reserved.
#pragma once
#include "BlobSerializationTests.generated.h"
UCLASS()
class UBlobSerializationTestClass : public UObject
{
GENERATED_BODY()
public:
UBlobSerializationTestClass()
: IntVariable(987654)
, FloatVariable(123.456)
, StringVariable("Hello World")
{
}
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(SaveGame, Replicated)
int IntVariable;
UPROPERTY(Replicated)
float FloatVariable;
UPROPERTY()
FString StringVariable;
bool operator==(const UBlobSerializationTestClass& Other) const
{
return IntVariable == Other.IntVariable && FloatVariable == Other.FloatVariable && StringVariable == Other.StringVariable;
}
};
UCLASS()
class UBlobSerializationTestClass2 : public UBlobSerializationTestClass
{
GENERATED_BODY()
public:
UPROPERTY()
bool BoolVariable;
bool operator==(const UBlobSerializationTestClass2& Other) const
{
return Super::operator==(Other) && BoolVariable == Other.BoolVariable;
}
};
USTRUCT()
struct FBlobSerializationTestStruct
{
GENERATED_BODY()
public:
FBlobSerializationTestStruct()
: IntVariable(987654)
, FloatVariable(123.456)
, StringVariable("Hello World")
{
}
UPROPERTY(SaveGame)
int IntVariable;
UPROPERTY()
float FloatVariable;
UPROPERTY(NotReplicated)
FString StringVariable;
bool operator==(const FBlobSerializationTestStruct& Other) const
{
return IntVariable == Other.IntVariable && FloatVariable == Other.FloatVariable && StringVariable == Other.StringVariable;
}
};
USTRUCT()
struct FBlobSerializationTestStruct2
{
GENERATED_BODY()
public:
FBlobSerializationTestStruct2()
: IntVariable(987654)
, FloatVariable(123.456)
, BoolVariable(false)
{
}
UPROPERTY()
int IntVariable;
UPROPERTY()
float FloatVariable;
UPROPERTY()
bool BoolVariable = false;
bool operator==(const FBlobSerializationTestStruct2& Other) const
{
return IntVariable == Other.IntVariable && FloatVariable == Other.FloatVariable && BoolVariable == Other.BoolVariable;
}
bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
{
Ar << IntVariable;
Ar << FloatVariable;
bOutSuccess = true;
return true;
}
};
template<>
struct TStructOpsTypeTraits<FBlobSerializationTestStruct2> : public TStructOpsTypeTraitsBase2<FBlobSerializationTestStruct2>
{
enum
{
WithNetSerializer = true,
};
};