Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncframework #36

Merged
merged 123 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
f427548
【creator3.0】清理老版本资源
wyb10a10 Mar 20, 2021
9c0aa6b
【creator3.0】新项目设置文件同步
wyb10a10 Mar 20, 2021
e7da3b4
【creator3.0】资源文件转换
wyb10a10 Mar 20, 2021
29504ff
【creator3.0】场景资源转换
wyb10a10 Mar 20, 2021
be91e4c
【creator3.0】通用脚本调整
wyb10a10 Mar 20, 2021
ce2436d
【creator3.0】网络框架调整
wyb10a10 Mar 20, 2021
9e240a1
【creator3.0】资源框架调整
wyb10a10 Mar 20, 2021
5edd368
【creator3.0】UI框架调整
wyb10a10 Mar 20, 2021
75c2a7e
【creator3.0】示例代码调整
wyb10a10 Mar 20, 2021
a6aea64
【creator3.0】UI遮罩层问题
wyb10a10 Mar 20, 2021
c818498
修复遮罩层bug
wyb10a10 Mar 25, 2021
13e2496
添加spine资源测试
wyb10a10 Apr 4, 2021
f4c8c46
测试Spine内存泄露
wyb10a10 Apr 4, 2021
2c75ac1
demo内存泄露fix
wyb10a10 Apr 9, 2021
95f494f
3.1.1
wyb10a10 Jun 14, 2021
7ec3b77
3.1.1
wyb10a10 Jun 14, 2021
5237cdc
网络同步
wyb10a10 Jun 27, 2021
13e77ce
完善属性复制逻辑
wyb10a10 Jun 29, 2021
38783c2
添加属性同步装饰器
wyb10a10 Jul 5, 2021
cede668
复制属性
wyb10a10 Jul 13, 2021
9cbcc15
清理资源
wyb10a10 Jul 15, 2021
ec55377
网络同步测试场景
wyb10a10 Aug 21, 2021
4aa09b0
优化代码结构
wyb10a10 Sep 5, 2021
e9a037f
调整测试场景
wyb10a10 Sep 6, 2021
1993477
添加动画
wyb10a10 Sep 7, 2021
d59ad2c
递归apply
wyb10a10 Sep 8, 2021
984ddab
Merge branch 'syncframework' of github.com:wyb10a10/cocos_creator_fra…
wyb10a10 Sep 8, 2021
9cac972
debug
wyb10a10 Sep 8, 2021
7b5ac3e
基础位置和缩放同步
wyb10a10 Sep 8, 2021
6f9bf47
指定属性同步与跳过属性同步
wyb10a10 Sep 8, 2021
6cbdf54
使用欧拉角和tween进行线性旋转
wyb10a10 Sep 13, 2021
8480a06
同步指定属性
wyb10a10 Sep 13, 2021
a2f3540
Merge branch 'syncframework' of github.com:wyb10a10/cocos_creator_fra…
wyb10a10 Sep 14, 2021
ef8d75b
改用keys来applyDiff
wyb10a10 Sep 14, 2021
e925137
调整跟踪的属性
wyb10a10 Sep 14, 2021
e5ccf21
新增setter选项,应对特殊的属性同步
wyb10a10 Sep 20, 2021
d57884a
类装饰器
wyb10a10 Sep 27, 2021
21c7f5a
初值不纳入变化,修正版本号计算
wyb10a10 Oct 1, 2021
c669acc
fix bug
wyb10a10 Dec 7, 2021
c9bbd04
fix example bug
wyb10a10 Dec 8, 2021
a111d3a
replicate mark
wyb10a10 Dec 13, 2021
3d7b0bd
new gen diff
wyb10a10 Dec 13, 2021
af96317
Merge branch 'syncframework' of github.com:wyb10a10/cocos_creator_fra…
wyb10a10 Dec 17, 2021
8684c77
重构装饰器
wyb10a10 Dec 17, 2021
0733cc9
完善类装饰器
wyb10a10 Dec 28, 2021
8b24592
测试代码
wyb10a10 Dec 28, 2021
cac6725
完善装饰器
wyb10a10 Dec 29, 2021
e6da1fb
内置对象不可枚举
wyb10a10 Dec 29, 2021
30e3e26
隐藏内置属性,并将Mark绑定到prototype
wyb10a10 Jan 10, 2022
2879f8a
Merge branch 'syncframework' of github.com:wyb10a10/cocos_creator_fra…
wyb10a10 Jan 10, 2022
7b8689f
debug
wyb10a10 Jan 10, 2022
dac6b55
跟踪原始值
wyb10a10 Jan 10, 2022
1ece9ce
优化代码
wyb10a10 Jan 14, 2022
4a197e7
代码调整
wyb10a10 Jan 16, 2022
2992991
重构装饰器
wyb10a10 Jan 19, 2022
360bdc8
移除返回值
wyb10a10 Jan 19, 2022
6a5a8ff
调通trigger
wyb10a10 Jan 19, 2022
ccc75a7
temp commit
wyb10a10 May 10, 2022
240c6c3
I come back
wyb10a10 Jul 16, 2022
ed421e3
diffscan
wyb10a10 Jul 18, 2022
3dae012
update
wyb10a10 Jul 18, 2022
71590d0
makeup datamap
wyb10a10 Jul 19, 2022
2be60d7
scanner diff apply
wyb10a10 Jul 22, 2022
39282c3
scanner and trigger
wyb10a10 Jul 23, 2022
1353052
makePropertyReplicatedMark
wyb10a10 Jul 23, 2022
de39692
makeObjectReplicatedMark
wyb10a10 Jul 23, 2022
94a7343
add factory and cocos replicator
wyb10a10 Jul 24, 2022
e28251c
auto gen mark
wyb10a10 Jul 24, 2022
d34ad4b
调通Cocos简单对象同步
wyb10a10 Jul 25, 2022
fe06c95
fix eulerAngles error
wyb10a10 Jul 26, 2022
59ee647
clear code
wyb10a10 Jul 26, 2022
f071783
debug
wyb10a10 Jul 29, 2022
e639405
auto get mark
wyb10a10 Jul 29, 2022
adf3a1a
delay init for class replicator
wyb10a10 Jul 29, 2022
60a1262
fix bug
wyb10a10 Jul 29, 2022
ac8eb04
fix init bug
wyb10a10 Jul 29, 2022
1d57741
change seq
wyb10a10 Jul 30, 2022
2ea0eb9
init server framework
YJH143 Aug 8, 2022
4bd7daf
array replicator
wyb10a10 Aug 9, 2022
ba4dc35
Merge branch 'syncframework' of github.com:wyb10a10/cocos_creator_fra…
wyb10a10 Aug 9, 2022
a668aca
array replicator
wyb10a10 Aug 10, 2022
2873b8f
SimpleArrayReplicator
wyb10a10 Aug 10, 2022
c451715
ArrayReplicator
wyb10a10 Aug 11, 2022
f3987e3
ArrayReplicator
wyb10a10 Aug 14, 2022
1a0eac0
temp commit
wyb10a10 Aug 16, 2022
4ff8fd6
gendiff
wyb10a10 Aug 17, 2022
5814812
apply diff
wyb10a10 Aug 25, 2022
0e3f95a
server framework
YJH143 Aug 28, 2022
6a2ecbe
temp commit
wyb10a10 Sep 3, 2022
5c79123
Merge branch 'syncframework' of github.com:wyb10a10/cocos_creator_fra…
wyb10a10 Sep 3, 2022
d278315
apply diff
wyb10a10 Sep 4, 2022
0fd1573
test simple array
wyb10a10 Sep 5, 2022
32f9895
test simple array version
wyb10a10 Sep 5, 2022
20f8e0d
createReplicator
wyb10a10 Sep 6, 2022
854f67c
debug
Sep 6, 2022
67b560f
delete meta files
Sep 6, 2022
ad456a0
调整目录,以及文件名
Sep 7, 2022
55e6e4e
array test
wyb10a10 Sep 9, 2022
20bbb03
Merge branch 'syncframework' of github.com:wyb10a10/cocos_creator_fra…
wyb10a10 Sep 9, 2022
b99b99f
fix init error
wyb10a10 Sep 12, 2022
51ebf9e
fix bug
wyb10a10 Sep 13, 2022
96dbaa2
debug
wyb10a10 Sep 15, 2022
8fa6aa9
fix bug
wyb10a10 Mar 13, 2023
6fb87e6
update array replicator
wyb10a10 Jul 13, 2023
7ecbfcb
fix scan bug
wyb10a10 Jul 21, 2023
98bb586
new array replicator
wyb10a10 Jul 21, 2023
9e3496a
fix lot of bug and add more test
wyb10a10 Jul 22, 2023
b94c64f
debug
wyb10a10 Jul 23, 2023
9e022d7
fix bug
wyb10a10 Jul 23, 2023
c040606
clean code
wyb10a10 Jul 23, 2023
c3605ce
update protocol
wyb10a10 Jul 23, 2023
d811835
finish array link
wyb10a10 Jul 23, 2023
baa3a11
add simple hash replicator
wyb10a10 Jul 24, 2023
29855d3
add simple set replicator
wyb10a10 Jul 25, 2023
5e86977
debug simple set
wyb10a10 Jul 26, 2023
11eec0f
add log
wyb10a10 Jul 26, 2023
1fee93f
update simple hash replicator
wyb10a10 Jul 28, 2023
60cf62d
add hash replicator
wyb10a10 Jul 28, 2023
df635d2
test hash replicator
wyb10a10 Jul 29, 2023
ab5dce6
update factory
wyb10a10 Jul 30, 2023
a7947af
fix bug
wyb10a10 Jul 30, 2023
b33b2f8
clean code
wyb10a10 Jul 30, 2023
ecf3d50
Merge branch 'master' into syncframework
wyb10a10 Jul 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
scanner diff apply
  • Loading branch information
wyb10a10 committed Jul 22, 2022
commit 2be60d765131fcaf600d5f574aa23747aab20f92
25 changes: 23 additions & 2 deletions assets/Script/sync/DiffScaner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*/

import { getReplicateMark } from "./ReplicateMark";
import { IDiffGenerator, ReplicateProperty } from "./SyncUtil";
import { IReplicator, ReplicateProperty } from "./SyncUtil";

export class ObjectDiffScanner implements IDiffGenerator {
export class ReplicateScanner implements IReplicator {
/** 最后一个有数据变化的版本号 */
private lastVersion: number = 0;
/** 最后一次检测的版本号 */
Expand Down Expand Up @@ -90,6 +90,27 @@ export class ObjectDiffScanner implements IDiffGenerator {
return ret;
}

/**
* 将Diff应用到目标Object上
* @param diff Diff
*/
applyDiff(diff: any) {
let keys = Object.keys(diff);
for (let key of keys) {
// 如果是setter函数,则执行函数
if (typeof this.target[key] === "function") {
this.target[key](diff[key]);
} else {
let property = this.dataMap.get(key);
// 判断是否实现了applyDiff接口
if (property instanceof Object && "applyDiff" in property.data) {
property.data.applyDiff(diff[key]);
} else {
this.target[key] = diff[key];
}
}
}
}
/**
* 获取当前版本号
* @returns 最后一个有数据变化的版本号
Expand Down
11 changes: 8 additions & 3 deletions assets/Script/sync/SyncUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,18 @@ export interface ReplicateProperty {
}

/**
* 属性同步器接口,抽象Diff的生成
* 属性同步器接口,抽象Diff的生成和Diff的应用
*/
export interface IDiffGenerator {
export interface IReplicator {
/**
* 生成一个Diff对象
*/
genDiff(fromVersion: number, toVersion: number): any
/**
* 应用一个Diff对象
* @param diff Diff对象
*/
applyDiff(diff: any): void
/**
* 获取当前版本
*/
Expand Down Expand Up @@ -326,7 +331,7 @@ class ReplicateObject {

/**
* 应用DIFF到target中
* @param diff
* @param diff
* @param target
*/
export function applyDiff(diff: any, target: any) {
Expand Down