Skip to content

Commit 64e3741

Browse files
committed
refactor(Network): 移除MessageObject中DeepClone的ID更新逻辑
DeepClone方法不再要求T继承自MessageObject,因此移除了克隆后更新唯一ID的逻辑,使方法更通用
1 parent f10a307 commit 64e3741

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

Runtime/Network/Base/MessageObject.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public virtual void Clear()
6363
/// <typeparam name="T">消息类型</typeparam>
6464
/// <param name="useJson">是否强制使用 JSON 进行克隆(较慢但兼容性最好)</param>
6565
/// <returns>克隆后的对象</returns>
66-
public T DeepClone<T>(bool useJson = false) where T : MessageObject, new()
66+
public T DeepClone<T>(bool useJson = false) where T : class, new()
6767
{
6868
T clone;
6969

@@ -92,12 +92,6 @@ public virtual void Clear()
9292
#endif
9393
}
9494

95-
// 确保每个克隆体都有唯一的 ID
96-
if (clone != null)
97-
{
98-
clone.UpdateUniqueId();
99-
}
100-
10195
return clone;
10296
}
10397

0 commit comments

Comments
 (0)