Add NetworkReplicator.AddObjectIdMapping for global/custom network objects sync
#3042
This commit is contained in:
@@ -1311,6 +1311,14 @@ void NetworkReplicator::MapObjectId(Guid& objectId)
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkReplicator::AddObjectIdMapping(const ScriptingObject* obj, const Guid& objectId)
|
||||
{
|
||||
CHECK(obj);
|
||||
const Guid id = obj->GetID();
|
||||
NETWORK_REPLICATOR_LOG(Info, "[NetworkReplicator] Remap object ID={} into object {}:{}", objectId, id.ToString(), obj->GetType().ToString());
|
||||
IdsRemappingTable[objectId] = id;
|
||||
}
|
||||
|
||||
ScriptingObject* NetworkReplicator::ResolveForeignObject(Guid objectId)
|
||||
{
|
||||
if (const auto& object = ResolveObject(objectId))
|
||||
|
||||
@@ -122,6 +122,13 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="objectId">The network object identifier to map. Contains result ID once the method completes.</param>
|
||||
API_FUNCTION() static void MapObjectId(API_PARAM(Ref) Guid& objectId);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new mapping for object identifier. Can be used to link locally-spawned object with across different clients.
|
||||
/// </summary>
|
||||
/// <param name="obj">The network object.</param>
|
||||
/// <param name="objectId">The network object identifier to use (eg. defined by server or global/static).</param>
|
||||
API_FUNCTION() static void AddObjectIdMapping(const ScriptingObject* obj, API_PARAM(Ref) const Guid& objectId);
|
||||
|
||||
/// <summary>
|
||||
/// Resolves foreign Guid into a local ScriptingObject
|
||||
|
||||
Reference in New Issue
Block a user