public static Action <MessageMetaData, BasicMessage.ReplicatePreExistingObject, NetBuffer> ReplicatePreExistingObject( ReplicatedObjectStore objectStore, IDictionary <Guid, GameObject> preExistingObjects) { return((metadata, message, reader) => { var instance = preExistingObjects[message.GlobalObjectId]; objectStore.AddExistingInstance(message.ObjectRole, metadata.ConnectionId, instance, message.NetworkObjectId, message.GlobalObjectId); }); }
public ReplicatedObject AddPreExistingInstance(ConnectionId ownerConnectionId, GameObject instance, Guid globalId) { var objectId = RequestObjectId(); var role = ObjectRole.Authority | ((ownerConnectionId == ConnectionId.Self) ? ObjectRole.Owner : ObjectRole.Nobody); var replicatedInstance = _store.AddExistingInstance(role, ownerConnectionId, instance, objectId, globalId); _networkReplicator.Replicate(_connectionGroup.ActiveConnections, replicatedInstance); return(replicatedInstance); }