public static void RemovePlayer(this IMessageSender messageSender, MessagePool messagePool, ConnectionId connectionId, IList <ConnectionId> others, Replicator replicator) { var store = replicator.Store; ObjectIdCache.Clear(); store.ObjectIds.CopyListInto(ObjectIdCache); for (int i = 0; i < ObjectIdCache.Count; i++) { var objectId = ObjectIdCache[i]; var instance = store.Find(objectId); if (instance.OwnerConnectionId == connectionId || instance.AuthorityConnectionId == connectionId) { replicator.RemoveReplicatedInstance(objectId); for (int j = 0; j < others.Count; j++) { var otherConnectionId = others[j]; messageSender.DeleteObject(messagePool, otherConnectionId, instance.Id); } } } }