Compare commits

...

263 Commits

Author SHA1 Message Date
Alex-Rachel
aad8ff3ee5 忽略Gizmos和编辑器资源 source:9bc0577423 2025-01-24 12:59:31 +08:00
Alex-Rachel
df25a1adad Update ResourceExtComponent.Resource.cs
typo
2025-01-22 09:27:42 +08:00
Alex-Rachel
634a392a1f Update HybridCLR -> 7.3.0
Update HybridCLR -> 7.3.0
2025-01-15 23:54:31 +08:00
Alex-Rachel
b869a05220 #104 目前调用 HideUI 会将 UIWindow 的 Visible 设置为 false,但是如果又调用 CloseUI 方法,会将刚才 Visible 设置为 false 的窗口重新设置为 true。 2024-12-22 13:13:59 +08:00
ALEX
37d88c2d94 Merge pull request #103 from 6ag/main
更新文档
2024-12-17 10:07:14 +08:00
feng
f3aa8824d8 更新文档 2024-12-17 10:03:53 +08:00
ALEX
99c5afcbc5 Merge pull request #102 from 6ag/main
UIWindow新增Hide方法,将UIWindow中的UserData和UserDatas属性移动到UIBase
2024-12-16 23:46:33 +08:00
feng
4075588c34 UIWindow新增Hide方法,将UIWindow中的UserData和UserDatas属性移动到UIBase 2024-12-16 22:36:26 +08:00
Alex-Rachel
fdd9f34132 Merge branch 'main' of https://github.com/ALEXTANGXIAO/TEngine 2024-12-09 11:34:17 +08:00
Alex-Rachel
a2ab6efc71 #101 2024-12-09 11:34:05 +08:00
ALEX
67025c806e Update README.md 2024-12-09 11:12:02 +08:00
ALEXTANGXIAO
38afa45f9c #100 2024-12-04 10:45:19 +08:00
ALEXTANGXIAO
0dc572f43e #97 2024-12-02 23:51:53 +08:00
ALEXTANGXIAO
0679d924c1 Merge branch 'main' of https://github.com/ALEXTANGXIAO/TEngine 2024-12-02 23:48:12 +08:00
ALEXTANGXIAO
3de8cad99a #99 2024-12-02 23:46:08 +08:00
ALEX
065d5a7303 Merge pull request #98 from 6ag/main
适配 luban-next 最新版本的配表结构,新增 Mac 设备相关的 shell 脚本支持
2024-11-30 23:29:45 +08:00
feng
c089eb32ba 适配 luban-next 最新版本的配表结构,新增 Mac 设备相关的 shell 脚本支持 2024-11-30 23:09:45 +08:00
ALEXTANGXIAO
d571a937f8 UIWindow同一帧关闭导致GameObject无法销毁的极小概率bug修复 2024-11-22 23:09:44 +08:00
ALEXTANGXIAO
89210483a9 ScriptGenerator控制台日志 2024-10-16 22:56:39 +08:00
ALEXTANGXIAO
058ac2c9a5 RemoveAllListenerByOwner 倒序移除 2024-10-11 21:47:21 +08:00
ALEXTANGXIAO
990222c7c6 资源释放时序优化 2024-10-05 15:18:51 +08:00
ALEXTANGXIAO
d3914a96bb Merge branch 'main' of https://github.com/ALEXTANGXIAO/TEngine 2024-09-20 22:43:29 +08:00
ALEXTANGXIAO
4b178a9fa9 #80 2024-09-20 22:43:08 +08:00
ALEXTANG
79929c4ac3 Merge pull request #95 from landoU/main
修正:异步获取窗口方法GetUIAsync获取不到已加载的窗口
2024-09-20 22:29:28 +08:00
liufeiwei
38fa4d5cbc 修正:异步获取窗口方法GetUIAsync获取不到已显示的窗口 2024-09-18 09:42:12 +08:00
ALEXTANG
3ac6977f93 Rmv 2024-09-02 16:40:19 +08:00
ALEXTANGXIAO
3facec8f93 Update ProcedureInitPackage.cs 2024-08-25 19:09:07 +08:00
ALEXTANGXIAO
0570982b97 * support package mode tengine setting
* support package mode tengine setting
2024-08-25 19:07:11 +08:00
ALEXTANG
f785264873 #94 资源加载assetLoadingList处理
#94 资源加载assetLoadingList处理
2024-08-24 21:02:12 +08:00
ALEXTANGXIAO
4911ec074c 新增GetUIAsync,ShowUIAsyncAwait
新增GetUIAsync,ShowUIAsyncAwait
2024-08-11 10:24:27 +08:00
ALEXTANGXIAO
6ff9546152 Update RedNoteMgr.cs 2024-08-10 22:21:17 +08:00
ALEXTANG
5a8dc04b9c Merge pull request #92 from Kojima648/main
[opt] TEngine 设置界面逻辑优化
2024-08-10 17:24:37 +08:00
chengshengfei
d4482cf1c4 [opt]
中文:优化设置界面的tab切换,页面数据保存逻辑
English: Optimize tab switching and page data saving logic in the settings interface
2024-08-10 16:47:30 +08:00
ALEXTANG
c7fad139ba Merge pull request #91 from mi1890/main
* [fix] installed  as a  package ,class not found issue
2024-08-09 00:43:18 +08:00
mr.zz
650469a7db * support package mode tengine setting 2024-08-09 00:25:48 +08:00
mr.zz
c7c00eac9f * [fix] installed as a package ,class not found issue 2024-08-07 23:58:47 +08:00
ALEXTANG
5a883bc8ec Merge pull request #88 from kenkinky/main
[fixed]选中ResourceModule时进入Play模式抛出异常
2024-08-03 18:55:40 +08:00
BCC
79c1026c7c [fixed]选中ResourceModule时进入Play模式抛出异常 2024-08-02 12:54:25 +08:00
ALEXTANGXIAO
f2c69d58b2 DefaultLogger支持Unity6 2024-07-14 14:51:44 +08:00
ALEXTANGXIAO
c38d3b7cfa 支持Unity6 2024-07-14 14:37:43 +08:00
ALEXTANGXIAO
98cb74537a update hybridclr_version & UnityPackage Version 2024-07-14 14:32:00 +08:00
ALEXTANGXIAO
ed19a75be9 Update GameApp_RegisterSystem.cs 2024-07-14 14:30:43 +08:00
ALEXTANG
fd82ddf427 Merge pull request #85 from Vorik-S/main
加载热更新程序集的崩溃bug修正
2024-07-11 12:23:12 +08:00
沈挺
e53ceb0095 单例对象销毁时的检查,修正由此错误的销毁单例对象的bug 2024-07-09 18:49:55 +08:00
沈挺
9afda78735 修正GameApp_RegisterSystem文件漏写基类导致真机上无法正确执行GameApp.Instance.Active方法的bug 2024-07-09 17:23:24 +08:00
沈挺
5734d4f995 加载热更新程序集的崩溃bug修正 2024-07-09 16:11:41 +08:00
ALEXTANG
dc7ab7fd64 Merge branch 'main' of https://github.com/ALEXTANGXIAO/TEngine 2024-06-27 21:02:55 +08:00
ALEXTANG
fcb3416acd Update ResourceManager.cs 2024-06-27 21:02:47 +08:00
ALEXTANG
3df18c006d Merge pull request #82 from SaberArtoriaFan/Dev2
扩展绑定TE UI框架的便捷工具
2024-06-21 14:19:12 +08:00
EdwardLee
6cfae215dc 11 2024-06-21 00:59:26 +08:00
ALEXTANG
1aaa46c82c 资源模块增加设置:是否使用系统释放无用资源策略。
资源模块增加设置:是否使用系统释放无用资源策略。
2024-06-20 09:42:49 +08:00
ALEXTANG
ca79adce7c Merge pull request #79 from Severn17/main
新增WebGL一键打包功能 及 全平台运行增加WebGL示例图片
2024-06-17 15:22:15 +08:00
yangshiqi
b520eba187 新增WebGL一键打包功能 及 全平台运行增加WebGL示例图片 2024-06-14 15:09:01 +08:00
ALEXTANG
b5afaca217 Merge pull request #78 from Senfee-Cheng/main
[fix] 在注册事件之前调用初始化
2024-06-13 17:32:39 +08:00
chengshengfei
ea2efbf588 [fix] 在注册事件之前调用初始化 2024-06-13 16:21:40 +08:00
ALEXTANG
a4b1befc5a Merge pull request #77 from Senfee-Cheng/main
[opt] (编辑器下)如果有多个资源的Package,组件提供一个下拉,使用Yoo收集器的列表
2024-05-28 19:22:53 +08:00
ALEXTANG
8dcddfa328 Update EventInterfaceGenerate.cs 2024-05-28 19:19:01 +08:00
chengshengfei
dd37d130da [opt] (编辑器下)如果有多个资源的Package,组件提供一个下拉,使用Yoo收集器的列表 2024-05-28 19:16:45 +08:00
ALEXTANG
24d7dbc677 EventInterfaceGenerate支持List与Dictionary(但不推荐用)
EventInterfaceGenerate支持List与Dictionary(但不推荐用)
2024-05-28 18:09:13 +08:00
ALEXTANG
491100b932 Merge pull request #76 from Senfee-Cheng/main
[opt] 优化下载更新界面的显示
2024-05-28 16:55:42 +08:00
chengshengfei
c84c21574d [opt] 优化下载更新界面的显示 2024-05-28 15:56:05 +08:00
ALEXTANG
7914660f8c Update SingletonSystem.cs 2024-05-24 14:00:51 +08:00
ALEXTANG
b00679a276 Merge pull request #75 from SunXuebing/main
调整编辑器模式下模块销毁顺序,解决编辑器退出运行后资源管理器销毁了还被调用问题
2024-05-20 14:17:40 +08:00
sxb
cd9a10ccac Update RootModule.cs
修复条件判断
2024-05-20 13:31:57 +08:00
sxb1067
f11098d32e 调整编辑器模式下模块销毁顺序,解决编辑器退出运行后资源管理器销毁了还被调用问题 2024-05-20 11:25:01 +08:00
ALEXTANGXIAO
db6e715fa6 Update ActorEventDispatcher.cs 2024-05-19 22:03:53 +08:00
ALEXTANG
c2edf71ee4 Update AssetItemObject.cs 2024-05-17 17:55:53 +08:00
ALEXTANG
75af7c22c7 Merge pull request #73 from Senfee-Cheng/main
[fix] 移除 `BuildDLLCommand` 构造函数以尝试解决hotfix dll数组被清除的问题
2024-05-17 15:48:27 +08:00
chengshengfei
2f9edf83bf Merge branch 'main' of github.com:Senfee-Cheng/TEngine 2024-05-17 15:45:26 +08:00
chengshengfei
815095efaf [fix] 移除 BuildDLLCommand 构造函数以尝试解决数组被清除的问题 2024-05-17 15:45:06 +08:00
ALEXTANG
3101a64a48 Merge pull request #72 from Severn17/main
yooasset 微信小游戏设置,详情看yooasset微信小游戏支持解决方案文档
2024-05-16 16:05:41 +08:00
yangshiqi
457e0f36a4 yooasset 微信小游戏设置,详情看yooasset微信小游戏支持解决方案文档 2024-05-16 15:19:32 +08:00
ALEXTANG
0bd30def23 移除示例package文件 2024-05-16 13:16:25 +08:00
ALEXTANG
d24db83c8b Update 99-各平台运行RunAble.md 2024-05-16 12:34:55 +08:00
ALEXTANG
18a2840777 Merge pull request #70 from Senfee-Cheng/main
[Platform] Supports console
2024-05-16 10:26:13 +08:00
chengshengfei
1d901514e1 新的平台支持[Sony Console] 2024-05-16 10:18:03 +08:00
chengshengfei
983279c56d 更新文档,添加新增的支持的平台。 2024-05-16 10:14:22 +08:00
ALEXTANG
e9540c620a Merge pull request #69 from Severn17/main
修改编辑器下webgl  平台名字 宏问题
2024-05-14 17:57:38 +08:00
yangshiqi
39be280d88 修改编辑器下webgl 平台名字 宏问题 2024-05-14 17:45:40 +08:00
ALEXTANG
f9f9122027 单例系统完善生命周期、支持Dispose 2024-05-13 14:09:32 +08:00
ALEXTANG
682a0bd786 Update UnityExtension.cs 2024-05-08 17:11:39 +08:00
ALEXTANG
34c514cae8 Update README.md 2024-05-08 10:31:41 +08:00
ALEXTANG
c707cc1a38 GameApp Shutdown 2024-05-08 10:06:33 +08:00
ALEXTANG
f016fdd0a6 Update ReleaseTools.cs 2024-05-07 20:09:15 +08:00
ALEXTANG
4c0f5a77f9 支持编辑器下EnterPlayMode Options 2024-05-07 18:05:41 +08:00
ALEXTANG
ae0d00424f Update ProfilerDefineSymbols.cs 2024-04-30 17:42:36 +08:00
ALEXTANG
c8ecac5815 Update README.md 2024-04-29 12:27:40 +08:00
ALEXTANG
4f8c1cdfdd 修正SpritePostprocessor处理Atlas的override 2024-04-25 15:43:44 +08:00
ALEXTANG
dff043e075 Update SahderVariantCollect
Update SahderVariantCollect
2024-04-24 11:17:38 +08:00
ALEXTANG
e69dc47b8f 修正编辑器调用转表bat 当前路径的问题
修正编辑器调用转表bat 当前路径的问题
2024-04-17 14:27:28 +08:00
ALEXTANG
fc2ef0714c 设置DefaultYooFolderName为package。原本设置默认为yoo。
设置DefaultYooFolderName为package。原本设置默认为yoo。
2024-04-15 19:58:57 +08:00
ALEXTANG
d75c1c8c93 升级YooAsset->2.1.1、UniTask->2.5.4
升级YooAsset->2.1.1、UniTask->2.5.4
2024-04-15 19:37:42 +08:00
ALEXTANG
83bea559e4 Merge pull request #65 from Senfee-Cheng/main 2024-04-12 18:19:10 +08:00
ALEXTANG
26689639ed Merge pull request #64 from ZemelLing/dev-launcher 2024-04-12 18:17:06 +08:00
chengshengfei
bd6ac5f4da 优化代码。 2024-04-12 10:58:06 +08:00
ZemelLing
70dcb03a3f 确保Launcher打开的main场景,而不是其他名称里包含main的场景。 2024-04-11 13:09:16 +08:00
ALEXTANG
59b3649155 优化框架轮询逻辑 ,用脏数据构建Execute数组。
优化框架轮询逻辑 ,用脏数据构建Execute数组。
2024-04-08 15:37:06 +08:00
ALEXTANG
2c025efe3b 修正预加载流程 2024-04-08 14:41:16 +08:00
ALEXTANG
7ae6ef94ba 修正同时对一个图片进行异步SetSprite的处理
修正同时对一个图片进行异步SetSprite的处理
2024-04-07 15:45:32 +08:00
ALEXTANG
d5bb64b314 资源异步加载从缓存中延迟分帧处理。 2024-04-07 15:33:45 +08:00
ALEXTANG
4c34858ce0 Update SettingsUtils.cs 2024-03-29 15:24:02 +08:00
ALEXTANG
5adb2f83e5 Update AssetBundleCollectorSetting.asset 2024-03-29 14:38:44 +08:00
ALEXTANG
f10a89180e 支持边玩边下载,合理化webgl下的流程
支持边玩边下载,合理化webgl下的流程
2024-03-28 15:55:27 +08:00
ALEXTANG
3e3314858e 优化加载游戏物体接口,常用Parent参数前置,编辑器模式下增加超时保护提示
优化加载游戏物体接口,常用Parent参数前置,编辑器模式下增加超时保护提示
2024-03-25 14:27:42 +08:00
ALEXTANGXIAO
da57ed845f 修正同时对一个资源进行异步加载的处理
修正同时对一个资源进行异步加载的处理
2024-03-24 15:58:57 +08:00
ALEXTANGXIAO
df570f453a Create UnityEditor.iOS_I2Loc.Xcode.dll 2024-03-24 15:50:44 +08:00
ALEXTANG
a500a08a30 更新Luban配置表使用文档 2024-03-19 14:25:48 +08:00
ALEXTANG
2daac0e065 默认一键打包使用ClearAndCopyAll 2024-03-19 14:09:27 +08:00
ALEXTANG
514da6e99e Update README.md 2024-03-18 15:44:29 +08:00
ALEXTANG
7f91241df7 Update Version.cs 2024-03-18 15:06:48 +08:00
ALEXTANG
071974ab4f Update GameLogic.asmdef 2024-03-18 15:05:40 +08:00
ALEXTANG
c01e03ff70 Update AssetBundleCollectorSetting.asset 2024-03-18 15:02:23 +08:00
ALEXTANG
6fec792e05 TEngine全面更新,升级YooAsset2.1.1、UniTask、UIWindow、I2Localization
TEngine全面更新,升级YooAsset2.1.1、UniTask、UIWindow、I2Localization
2024-03-18 14:53:26 +08:00
ALEXTANG
04ecf71eab Update ProcedureLoadAssembly.cs 2024-02-27 12:05:26 +08:00
ALEXTANG
693ca5bb3d 编辑器模式重定向所有热更dll,以防编辑器运行AB时出现两份元数据。
编辑器模式重定向所有热更dll,以防编辑器运行AB时出现两份元数据。
2024-01-25 15:10:30 +08:00
ALEXTANG
90f84a2764 更新README
更新README
2023-12-20 12:43:39 +08:00
ALEXTANG
6107b41770 修正动态添加/异步添加ui组件的脏数据问题
修正动态添加/异步添加ui组件的脏数据问题
2023-12-19 18:24:33 +08:00
ALEXTANG
1423a3716a 编辑器模式重定向所有热更dll,以防编辑器运行AB时出现两份元数据。
编辑器模式重定向所有热更dll,以防编辑器运行AB时出现两份元数据。
2023-12-18 19:49:46 +08:00
ALEXTANG
6a87db76ee 优化局部单位事件分发器ActorEventDispatcher,EventRegInfo池化
优化局部单位事件分发器ActorEventDispatcher,EventRegInfo池化
2023-12-15 15:11:12 +08:00
ALEXTANG
3a6170dca6 Update UIWidget.cs 2023-12-15 14:25:41 +08:00
ALEXTANG
9d137d613a 修正Utility.Unity注入非Mono的LateUpdate时序问题
修正Utility.Unity注入非Mono的LateUpdate时序问题
2023-12-15 14:15:08 +08:00
ALEXTANG
ba77ec6b45 Update EventInterfaceGenerate.cs 2023-12-14 15:07:04 +08:00
ALEXTANG
b661da68f2 Update EventInterfaceGenerate.cs 2023-12-14 10:12:56 +08:00
ALEXTANGXIAO
e1040110bb 升级拓展GameEvent,支持基于Interface的方法调用抛出事件,以及自动化根据声明的Interface来生成实现代码。
升级拓展GameEvent,支持基于Interface的方法调用抛出事件,以及自动化根据声明的Interface来生成实现代码。
2023-12-13 23:27:54 +08:00
ALEXTANGXIAO
2d53fa1687 升级HybridCLR 4.0.13=>4.0.14
升级HybridCLR 4.0.13=>4.0.14
2023-12-13 19:27:05 +08:00
ALEXTANG
c4ef07f13e Update UnityExtension.cs 2023-12-12 13:00:53 +08:00
ALEXTANG
1f2d99ddc9 修正UIWindow资源句柄时序导致UI同步显示失效的问题。 2023-12-08 10:38:19 +08:00
ALEXTANG
edf4925a7a UIWidget增加Visible设置
UIWidget增加Visible设置
2023-12-07 16:32:54 +08:00
ALEXTANG
5d67238c8f 统一封装对shader的管理和示例。
统一封装对shader的管理和示例。
2023-12-07 10:55:50 +08:00
ALEXTANG
6cfd352482 关闭ResourceCacheMgr测试日志
关闭ResourceCacheMgr测试日志
2023-12-07 10:30:50 +08:00
ALEXTANG
40373c473d 修改通过Tag加载资源对象集合接口。(Operation需要自行管理生命周期释放)
修改通过Tag加载资源对象集合接口。(Operation需要自行管理生命周期释放)
2023-12-07 10:27:17 +08:00
ALEXTANG
d799f9fdf0 优化资源引用类与资源分组类。 2023-12-06 17:57:54 +08:00
ALEXTANG
15735c3d2d 修正循环列表GetItem,增加普通列表组件。 2023-12-06 14:41:31 +08:00
ALEXTANG
818a74f437 释放资源前判断资源合法性 2023-12-06 11:35:33 +08:00
ALEXTANG
f248757401 消除Editor引用隐患
消除Editor引用隐患
2023-12-01 17:41:43 +08:00
ALEXTANG
6ada0e7de7 移除测试日志 2023-12-01 17:18:13 +08:00
ALEXTANG
7ea472f97e 修正日志重定向下层日志跳转功能
修正日志重定向下层日志跳转功能
2023-12-01 10:45:57 +08:00
ALEXTANG
fb8528ff52 音频代理类增加暂停和取消暂停接口。
音频代理类增加暂停和取消暂停接口。
2023-11-30 16:17:35 +08:00
ALEXTANG
e3ac92ef46 修正音频模块回收池
修正音频模块回收池
2023-11-30 15:30:01 +08:00
ALEXTANG
be6a19c26a 修正Sound轨道不受SoundVolume的影响,调整AudioMixer音频Group命名
修正Sound轨道不受SoundVolume的影响,调整AudioMixer音频Group命名
2023-11-30 13:18:20 +08:00
ALEXTANG
e7f0636f30 拓展细分内存对象生命周期。
拓展细分内存对象生命周期。
2023-11-30 00:13:23 +08:00
ALEXTANG
fb38e96e9e 修正循环列表根据下标获取索引Item
修正循环列表根据下标获取索引Item
2023-11-29 19:48:18 +08:00
ALEXTANG
dd658c7e1d 对象池支持ShutDown
对象池支持ShutDown
2023-11-29 15:39:44 +08:00
ALEXTANG
4d7cb7641d 修正LoadGameObjectAsync接口传参
修正LoadGameObjectAsync接口传参
2023-11-29 15:24:02 +08:00
ALEXTANG
ae075b1fad 修正ProcedureDownloadFile更新时网速计算
修正ProcedureDownloadFile更新时网速计算
2023-11-29 12:55:36 +08:00
ALEXTANG
02827ce3b8 优化/新增超牛逼且很方便使用的对象池。
优化/新增超牛逼且很方便使用的对象池。
2023-11-28 19:36:26 +08:00
ALEXTANG
1a0e3f91e0 优化/新增超牛逼且很方便使用的对象池。
优化/新增超牛逼且很方便使用的对象池。
2023-11-28 15:27:34 +08:00
ALEXTANG
6d376b0e07 增加安全定时器GameTimerTick
增加安全定时器GameTimerTick
2023-11-28 14:25:25 +08:00
ALEXTANGXIAO
cb73c9a9eb 升级HybridCLR 4.0.12=>4.0.13 强烈建议升级,修复了若干bug
升级HybridCLR 4.0.12=>4.0.13 强烈建议升级,修复了若干bug
2023-11-27 22:47:30 +08:00
ALEXTANG
7dda73a7ac 增加泛用加载资源并绑定资源引用到GameObject上。
增加泛用加载资源并绑定资源引用到GameObject上。
2023-11-23 13:34:33 +08:00
ALEXTANG
9bcb636ed7 修正SetSprite接口绑定资源引用关系,避免0引用导致AssetBundle被释放使图片丢失。
修正SetSprite接口绑定资源引用关系,避免0引用导致AssetBundle被释放使图片丢失。
2023-11-23 11:44:43 +08:00
ALEXTANG
bd0cfc5577 增加计时器TimerModule。
增加计时器TimerModule。
2023-11-22 12:20:08 +08:00
ALEXTANG
ff613e4130 更新修复导入图集初始化信息不全的bug
更新修复导入图集初始化信息不全的bug
2023-11-20 17:49:08 +08:00
ALEXTANG
fea1ae2278 Merge pull request #59 from AlanWeekend/main
优化分包资源下载逻辑,统一WebGL平台与其他平台的远程热更资源引用方式
2023-11-20 11:56:04 +08:00
Weekend
866c440479 add:初始化Package流程中增加webgl平台更新update配置 2023-11-19 02:01:15 +08:00
Weekend
48ff839d64 Merge branch 'main' of https://github.com/AlanWeekend/TEngine 2023-11-19 01:43:59 +08:00
Weekend
69be3cfa23 update:统一WebGL平台与其他平台的远程热更资源引用方式 2023-11-19 01:41:47 +08:00
Weekend
5f2c27ecf0 Merge branch 'ALEXTANGXIAO:main' into main 2023-11-18 21:46:00 +08:00
Weekend
ef17cd851b add:优化分包下载 2023-11-18 21:44:24 +08:00
ALEXTANG
f186d6b058 Merge pull request #58 from AlanWeekend/main
增加初始化指定资源包操作,单独下载指定地址的资源文件
2023-11-16 10:52:14 +08:00
Weekend
4385123976 add:设置图片资源支持从指定资源包中加载 2023-11-15 15:39:04 +08:00
Weekend
1334dc30f9 Merge branch 'main' of https://github.com/AlanWeekend/TEngine 2023-11-15 15:15:11 +08:00
Weekend
af822add2c add:下载资源包中指定地址的资源文件 2023-11-15 15:14:47 +08:00
Weekend
ffb1f214ad Merge branch 'ALEXTANGXIAO:main' into main 2023-11-15 14:41:45 +08:00
Weekend
213aaed426 add:初始化指定资源包 2023-11-15 14:40:35 +08:00
ALEXTANG
623d301e41 修正异步创建子Widget时SetParent的问题
修正异步创建子Widget时SetParent的问题
2023-11-15 14:06:49 +08:00
ALEXTANG
2870383afe Resource模块支持操作指定资源包的资源
Resource模块支持操作指定资源包的资源
2023-11-15 10:48:28 +08:00
ALEXTANG
1ad435958a Merge pull request #57 from AlanWeekend/main
add:Resource模块支持操作指定资源包的资源
2023-11-15 10:08:53 +08:00
Weekend
386787c6ec add:Resource模块支持操作指定资源包的资源 2023-11-15 00:14:07 +08:00
ALEXTANG
cd65dde4c3 ReleasePreLoadAssets修正在webgl模式下Shutdown的问题
ReleasePreLoadAssets修正在webgl模式下Shutdown的问题
2023-11-14 16:00:09 +08:00
ALEXTANG
8321e77421 Merge pull request #56 from AlanWeekend/main
fixed:looplistitem重复赋值问题
2023-11-13 13:09:25 +08:00
Weekend
1b6f80952e fixed:looplistitem重复赋值问题
fixed:looplistitem重复赋值问题
2023-11-12 19:49:02 +08:00
ALEXTANG
b52e655c30 更正错误注释
更正错误注释
2023-11-07 11:04:59 +08:00
ALEXTANG
8c0df95626 修正CancellationTokenSource重复Dispose问题
修正CancellationTokenSource重复Dispose问题
2023-11-03 16:58:42 +08:00
ALEXTANG
0d1e308f1c Update ResourceModule.cs 2023-11-03 10:07:25 +08:00
ALEXTANG
f8797538fd Update UIBase.cs 2023-11-03 09:55:36 +08:00
ALEXTANG
fe4e168041 Update ProcedurePreload.cs 2023-11-02 15:35:01 +08:00
ALEXTANG
8e9047d3a3 基于资源框架实现对标签WEBGL_PRELOAD、PRELOAD的预加载。 接口GameModule.Resource.GetPreLoadAsset<T>(location)
基于资源框架实现对标签WEBGL_PRELOAD、PRELOAD的预加载。 接口GameModule.Resource.GetPreLoadAsset<T>(location)
2023-11-02 13:16:05 +08:00
ALEXTANG
04bfaeccc8 示例CLI工作流
示例CLI工作流
2023-11-02 12:55:27 +08:00
ALEXTANG
d66c823c15 更新优化启用UpdateData时UILoadUpdate时序的问题
更新优化启用UpdateData时UILoadUpdate时序的问题
2023-11-02 11:48:47 +08:00
ALEXTANG
0ec1424f0a 升级HybridCLR 4.0.11=>4.0.12
升级HybridCLR 4.0.11=>4.0.12
2023-11-02 11:12:56 +08:00
ALEXTANG
01f8eb9d57 升级HybridCLR 4.0.10=>4.0.11 强烈建议升级,修复了若干bug
升级HybridCLR 4.0.10=>4.0.11 强烈建议升级,修复了若干bug
2023-11-02 10:01:30 +08:00
ALEXTANG
f5021a9688 修正Utility生命周期注入OnDestroy和OnDrawGizmos无效的问题
修正Utility生命周期注入OnDestroy和OnDrawGizmos无效的问题
2023-10-31 12:45:40 +08:00
ALEXTANG
a632f7a5ad Merge pull request #55 from AlanWeekend/main
修复demo流程的下载网速显示错误问题
2023-10-30 23:48:17 +08:00
Weekend
5f968f4154 优化网速计算
优化网速计算
2023-10-30 23:47:07 +08:00
Weekend
c9fe83c2bd Merge branch 'main' of https://github.com/AlanWeekend/TEngine 2023-10-30 23:04:05 +08:00
Weekend
2c00d103cb Update ProcedureDownloadFile.cs
fixed:demo流程的下载网速错误显示问题
2023-10-30 23:04:01 +08:00
ALEXTANG
1d56437d9f Update Utility.Http.cs 2023-10-30 11:15:52 +08:00
ALEXTANG
69db1ff977 修正音频模块音频代理类赋值问题
#54 修正音频模块音频代理类赋值问题
2023-10-30 10:40:22 +08:00
ALEXTANG
48887b1aee 框架支持Shudown不关闭游戏重启
框架支持Shudown不关闭游戏重启
2023-10-27 13:18:12 +08:00
ALEXTANG
381ea8bb8d 增加支持ComponentAutoBindTool自动绑定UI元素组件。
增加支持ComponentAutoBindTool自动绑定UI元素组件。
2023-10-27 10:48:21 +08:00
ALEXTANG
7401edac15 移除UIElement代码绑定工具,为后续AutoBind代码绑定工具做准备
移除UIElement代码绑定工具,为后续AutoBind代码绑定工具做准备
2023-10-27 00:13:04 +08:00
ALEXTANG
b1c7f30be9 ErrorLogger屏幕显示开启与DebugModule关联。
ErrorLogger屏幕显示开启与DebugModule关联。
2023-10-26 23:45:26 +08:00
ALEXTANG
cfaf82a623 释放资源判断资源是否有效
释放资源判断资源是否有效
2023-10-26 14:07:38 +08:00
ALEXTANG
6992d12c6c 修复循环列表主动GetItemByIndex和GetItemList的问题
修复循环列表主动GetItemByIndex和GetItemList的问题
2023-10-26 13:12:35 +08:00
ALEXTANG
119d9683ad Merge pull request #53 from AlanWeekend/main
修复UIListBase和UILoopListWidget赋值问题
2023-10-26 12:49:00 +08:00
ALEXTANG
9478868513 修正HttpDispose
修正HttpDispose
2023-10-26 12:28:06 +08:00
ALEXTANG
6ed32082e1 修正HttpDispose
修正HttpDispose
2023-10-26 11:43:32 +08:00
ALEXTANG
6ee515e8c5 增加局部单位事件分发器的封装。
增加局部单位事件分发器的封装。
2023-10-26 10:28:05 +08:00
ALEXTANG
b839afa76a 释放资源判断资源是否有效、支持YooAssets日志重定向
释放资源判断资源是否有效、支持YooAssets日志重定向
2023-10-26 00:22:02 +08:00
Weekend
d9605b348a 修复UILoopListWidget赋值问题 2023-10-25 22:34:02 +08:00
Weekend
dfef83919c 修复UIListBase和UIUILoopListWidget赋值问题 2023-10-25 22:18:57 +08:00
ALEXTANG
f5f983f220 移除资源模块加载场景,加载场景统一走场景管理模块。增加场景加载进度回调。
移除资源模块加载场景,加载场景统一走场景管理模块。增加场景加载进度回调。
2023-10-23 17:01:06 +08:00
ALEXTANG
d61b1206ee 通过CommandLineReader可以不前台开启Unity实现静默打包,详见CommandLineReader.cs example1
通过CommandLineReader可以不前台开启Unity实现静默打包,详见CommandLineReader.cs example1
2023-10-23 15:22:34 +08:00
ALEXTANG
3650ba1a8b 更新转表bat自动拷贝ConfigSystem
更新转表bat自动拷贝ConfigSystem
2023-10-23 13:00:40 +08:00
ALEXTANG
8f14a4d2cb 日志重定向相关的实用函数。
日志重定向相关的实用函数。
2023-10-23 11:41:44 +08:00
ALEXTANG
dc22e595c9 拓展支持AssetInspector,支持更多文件类型在Inspector显示
拓展支持AssetInspector,支持更多文件类型在Inspector显示
2023-10-23 11:41:33 +08:00
ALEXTANG
0e70f7d446 日志重定向相关的实用函数。
日志重定向相关的实用函数。
2023-10-23 11:27:06 +08:00
ALEXTANG
039569b2d4 提交配置表加载模板
提交配置表加载模板
2023-10-23 10:15:11 +08:00
ALEXTANG
ea38004ba2 luban-next支持懒加载 感谢半仙儿提供支持
luban-next支持懒加载 感谢半仙儿提供支持
2023-10-20 16:24:00 +08:00
ALEXTANG
cc97c0583a 升级luban-next
升级luban-next
2023-10-20 11:53:29 +08:00
ALEXTANG
887094a4b1 升级luban-next
升级luban-next
2023-10-20 11:38:51 +08:00
ALEXTANG
0d09a7e73b 增加场景管理模块。
增加场景管理模块。
2023-10-18 16:42:44 +08:00
ALEXTANG
d8f8514f9d WebGL下不对YooAssets.Destroy();
WebGL下不对YooAssets.Destroy();
2023-10-18 11:23:20 +08:00
ALEXTANG
f2f6b2422f 资源模块优化、UI模块优化,增加接口参数是否使用缓存资源操作句柄。
资源模块优化、UI模块优化,增加接口参数是否使用缓存资源操作句柄、如果需要则不会淘汰缓存队列中的资源清单。
2023-10-18 10:30:12 +08:00
ALEXTANG
3a9cad9397 Update ResourceManager.cs 2023-10-16 16:38:13 +08:00
ALEXTANG
5e70e7972e 更新资源模块接口
更新资源模块接口
2023-10-16 13:03:41 +08:00
ALEXTANG
8d2b4200d6 升级HybridCLR 4.0.8=>4.0.10
升级HybridCLR 4.0.8=>4.0.10
2023-10-13 16:09:34 +08:00
ALEXTANG
b983e85416 资源模块优化-使用资源缓存表以及资源淘汰算法,缓存常用资源,利于获取、淘汰不常用资源。
资源模块优化-使用资源缓存表以及资源淘汰算法,缓存常用资源,利于获取、淘汰不常用资源。
2023-10-13 15:53:16 +08:00
ALEXTANG
99d2afdbd7 事件模块通用命名。
事件模块通用命名。
2023-10-10 21:00:21 +08:00
ALEXTANG
57ce836b3c 升级HybridCLR 4.0.7=>4.0.8
升级HybridCLR 4.0.7=>4.0.8
2023-10-10 20:21:33 +08:00
ALEXTANG
8dce78d6fb 事件模块拓展参数支持。
事件模块拓展参数支持。
2023-10-10 18:13:51 +08:00
ALEXTANG
6d41adffd9 音频模块初始化可自定义音频混响器.
音频模块初始化可自定义音频混响器.
2023-10-10 18:09:35 +08:00
ALEXTANG
cb9129261b 增加通过Tag加载资源对象集合的接口。
增加通过Tag加载资源对象集合的接口。
2023-10-09 19:37:00 +08:00
ALEXTANG
89dd6214d4 修复首次图集导入bug
修复首次图集导入bug
2023-10-09 19:37:00 +08:00
ALEXTANG
1aec76d64c 更新packages
1.升级HybridCLR 4.0.6=>4.0.7
2.使用Unity新版MemoryProfiler
2023-10-09 19:37:00 +08:00
ALEXTANG
859f654f6d 关闭垂直同步,避免设置帧率失效
关闭垂直同步,避免设置帧率失效
2023-10-09 19:37:00 +08:00
ALEXTANG
391d690f9d Merge pull request #49 from ALEXTANGXIAO/TEngine_v4.0.0
TEngine v4.0.0
2023-10-08 16:02:59 +08:00
ALEXTANG
bb0b4104f9 Create about.txt 2023-10-08 15:49:30 +08:00
ALEXTANG
20d0ecd8da Init TEngine4.0.0
Init TEngine4.0.0
2023-10-08 15:47:33 +08:00
ALEXTANG
8c3d6308b9 Init TEngine4.0.0
Init TEngine4.0.0
2023-10-08 15:21:33 +08:00
ALEXTANGXIAO
4c8c37ffd8 异步加载原生文件接口问题修正。
异步加载原生文件接口问题修正。
2023-10-04 18:58:45 +08:00
ALEXTANG
5f694c2bed WebGL毛玻璃效果使用默认
WebGL毛玻璃效果使用默认
2023-09-18 16:41:08 +08:00
ALEXTANG
7ff74bb747 Update GameTime.cs 2023-09-18 16:40:51 +08:00
ALEXTANG
a5de63397a Update 3-4-对象池模块.md 2023-09-18 12:00:36 +08:00
ALEXTANG
13cc62f3f1 增加打印输出协议
增加打印输出协议
2023-09-15 14:07:26 +08:00
ALEXTANGXIAO
95dfac5294 支持普通协议对象数据结构不加入opcode
支持普通协议对象数据结构不加入opcode
2023-09-06 00:13:14 +08:00
ALEXTANGXIAO
14e95107c9 服务器ByteBuf消除警告
服务器ByteBuf消除警告
2023-09-05 23:57:12 +08:00
ALEXTANGXIAO
caf5b2b54e 导出网络协议增加了缓存文件保证一致性
导出网络协议增加了缓存文件保证一致性
2023-09-05 23:56:50 +08:00
ALEXTANG
285483034e Update Exporter.cs 2023-09-05 21:08:54 +08:00
ALEXTANG
1cdd8b63b4 同步服务器导出SceneType
同步服务器导出SceneType
2023-09-05 21:07:33 +08:00
ALEXTANG
4c748df7ac Update ProcedureInitPackage.cs 2023-09-05 20:53:56 +08:00
ALEXTANG
e1229b5a4b 移除无用Extension
移除无用Extension
2023-09-05 20:28:37 +08:00
ALEXTANG
b937fb1a37 [-] 移除Luban无用转表bat
[-] 移除Luban无用转表bat
2023-09-05 19:08:02 +08:00
ALEXTANG
87ab99b363 修复了KCPClientNetwork断开网络连接会发生异常的问题
修复了KCPClientNetwork断开网络连接会发生异常的问题
2023-09-05 14:39:53 +08:00
ALEXTANG
e3a47393f4 [+] 新增游戏物体缓存池ResourcePool
[+] 新增游戏物体缓存池ResourcePool
2023-09-05 14:35:19 +08:00
ALEXTANG
75725314ad FIxed 网络模块对象池复使用问题
FIxed 网络模块对象池复使用问题
2023-09-04 10:06:20 +08:00
ALEXTANG
d3ed2b21b9 Update AudioModule.cs 2023-08-28 20:53:40 +08:00
ALEXTANG
ec34dfbb16 Delete protobuf-net.csproj.meta 2023-08-28 20:41:10 +08:00
ALEXTANG
bd76e3a651 移除示例配置资源.
移除示例配置资源.
2023-08-28 20:35:30 +08:00
ALEXTANG
278c8f23be Update DefaultSettingSerializer.cs 2023-08-28 20:24:31 +08:00
ALEXTANG
42568db2ab Add System.Runtime.CompilerServices.Unsafe.dll
Add System.Runtime.CompilerServices.Unsafe.dll
2023-08-28 20:13:06 +08:00
ALEXTANG
b033c59b00 Aot程序集不查找热更域的Type
Aot程序集不查找热更域的Type
2023-08-28 15:08:18 +08:00
ALEXTANG
04a43a3f11 1.增加重启流程Procedure接口。2.增加进入热更域后的流程Procedure。
1.增加重启流程Procedure接口。2.增加进入热更域后的流程Procedure。
2023-08-26 11:08:46 +08:00
ALEXTANG
54214cdd0b 程序集AssemblyDefine增加对UniTask textmeshpro和dotween的拓展
程序集AssemblyDefine增加对UniTask textmeshpro和dotween的拓展
2023-08-25 14:50:20 +08:00
ALEXTANG
fa870b6228 DotNet支持自定义协议目录
DotNet支持自定义协议目录
2023-08-24 18:38:05 +08:00
ALEXTANG
8a49d3437b Delete proto_csOuterMessage.proto 2023-08-24 17:47:42 +08:00
ALEXTANG
f19b889deb DotNet支持自定义协议目录
DotNet支持自定义协议目录
2023-08-24 17:47:21 +08:00
ALEXTANG
d55f6e29d9 Update RootModule.cs 2023-08-22 11:27:58 +08:00
ALEXTANG
8e4af31f26 修改默认UI资源组的PackRule为PackSeparately
修改默认UI资源组的PackRule为PackSeparately
2023-08-21 20:21:59 +08:00
ALEXTANG
58a4b3e043 YooAsset增加补丁包导入工具和补丁包对比工具
YooAsset增加补丁包导入工具和补丁包对比工具
2023-08-21 20:21:03 +08:00
ALEXTANG
576bf3bb48 增加可选的JsonHelper - NewtonsoftJsonHelper
增加可选的JsonHelper - NewtonsoftJsonHelper
2023-08-21 20:20:28 +08:00
ALEXTANG
d282b81546 增加使用UniTask的常用资源加载接口
增加使用UniTask的常用资源加载接口
2023-08-19 16:23:19 +08:00
4371 changed files with 83605 additions and 181136 deletions

135
.gitignore vendored
View File

@@ -1,132 +1,15 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/
/EditorBuild/
# /[Aa]ssets/TResources/DLL/
/[Aa]ssets/StreamingAssets
/BuildBundleInfo/
[Aa]ssets/AATest/
[Aa]ssets/AATest.meta
# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
# Crashlytics generated file
crashlytics-build.properties
# TEnginePersistentDataPath
TEnginePersistentDataPath/
# Hotfix
TEngineHotUpdate/bin
TEngineHotUpdate/obj
#HybirdCLR(HuaTuo)
/HybirdCLRData/
[Hh]ybridCLRData/
#AATemp
[Aa]ssets/AATemp/
[Aa]ssets/AATemp.meta
#Rider
/.idea/
# ABConfig
[Aa]ssets/BuildConfig/
[Aa]ssets/BuildConfig.meta
[Aa]ssets/StreamingAssets/
[Aa]ssets/StreamingAssets.meta
Assets/HybridCLRBuildCache/AssetBundleOutput.meta
Assets/HybridCLRBuildCache/AssetBundleOutput/StandaloneWindows.meta
Assets/HybridCLRBuildCache.meta
Assets/HybridCLRBuildCache/AssetBundleSourceData.meta
Assets/HybridCLRBuildCache/AssetBundleSourceData/StandaloneWindows.meta
#Bundles
Bundles/
#Sandbox
Sandbox/
UnityProject/UserSettings/Layouts/default-2021.dwlt
UnityProject/UserSettings/Search.settings
#Luban
Luban/.cache.meta
Tools/Luban/
Tools/Luban.ClientServer/
Configs/.cache.meta
GenerateDatas/
#HybridCLR
Assets/HybridCLRData.meta
UserSettings/Search.settings
#FileServer
Tools/FileServer/AssetRoot
#Unity UserSettings
UserSettings/Search.index
UserSettings/Layouts/default-2021.dwlt
#UnityOnlineServiceData
Assets/UnityOnlineServiceData.meta
Assets/UnityOnlineServiceData
#MAC
.DS_Store
#Server_sln
DotNet/.idea/
DotNet/App/obj/
DotNet/Core/obj/
DotNet/Logic/obj/
DotNet/ThirdParty/obj/
Bin/
#Server_Config
DotNet/Config/GameConfig
UnityProject/ProjectSettings/CommonBurstAotSettings.json
UnityProject/ProjectSettings/BurstAotSettings_StandaloneWindows.json

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 6a824de3af698c34bb4343dbb911498b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 8f3bcefaf67e76141a6d8edeb8354fea
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 25113973d38eb5a48b064863830539a4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ef51ed54e72f97a4ab530b932680e08b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 090163c612f34ac4fb80004ac5f057b4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 930f8bca659c7504b8fe431ee8c40e7b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ad23fce0bd282924fa4aedb4da24684f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ed92f6b6b24543747bc10eba9141feb1
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,69 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!687078895 &4343727234628468602
SpriteAtlas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UIRaw_Atlas_Common
serializedVersion: 2
m_EditorData:
serializedVersion: 2
textureSettings:
serializedVersion: 2
anisoLevel: 0
compressionQuality: 0
maxTextureSize: 0
textureCompression: 0
filterMode: 1
generateMipMaps: 0
readable: 0
crunchedCompression: 0
sRGB: 1
platformSettings:
- serializedVersion: 3
m_BuildTarget: iPhone
m_MaxTextureSize: 2048
m_ResizeAlgorithm: 0
m_TextureFormat: 49
m_TextureCompression: 1
m_CompressionQuality: 100
m_CrunchedCompression: 0
m_AllowsAlphaSplitting: 0
m_Overridden: 1
m_AndroidETC2FallbackOverride: 0
m_ForceMaximumCompressionQuality_BC6H_BC7: 0
packingSettings:
serializedVersion: 2
padding: 2
blockOffset: 1
allowAlphaSplitting: 0
enableRotation: 1
enableTightPacking: 0
enableAlphaDilation: 0
secondaryTextureSettings: {}
variantMultiplier: 1
packables:
- {fileID: 21300000, guid: f9a06e163014f4f46b14f4499d3e7240, type: 3}
- {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3}
- {fileID: 21300000, guid: d623a2b7e069a4c4592d3da48f476189, type: 3}
- {fileID: 21300000, guid: 57e4117f4cd6ae54284898652e70d553, type: 3}
bindAsDefault: 1
isAtlasV2: 0
cachedData: {fileID: 0}
m_MasterAtlas: {fileID: 0}
m_PackedSprites:
- {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3}
- {fileID: 21300000, guid: f9a06e163014f4f46b14f4499d3e7240, type: 3}
- {fileID: 21300000, guid: d623a2b7e069a4c4592d3da48f476189, type: 3}
- {fileID: 21300000, guid: 57e4117f4cd6ae54284898652e70d553, type: 3}
m_PackedSpriteNamesToIndex:
- red_button
- blue_button
- white_background
- white_button
m_RenderDataMap: {}
m_Tag: UIRaw_Atlas_Common
m_IsVariant: 0
m_IsPlaceholder: 0

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: dbb608c870018e94d9603500e9cb4d5e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: fdae3569c5cbfe54e97778a1f7e7af21
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,117 +0,0 @@
#if TENGINE_NET
using CommandLine;
using TEngine.Core;
using NLog;
namespace TEngine
{
public static class App
{
public static void Init()
{
try
{
// 设置默认的线程的同步上下文
SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Main);
// 解析命令行参数
Parser.Default.ParseArguments<CommandLineOptions>(Environment.GetCommandLineArgs())
.WithNotParsed(error => throw new Exception("Command line format error!"))
.WithParsed(option => AppDefine.Options = option);
// 加载框架配置
TEngineSettingsHelper.Initialize();
// 检查启动参数
switch (AppDefine.Options.AppType)
{
case AppType.Game:
{
break;
}
case AppType.Export:
{
new Exporter().Start();
return;
}
default:
{
throw new NotSupportedException($"AppType is {AppDefine.Options.AppType} Unrecognized!");
}
}
// 根据不同的运行模式来选择日志的方式
switch (AppDefine.Options.Mode)
{
case Mode.Develop:
{
LogManager.Configuration.RemoveRuleByName("ConsoleTrace");
LogManager.Configuration.RemoveRuleByName("ConsoleDebug");
LogManager.Configuration.RemoveRuleByName("ConsoleInfo");
LogManager.Configuration.RemoveRuleByName("ConsoleWarn");
LogManager.Configuration.RemoveRuleByName("ConsoleError");
LogManager.Configuration.RemoveRuleByName("ServerDebug");
LogManager.Configuration.RemoveRuleByName("ServerTrace");
LogManager.Configuration.RemoveRuleByName("ServerInfo");
LogManager.Configuration.RemoveRuleByName("ServerWarn");
LogManager.Configuration.RemoveRuleByName("ServerError");
break;
}
case Mode.Release:
{
LogManager.Configuration.RemoveRuleByName("ConsoleTrace");
LogManager.Configuration.RemoveRuleByName("ConsoleDebug");
LogManager.Configuration.RemoveRuleByName("ConsoleInfo");
LogManager.Configuration.RemoveRuleByName("ConsoleWarn");
LogManager.Configuration.RemoveRuleByName("ConsoleError");
break;
}
}
// 初始化SingletonSystemCenter这个一定要放到最前面
// 因为SingletonSystem会注册AssemblyManager的OnLoadAssemblyEvent和OnUnLoadAssemblyEvent的事件
// 如果不这样、会无法把程序集的单例注册到SingletonManager中
SingletonSystem.Initialize();
// 加载核心程序集
AssemblyManager.Initialize();
Log.Info($"Start Server Param => {Parser.Default.FormatCommandLine(AppDefine.Options)}");
}
catch (Exception exception)
{
Log.Error(exception);
}
}
public static async FTask Start()
{
switch (AppDefine.Options.Mode)
{
case Mode.Develop:
{
// 开发模式默认所有Server都在一个进程中、方便调试、但网络还都是独立的
var serverConfigInfos = ConfigTableManage.AllServerConfig();
foreach (var serverConfig in serverConfigInfos)
{
await Server.Create(serverConfig.Id);
}
return;
}
case Mode.Release:
{
// 发布模式只会启动启动参数传递的Server、也就是只会启动一个Server
// 您可以做一个Server专门用于管理启动所有Server的工作
await Server.Create(AppDefine.Options.AppId);
return;
}
}
}
public static void Close()
{
SingletonSystem.Dispose();
AssemblyManager.Dispose();
}
}
}
#endif

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f6b4f60ee2b59b649835c9b25028d9e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,11 +0,0 @@
#if TENGINE_NET
#pragma warning disable CS8618
namespace TEngine
{
public static class AppDefine
{
public static CommandLineOptions Options;
public static uint AppId => Options.AppId;
}
}
#endif

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e08a4791989b16843a924bf798cdaa34
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9d838cbc15b0f034bb83f3aa5ea5b72d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,44 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using TEngine.DataStructure;
namespace TEngine.Core
{
public sealed class AssemblyInfo
{
public Assembly Assembly { get; private set; }
public readonly List<Type> AssemblyTypeList = new List<Type>();
public readonly OneToManyList<Type, Type> AssemblyTypeGroupList = new OneToManyList<Type, Type>();
public void Load(Assembly assembly)
{
Assembly = assembly;
var assemblyTypes = assembly.GetTypes().ToList();
foreach (var type in assemblyTypes)
{
if (type.IsAbstract || type.IsInterface)
{
continue;
}
var interfaces = type.GetInterfaces();
foreach (var interfaceType in interfaces)
{
AssemblyTypeGroupList.Add(interfaceType, type);
}
}
AssemblyTypeList.AddRange(assemblyTypes);
}
public void Unload()
{
AssemblyTypeList.Clear();
AssemblyTypeGroupList.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: aee73bf0d744afd439ef9b6a5d531951
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,172 +0,0 @@
using System;
using System.Collections.Generic;
using System.Reflection;
#if TENGINE_NET
using System.Runtime.Loader;
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
#endif
#pragma warning disable CS8603
#pragma warning disable CS8618
namespace TEngine.Core
{
public static class AssemblyManager
{
public static event Action<int> OnLoadAssemblyEvent;
public static event Action<int> OnUnLoadAssemblyEvent;
public static event Action<int> OnReLoadAssemblyEvent;
private static readonly Dictionary<int, AssemblyInfo> AssemblyList = new Dictionary<int, AssemblyInfo>();
public static void Initialize()
{
LoadAssembly(int.MaxValue, typeof(AssemblyManager).Assembly);
}
public static void LoadAssembly(int assemblyName, Assembly assembly)
{
var isReLoad = false;
if (!AssemblyList.TryGetValue(assemblyName, out var assemblyInfo))
{
assemblyInfo = new AssemblyInfo();
AssemblyList.Add(assemblyName, assemblyInfo);
}
else
{
isReLoad = true;
assemblyInfo.Unload();
if (OnUnLoadAssemblyEvent != null)
{
OnUnLoadAssemblyEvent(assemblyName);
}
}
assemblyInfo.Load(assembly);
if (OnLoadAssemblyEvent != null)
{
OnLoadAssemblyEvent(assemblyName);
}
if (isReLoad && OnReLoadAssemblyEvent != null)
{
OnReLoadAssemblyEvent(assemblyName);
}
}
public static void Load(int assemblyName, Assembly assembly)
{
if (int.MaxValue == assemblyName)
{
throw new NotSupportedException("AssemblyName cannot be 2147483647");
}
LoadAssembly(assemblyName, assembly);
}
public static IEnumerable<int> ForEachAssemblyName()
{
foreach (var (key, _) in AssemblyList)
{
yield return key;
}
}
public static IEnumerable<Type> ForEach()
{
foreach (var (_, assemblyInfo) in AssemblyList)
{
foreach (var type in assemblyInfo.AssemblyTypeList)
{
yield return type;
}
}
}
public static IEnumerable<Type> ForEach(int assemblyName)
{
if (!AssemblyList.TryGetValue(assemblyName, out var assemblyInfo))
{
yield break;
}
foreach (var type in assemblyInfo.AssemblyTypeList)
{
yield return type;
}
}
public static IEnumerable<Type> ForEach(Type findType)
{
foreach (var (_, assemblyInfo) in AssemblyList)
{
if (!assemblyInfo.AssemblyTypeGroupList.TryGetValue(findType, out var assemblyLoad))
{
yield break;
}
foreach (var type in assemblyLoad)
{
yield return type;
}
}
}
public static IEnumerable<Type> ForEach(int assemblyName, Type findType)
{
if (!AssemblyList.TryGetValue(assemblyName, out var assemblyInfo))
{
yield break;
}
if (!assemblyInfo.AssemblyTypeGroupList.TryGetValue(findType, out var assemblyLoad))
{
yield break;
}
foreach (var type in assemblyLoad)
{
yield return type;
}
}
public static Assembly GetAssembly(int assemblyName)
{
return !AssemblyList.TryGetValue(assemblyName, out var assemblyInfo) ? null : assemblyInfo.Assembly;
}
public static void Dispose()
{
foreach (var (_, assemblyInfo) in AssemblyList)
{
assemblyInfo.Unload();
}
AssemblyList.Clear();
if (OnLoadAssemblyEvent != null)
{
foreach (var @delegate in OnLoadAssemblyEvent.GetInvocationList())
{
OnLoadAssemblyEvent -= @delegate as Action<int>;
}
}
if (OnUnLoadAssemblyEvent != null)
{
foreach (var @delegate in OnUnLoadAssemblyEvent.GetInvocationList())
{
OnUnLoadAssemblyEvent -= @delegate as Action<int>;
}
}
if (OnReLoadAssemblyEvent != null)
{
foreach (var @delegate in OnReLoadAssemblyEvent.GetInvocationList())
{
OnReLoadAssemblyEvent -= @delegate as Action<int>;
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8d7a578f700ea034a9b98a5f63491eb3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,67 +0,0 @@
#if TENGINE_NET
using CommandLine;
using TEngine.Core;
#pragma warning disable CS8618
namespace TEngine;
public enum AppType
{
Game,
Export,
/// <summary>
/// 每台物理机一个守护进程,用来启动该物理机上的所有进程。
/// </summary>
Watcher,
}
public enum Mode
{
/// <summary>
/// Develop:所有Server都在一个进程中,Release:每个Server都在独立的进程中。
/// </summary>
Release,
Develop,
}
public class CommandLineOptions
{
/// <summary>
/// 进程Id
/// </summary>
[Option("AppId", Required = false, Default = (uint)0, HelpText = "Enter an AppId such as 1")]
public uint AppId { get; set; }
/// <summary>
/// App类型
/// Game - 游戏服务器App
/// Export - 导表App
/// </summary>
[Option("AppType", Required = false, Default = AppType.Game, HelpText = "AppType enum")]
public AppType AppType { get; set; }
/// <summary>
/// 服务器运行模式
/// Develop - 开发模式所有Server都在一个进程中
/// Release - 发布模式每个Server都在独立的进程中
/// </summary>
[Option("Mode", Required = false, Default = Mode.Develop, HelpText = "Mode enum")]
public Mode Mode { get; set; }
[Option("LogLevel", Required = false, Default = 2)]
public int LogLevel { get; set; }
#if TENGINE_NET
/// <summary>
/// 导表的类型
/// </summary>
[Option("ExcelExportType", Required = false, Default = ExportType.None, HelpText = "Increment,All")]
public ExportType ExportType { get; set; }
#endif
}
#endif

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c644dc25b4098d24683e949b5a14f754
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
namespace TEngine.Core
{
public class CoreErrorCode
{
public const uint ErrRpcFail = 100000002; // Rpc消息发送失败
public const uint ErrNotFoundRoute = 100000003; // 没有找到Route消息
public const uint ErrRouteTimeout = 100000004; // 发送Route消息超时
public const uint Error_NotFindEntity = 100000008; // 没有找到Entity
public const uint Error_CopyTimeout = 100000009; // CopyTimeout不能小于或等于0
public const uint Error_Transfer = 100000010;// 传送发生了错误
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d0b2fb99ac2580c418659e6a1328206b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 21519f62191bd1447bfafd815de9046d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,61 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.Core
{
public sealed class CoroutineLockQueue : IDisposable
{
public long Key { get; private set; }
public CoroutineLockQueueType CoroutineLockQueueType { get; private set; }
private readonly Queue<WaitCoroutineLock> _waitCoroutineLocks = new Queue<WaitCoroutineLock>();
public static CoroutineLockQueue Create(long key, int time, CoroutineLockQueueType coroutineLockQueueType)
{
var coroutineLockQueue = Pool<CoroutineLockQueue>.Rent();
coroutineLockQueue.Key = key;
coroutineLockQueue.CoroutineLockQueueType = coroutineLockQueueType;
return coroutineLockQueue;
}
public void Dispose()
{
Key = 0;
CoroutineLockQueueType = null;
Pool<CoroutineLockQueue>.Return(this);
}
public async FTask<WaitCoroutineLock> Lock(string tag, int time)
{
#if TENGINE_DEVELOP
if (_waitCoroutineLocks.Count >= 100)
{
// 当等待队列超过100个、表示这个协程锁可能有问题、打印一个警告方便排查错误
Log.Warning($"too much waitCoroutineLock CoroutineLockQueueType:{CoroutineLockQueueType.Name} Key:{Key} Count: {_waitCoroutineLocks.Count} ");
}
#endif
var waitCoroutineLock = WaitCoroutineLock.Create(this, tag, time);
_waitCoroutineLocks.Enqueue(waitCoroutineLock);
return await waitCoroutineLock.Tcs;
}
public void Release()
{
if (_waitCoroutineLocks.Count == 0)
{
CoroutineLockQueueType.Remove(Key);
return;
}
while (_waitCoroutineLocks.TryDequeue(out var waitCoroutineLock))
{
if (waitCoroutineLock.IsDisposed)
{
continue;
}
waitCoroutineLock.SetResult();
break;
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8f07b80619d455d4499aefbc3eab9f65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.Core
{
public sealed class CoroutineLockQueueType
{
public readonly string Name;
private readonly Dictionary<long, CoroutineLockQueue> _coroutineLockQueues = new Dictionary<long, CoroutineLockQueue>();
private CoroutineLockQueueType() { }
public CoroutineLockQueueType(string name)
{
Name = name;
}
public async FTask<WaitCoroutineLock> Lock(long key, string tag = null, int time = 10000)
{
if (_coroutineLockQueues.TryGetValue(key, out var coroutineLockQueue))
{
return await coroutineLockQueue.Lock(tag,time);
}
coroutineLockQueue = CoroutineLockQueue.Create(key, time, this);
_coroutineLockQueues.Add(key, coroutineLockQueue);
return WaitCoroutineLock.Create(coroutineLockQueue, tag, time);
}
public void Remove(long key)
{
if (_coroutineLockQueues.Remove(key, out var coroutineLockQueue))
{
coroutineLockQueue.Dispose();
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2067a4304a800324bbe9c547eefac9fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,93 +0,0 @@
using System;
using TEngine.Core;
namespace TEngine.Core
{
public struct CoroutineLockTimeout
{
public long LockId;
public WaitCoroutineLock WaitCoroutineLock;
}
public sealed class OnCoroutineLockTimeout : EventSystem<CoroutineLockTimeout>
{
public override void Handler(CoroutineLockTimeout self)
{
if (self.LockId != self.WaitCoroutineLock.LockId)
{
return;
}
var coroutineLockQueue = self.WaitCoroutineLock.CoroutineLockQueue;
var coroutineLockQueueType = coroutineLockQueue.CoroutineLockQueueType;
var key = coroutineLockQueue.Key;
Log.Error($"coroutine lock timeout CoroutineLockQueueType:{coroutineLockQueueType.Name} Key:{key} Tag:{self.WaitCoroutineLock.Tag}");
}
}
public sealed class WaitCoroutineLock : IDisposable
{
private long _timerId;
public bool IsDisposed => LockId == 0;
public string Tag { get; private set; }
public long LockId { get; private set; }
public FTask<WaitCoroutineLock> Tcs { get; private set; }
public CoroutineLockQueue CoroutineLockQueue{ get; private set; }
public static WaitCoroutineLock Create(CoroutineLockQueue coroutineLockQueue, string tag, int timeOut)
{
var lockId = IdFactory.NextRunTimeId();
var waitCoroutineLock = Pool<WaitCoroutineLock>.Rent();
waitCoroutineLock.Tag = tag;
waitCoroutineLock.LockId = lockId;
waitCoroutineLock.CoroutineLockQueue = coroutineLockQueue;
waitCoroutineLock.Tcs = FTask<WaitCoroutineLock>.Create();
waitCoroutineLock._timerId = TimerScheduler.Instance.Core.OnceTimer(timeOut, new CoroutineLockTimeout()
{
LockId = lockId, WaitCoroutineLock = waitCoroutineLock
});
return waitCoroutineLock;
}
public void Dispose()
{
if (IsDisposed)
{
Log.Error("WaitCoroutineLock is Dispose");
return;
}
Release(CoroutineLockQueue);
LockId = 0;
Tcs = null;
Tag = null;
CoroutineLockQueue = null;
if (_timerId != 0)
{
TimerScheduler.Instance.Core.RemoveByRef(ref _timerId);
}
Pool<WaitCoroutineLock>.Return(this);
}
private static void Release(CoroutineLockQueue coroutineLockQueue)
{
// 放到下一帧执行释放锁、如果不这样、会导致逻辑的顺序不正常
ThreadSynchronizationContext.Main.Post(coroutineLockQueue.Release);
}
public void SetResult()
{
if (Tcs == null)
{
throw new NullReferenceException("SetResult tcs is null");
}
Tcs.SetResult(this);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1ee0d61ec53909c4695fe2ecc97f42bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9f6012de0e164ce4da102c93fa2df9ea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: bd10fb6ee217e1e4a82db518e161aaec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,48 +0,0 @@
#if TENGINE_NET
using System.Linq.Expressions;
#pragma warning disable CS8625
namespace TEngine.Core.DataBase;
public interface IDateBase
{
public static readonly CoroutineLockQueueType DataBaseLock = new CoroutineLockQueueType("DataBaseLock");
IDateBase Initialize(string connectionString, string dbName);
FTask<long> Count<T>(string collection = null) where T : Entity;
FTask<long> Count<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity;
FTask<bool> Exist<T>(string collection = null) where T : Entity;
FTask<bool> Exist<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity;
FTask<T> QueryNotLock<T>(long id, string collection = null) where T : Entity;
FTask<T> Query<T>(long id, string collection = null) where T : Entity;
FTask<(int count, List<T> dates)> QueryCountAndDatesByPage<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, string collection = null) where T : Entity;
FTask<(int count, List<T> dates)> QueryCountAndDatesByPage<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, string[] cols, string collection = null) where T : Entity;
FTask<List<T>> QueryByPage<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, string collection = null) where T : Entity;
FTask<List<T>> QueryByPage<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, string[] cols, string collection = null) where T : Entity;
FTask<List<T>> QueryByPageOrderBy<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, Expression<Func<T, object>> orderByExpression, bool isAsc = true, string collection = null) where T : Entity;
FTask<T> First<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity;
FTask<T> First<T>(string json, string[] cols, string collection = null) where T : Entity;
FTask<T> Last<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity;
FTask<List<T>> QueryOrderBy<T>(Expression<Func<T, bool>> filter, Expression<Func<T, object>> orderByExpression, bool isAsc = true, string collection = null) where T : Entity;
FTask<List<T>> Query<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity;
FTask Query(long id, List<string> collectionNames, List<Entity> result);
FTask<List<T>> QueryJson<T>(string json, string collection = null) where T : Entity;
FTask<List<T>> QueryJson<T>(string json, string[] cols, string collection = null) where T : Entity;
FTask<List<T>> QueryJson<T>(long taskId, string json, string collection = null) where T : Entity;
FTask<List<T>> Query<T>(Expression<Func<T, bool>> filter, string[] cols, string collection = null) where T : class;
FTask Save<T>(T entity, string collection = null) where T : Entity, new();
FTask Save(long id, List<Entity> entities);
FTask Save<T>(object transactionSession, T entity, string collection = null) where T : Entity;
FTask Insert<T>(T entity, string collection = null) where T : Entity, new();
FTask InsertBatch<T>(IEnumerable<T> list, string collection = null) where T : Entity, new();
FTask InsertBatch<T>(object transactionSession, IEnumerable<T> list, string collection = null) where T : Entity, new();
FTask<long> Remove<T>(object transactionSession, long id, string collection = null) where T : Entity, new();
FTask<long> Remove<T>(long id, string collection = null) where T : Entity, new();
FTask<long> Remove<T>(long id,object transactionSession, Expression<Func<T, bool>> filter, string collection = null) where T : Entity, new();
FTask<long> Remove<T>(long id, Expression<Func<T, bool>> filter, string collection = null) where T : Entity, new();
FTask<long> Sum<T>(Expression<Func<T, bool>> filter, Expression<Func<T, object>> sumExpression, string collection = null) where T : Entity;
FTask CreateIndex<T>(string collection, params object[] keys) where T : Entity;
FTask CreateIndex<T>(params object[] keys) where T : Entity;
FTask CreateDB<T>() where T : Entity;
FTask CreateDB(Type type);
}
#endif

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 801a4f2fbf5d7944480423ade9d8a998
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,42 +0,0 @@
#if TENGINE_NET
namespace TEngine.Core.DataBase;
public sealed class World
{
public uint Id { get; private init; }
public IDateBase DateBase { get; private init; }
public WorldConfigInfo Config => ConfigTableManage.WorldConfigInfo(Id);
private static readonly Dictionary<uint, World> Worlds = new();
public World(WorldConfigInfo worldConfigInfo)
{
Id = worldConfigInfo.Id;
var dbType = worldConfigInfo.DbType.ToLower();
switch (dbType)
{
case "mongodb":
{
DateBase = new MongoDataBase();
DateBase.Initialize(worldConfigInfo.DbConnection, worldConfigInfo.DbName);
break;
}
default:
throw new Exception("No supported database");
}
}
public static World Create(uint id)
{
if (Worlds.TryGetValue(id, out var world))
{
return world;
}
var worldConfigInfo = ConfigTableManage.WorldConfigInfo(id);
world = new World(worldConfigInfo);
Worlds.Add(id, world);
return world;
}
}
#endif

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e207b62400a4d2742945b50eb84f8233
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
#if TENGINE_NET
namespace TEngine.Core.DataBase;
public class WorldConfigInfo
{
public uint Id;
public string WorldName;
public string DbConnection;
public string DbName;
public string DbType;
}
#endif

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1c1d63a41ee591348a2aeab0a1ff5b2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,556 +0,0 @@
#if TENGINE_NET
using System.Linq.Expressions;
using TEngine.Core;
using MongoDB.Bson;
using MongoDB.Driver;
namespace TEngine.Core.DataBase;
public sealed class MongoDataBase : IDateBase
{
private string _dbName;
private string _connectionString;
private MongoClient _mongoClient;
private IMongoDatabase _mongoDatabase;
private readonly HashSet<string> _collections = new HashSet<string>();
public IDateBase Initialize(string connectionString, string dbName)
{
_dbName = dbName;
_connectionString = connectionString;
_mongoClient = new MongoClient(connectionString);
_mongoDatabase = _mongoClient.GetDatabase(dbName);
// 记录所有集合名
_collections.UnionWith(_mongoDatabase.ListCollectionNames().ToList());
return this;
}
#region Other
public async FTask<long> Sum<T>(Expression<Func<T, bool>> filter, Expression<Func<T, object>> sumExpression, string collection = null) where T : Entity
{
var member = (MemberExpression) ((UnaryExpression) sumExpression.Body).Operand;
var projection =
new BsonDocument("_id", "null").Add("Result", new BsonDocument("$sum", $"${member.Member.Name}"));
var data = await GetCollection<T>(collection).Aggregate().Match(filter).Group(projection)
.FirstOrDefaultAsync();
return data == null ? 0 : Convert.ToInt64(data["Result"]);
}
#endregion
#region GetCollection
private IMongoCollection<T> GetCollection<T>(string collection = null)
{
return _mongoDatabase.GetCollection<T>(collection ?? typeof(T).Name);
}
private IMongoCollection<Entity> GetCollection(string name)
{
return _mongoDatabase.GetCollection<Entity>(name);
}
#endregion
#region Count
public async FTask<long> Count<T>(string collection = null) where T : Entity
{
return await GetCollection<T>(collection).CountDocumentsAsync(d => true);
}
public async FTask<long> Count<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity
{
return await GetCollection<T>(collection).CountDocumentsAsync(filter);
}
#endregion
#region Exist
public async FTask<bool> Exist<T>(string collection = null) where T : Entity
{
return await Count<T>(collection) > 0;
}
public async FTask<bool> Exist<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity
{
return await Count(filter, collection) > 0;
}
#endregion
#region Query
public async FTask<T> QueryNotLock<T>(long id, string collection = null) where T : Entity
{
var cursor = await GetCollection<T>(collection).FindAsync(d => d.Id == id);
var v = await cursor.FirstOrDefaultAsync();
return v;
}
public async FTask<T> Query<T>(long id, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(id))
{
var cursor = await GetCollection<T>(collection).FindAsync(d => d.Id == id);
var v = await cursor.FirstOrDefaultAsync();
return v;
}
}
public async FTask<(int count, List<T> dates)> QueryCountAndDatesByPage<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var count = await Count(filter);
var dates = await QueryByPage(filter, pageIndex, pageSize, collection);
return ((int)count, dates);
}
}
public async FTask<(int count, List<T> dates)> QueryCountAndDatesByPage<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, string[] cols, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var count = await Count(filter);
var dates = await QueryByPage(filter, pageIndex, pageSize, cols, collection);
return ((int) count, dates);
}
}
public async FTask<List<T>> QueryByPage<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
return await GetCollection<T>(collection).Find(filter).Skip((pageIndex - 1) * pageSize)
.Limit(pageSize)
.ToListAsync();
}
}
public async FTask<List<T>> QueryByPage<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, string[] cols, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var projection = Builders<T>.Projection.Include("");
foreach (var col in cols)
{
projection = projection.Include(col);
}
return await GetCollection<T>(collection).Find(filter).Project<T>(projection)
.Skip((pageIndex - 1) * pageSize).Limit(pageSize).ToListAsync();
}
}
public async FTask<List<T>> QueryByPageOrderBy<T>(Expression<Func<T, bool>> filter, int pageIndex, int pageSize, Expression<Func<T, object>> orderByExpression, bool isAsc = true, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
if (isAsc)
{
return await GetCollection<T>(collection).Find(filter).SortBy(orderByExpression)
.Skip((pageIndex - 1) * pageSize).Limit(pageSize).ToListAsync();
}
return await GetCollection<T>(collection).Find(filter).SortByDescending(orderByExpression)
.Skip((pageIndex - 1) * pageSize).Limit(pageSize).ToListAsync();
}
}
public async FTask<T> First<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var cursor = await GetCollection<T>(collection).FindAsync(filter);
return await cursor.FirstOrDefaultAsync();
}
}
public async FTask<T> First<T>(string json, string[] cols, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var projection = Builders<T>.Projection.Include("");
foreach (var col in cols)
{
projection = projection.Include(col);
}
var options = new FindOptions<T, T> {Projection = projection};
FilterDefinition<T> filterDefinition = new JsonFilterDefinition<T>(json);
var cursor = await GetCollection<T>(collection).FindAsync(filterDefinition, options);
return await cursor.FirstOrDefaultAsync();
}
}
public async FTask<T> Last<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var cursor = await GetCollection<T>(collection).FindAsync(filter);
var list = await cursor.ToListAsync();
return list.LastOrDefault();
}
}
public async FTask<List<T>> QueryOrderBy<T>(Expression<Func<T, bool>> filter, Expression<Func<T, object>> orderByExpression, bool isAsc = true, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
if (isAsc)
{
return await GetCollection<T>(collection).Find(filter).SortBy(orderByExpression).ToListAsync();
}
return await GetCollection<T>(collection).Find(filter).SortByDescending(orderByExpression)
.ToListAsync();
}
}
public async FTask<List<T>> Query<T>(Expression<Func<T, bool>> filter, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var cursor = await GetCollection<T>(collection).FindAsync(filter);
var v = await cursor.ToListAsync();
return v;
}
}
public async FTask Query(long id, List<string> collectionNames, List<Entity> result)
{
using (await IDateBase.DataBaseLock.Lock(id))
{
if (collectionNames == null || collectionNames.Count == 0)
{
return;
}
foreach (var collectionName in collectionNames)
{
var cursor = await GetCollection(collectionName).FindAsync(d => d.Id == id);
var e = await cursor.FirstOrDefaultAsync();
if (e == null)
{
continue;
}
result.Add(e);
}
}
}
public async FTask<List<T>> QueryJson<T>(string json, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
FilterDefinition<T> filterDefinition = new JsonFilterDefinition<T>(json);
var cursor = await GetCollection<T>(collection).FindAsync(filterDefinition);
var v = await cursor.ToListAsync();
return v;
}
}
public async FTask<List<T>> QueryJson<T>(string json, string[] cols, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var projection = Builders<T>.Projection.Include("");
foreach (var col in cols)
{
projection = projection.Include(col);
}
var options = new FindOptions<T, T> {Projection = projection};
FilterDefinition<T> filterDefinition = new JsonFilterDefinition<T>(json);
var cursor = await GetCollection<T>(collection).FindAsync(filterDefinition, options);
var v = await cursor.ToListAsync();
return v;
}
}
public async FTask<List<T>> QueryJson<T>(long taskId, string json, string collection = null) where T : Entity
{
using (await IDateBase.DataBaseLock.Lock(taskId))
{
FilterDefinition<T> filterDefinition = new JsonFilterDefinition<T>(json);
var cursor = await GetCollection<T>(collection).FindAsync(filterDefinition);
var v = await cursor.ToListAsync();
return v;
}
}
public async FTask<List<T>> Query<T>(Expression<Func<T, bool>> filter, string[] cols, string collection = null) where T : class
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
var projection = Builders<T>.Projection.Include(cols[0]);
for (var i = 1; i < cols.Length; i++)
{
projection = projection.Include(cols[i]);
}
return await GetCollection<T>(collection).Find(filter).Project<T>(projection).ToListAsync();
}
}
#endregion
#region Save
public async FTask Save<T>(object transactionSession, T entity, string collection = null) where T : Entity
{
if (entity == null)
{
Log.Error($"save entity is null: {typeof(T).Name}");
return;
}
var clone = MongoHelper.Instance.Clone(entity);
using (await IDateBase.DataBaseLock.Lock(clone.Id))
{
await GetCollection(collection ?? clone.GetType().Name).ReplaceOneAsync(
(IClientSessionHandle) transactionSession, d => d.Id == clone.Id, clone,
new ReplaceOptions {IsUpsert = true});
}
}
public async FTask Save<T>(T entity, string collection = null) where T : Entity, new()
{
if (entity == null)
{
Log.Error($"save entity is null: {typeof(T).Name}");
return;
}
var clone = MongoHelper.Instance.Clone(entity);
using (await IDateBase.DataBaseLock.Lock(clone.Id))
{
await GetCollection(collection ?? clone.GetType().Name).ReplaceOneAsync(d => d.Id == clone.Id, clone,
new ReplaceOptions {IsUpsert = true});
}
}
private async FTask SaveBase<T>(T entity, string collection = null) where T : Entity
{
if (entity == null)
{
Log.Error($"save entity is null: {typeof(T).Name}");
return;
}
var clone = MongoHelper.Instance.Clone(entity);
using (await IDateBase.DataBaseLock.Lock(clone.Id))
{
await GetCollection(collection ?? clone.GetType().Name).ReplaceOneAsync(d => d.Id == clone.Id, clone, new ReplaceOptions {IsUpsert = true});
}
}
public async FTask Save(long id, List<Entity> entities)
{
if (entities == null)
{
Log.Error("save entity is null");
return;
}
var clones = MongoHelper.Instance.Clone(entities);
using (await IDateBase.DataBaseLock.Lock(id))
{
foreach (Entity clone in clones)
{
try
{
await GetCollection(clone.GetType().Name).ReplaceOneAsync(d => d.Id == clone.Id, clone,
new ReplaceOptions {IsUpsert = true});
}
catch (Exception e)
{
Log.Error($"Save List Entity Error: {clone.GetType().Name} {clone}\n{e}");
}
}
}
}
#endregion
#region Insert
public FTask Insert<T>(T entity, string collection = null) where T : Entity, new()
{
return Save(entity);
}
public async FTask InsertBatch<T>(IEnumerable<T> list, string collection = null) where T : Entity, new()
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
await GetCollection<T>(collection ?? typeof(T).Name).InsertManyAsync(list);
}
}
public async FTask InsertBatch<T>(object transactionSession, IEnumerable<T> list, string collection = null) where T : Entity, new()
{
using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64()))
{
await GetCollection<T>(collection ?? typeof(T).Name).InsertManyAsync((IClientSessionHandle) transactionSession, list);
}
}
#endregion
#region Remove
public async FTask<long> Remove<T>(object transactionSession, long id, string collection = null) where T : Entity, new()
{
using (await IDateBase.DataBaseLock.Lock(id))
{
var result = await GetCollection<T>(collection).DeleteOneAsync((IClientSessionHandle) transactionSession, d => d.Id == id);
return result.DeletedCount;
}
}
public async FTask<long> Remove<T>(long id, string collection = null) where T : Entity, new()
{
using (await IDateBase.DataBaseLock.Lock(id))
{
var result = await GetCollection<T>(collection).DeleteOneAsync(d => d.Id == id);
return result.DeletedCount;
}
}
public async FTask<long> Remove<T>(long id, object transactionSession, Expression<Func<T, bool>> filter, string collection = null) where T : Entity, new()
{
using (await IDateBase.DataBaseLock.Lock(id))
{
var result = await GetCollection<T>(collection).DeleteManyAsync((IClientSessionHandle) transactionSession, filter);
return result.DeletedCount;
}
}
public async FTask<long> Remove<T>(long id, Expression<Func<T, bool>> filter, string collection = null) where T : Entity, new()
{
using (await IDateBase.DataBaseLock.Lock(id))
{
var result = await GetCollection<T>(collection).DeleteManyAsync(filter);
return result.DeletedCount;
}
}
#endregion
#region Index
/// <summary>
/// 创建数据库索引
/// </summary>
/// <param name="collection"></param>
/// <param name="keys"></param>
/// <typeparam name="T"></typeparam>
/// <code>
/// 使用例子(可多个):
/// 1 : Builders.IndexKeys.Ascending(d=>d.Id)
/// 2 : Builders.IndexKeys.Descending(d=>d.Id).Ascending(d=>d.Name)
/// 3 : Builders.IndexKeys.Descending(d=>d.Id),Builders.IndexKeys.Descending(d=>d.Name)
/// </code>
public async FTask CreateIndex<T>(string collection, params object[] keys) where T : Entity
{
if (keys == null || keys.Length <= 0)
{
return;
}
var indexModels = new List<CreateIndexModel<T>>();
foreach (object key in keys)
{
IndexKeysDefinition<T> indexKeysDefinition = (IndexKeysDefinition<T>) key;
indexModels.Add(new CreateIndexModel<T>(indexKeysDefinition));
}
await GetCollection<T>(collection).Indexes.CreateManyAsync(indexModels);
}
public async FTask CreateIndex<T>(params object[] keys) where T : Entity
{
if (keys == null)
{
return;
}
List<CreateIndexModel<T>> indexModels = new List<CreateIndexModel<T>>();
foreach (object key in keys)
{
IndexKeysDefinition<T> indexKeysDefinition = (IndexKeysDefinition<T>) key;
indexModels.Add(new CreateIndexModel<T>(indexKeysDefinition));
}
await GetCollection<T>().Indexes.CreateManyAsync(indexModels);
}
#endregion
#region CreateDB
public async FTask CreateDB<T>() where T : Entity
{
// 已经存在数据库表
string name = typeof(T).Name;
if (_collections.Contains(name))
{
return;
}
await _mongoDatabase.CreateCollectionAsync(name);
_collections.Add(name);
}
public async FTask CreateDB(Type type)
{
string name = type.Name;
if (_collections.Contains(name))
{
return;
}
await _mongoDatabase.CreateCollectionAsync(name);
_collections.Add(name);
}
#endregion
}
#endif

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 0aaa971dc58538e46b0e43df7cc72a2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: ddb0edd718602754083d07d649e65d8f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e9c6ac6ade3864b42887435f6eac263f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,261 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
#pragma warning disable CS8625
#pragma warning disable CS8618
namespace TEngine.DataStructure
{
/// <summary>
/// 环形缓存自动扩充、不会收缩缓存、所以不要用这个操作过大的IO流
/// 1、环大小8192溢出的会自动增加环的大小。
/// 2、每个块都是一个环形缓存当溢出的时候会自动添加到下一个环中。
/// 3、当读取完成后用过的环会放在缓存中不会销毁掉。
/// </summary>
public sealed class CircularBuffer : Stream, IDisposable
{
private byte[] _lastBuffer;
public const int ChunkSize = 8192; // 环形缓存块大小
private readonly Queue<byte[]> _bufferCache = new Queue<byte[]>();
private readonly Queue<byte[]> _bufferQueue = new Queue<byte[]>();
public int FirstIndex { get; set; }
public int LastIndex { get; set; }
public override long Length
{
get
{
if (_bufferQueue.Count == 0)
{
return 0;
}
return (_bufferQueue.Count - 1) * ChunkSize + LastIndex - FirstIndex;
}
}
public byte[] First
{
get
{
if (_bufferQueue.Count == 0)
{
AddLast();
}
return _bufferQueue.Peek();
}
}
public byte[] Last
{
get
{
if (_bufferQueue.Count == 0)
{
AddLast();
}
return _lastBuffer;
}
}
public void AddLast()
{
var buffer = _bufferCache.Count > 0 ? _bufferCache.Dequeue() : new byte[ChunkSize];
_bufferQueue.Enqueue(buffer);
_lastBuffer = buffer;
}
public void RemoveFirst()
{
_bufferCache.Enqueue(_bufferQueue.Dequeue());
}
public void Read(Stream stream, int count)
{
if (count > Length)
{
throw new Exception($"bufferList length < count, {Length} {count}");
}
var copyCount = 0;
while (copyCount < count)
{
var n = count - copyCount;
if (ChunkSize - FirstIndex > n)
{
stream.Write(First, FirstIndex, n);
FirstIndex += n;
copyCount += n;
}
else
{
stream.Write(First, FirstIndex, ChunkSize - FirstIndex);
copyCount += ChunkSize - FirstIndex;
FirstIndex = 0;
RemoveFirst();
}
}
}
public void Read(Memory<byte> memory, int count)
{
if (count > Length)
{
throw new Exception($"bufferList length < count, {Length} {count}");
}
var copyCount = 0;
while (copyCount < count)
{
var n = count - copyCount;
var asMemory = First.AsMemory();
if (ChunkSize - FirstIndex > n)
{
var slice = asMemory.Slice(FirstIndex, n);
slice.CopyTo(memory.Slice(copyCount, n));
FirstIndex += n;
copyCount += n;
}
else
{
var length = ChunkSize - FirstIndex;
var slice = asMemory.Slice(FirstIndex, length);
slice.CopyTo(memory.Slice(copyCount, length));
copyCount += ChunkSize - FirstIndex;
FirstIndex = 0;
RemoveFirst();
}
}
}
public override int Read(byte[] buffer, int offset, int count)
{
if (buffer.Length < offset + count)
{
throw new Exception($"buffer length < count, buffer length: {buffer.Length} {offset} {count}");
}
var length = Length;
if (length < count)
{
count = (int) length;
}
var copyCount = 0;
while (copyCount < count)
{
var copyLength = count - copyCount;
if (ChunkSize - FirstIndex > copyLength)
{
Array.Copy(First, FirstIndex, buffer, copyCount + offset, copyLength);
FirstIndex += copyLength;
copyCount += copyLength;
continue;
}
Array.Copy(First, FirstIndex, buffer, copyCount + offset, ChunkSize - FirstIndex);
copyCount += ChunkSize - FirstIndex;
FirstIndex = 0;
RemoveFirst();
}
return count;
}
public void Write(byte[] buffer)
{
Write(buffer, 0, buffer.Length);
}
public void Write(Stream stream)
{
var copyCount = 0;
var count = (int) (stream.Length - stream.Position);
while (copyCount < count)
{
if (LastIndex == ChunkSize)
{
AddLast();
LastIndex = 0;
}
var n = count - copyCount;
if (ChunkSize - LastIndex > n)
{
_ = stream.Read(Last, LastIndex, n);
LastIndex += count - copyCount;
copyCount += n;
}
else
{
_ = stream.Read(Last, LastIndex, ChunkSize - LastIndex);
copyCount += ChunkSize - LastIndex;
LastIndex = ChunkSize;
}
}
}
public override void Write(byte[] buffer, int offset, int count)
{
var copyCount = 0;
while (copyCount < count)
{
if (ChunkSize == LastIndex)
{
AddLast();
LastIndex = 0;
}
var byteLength = count - copyCount;
if (ChunkSize - LastIndex > byteLength)
{
Array.Copy(buffer, copyCount + offset, Last, LastIndex, byteLength);
LastIndex += byteLength;
copyCount += byteLength;
}
else
{
Array.Copy(buffer, copyCount + offset, _lastBuffer, LastIndex, ChunkSize - LastIndex);
copyCount += ChunkSize - LastIndex;
LastIndex = ChunkSize;
}
}
}
public override bool CanRead { get; } = true;
public override bool CanSeek { get; } = false;
public override bool CanWrite { get; } = true;
public override long Position { get; set; }
public override void Flush()
{
throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public new void Dispose()
{
_bufferQueue.Clear();
_lastBuffer = null;
FirstIndex = 0;
LastIndex = 0;
base.Dispose();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 28188b5e2acefe14a996fb93df6b2fc6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,115 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
#pragma warning disable CS8603
namespace TEngine.DataStructure
{
public class ConcurrentOneToManyListPool<TKey, TValue> : ConcurrentOneToManyList<TKey, TValue>, IDisposable where TKey : notnull
{
private bool _isDispose;
public static ConcurrentOneToManyListPool<TKey, TValue> Create()
{
var a = Pool<ConcurrentOneToManyListPool<TKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<ConcurrentOneToManyListPool<TKey, TValue>>.Return(this);
}
}
public class ConcurrentOneToManyList<TKey, TValue> : ConcurrentDictionary<TKey, List<TValue>> where TKey : notnull
{
private readonly Queue<List<TValue>> _queue = new Queue<List<TValue>>();
private readonly int _recyclingLimit = 120;
public ConcurrentOneToManyList()
{
}
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public ConcurrentOneToManyList(int recyclingLimit)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValue value)
{
TryGetValue(key, out var list);
return list != null && list.Contains(value);
}
public void Add(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
list = Fetch();
list.Add(value);
base[key] = list;
return;
}
list.Add(value);
}
public TValue First(TKey key)
{
return !TryGetValue(key, out var list) ? default : list.FirstOrDefault();
}
public void RemoveValue(TKey key, TValue value)
{
if (!TryGetValue(key, out var list)) return;
list.Remove(value);
if (list.Count == 0) RemoveKey(key);
}
public void RemoveKey(TKey key)
{
if (!TryRemove(key, out var list)) return;
Recycle(list);
}
private List<TValue> Fetch()
{
return _queue.Count <= 0 ? new List<TValue>() : _queue.Dequeue();
}
private void Recycle(List<TValue> list)
{
list.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return;
_queue.Enqueue(list);
}
protected new void Clear()
{
base.Clear();
_queue.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f35e267f0b797464e856a9b9244b4215
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,116 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
#pragma warning disable CS8603
namespace TEngine.DataStructure
{
public class ConcurrentOneToManyQueuePool<TKey, TValue> : ConcurrentOneToManyQueue<TKey, TValue>, IDisposable
where TKey : notnull
{
private bool _isDispose;
public static ConcurrentOneToManyQueuePool<TKey, TValue> Create()
{
var a = Pool<ConcurrentOneToManyQueuePool<TKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<ConcurrentOneToManyQueue<TKey, TValue>>.Return(this);
}
}
public class ConcurrentOneToManyQueue<TKey, TValue> : ConcurrentDictionary<TKey, Queue<TValue>> where TKey : notnull
{
private readonly Queue<Queue<TValue>> _queue = new Queue<Queue<TValue>>();
private readonly int _recyclingLimit;
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public ConcurrentOneToManyQueue(int recyclingLimit = 0)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValue value)
{
TryGetValue(key, out var list);
return list != null && list.Contains(value);
}
public void Enqueue(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
list = Fetch();
list.Enqueue(value);
TryAdd(key, list);
return;
}
list.Enqueue(value);
}
public TValue Dequeue(TKey key)
{
if (!TryGetValue(key, out var list) || list.Count == 0) return default;
var value = list.Dequeue();
if (list.Count == 0) RemoveKey(key);
return value;
}
public bool TryDequeue(TKey key, out TValue value)
{
value = Dequeue(key);
return value != null;
}
public void RemoveKey(TKey key)
{
if (!TryGetValue(key, out var list)) return;
TryRemove(key, out _);
Recycle(list);
}
private Queue<TValue> Fetch()
{
return _queue.Count <= 0 ? new Queue<TValue>() : _queue.Dequeue();
}
private void Recycle(Queue<TValue> list)
{
list.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return;
_queue.Enqueue(list);
}
protected new void Clear()
{
base.Clear();
_queue.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 162f7b8459ead1940bfaef049f6d8e2c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,44 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.DataStructure
{
public sealed class EntityList<T> : List<T>, IDisposable where T : IDisposable
{
private bool _isDispose;
public static EntityList<T> Create()
{
var list = Pool<EntityList<T>>.Rent();
list._isDispose = false;
return list;
}
public new void Clear()
{
for (var i = 0; i < this.Count; i++)
{
this[i].Dispose();
}
base.Clear();
}
public void ClearNotDispose()
{
base.Clear();
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<EntityList<T>>.Return(this);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 763e9615aee0ac1428f141df39057bf7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.DataStructure
{
public sealed class HashSetPool<T> : HashSet<T>, IDisposable
{
private bool _isDispose;
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<HashSetPool<T>>.Return(this);
}
public static HashSetPool<T> Create()
{
var list = Pool<HashSetPool<T>>.Rent();
list._isDispose = false;
return list;
}
}
public sealed class HashSetBasePool<T> : IDisposable
{
public HashSet<T> Set = new HashSet<T>();
public static HashSetBasePool<T> Create()
{
return Pool<HashSetBasePool<T>>.Rent();
}
public void Dispose()
{
Set.Clear();
Pool<HashSetBasePool<T>>.Return(this);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 0f2f1a1f1a3f5f246a40be1e7bff871a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.DataStructure
{
public sealed class ListPool<T> : List<T>, IDisposable
{
private bool _isDispose;
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<ListPool<T>>.Return(this);
}
public static ListPool<T> Create(params T[] args)
{
var list = Pool<ListPool<T>>.Rent();
list._isDispose = false;
if (args != null) list.AddRange(args);
return list;
}
public static ListPool<T> Create(List<T> args)
{
var list = Pool<ListPool<T>>.Rent();
list._isDispose = false;
if (args != null) list.AddRange(args);
return list;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3014ce89f46d33742acca54a28995242
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,121 +0,0 @@
using System;
using System.Collections.Generic;
#pragma warning disable CS8600
namespace TEngine.DataStructure
{
public class OneToManyHashSetPool<TKey, TValue> : OneToManyHashSet<TKey, TValue>, IDisposable where TKey : notnull
{
private bool _isDispose;
public static OneToManyHashSetPool<TKey, TValue> Create()
{
var a = Pool<OneToManyHashSetPool<TKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<OneToManyHashSetPool<TKey, TValue>>.Return(this);
}
}
public class OneToManyHashSet<TKey, TValue> : Dictionary<TKey, HashSet<TValue>> where TKey : notnull
{
private readonly Queue<HashSet<TValue>> _queue = new Queue<HashSet<TValue>>();
private readonly int _recyclingLimit = 120;
private static HashSet<TValue> _empty = new HashSet<TValue>();
public OneToManyHashSet()
{
}
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public OneToManyHashSet(int recyclingLimit)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValue value)
{
TryGetValue(key, out var list);
return list != null && list.Contains(value);
}
public void Add(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
list = Fetch();
list.Add(value);
Add(key, list);
return;
}
list.Add(value);
}
public void RemoveValue(TKey key, TValue value)
{
if (!TryGetValue(key, out var list)) return;
list.Remove(value);
if (list.Count == 0) RemoveKey(key);
}
public void RemoveKey(TKey key)
{
if (!TryGetValue(key, out var list)) return;
Remove(key);
Recycle(list);
}
public HashSet<TValue> GetValue(TKey key)
{
if (TryGetValue(key, out HashSet<TValue> value))
{
return value;
}
return _empty;
}
private HashSet<TValue> Fetch()
{
return _queue.Count <= 0 ? new HashSet<TValue>() : _queue.Dequeue();
}
private void Recycle(HashSet<TValue> list)
{
list.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return;
_queue.Enqueue(list);
}
protected new void Clear()
{
base.Clear();
_queue.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 393302e735c4b2f4885c21dd4235b64a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,141 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
#pragma warning disable CS8600
#pragma warning disable CS8603
namespace TEngine.DataStructure
{
public class OneToManyListPool<TKey, TValue> : OneToManyList<TKey, TValue>, IDisposable where TKey : notnull
{
private bool _isDispose;
public static OneToManyListPool<TKey, TValue> Create()
{
var list = Pool<OneToManyListPool<TKey, TValue>>.Rent();
list._isDispose = false;
return list;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<OneToManyListPool<TKey, TValue>>.Return(this);
}
}
public class OneToManyList<TKey, TValue> : Dictionary<TKey, List<TValue>> where TKey : notnull
{
private readonly Queue<List<TValue>> _queue = new Queue<List<TValue>>();
private readonly int _recyclingLimit = 120;
private static List<TValue> _empty = new List<TValue>();
public OneToManyList()
{
}
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public OneToManyList(int recyclingLimit)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValue value)
{
TryGetValue(key, out var list);
return list != null && list.Contains(value);
}
public void Add(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
list = Fetch();
list.Add(value);
Add(key, list);
return;
}
list.Add(value);
}
public TValue First(TKey key)
{
return !TryGetValue(key, out var list) ? default : list.FirstOrDefault();
}
public bool RemoveValue(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
return true;
}
var isRemove = list.Remove(value);
if (list.Count == 0)
{
isRemove = RemoveByKey(key);
}
return isRemove;
}
public bool RemoveByKey(TKey key)
{
if (!TryGetValue(key, out var list))
{
return false;
}
Remove(key);
Recycle(list);
return true;
}
public List<TValue> GetValues(TKey key)
{
if (TryGetValue(key, out List<TValue> list))
{
return list;
}
return _empty;
}
public new void Clear()
{
foreach (var keyValuePair in this) Recycle(keyValuePair.Value);
base.Clear();
}
private List<TValue> Fetch()
{
return _queue.Count <= 0 ? new List<TValue>() : _queue.Dequeue();
}
private void Recycle(List<TValue> list)
{
list.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return;
_queue.Enqueue(list);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 7a6fdf7c8423c0e41804022df95a399d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,120 +0,0 @@
using System;
using System.Collections.Generic;
#pragma warning disable CS8603
namespace TEngine.DataStructure
{
public class OneToManyQueuePool<TKey, TValue> : OneToManyQueue<TKey, TValue>, IDisposable where TKey : notnull
{
private bool _isDispose;
public static OneToManyQueuePool<TKey, TValue> Create()
{
var a = Pool<OneToManyQueuePool<TKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<OneToManyQueuePool<TKey, TValue>>.Return(this);
}
}
public class OneToManyQueue<TKey, TValue> : Dictionary<TKey, Queue<TValue>> where TKey : notnull
{
private readonly Queue<Queue<TValue>> _queue = new Queue<Queue<TValue>>();
private readonly int _recyclingLimit;
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public OneToManyQueue(int recyclingLimit = 0)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValue value)
{
TryGetValue(key, out var list);
return list != null && list.Contains(value);
}
public void Enqueue(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
list = Fetch();
list.Enqueue(value);
Add(key, list);
return;
}
list.Enqueue(value);
}
public TValue Dequeue(TKey key)
{
if (!TryGetValue(key, out var list) || list.Count == 0)
{
return default;
}
var value = list.Dequeue();
if (list.Count == 0)
{
RemoveKey(key);
}
return value;
}
public bool TryDequeue(TKey key, out TValue value)
{
value = Dequeue(key);
return value != null;
}
public void RemoveKey(TKey key)
{
if (!TryGetValue(key, out var list)) return;
Remove(key);
Recycle(list);
}
private Queue<TValue> Fetch()
{
return _queue.Count <= 0 ? new Queue<TValue>() : _queue.Dequeue();
}
private void Recycle(Queue<TValue> list)
{
list.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return;
_queue.Enqueue(list);
}
protected new void Clear()
{
base.Clear();
_queue.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 35d6a9fde65a99143b0abf6d9569c462
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,537 +0,0 @@
// #if UNITY_5_3_OR_NEWER
// using System;
// using System.Collections;
// using System.Collections.Generic;
// using System.Diagnostics;
// using System.Diagnostics.CodeAnalysis;
// using System.Linq;
// using System.Runtime.CompilerServices;
// #pragma warning disable CS8600
//
// namespace System.Collections.Generic
// {
// public class PriorityQueue<TElement, TPriority>
// {
// private const int DefaultCapacity = 4;
//
// private readonly IComparer<TPriority> _priorityComparer;
//
// private HeapEntry[] _heap;
// private int _count;
// private int _version;
//
// private UnorderedItemsCollection? _unorderedItemsCollection;
//
// #region Constructors
// public PriorityQueue() : this(0, null)
// {
//
// }
//
// // public PriorityQueue(int initialCapacity) : this(initialCapacity, null)
// // {
// //
// // }
//
// // public PriorityQueue(IComparer<TPriority>? comparer) : this(0, comparer)
// // {
// //
// // }
//
// // public PriorityQueue(int initialCapacity, IComparer<TPriority>? comparer)
// // {
// // if (initialCapacity < 0)
// // {
// // throw new ArgumentOutOfRangeException(nameof(initialCapacity));
// // }
// //
// // if (initialCapacity == 0)
// // {
// // _heap = Array.Empty<HeapEntry>();
// // }
// // else
// // {
// // _heap = new HeapEntry[initialCapacity];
// // }
// //
// // _priorityComparer = comparer ?? Comparer<TPriority>.Default;
// // }
//
// public PriorityQueue(IEnumerable<(TElement Element, TPriority Priority)> values) : this(values, null)
// {
//
// }
//
// public PriorityQueue(IEnumerable<(TElement Element, TPriority Priority)> values, IComparer<TPriority>? comparer)
// {
// _priorityComparer = comparer ?? Comparer<TPriority>.Default;
// _heap = Array.Empty<HeapEntry>();
// _count = 0;
//
// AppendRaw(values);
// Heapify();
// }
// #endregion
//
// public int Count => _count;
// public IComparer<TPriority> Comparer => _priorityComparer;
//
// public void Enqueue(TElement element, TPriority priority)
// {
// _version++;
// if (_count == _heap.Length)
// {
// Resize(ref _heap);
// }
//
// SiftUp(index: _count++, in element, in priority);
// }
//
// public void EnqueueRange(IEnumerable<(TElement Element, TPriority Priority)> values)
// {
// _version++;
// if (_count == 0)
// {
// AppendRaw(values);
// Heapify();
// }
// else
// {
// foreach ((TElement element, TPriority priority) in values)
// {
// if (_count == _heap.Length)
// {
// Resize(ref _heap);
// }
//
// SiftUp(index: _count++, in element, in priority);
// }
// }
// }
//
// // TODO optimize
// public void EnqueueRange(IEnumerable<TElement> elements, TPriority priority) => EnqueueRange(elements.Select(e => (e, priority)));
//
// public TElement Peek()
// {
// if (_count == 0)
// {
// throw new InvalidOperationException();
// }
//
// return _heap[0].Element;
// }
//
// public bool TryPeek([MaybeNullWhen(false)] out TElement element, [MaybeNullWhen(false)] out TPriority priority)
// {
// if (_count == 0)
// {
// element = default;
// priority = default;
// return false;
// }
//
// (element, priority) = _heap[0];
// return true;
// }
//
// public TElement Dequeue()
// {
// if (_count == 0)
// {
// throw new InvalidOperationException();
// }
//
// _version++;
// RemoveIndex(index: 0, out TElement result, out _);
// return result;
// }
//
// public bool TryDequeue([MaybeNullWhen(false)] out TElement element, [MaybeNullWhen(false)] out TPriority priority)
// {
// if (_count == 0)
// {
// element = default;
// priority = default;
// return false;
// }
//
// _version++;
// RemoveIndex(index: 0, out element, out priority);
// return true;
// }
//
// public TElement EnqueueDequeue(TElement element, TPriority priority)
// {
// if (_count == 0)
// {
// return element;
// }
//
// ref HeapEntry minEntry = ref _heap[0];
// if (_priorityComparer.Compare(priority, minEntry.Priority) <= 0)
// {
// return element;
// }
//
// _version++;
// TElement minElement = minEntry.Element;
// #if SIFTDOWN_EMPTY_NODES
// SiftDownHeapPropertyRequired(index: 0, in element, in priority);
// #else
// SiftDown(index: 0, in element, in priority);
// #endif
// return minElement;
// }
//
// public void Clear()
// {
// _version++;
// if (_count > 0)
// {
// //if (RuntimeHelpers.IsReferenceOrContainsReferences<HeapEntry>())
// {
// Array.Clear(_heap, 0, _count);
// }
//
// _count = 0;
// }
// }
//
// public void TrimExcess()
// {
// int count = _count;
// int threshold = (int)(((double)_heap.Length) * 0.9);
// if (count < threshold)
// {
// Array.Resize(ref _heap, count);
// }
// }
//
// public void EnsureCapacity(int capacity)
// {
// if (capacity < 0)
// {
// throw new ArgumentOutOfRangeException();
// }
//
// if (capacity > _heap.Length)
// {
// Array.Resize(ref _heap, capacity);
// }
// }
//
// public UnorderedItemsCollection UnorderedItems => _unorderedItemsCollection ??= new UnorderedItemsCollection(this);
//
// public class UnorderedItemsCollection : IReadOnlyCollection<(TElement Element, TPriority Priority)>, ICollection
// {
// private readonly PriorityQueue<TElement, TPriority> _priorityQueue;
//
// internal UnorderedItemsCollection(PriorityQueue<TElement, TPriority> priorityQueue)
// {
// _priorityQueue = priorityQueue;
// }
//
// public int Count => _priorityQueue.Count;
// public bool IsSynchronized => false;
// public object SyncRoot => _priorityQueue;
//
// public Enumerator GetEnumerator() => new Enumerator(_priorityQueue);
// IEnumerator<(TElement Element, TPriority Priority)> IEnumerable<(TElement Element, TPriority Priority)>.GetEnumerator() => new Enumerator(_priorityQueue);
// IEnumerator IEnumerable.GetEnumerator() => new Enumerator(_priorityQueue);
//
// bool ICollection.IsSynchronized => false;
// object ICollection.SyncRoot => this;
// void ICollection.CopyTo(Array array, int index)
// {
// if (array == null)
// throw new ArgumentNullException(nameof(array));
// if (array.Rank != 1)
// throw new ArgumentException("SR.Arg_RankMultiDimNotSupported", nameof(array));
// if (index < 0)
// throw new ArgumentOutOfRangeException(nameof(index), "SR.ArgumentOutOfRange_Index");
//
// int arrayLen = array.Length;
// if (arrayLen - index < _priorityQueue._count)
// throw new ArgumentException("SR.Argument_InvalidOffLen");
//
// int numToCopy = _priorityQueue._count;
// HeapEntry[] heap = _priorityQueue._heap;
//
// for (int i = 0; i < numToCopy; i++)
// {
// ref HeapEntry entry = ref heap[i];
// array.SetValue((entry.Element, entry.Priority), index + i);
// }
// }
//
// public struct Enumerator : IEnumerator<(TElement Element, TPriority Priority)>, IEnumerator
// {
// private readonly PriorityQueue<TElement, TPriority> _queue;
// private readonly int _version;
// private int _index;
// private (TElement Element, TPriority Priority) _current;
//
// internal Enumerator(PriorityQueue<TElement, TPriority> queue)
// {
// _version = queue._version;
// _queue = queue;
// _index = 0;
// _current = default;
// }
//
// public bool MoveNext()
// {
// PriorityQueue<TElement, TPriority> queue = _queue;
//
// if (queue._version == _version && _index < queue._count)
// {
// ref HeapEntry entry = ref queue._heap[_index];
// _current = (entry.Element, entry.Priority);
// _index++;
// return true;
// }
//
// if (queue._version != _version)
// {
// throw new InvalidOperationException("collection was modified");
// }
//
// return false;
// }
//
// public (TElement Element, TPriority Priority) Current => _current;
// object IEnumerator.Current => _current;
//
// public void Reset()
// {
// if (_queue._version != _version)
// {
// throw new InvalidOperationException("collection was modified");
// }
//
// _index = 0;
// _current = default;
// }
//
// public void Dispose()
// {
// }
// }
// }
//
// #region Private Methods
// private void Heapify()
// {
// HeapEntry[] heap = _heap;
//
// for (int i = (_count - 1) >> 2; i >= 0; i--)
// {
// HeapEntry entry = heap[i]; // ensure struct is copied before sifting
// SiftDown(i, in entry.Element, in entry.Priority);
// }
// }
//
// private void AppendRaw(IEnumerable<(TElement Element, TPriority Priority)> values)
// {
// // TODO: specialize on ICollection types
// var heap = _heap;
// int count = _count;
//
// foreach ((TElement element, TPriority priority) in values)
// {
// if (count == heap.Length)
// {
// Resize(ref heap);
// }
//
// ref HeapEntry entry = ref heap[count];
// entry.Element = element;
// entry.Priority = priority;
// count++;
// }
//
// _heap = heap;
// _count = count;
// }
//
// private void RemoveIndex(int index, out TElement element, out TPriority priority)
// {
// Debug.Assert(index < _count);
//
// (element, priority) = _heap[index];
//
// int lastElementPos = --_count;
// ref HeapEntry lastElement = ref _heap[lastElementPos];
//
// if (lastElementPos > 0)
// {
// #if SIFTDOWN_EMPTY_NODES
// SiftDownHeapPropertyRequired(index, in lastElement.Element, in lastElement.Priority);
// #else
// SiftDown(index, in lastElement.Element, in lastElement.Priority);
// #endif
// }
//
// //if (RuntimeHelpers.IsReferenceOrContainsReferences<HeapEntry>())
// {
// lastElement = default;
// }
// }
//
// private void SiftUp(int index, in TElement element, in TPriority priority)
// {
// while (index > 0)
// {
// int parentIndex = (index - 1) >> 2;
// ref HeapEntry parent = ref _heap[parentIndex];
//
// if (_priorityComparer.Compare(parent.Priority, priority) <= 0)
// {
// // parentPriority <= priority, heap property is satisfed
// break;
// }
//
// _heap[index] = parent;
// index = parentIndex;
// }
//
// ref HeapEntry entry = ref _heap[index];
// entry.Element = element;
// entry.Priority = priority;
// }
//
// private void SiftDown(int index, in TElement element, in TPriority priority)
// {
// int minChildIndex;
// int count = _count;
// HeapEntry[] heap = _heap;
//
// while ((minChildIndex = (index << 2) + 1) < count)
// {
// // find the child with the minimal priority
// ref HeapEntry minChild = ref heap[minChildIndex];
// int childUpperBound = Math.Min(count, minChildIndex + 4);
//
// for (int nextChildIndex = minChildIndex + 1; nextChildIndex < childUpperBound; nextChildIndex++)
// {
// ref HeapEntry nextChild = ref heap[nextChildIndex];
// if (_priorityComparer.Compare(nextChild.Priority, minChild.Priority) < 0)
// {
// minChildIndex = nextChildIndex;
// minChild = ref nextChild;
// }
// }
//
// // compare with inserted priority
// if (_priorityComparer.Compare(priority, minChild.Priority) <= 0)
// {
// // priority <= minChild, heap property is satisfied
// break;
// }
//
// heap[index] = minChild;
// index = minChildIndex;
// }
//
// ref HeapEntry entry = ref heap[index];
// entry.Element = element;
// entry.Priority = priority;
// }
//
// #if SIFTDOWN_EMPTY_NODES
// private void SiftDownHeapPropertyRequired(int index, in TElement element, in TPriority priority)
// {
// int emptyNodeIndex = SiftDownEmptyNode(index);
// SiftUp(emptyNodeIndex, in element, in priority);
// }
//
// private int SiftDownEmptyNode(int emptyNodeIndex)
// {
// int count = _count;
// int minChildIndex;
// HeapEntry[] heap = _heap;
//
// while ((minChildIndex = (emptyNodeIndex << 2) + 1) < count)
// {
// // find the child with the minimal priority
// ref HeapEntry minChild = ref heap[minChildIndex];
// int childUpperBound = Math.Min(count, minChildIndex + 4);
//
// for (int nextChildIndex = minChildIndex + 1; nextChildIndex < childUpperBound; nextChildIndex++)
// {
// ref HeapEntry nextChild = ref heap[nextChildIndex];
// if (_priorityComparer.Compare(nextChild.Priority, minChild.Priority) < 0)
// {
// minChildIndex = nextChildIndex;
// minChild = ref nextChild;
// }
// }
//
// heap[emptyNodeIndex] = minChild;
// emptyNodeIndex = minChildIndex;
// }
//
// return emptyNodeIndex;
// }
// #endif
//
// private void Resize(ref HeapEntry[] heap)
// {
// int newSize = heap.Length == 0 ? DefaultCapacity : 2 * heap.Length;
// Array.Resize(ref heap, newSize);
// }
//
// private struct HeapEntry
// {
// public TElement Element;
// public TPriority Priority;
//
// public void Deconstruct(out TElement element, out TPriority priority)
// {
// element = Element;
// priority = Priority;
// }
// }
//
// #if DEBUG
// public void ValidateInternalState()
// {
// if (_heap.Length < _count)
// {
// throw new Exception("invalid elements array length");
// }
//
// foreach ((var element, var idx) in _heap.Select((x, i) => (x.Element, i)).Skip(_count))
// {
// if (!IsDefault(element))
// {
// throw new Exception($"Non-zero element '{element}' at index {idx}.");
// }
// }
//
// foreach ((var priority, var idx) in _heap.Select((x, i) => (x.Priority, i)).Skip(_count))
// {
// if (!IsDefault(priority))
// {
// throw new Exception($"Non-zero priority '{priority}' at index {idx}.");
// }
// }
//
// static bool IsDefault<T>(T value)
// {
// T defaultVal = default;
//
// if (defaultVal is null)
// {
// return value is null;
// }
//
// return value!.Equals(defaultVal);
// }
// }
// #endif
// #endregion
// }
// }
// #endif

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1e7e9292b9c27384d9aed58ea3d5098d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,29 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.DataStructure
{
public sealed class ReuseList<T> : List<T>, IDisposable
{
private bool _isDispose;
public static ReuseList<T> Create()
{
var list = Pool<ReuseList<T>>.Rent();
list._isDispose = false;
return list;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<ReuseList<T>>.Return(this);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fe34244ec94ec0240a92d11c66f9d94e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,139 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
#pragma warning disable CS8603
namespace TEngine.DataStructure
{
public class SortedConcurrentOneToManyListPool<TKey, TValue> : SortedConcurrentOneToManyList<TKey, TValue>,
IDisposable where TKey : notnull
{
private bool _isDispose;
public static SortedConcurrentOneToManyListPool<TKey, TValue> Create()
{
var a = Pool<SortedConcurrentOneToManyListPool<TKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<SortedConcurrentOneToManyListPool<TKey, TValue>>.Return(this);
}
}
public class SortedConcurrentOneToManyList<TKey, TValue> : SortedDictionary<TKey, List<TValue>> where TKey : notnull
{
private readonly object _lockObject = new object();
private readonly Queue<List<TValue>> _queue = new Queue<List<TValue>>();
private readonly int _recyclingLimit;
public SortedConcurrentOneToManyList()
{
}
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public SortedConcurrentOneToManyList(int recyclingLimit = 0)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValue value)
{
lock (_lockObject)
{
TryGetValue(key, out var list);
return list != null && list.Contains(value);
}
}
public void Add(TKey key, TValue value)
{
lock (_lockObject)
{
if (!TryGetValue(key, out var list))
{
list = Fetch();
list.Add(value);
base[key] = list;
return;
}
list.Add(value);
}
}
public TValue First(TKey key)
{
lock (_lockObject)
{
return !TryGetValue(key, out var list) ? default : list.FirstOrDefault();
}
}
public void RemoveValue(TKey key, TValue value)
{
lock (_lockObject)
{
if (!TryGetValue(key, out var list)) return;
list.Remove(value);
if (list.Count == 0) RemoveKey(key);
}
}
public void RemoveKey(TKey key)
{
lock (_lockObject)
{
if (!TryGetValue(key, out var list)) return;
Remove(key);
Recycle(list);
}
}
private List<TValue> Fetch()
{
lock (_lockObject)
{
return _queue.Count <= 0 ? new List<TValue>() : _queue.Dequeue();
}
}
private void Recycle(List<TValue> list)
{
lock (_lockObject)
{
list.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return;
_queue.Enqueue(list);
}
}
protected new void Clear()
{
base.Clear();
_queue.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 24aa8bc8ac4d8584cb9ceb23a51c78fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,111 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.DataStructure
{
public class SortedOneToManyHashSetPool<TKey, TValue> : SortedOneToManyHashSet<TKey, TValue>, IDisposable
where TKey : notnull
{
private bool _isDispose;
public static SortedOneToManyHashSetPool<TKey, TValue> Create()
{
var a = Pool<SortedOneToManyHashSetPool<TKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<SortedOneToManyHashSetPool<TKey, TValue>>.Return(this);
}
}
public class SortedOneToManyHashSet<TKey, TValue> : SortedDictionary<TKey, HashSet<TValue>> where TKey : notnull
{
private readonly Queue<HashSet<TValue>> _queue = new Queue<HashSet<TValue>>();
private readonly int _recyclingLimit = 120;
public SortedOneToManyHashSet()
{
}
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public SortedOneToManyHashSet(int recyclingLimit)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValue value)
{
TryGetValue(key, out var list);
return list != null && list.Contains(value);
}
public void Add(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
list = Fetch();
list.Add(value);
Add(key, list);
return;
}
list.Add(value);
}
public void RemoveValue(TKey key, TValue value)
{
if (!TryGetValue(key, out var list)) return;
list.Remove(value);
if (list.Count == 0) RemoveKey(key);
}
public void RemoveKey(TKey key)
{
if (!TryGetValue(key, out var list)) return;
Remove(key);
Recycle(list);
}
private HashSet<TValue> Fetch()
{
return _queue.Count <= 0 ? new HashSet<TValue>() : _queue.Dequeue();
}
private void Recycle(HashSet<TValue> list)
{
list.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return;
_queue.Enqueue(list);
}
protected new void Clear()
{
base.Clear();
_queue.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ddf73601eadf11349b77b78a4d91f35a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,128 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
#pragma warning disable CS8603
namespace TEngine.DataStructure
{
public class SortedOneToManyListPool<TKey, TValue> : SortedOneToManyList<TKey, TValue>, IDisposable
where TKey : notnull
{
private bool _isDispose;
public static SortedOneToManyListPool<TKey, TValue> Create()
{
var a = Pool<SortedOneToManyListPool<TKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<SortedOneToManyListPool<TKey, TValue>>.Return(this);
}
}
public class SortedOneToManyList<TKey, TValue> : SortedDictionary<TKey, List<TValue>> where TKey : notnull
{
private readonly Queue<List<TValue>> _queue = new Queue<List<TValue>>();
private readonly int _recyclingLimit;
public SortedOneToManyList()
{
}
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public SortedOneToManyList(int recyclingLimit = 0)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValue value)
{
TryGetValue(key, out var list);
return list != null && list.Contains(value);
}
public void Add(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
list = Fetch();
list.Add(value);
base[key] = list;
return;
}
list.Add(value);
}
public TValue First(TKey key)
{
return !TryGetValue(key, out var list) ? default : list.FirstOrDefault();
}
public void RemoveValue(TKey key, TValue value)
{
if (!TryGetValue(key, out var list))
{
return;
}
list.Remove(value);
if (list.Count == 0)
{
RemoveKey(key);
}
}
public void RemoveKey(TKey key)
{
if (!TryGetValue(key, out var list))
{
return;
}
Remove(key);
Recycle(list);
}
private List<TValue> Fetch()
{
return _queue.Count <= 0 ? new List<TValue>() : _queue.Dequeue();
}
private void Recycle(List<TValue> list)
{
list.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit)
{
return;
}
_queue.Enqueue(list);
}
protected new void Clear()
{
base.Clear();
_queue.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: db62c1998de4d5048bde5d5e09d6f284
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3217a5df0b4fae04cad4694ae07948b8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,19 +0,0 @@
using System.Collections.Generic;
#pragma warning disable CS8601
namespace TEngine.DataStructure
{
public static class DictionaryExtensions
{
public static bool TryRemove<T, TV>(this IDictionary<T, TV> self, T key, out TV value)
{
if (!self.TryGetValue(key, out value))
{
return false;
}
self.Remove(key);
return true;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2906692879c7825458790e8cb128e7f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,29 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.DataStructure
{
public sealed class DictionaryPool<TM, TN> : Dictionary<TM, TN>, IDisposable where TM : notnull
{
private bool _isDispose;
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<DictionaryPool<TM, TN>>.Return(this);
}
public static DictionaryPool<TM, TN> Create()
{
var dictionary = Pool<DictionaryPool<TM, TN>>.Rent();
dictionary._isDispose = false;
return dictionary;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 45285f160861f9c4bb96634e744e2c74
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,174 +0,0 @@
using System;
using System.Collections.Generic;
#pragma warning disable CS8601
#pragma warning disable CS8604
#pragma warning disable CS8603
namespace TEngine.DataStructure
{
public class DoubleMapDictionaryPool<TKey, TValue> : DoubleMapDictionary<TKey, TValue>, IDisposable
where TKey : notnull where TValue : notnull
{
private bool _isDispose;
public static DoubleMapDictionaryPool<TKey, TValue> Create()
{
var a = Pool<DoubleMapDictionaryPool<TKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<DoubleMapDictionaryPool<TKey, TValue>>.Return(this);
}
}
public class DoubleMapDictionary<TK, TV> where TK : notnull where TV : notnull
{
private readonly Dictionary<TK, TV> _kv = new Dictionary<TK, TV>();
private readonly Dictionary<TV, TK> _vk = new Dictionary<TV, TK>();
public DoubleMapDictionary()
{
}
public DoubleMapDictionary(int capacity)
{
_kv = new Dictionary<TK, TV>(capacity);
_vk = new Dictionary<TV, TK>(capacity);
}
public List<TK> Keys => new List<TK>(_kv.Keys);
public List<TV> Values => new List<TV>(_vk.Keys);
public void ForEach(Action<TK, TV> action)
{
if (action == null)
{
return;
}
var keys = _kv.Keys;
foreach (var key in keys)
{
action(key, _kv[key]);
}
}
public void Add(TK key, TV value)
{
if (key == null || value == null || _kv.ContainsKey(key) || _vk.ContainsKey(value))
{
return;
}
_kv.Add(key, value);
_vk.Add(value, key);
}
public TV GetValueByKey(TK key)
{
if (key != null && _kv.ContainsKey(key))
{
return _kv[key];
}
return default;
}
public bool TryGetValueByKey(TK key, out TV value)
{
var result = key != null && _kv.ContainsKey(key);
value = result ? _kv[key] : default;
return result;
}
public TK GetKeyByValue(TV value)
{
if (value != null && _vk.ContainsKey(value))
{
return _vk[value];
}
return default;
}
public bool TryGetKeyByValue(TV value, out TK key)
{
var result = value != null && _vk.ContainsKey(value);
key = result ? _vk[value] : default;
return result;
}
public void RemoveByKey(TK key)
{
if (key == null)
{
return;
}
if (!_kv.TryGetValue(key, out var value))
{
return;
}
_kv.Remove(key);
_vk.Remove(value);
}
public void RemoveByValue(TV value)
{
if (value == null)
{
return;
}
if (!_vk.TryGetValue(value, out var key))
{
return;
}
_kv.Remove(key);
_vk.Remove(value);
}
public void Clear()
{
_kv.Clear();
_vk.Clear();
}
public bool ContainsKey(TK key)
{
return key != null && _kv.ContainsKey(key);
}
public bool ContainsValue(TV value)
{
return value != null && _vk.ContainsKey(value);
}
public bool Contains(TK key, TV value)
{
if (key == null || value == null)
{
return false;
}
return _kv.ContainsKey(key) && _vk.ContainsKey(value);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e9b1abd0ffc450842bea6ec96e84425f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,44 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.DataStructure
{
public sealed class EntityDictionary<TM, TN> : Dictionary<TM, TN>, IDisposable where TN : IDisposable where TM : notnull
{
private bool _isDispose;
public static EntityDictionary<TM, TN> Create()
{
var entityDictionary = Pool<EntityDictionary<TM, TN>>.Rent();
entityDictionary._isDispose = false;
return entityDictionary;
}
public new void Clear()
{
foreach (var keyValuePair in this)
{
keyValuePair.Value.Dispose();
}
base.Clear();
}
public void ClearNotDispose()
{
base.Clear();
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<EntityDictionary<TM, TN>>.Return(this);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3e08b2b0077e40143a1f772a0f7b1ad5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,147 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
#pragma warning disable CS8603
#pragma warning disable CS8601
namespace TEngine.DataStructure
{
public class OneToManyDictionaryPool<TKey, TValueKey, TValue> : OneToManyDictionary<TKey, TValueKey, TValue>,
IDisposable where TKey : notnull where TValueKey : notnull
{
private bool _isDispose;
public static OneToManyDictionaryPool<TKey, TValueKey, TValue> Create()
{
var a = Pool<OneToManyDictionaryPool<TKey, TValueKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<OneToManyDictionaryPool<TKey, TValueKey, TValue>>.Return(this);
}
}
public class OneToManyDictionary<TKey, TValueKey, TValue> : Dictionary<TKey, Dictionary<TValueKey, TValue>>
where TKey : notnull where TValueKey : notnull
{
private readonly Queue<Dictionary<TValueKey, TValue>> _queue = new Queue<Dictionary<TValueKey, TValue>>();
private readonly int _recyclingLimit = 120;
public OneToManyDictionary()
{
}
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public OneToManyDictionary(int recyclingLimit = 0)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key, TValueKey valueKey)
{
TryGetValue(key, out var dic);
return dic != null && dic.ContainsKey(valueKey);
}
public bool TryGetValue(TKey key, TValueKey valueKey, out TValue value)
{
value = default;
return TryGetValue(key, out var dic) && dic.TryGetValue(valueKey, out value);
}
public TValue First(TKey key)
{
return !TryGetValue(key, out var dic) ? default : dic.First().Value;
}
public void Add(TKey key, TValueKey valueKey, TValue value)
{
if (!TryGetValue(key, out var dic))
{
dic = Fetch();
dic[valueKey] = value;
// dic.Add(valueKey, value);
Add(key, dic);
return;
}
dic[valueKey] = value;
// dic.Add(valueKey, value);
}
public bool Remove(TKey key, TValueKey valueKey)
{
if (!TryGetValue(key, out var dic)) return false;
var result = dic.Remove(valueKey);
if (dic.Count == 0) RemoveKey(key);
return result;
}
public bool Remove(TKey key, TValueKey valueKey, out TValue value)
{
if (!TryGetValue(key, out var dic))
{
value = default;
return false;
}
var result = dic.TryGetValue(valueKey, out value);
if (result) dic.Remove(valueKey);
if (dic.Count == 0) RemoveKey(key);
return result;
}
public void RemoveKey(TKey key)
{
if (!TryGetValue(key, out var dic)) return;
Remove(key);
Recycle(dic);
}
private Dictionary<TValueKey, TValue> Fetch()
{
return _queue.Count <= 0 ? new Dictionary<TValueKey, TValue>() : _queue.Dequeue();
}
private void Recycle(Dictionary<TValueKey, TValue> dic)
{
dic.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return;
_queue.Enqueue(dic);
}
public new void Clear()
{
foreach (var keyValuePair in this) Recycle(keyValuePair.Value);
base.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5db437bfa1f9b8b438b7260196e01934
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,150 +0,0 @@
using System;
using System.Collections.Generic;
#pragma warning disable CS8601
namespace TEngine.DataStructure
{
public class
OneToManySortedDictionaryPool<TKey, TSortedKey, TValue> : OneToManySortedDictionary<TKey, TSortedKey, TValue>,
IDisposable where TKey : notnull where TSortedKey : notnull
{
private bool _isDispose;
public static OneToManySortedDictionaryPool<TKey, TSortedKey, TValue> Create()
{
var a = Pool<OneToManySortedDictionaryPool<TKey, TSortedKey, TValue>>.Rent();
a._isDispose = false;
return a;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<OneToManySortedDictionaryPool<TKey, TSortedKey, TValue>>.Return(this);
}
}
public class
OneToManySortedDictionary<TKey, TSortedKey, TValue> : Dictionary<TKey, SortedDictionary<TSortedKey, TValue>>
where TSortedKey : notnull where TKey : notnull
{
private readonly int _recyclingLimit = 120;
private readonly Queue<SortedDictionary<TSortedKey, TValue>> _queue =
new Queue<SortedDictionary<TSortedKey, TValue>>();
protected OneToManySortedDictionary()
{
}
/// <summary>
/// 设置最大缓存数量
/// </summary>
/// <param name="recyclingLimit">
/// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC.
/// 2:设置成0不控制数量全部缓存
/// </param>
public OneToManySortedDictionary(int recyclingLimit)
{
_recyclingLimit = recyclingLimit;
}
public bool Contains(TKey key)
{
return this.ContainsKey(key);
}
public bool Contains(TKey key, TSortedKey sortedKey)
{
return TryGetValue(key, out var dic) && dic.ContainsKey(sortedKey);
}
public new bool TryGetValue(TKey key, out SortedDictionary<TSortedKey, TValue> dic)
{
return base.TryGetValue(key, out dic);
}
public bool TryGetValueBySortedKey(TKey key, TSortedKey sortedKey, out TValue value)
{
if (base.TryGetValue(key, out var dic))
{
return dic.TryGetValue(sortedKey, out value);
}
value = default;
return false;
}
public void Add(TKey key, TSortedKey sortedKey, TValue value)
{
if (!TryGetValue(key, out var dic))
{
dic = Fetch();
dic.Add(sortedKey, value);
Add(key, dic);
return;
}
dic.Add(sortedKey, value);
}
public bool RemoveSortedKey(TKey key, TSortedKey sortedKey)
{
if (!TryGetValue(key, out var dic))
{
return false;
}
var isRemove = dic.Remove(sortedKey);
if (dic.Count == 0)
{
isRemove = RemoveKey(key);
}
return isRemove;
}
public bool RemoveKey(TKey key)
{
if (!TryGetValue(key, out var list))
{
return false;
}
Remove(key);
Recycle(list);
return true;
}
private SortedDictionary<TSortedKey, TValue> Fetch()
{
return _queue.Count <= 0 ? new SortedDictionary<TSortedKey, TValue>() : _queue.Dequeue();
}
private void Recycle(SortedDictionary<TSortedKey, TValue> dic)
{
dic.Clear();
if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit)
{
return;
}
_queue.Enqueue(dic);
}
protected new void Clear()
{
base.Clear();
_queue.Clear();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c0ac9ed7abbf4e4408901274ee344642
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,29 +0,0 @@
using System;
using System.Collections.Generic;
namespace TEngine.DataStructure
{
public sealed class ReuseDictionary<TM, TN> : Dictionary<TM, TN>, IDisposable where TM : notnull
{
private bool _isDispose;
public static ReuseDictionary<TM, TN> Create()
{
var entityDictionary = Pool<ReuseDictionary<TM, TN>>.Rent();
entityDictionary._isDispose = false;
return entityDictionary;
}
public void Dispose()
{
if (_isDispose)
{
return;
}
_isDispose = true;
Clear();
Pool<ReuseDictionary<TM, TN>>.Return(this);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: bf01018dd07bd2243b8636a1321f50c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: a7e0baed1cdd57b4e916270c39382710
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,166 +0,0 @@
#pragma warning disable CS8602
#pragma warning disable CS8601
#pragma warning disable CS8625
#pragma warning disable CS8604
#pragma warning disable CS8600
namespace TEngine.DataStructure
{
/// <summary>
/// 跳表升序版
/// </summary>
/// <typeparam name="TValue"></typeparam>
public class SkipTable<TValue> : SkipTableBase<TValue>
{
public SkipTable(int maxLayer = 8) : base(maxLayer) { }
public override void Add(long sortKey, long viceKey, long key, TValue value)
{
var rLevel = 1;
while (rLevel <= MaxLayer && Random.Next(3) == 0)
{
++rLevel;
}
SkipTableNode<TValue> cur = TopHeader, last = null;
for (var layer = MaxLayer; layer >= 1; --layer)
{
// 节点有next节点next主键 < 插入主键) 或 next主键 == 插入主键 且 next副键 < 插入副键)
while (cur.Right != null && ((cur.Right.SortKey < sortKey) ||
(cur.Right.SortKey == sortKey && cur.Right.ViceKey < viceKey)))
{
cur = cur.Right;
}
if (layer <= rLevel)
{
var currentRight = cur.Right;
cur.Right = new SkipTableNode<TValue>(sortKey, viceKey, key, value, layer == 1 ? cur.Index + 1 : 0, cur, cur.Right, null);
if (currentRight != null)
{
currentRight.Left = cur.Right;
}
if (last != null)
{
last.Down = cur.Right;
}
if (layer == 1)
{
cur.Right.Index = cur.Index + 1;
Node.Add(key, cur.Right);
SkipTableNode<TValue> v = cur.Right.Right;
while (v != null)
{
v.Index++;
v = v.Right;
}
}
last = cur.Right;
}
cur = cur.Down;
}
}
public override bool Remove(long sortKey, long viceKey, long key, out TValue value)
{
value = default;
var seen = false;
var cur = TopHeader;
for (var layer = MaxLayer; layer >= 1; --layer)
{
// 先按照主键查找 再 按副键查找
while (cur.Right != null && cur.Right.SortKey < sortKey && cur.Right.Key != key) cur = cur.Right;
while (cur.Right != null && (cur.Right.SortKey == sortKey && cur.Right.ViceKey <= viceKey) &&
cur.Right.Key != key) cur = cur.Right;
var isFind = false;
var currentCur = cur;
SkipTableNode<TValue> removeCur = null;
// 如果当前不是要删除的节点、但主键和副键都一样、需要特殊处理下。
if (cur.Right != null && cur.Right.Key == key)
{
isFind = true;
removeCur = cur.Right;
currentCur = cur;
}
else
{
// 先向左查找下
var currentNode = cur.Left;
while (currentNode != null && currentNode.SortKey == sortKey && currentNode.ViceKey == viceKey)
{
if (currentNode.Key == key)
{
isFind = true;
removeCur = currentNode;
currentCur = currentNode.Left;
break;
}
currentNode = currentNode.Left;
}
// 再向右查找下
if (!isFind)
{
currentNode = cur.Right;
while (currentNode != null && currentNode.SortKey == sortKey && currentNode.ViceKey == viceKey)
{
if (currentNode.Key == key)
{
isFind = true;
removeCur = currentNode;
currentCur = currentNode.Left;
break;
}
currentNode = currentNode.Right;
}
}
}
if (isFind && currentCur != null)
{
value = removeCur.Value;
currentCur.Right = removeCur.Right;
if (removeCur.Right != null)
{
removeCur.Right.Left = currentCur;
removeCur.Right = null;
}
removeCur.Left = null;
removeCur.Down = null;
removeCur.Value = default;
if (layer == 1)
{
var tempCur = currentCur.Right;
while (tempCur != null)
{
tempCur.Index--;
tempCur = tempCur.Right;
}
Node.Remove(removeCur.Key);
}
seen = true;
}
cur = cur.Down;
}
return seen;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 94af5a03823f82246a24b4e5dfdc2be5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,181 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
#pragma warning disable CS8601
#pragma warning disable CS8603
#pragma warning disable CS8625
#pragma warning disable CS8604
namespace TEngine.DataStructure
{
public abstract class SkipTableBase<TValue> : IEnumerable<SkipTableNode<TValue>>
{
public readonly int MaxLayer;
public readonly SkipTableNode<TValue> TopHeader;
public SkipTableNode<TValue> BottomHeader;
public int Count => Node.Count;
protected readonly Random Random = new Random();
protected readonly Dictionary<long, SkipTableNode<TValue>> Node = new();
protected readonly Stack<SkipTableNode<TValue>> AntiFindStack = new Stack<SkipTableNode<TValue>>();
protected SkipTableBase(int maxLayer = 8)
{
MaxLayer = maxLayer;
var cur = TopHeader = new SkipTableNode<TValue>(long.MinValue, 0, 0, default, 0, null, null, null);
for (var layer = MaxLayer - 1; layer >= 1; --layer)
{
cur.Down = new SkipTableNode<TValue>(long.MinValue, 0, 0, default, 0, null, null, null);
cur = cur.Down;
}
BottomHeader = cur;
}
public TValue this[long key] => !TryGetValueByKey(key, out TValue value) ? default : value;
public int GetRanking(long key)
{
if (!Node.TryGetValue(key, out var node))
{
return 0;
}
return node.Index;
}
public int GetAntiRanking(long key)
{
var ranking = GetRanking(key);
if (ranking == 0)
{
return 0;
}
return Count + 1 - ranking;
}
public bool TryGetValueByKey(long key, out TValue value)
{
if (!Node.TryGetValue(key, out var node))
{
value = default;
return false;
}
value = node.Value;
return true;
}
public bool TryGetNodeByKey(long key, out SkipTableNode<TValue> node)
{
if (Node.TryGetValue(key, out node))
{
return true;
}
return false;
}
public void Find(int start, int end, ListPool<SkipTableNode<TValue>> list)
{
var cur = BottomHeader;
var count = end - start;
for (var i = 0; i < start; i++)
{
cur = cur.Right;
}
for (var i = 0; i <= count; i++)
{
if (cur == null)
{
break;
}
list.Add(cur);
cur = cur.Right;
}
}
public void AntiFind(int start, int end, ListPool<SkipTableNode<TValue>> list)
{
var cur = BottomHeader;
start = Count + 1 - start;
end = start - end;
for (var i = 0; i < start; i++)
{
cur = cur.Right;
if (cur == null)
{
break;
}
if (i < end)
{
continue;
}
AntiFindStack.Push(cur);
}
while (AntiFindStack.TryPop(out var node))
{
list.Add(node);
}
}
public TValue GetLastValue()
{
var cur = TopHeader;
while (cur.Right != null || cur.Down != null)
{
while (cur.Right != null)
{
cur = cur.Right;
}
if (cur.Down != null)
{
cur = cur.Down;
}
}
return cur.Value;
}
public bool Remove(long key)
{
if (!Node.TryGetValue(key, out var node))
{
return false;
}
return Remove(node.SortKey, node.ViceKey, key, out _);
}
public abstract void Add(long sortKey, long viceKey, long key, TValue value);
public abstract bool Remove(long sortKey, long viceKey, long key, out TValue value);
public IEnumerator<SkipTableNode<TValue>> GetEnumerator()
{
var cur = BottomHeader.Right;
while (cur != null)
{
yield return cur;
cur = cur.Right;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c3dacacc147f7c8499e328284a0542ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,166 +0,0 @@
#pragma warning disable CS8602
#pragma warning disable CS8601
#pragma warning disable CS8625
#pragma warning disable CS8604
#pragma warning disable CS8600
namespace TEngine.DataStructure
{
/// <summary>
/// 跳表降序版
/// </summary>
/// <typeparam name="TValue"></typeparam>
public class SkipTableDesc<TValue> : SkipTableBase<TValue>
{
public SkipTableDesc(int maxLayer = 8) : base(maxLayer) { }
public override void Add(long sortKey, long viceKey, long key, TValue value)
{
var rLevel = 1;
while (rLevel <= MaxLayer && Random.Next(3) == 0)
{
++rLevel;
}
SkipTableNode<TValue> cur = TopHeader, last = null;
for (var layer = MaxLayer; layer >= 1; --layer)
{
// 节点有next节点next主键 > 插入主键) 或 next主键 == 插入主键 且 next副键 > 插入副键)
while (cur.Right != null && ((cur.Right.SortKey > sortKey) ||
(cur.Right.SortKey == sortKey && cur.Right.ViceKey > viceKey)))
{
cur = cur.Right;
}
if (layer <= rLevel)
{
var currentRight = cur.Right;
cur.Right = new SkipTableNode<TValue>(sortKey, viceKey, key, value,
layer == 1 ? cur.Index + 1 : 0, cur, cur.Right, null);
if (currentRight != null)
{
currentRight.Left = cur.Right;
}
if (last != null)
{
last.Down = cur.Right;
}
if (layer == 1)
{
cur.Right.Index = cur.Index + 1;
Node.Add(key, cur.Right);
SkipTableNode<TValue> v = cur.Right.Right;
while (v != null)
{
v.Index++;
v = v.Right;
}
}
last = cur.Right;
}
cur = cur.Down;
}
}
public override bool Remove(long sortKey, long viceKey, long key, out TValue value)
{
value = default;
var seen = false;
var cur = TopHeader;
for (var layer = MaxLayer; layer >= 1; --layer)
{
// 先按照主键查找 再 按副键查找
while (cur.Right != null && cur.Right.SortKey > sortKey && cur.Right.Key != key) cur = cur.Right;
while (cur.Right != null && (cur.Right.SortKey == sortKey && cur.Right.ViceKey >= viceKey) &&
cur.Right.Key != key) cur = cur.Right;
var isFind = false;
var currentCur = cur;
SkipTableNode<TValue> removeCur = null;
// 如果当前不是要删除的节点、但主键和副键都一样、需要特殊处理下。
if (cur.Right != null && cur.Right.Key == key)
{
isFind = true;
removeCur = cur.Right;
currentCur = cur;
}
else
{
// 先向左查找下
var currentNode = cur.Left;
while (currentNode != null && currentNode.SortKey == sortKey && currentNode.ViceKey == viceKey)
{
if (currentNode.Key == key)
{
isFind = true;
removeCur = currentNode;
currentCur = currentNode.Left;
break;
}
currentNode = currentNode.Left;
}
// 再向右查找下
if (!isFind)
{
currentNode = cur.Right;
while (currentNode != null && currentNode.SortKey == sortKey && currentNode.ViceKey == viceKey)
{
if (currentNode.Key == key)
{
isFind = true;
removeCur = currentNode;
currentCur = currentNode.Left;
break;
}
currentNode = currentNode.Right;
}
}
}
if (isFind && currentCur != null)
{
value = removeCur.Value;
currentCur.Right = removeCur.Right;
if (removeCur.Right != null)
{
removeCur.Right.Left = currentCur;
removeCur.Right = null;
}
removeCur.Left = null;
removeCur.Down = null;
removeCur.Value = default;
if (layer == 1)
{
var tempCur = currentCur.Right;
while (tempCur != null)
{
tempCur.Index--;
tempCur = tempCur.Right;
}
Node.Remove(removeCur.Key);
}
seen = true;
}
cur = cur.Down;
}
return seen;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5dd291e3d391b8842a15ea93f72e4771
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More