// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
#pragma once
#include "Types.h"
#include "Engine/Core/Types/Pair.h"
#include "Engine/Core/Collections/Dictionary.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "Engine/Scripting/ScriptingType.h"
///
/// High-level networking replication system for game objects.
///
API_CLASS(static, Namespace = "FlaxEngine.Networking") class FLAXENGINE_API NetworkReplicator
{
DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkReplicator);
public:
typedef void (*SerializeFunc)(void* instance, NetworkStream* stream);
typedef Pair SerializeFuncPair;
static SerializeFuncPair GetSerializer(const ScriptingTypeHandle& typeHandle);
///
/// Global table for registered types serialization methods (key is type name, value is pair of methods to serialize and deserialize object).
///
static Dictionary SerializersTable;
public:
///
/// Adds the object to the network replication system.
///
/// Does nothing if network is offline.
/// The object to replicate.
/// The owner of the object (eg. player that spawned it).
API_FUNCTION() static void AddObject(ScriptingObject* obj, ScriptingObject* owner);
};