RealtimeStyleTransferRuntime/Source/LyraGame/Messages/LyraVerbMessageReplication.h

96 lines
2.4 KiB
C
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
2022-09-13 07:18:28 +00:00
#include "Containers/Array.h"
#include "Containers/ArrayView.h"
#include "Containers/Map.h"
#include "Containers/Set.h"
#include "Containers/SparseArray.h"
#include "Containers/UnrealString.h"
#include "HAL/Platform.h"
2022-05-23 18:41:30 +00:00
#include "LyraVerbMessage.h"
2022-09-13 07:18:28 +00:00
#include "Net/Serialization/FastArraySerializer.h"
#include "Templates/UnrealTemplate.h"
#include "UObject/Class.h"
2022-05-23 18:41:30 +00:00
#include "LyraVerbMessageReplication.generated.h"
2022-09-13 07:18:28 +00:00
class UObject;
2022-05-23 18:41:30 +00:00
struct FLyraVerbMessageReplication;
2022-09-13 07:18:28 +00:00
struct FNetDeltaSerializeInfo;
2022-05-23 18:41:30 +00:00
/**
* Represents one verb message
*/
USTRUCT(BlueprintType)
struct FLyraVerbMessageReplicationEntry : public FFastArraySerializerItem
{
GENERATED_BODY()
FLyraVerbMessageReplicationEntry()
{}
FLyraVerbMessageReplicationEntry(const FLyraVerbMessage& InMessage)
: Message(InMessage)
{
}
FString GetDebugString() const;
private:
friend FLyraVerbMessageReplication;
UPROPERTY()
FLyraVerbMessage Message;
};
/** Container of verb messages to replicate */
USTRUCT(BlueprintType)
struct FLyraVerbMessageReplication : public FFastArraySerializer
{
GENERATED_BODY()
FLyraVerbMessageReplication()
{
}
public:
void SetOwner(UObject* InOwner) { Owner = InOwner; }
// Broadcasts a message from server to clients
void AddMessage(const FLyraVerbMessage& Message);
//~FFastArraySerializer contract
void PreReplicatedRemove(const TArrayView<int32> RemovedIndices, int32 FinalSize);
void PostReplicatedAdd(const TArrayView<int32> AddedIndices, int32 FinalSize);
void PostReplicatedChange(const TArrayView<int32> ChangedIndices, int32 FinalSize);
//~End of FFastArraySerializer contract
bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms)
{
return FFastArraySerializer::FastArrayDeltaSerialize<FLyraVerbMessageReplicationEntry, FLyraVerbMessageReplication>(CurrentMessages, DeltaParms, *this);
}
private:
void RebroadcastMessage(const FLyraVerbMessage& Message);
private:
// Replicated list of gameplay tag stacks
UPROPERTY()
TArray<FLyraVerbMessageReplicationEntry> CurrentMessages;
// Owner (for a route to a world)
UPROPERTY()
2022-09-13 07:18:28 +00:00
TObjectPtr<UObject> Owner = nullptr;
2022-05-23 18:41:30 +00:00
};
template<>
struct TStructOpsTypeTraits<FLyraVerbMessageReplication> : public TStructOpsTypeTraitsBase2<FLyraVerbMessageReplication>
{
enum
{
WithNetDeltaSerializer = true,
};
};