keytops-game-framework 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +214 -0
  2. package/dist/app/base/RuntimeApplicationImpl.d.ts +22 -0
  3. package/dist/app/base/base.d.ts +113 -0
  4. package/dist/app/base/event/Event.d.ts +12 -0
  5. package/dist/app/base/event/EventDispatcher.d.ts +66 -0
  6. package/dist/app/base/pool/IRecoverable.d.ts +13 -0
  7. package/dist/app/base/pool/Pool.d.ts +45 -0
  8. package/dist/app/base/utils/Handler.d.ts +69 -0
  9. package/dist/app/base/utils/Injector.d.ts +19 -0
  10. package/dist/app/base/utils/Json.d.ts +14 -0
  11. package/dist/app/base/utils/MathUtils.d.ts +74 -0
  12. package/dist/app/base/utils/NativeUtils.d.ts +4 -0
  13. package/dist/app/base/utils/PromiseUtils.d.ts +20 -0
  14. package/dist/app/base/utils/StringUtils.d.ts +66 -0
  15. package/dist/app/module/abTesting/ABTesting.d.ts +41 -0
  16. package/dist/app/module/analytics/ALiAnalyticsSender.d.ts +59 -0
  17. package/dist/app/module/analytics/AnalyticsAble.d.ts +191 -0
  18. package/dist/app/module/analytics/AnalyticsAbleConst.d.ts +20 -0
  19. package/dist/app/module/analytics/BaseDimension.d.ts +19 -0
  20. package/dist/app/module/analytics/KeytopsAnalyticsSender.d.ts +67 -0
  21. package/dist/app/module/analytics/ad/ADAnalyticsAble.d.ts +19 -0
  22. package/dist/app/module/analytics/ad/ADBehaviorReporter.d.ts +90 -0
  23. package/dist/app/module/analytics/ad/AdDimension.d.ts +34 -0
  24. package/dist/app/module/analytics/index.d.ts +65 -0
  25. package/dist/app/module/analytics/launch/LaunchAnalyticsAble.d.ts +11 -0
  26. package/dist/app/module/analytics/level/GameDimension.d.ts +39 -0
  27. package/dist/app/module/analytics/level/LevelAnalyticsAble.d.ts +86 -0
  28. package/dist/app/module/analytics/level/LevelBehaviorReporter.d.ts +29 -0
  29. package/dist/app/module/analytics/level/LevelStatsDimension.d.ts +70 -0
  30. package/dist/app/module/analytics/level/PlayerAbilityDimension.d.ts +147 -0
  31. package/dist/app/module/analytics/session/SessionAnalyticsAble.d.ts +9 -0
  32. package/dist/app/module/analytics/session/SessionDimension.d.ts +48 -0
  33. package/dist/app/module/analytics/social/SocialAnalyticsAble.d.ts +14 -0
  34. package/dist/app/module/analytics/social/SocialDimension.d.ts +14 -0
  35. package/dist/app/module/bidding/Bidding.d.ts +37 -0
  36. package/dist/app/module/business/BusinessCenter.d.ts +33 -0
  37. package/dist/app/module/business/IBusiness.d.ts +6 -0
  38. package/dist/app/module/business/RewardVideoMaskBusiness.d.ts +18 -0
  39. package/dist/app/module/config/ConfigHelper.d.ts +142 -0
  40. package/dist/app/module/ecs/Component.d.ts +125 -0
  41. package/dist/app/module/ecs/ECS.d.ts +162 -0
  42. package/dist/app/module/ecs/ECSManager.d.ts +56 -0
  43. package/dist/app/module/ecs/Entity.d.ts +1 -0
  44. package/dist/app/module/ecs/Mask.d.ts +12 -0
  45. package/dist/app/module/ecs/System.d.ts +54 -0
  46. package/dist/app/module/fsm/Fsm.d.ts +44 -0
  47. package/dist/app/module/fsm/FsmBase.d.ts +28 -0
  48. package/dist/app/module/fsm/FsmManager.d.ts +67 -0
  49. package/dist/app/module/fsm/IFsm.d.ts +67 -0
  50. package/dist/app/module/fsm/IFsmState.d.ts +38 -0
  51. package/dist/app/module/logger/Logger.d.ts +58 -0
  52. package/dist/app/module/native/INativeHelper.d.ts +6 -0
  53. package/dist/app/module/native/NativeHelper.d.ts +10 -0
  54. package/dist/app/module/net/NetInterface.d.ts +22 -0
  55. package/dist/app/module/net/NetManager.d.ts +24 -0
  56. package/dist/app/module/net/byte/ByteView.d.ts +391 -0
  57. package/dist/app/module/net/http/HttpNode.d.ts +104 -0
  58. package/dist/app/module/net/http/HttpRequest.d.ts +104 -0
  59. package/dist/app/module/net/server/IServer.d.ts +20 -0
  60. package/dist/app/module/net/server/LevelOnlineConfig.d.ts +9 -0
  61. package/dist/app/module/net/server/Server.d.ts +105 -0
  62. package/dist/app/module/net/server/SystemOnlineConfig.d.ts +34 -0
  63. package/dist/app/module/net/socket/BaseProtocolHelper.d.ts +31 -0
  64. package/dist/app/module/net/socket/Socket.d.ts +145 -0
  65. package/dist/app/module/net/socket/SocketNode.d.ts +63 -0
  66. package/dist/app/module/publisher/IADAble.d.ts +46 -0
  67. package/dist/app/module/publisher/IAble.d.ts +6 -0
  68. package/dist/app/module/publisher/IDevice.d.ts +42 -0
  69. package/dist/app/module/publisher/IGameUpdateAble.d.ts +21 -0
  70. package/dist/app/module/publisher/ILoginAble.d.ts +38 -0
  71. package/dist/app/module/publisher/IPayAble.d.ts +11 -0
  72. package/dist/app/module/publisher/IPublisher.d.ts +154 -0
  73. package/dist/app/module/publisher/IPublisherManager.d.ts +69 -0
  74. package/dist/app/module/publisher/IRecordAble.d.ts +16 -0
  75. package/dist/app/module/publisher/IShareAble.d.ts +39 -0
  76. package/dist/app/module/publisher/PublisherManager.d.ts +106 -0
  77. package/dist/app/module/publisher/PublisherManagerImpl.d.ts +24 -0
  78. package/dist/app/module/publisher/ks/KSAd.d.ts +7 -0
  79. package/dist/app/module/publisher/ks/KSDevice.d.ts +8 -0
  80. package/dist/app/module/publisher/ks/KSLogin.d.ts +7 -0
  81. package/dist/app/module/publisher/ks/KSPublisher.d.ts +34 -0
  82. package/dist/app/module/publisher/ks/KSRecorder.d.ts +13 -0
  83. package/dist/app/module/publisher/ks/KSShare.d.ts +32 -0
  84. package/dist/app/module/publisher/my/MYAd.d.ts +13 -0
  85. package/dist/app/module/publisher/my/MYDevice.d.ts +7 -0
  86. package/dist/app/module/publisher/my/MYLogin.d.ts +6 -0
  87. package/dist/app/module/publisher/my/MYPublisher.d.ts +6 -0
  88. package/dist/app/module/publisher/native/NativeAd.d.ts +22 -0
  89. package/dist/app/module/publisher/native/NativeAnalyticsSender.d.ts +9 -0
  90. package/dist/app/module/publisher/native/NativeDevice.d.ts +6 -0
  91. package/dist/app/module/publisher/native/NativeLogin.d.ts +27 -0
  92. package/dist/app/module/publisher/native/NativePay.d.ts +6 -0
  93. package/dist/app/module/publisher/native/NativePublisher.d.ts +21 -0
  94. package/dist/app/module/publisher/native/NativeRecord.d.ts +10 -0
  95. package/dist/app/module/publisher/native/NativeShare.d.ts +23 -0
  96. package/dist/app/module/publisher/tk/TKAd.d.ts +14 -0
  97. package/dist/app/module/publisher/tk/TKAnalyticsSender.d.ts +7 -0
  98. package/dist/app/module/publisher/tk/TKDevice.d.ts +9 -0
  99. package/dist/app/module/publisher/tk/TKLogin.d.ts +5 -0
  100. package/dist/app/module/publisher/tk/TKPublisher.d.ts +34 -0
  101. package/dist/app/module/publisher/tt/TTAd.d.ts +14 -0
  102. package/dist/app/module/publisher/tt/TTAnalyticsSender.d.ts +7 -0
  103. package/dist/app/module/publisher/tt/TTDevice.d.ts +9 -0
  104. package/dist/app/module/publisher/tt/TTLogin.d.ts +6 -0
  105. package/dist/app/module/publisher/tt/TTPay.d.ts +4 -0
  106. package/dist/app/module/publisher/tt/TTPublisher.d.ts +34 -0
  107. package/dist/app/module/publisher/tt/TTRecorder.d.ts +11 -0
  108. package/dist/app/module/publisher/tt/TTShare.d.ts +50 -0
  109. package/dist/app/module/publisher/tt/TTUpdateGameAble.d.ts +7 -0
  110. package/dist/app/module/publisher/wx/WXAd.d.ts +14 -0
  111. package/dist/app/module/publisher/wx/WXAnalyticsSender.d.ts +7 -0
  112. package/dist/app/module/publisher/wx/WXDevice.d.ts +8 -0
  113. package/dist/app/module/publisher/wx/WXLogin.d.ts +9 -0
  114. package/dist/app/module/publisher/wx/WXPay.d.ts +4 -0
  115. package/dist/app/module/publisher/wx/WXPublisher.d.ts +33 -0
  116. package/dist/app/module/publisher/wx/WXShare.d.ts +56 -0
  117. package/dist/app/module/publisher/wx/WXUpdateGameAble.d.ts +7 -0
  118. package/dist/app/module/storage/Storage.d.ts +123 -0
  119. package/dist/app/module/storage/StorageImpl.d.ts +13 -0
  120. package/dist/app/module/structure/Dictionary.d.ts +48 -0
  121. package/dist/app/module/structure/Link.d.ts +149 -0
  122. package/dist/app/module/structure/List.d.ts +93 -0
  123. package/dist/app/module/task/Task.d.ts +33 -0
  124. package/dist/app/module/task/TaskQueue.d.ts +17 -0
  125. package/dist/app/module/task/TaskSequence.d.ts +19 -0
  126. package/dist/app/module/timer/ITimer.d.ts +4 -0
  127. package/dist/app/module/timer/Timer.d.ts +133 -0
  128. package/dist/app/module/timer/TimerImpl.d.ts +10 -0
  129. package/dist/app/module/utils/md5.d.ts +3 -0
  130. package/dist/app/module/view/IView.d.ts +94 -0
  131. package/dist/app/module/view/IViewLoader.d.ts +48 -0
  132. package/dist/app/module/view/ViewManager.d.ts +242 -0
  133. package/dist/audio/AudioManager.d.ts +146 -0
  134. package/dist/business/AudioBusiness.d.ts +11 -0
  135. package/dist/cocos.d.ts +1 -0
  136. package/dist/index.d.ts +146 -0
  137. package/dist/index.js +14981 -0
  138. package/dist/native/CocosNativeHelper.d.ts +12 -0
  139. package/dist/resource/ResourceManager.d.ts +187 -0
  140. package/dist/utils/Async.d.ts +28 -0
  141. package/dist/utils/CocosStorageUtils.d.ts +10 -0
  142. package/dist/utils/GeometryUtils.d.ts +31 -0
  143. package/dist/view/CCPViewLoader.d.ts +95 -0
  144. package/dist/view/CCSceneLoader.d.ts +25 -0
  145. package/dist/view/CocosViewManager.d.ts +12 -0
  146. package/dist/view/Scene.d.ts +35 -0
  147. package/dist/view/View.d.ts +151 -0
  148. package/dist/view/ViewControl.d.ts +106 -0
  149. package/dist/view/tips/TipsView.d.ts +12 -0
  150. package/dist/vitest.config.d.ts +2 -0
  151. package/package.json +33 -0
@@ -0,0 +1,142 @@
1
+ /**
2
+ * 数据/配置查询协助工具
3
+ * @type DataStructure 数据结构
4
+ */
5
+ export declare abstract class ConfigHelper<DataStructure> {
6
+ protected _path: string;
7
+ protected _data: DataStructure;
8
+ constructor(path?: string);
9
+ /**
10
+ * 直接设置数据
11
+ * @param data
12
+ * @returns
13
+ */
14
+ setData(data: DataStructure): ConfigHelper<DataStructure>;
15
+ /**
16
+ * 数据
17
+ */
18
+ get data(): DataStructure;
19
+ /**
20
+ * 加载配置(需要在子类中实现)
21
+ * @param onComplete
22
+ * @param caller
23
+ * @param path
24
+ * @returns
25
+ */
26
+ abstract loadData(onComplete?: (error: Error, config: ConfigHelper<DataStructure>) => void, caller?: any, path?: string): Promise<ConfigHelper<DataStructure>>;
27
+ /**
28
+ * loadData的Promise包装
29
+ * @returns
30
+ */
31
+ load(): Promise<ConfigHelper<DataStructure>>;
32
+ get path(): string;
33
+ /**
34
+ * 获取字段对应的数据
35
+ * @param key 字段名,支持'att.subatt.subatt...'多层字段
36
+ * @returns
37
+ */
38
+ findData<T>(key: string | number): T;
39
+ /**
40
+ * 通过指定条件筛选并返回第一个子项
41
+ * @param filterKey 子项拥有的字段名
42
+ * @param filterValue 子项的key字段的值等于value
43
+ * @param subKey 目标数据路径,支持'att.subatt.subatt...'多层字段, 默认为根数据
44
+ * @returns 匹配结果为0个的情况下返回Null
45
+ */
46
+ firstData<T>(filterKey: string, filterValue: any, subKey?: string | number): T;
47
+ /**
48
+ * 通过指定条件筛选并返回最后一个子项
49
+ * @param filterKey 子项拥有的字段名
50
+ * @param filterValue 子项的key字段的值等于value
51
+ * @param subKey 目标数据路径,支持'att.subatt.subatt...'多层字段, 默认为根数据
52
+ * @returns 匹配结果为0个的情况下返回Null
53
+ *
54
+ * 关于顺序:先以升序枚举数值键,然后以插入顺序枚举字符串和符号键
55
+ */
56
+ lastData<T>(filterKey: string, filterValue: any, subKey?: string | number): T;
57
+ /**
58
+ * 通过指定条件筛选子项. 比如查询道具类型(type)为1的道具列表.比如章节(chapter)为第1章的关卡列表.
59
+ * @param filterKey 子项拥有的字段名
60
+ * @param filterValue 子项的key字段的值等于value
61
+ * @param subKey 目标数据路径,支持'att.subatt.subatt...'多层字段, 默认为根数据
62
+ * @returns 符合条件的子项数组.
63
+ */
64
+ selectData<T>(filterKey: string, filterValue: any, subKey?: string | number): T[];
65
+ /**
66
+ * 索引数据位置,-1为不存在
67
+ * @param value 查找的值
68
+ * @param key [可选] 子数据字段名,支持'att.subatt.subatt...'多层字段, 默认为根数据
69
+ * @returns -1不存在, >=0为值所在的位置
70
+ */
71
+ indexof<T>(value: T, key?: string | number): number;
72
+ /**
73
+ * 最后索引数据位置,-1为不存在
74
+ * @param value 查找的值
75
+ * @param key [可选] 子数据字段名,支持'att.subatt.subatt...'多层字段, 默认为根数据
76
+ * @param fromIndex [可选] 开始检索的索引
77
+ * @returns -1不存在, >=0为值所在的位置
78
+ */
79
+ lastIndexof<T>(value: T, key?: string | number, fromIndex?: number): number;
80
+ /**
81
+ * 获取数据数量,取数据的length或者size,可以自定义或者配置为数组
82
+ * @returns
83
+ */
84
+ get size(): number;
85
+ /**
86
+ * 获取字段对应的数据
87
+ * @param data 要查询的数据集
88
+ * @param key 字段名,支持'att.subatt.subatt...'多层字段
89
+ * @returns
90
+ */
91
+ static findData<T>(data: any, key: string | number): T;
92
+ /**
93
+ * 通过指定条件筛选并返回第一个子项
94
+ * @param data 要查询的数据集
95
+ * @param filterKey 子项拥有的字段名
96
+ * @param filterValue 子项的key字段的值等于value
97
+ * @param subKey 目标数据路径,支持'att.subatt.subatt...'多层字段, 默认为根数据
98
+ * @returns 匹配结果为0个的情况下返回Null
99
+ *
100
+ * 关于顺序:先以升序枚举数值键,然后以插入顺序枚举字符串和符号键
101
+ */
102
+ static firstData<T>(data: any, filterKey: string, filterValue: any, subKey?: string | number): T;
103
+ /**
104
+ * 通过指定条件筛选并返回最后一个子项
105
+ * @param data 要查询的数据集
106
+ * @param filterKey 子项拥有的字段名
107
+ * @param filterValue 子项的key字段的值等于value
108
+ * @param subKey 目标数据路径,支持'att.subatt.subatt...'多层字段, 默认为根数据
109
+ * @returns 匹配结果为0个的情况下返回Null
110
+ *
111
+ * 关于顺序:先以升序枚举数值键,然后以插入顺序枚举字符串和符号键
112
+ */
113
+ static lastData<T>(data: any, filterKey: string, filterValue: any, subKey?: string | number): T;
114
+ /**
115
+ * 通过指定条件筛选子项. 比如查询道具类型(type)为1的道具列表.比如章节(chapter)为第1章的关卡列表.
116
+ * @param data 要查询的数据集
117
+ * @param filterKey 子项拥有的字段名
118
+ * @param filterValue 子项的key字段的值等于value
119
+ * @param subKey 目标数据路径,支持'att.subatt.subatt...'多层字段, 默认为根数据
120
+ * @returns 符合条件的子项数组.
121
+ *
122
+ * 关于顺序:先以升序枚举数值键,然后以插入顺序枚举字符串和符号键
123
+ */
124
+ static selectData<T>(data: any, filterKey: string, filterValue: any, subKey?: string | number): T[];
125
+ /**
126
+ * 索引数据位置,-1为不存在
127
+ * @param data 要查询的数据集
128
+ * @param value 查找的值
129
+ * @param key [可选] 子数据字段名,支持'att1.att2.att3...'多层字段, 默认为根数据
130
+ * @returns -1不存在, >=0为值所在的位置
131
+ */
132
+ static indexof<T>(data: any, value: T, key?: string | number): number;
133
+ /**
134
+ * 最后索引数据位置,-1为不存在
135
+ * @param data 要查询的数据集
136
+ * @param value 查找的值
137
+ * @param key [可选] 子数据字段名,支持'att1/att2/att3...'多层字段, 默认为根数据
138
+ * @param fromIndex [可选] 开始检索的索引
139
+ * @returns -1不存在, >=0为值所在的位置
140
+ */
141
+ static lastIndexof<T>(data: any, value: T, key?: string | number, fromIndex?: number): number;
142
+ }
@@ -0,0 +1,125 @@
1
+ import { ComponentType } from "./ECS";
2
+ import { EntityID } from "./Entity";
3
+ /**
4
+ * 组件接口
5
+ */
6
+ export interface IComponent {
7
+ /**
8
+ * 组件名称,在onCreate中传入设置,无需手动设置
9
+ */
10
+ readonly name: string;
11
+ /**
12
+ * 组件ID
13
+ */
14
+ readonly id: number;
15
+ /**
16
+ * 组件类型,在onCreate中传入设置,无需手动设置
17
+ */
18
+ readonly type: number;
19
+ /**
20
+ * 拥有该组件的实体
21
+ */
22
+ readonly entity: EntityID;
23
+ /**
24
+ * 释放组件,并存放到缓存中.组件未从entity移除时,什么都不会发生.
25
+ */
26
+ release(): void;
27
+ /**
28
+ * 组件被创建时
29
+ * @param type
30
+ * @param name
31
+ * @param datas 其他数据
32
+ */
33
+ onCreate(type: number, name: string, ...datas: any[]): void;
34
+ /**
35
+ * 组件被添加到实体上时调用
36
+ * @param entity
37
+ */
38
+ onAdd(entity: EntityID): void;
39
+ /**
40
+ * 组件被移除时调用
41
+ */
42
+ onRemove(): void;
43
+ /**
44
+ * 组件被释放时调用
45
+ */
46
+ onRelease(): void;
47
+ }
48
+ export type ComponentClass = {
49
+ create<T extends Component>(): T;
50
+ };
51
+ /**
52
+ * 携带了数据的组件创建类型
53
+ */
54
+ export type ComponentMate = {
55
+ clazz: ComponentClass;
56
+ data?: any[];
57
+ } | ComponentClass;
58
+ /**
59
+ * 基础组件
60
+ */
61
+ export declare class Component implements IComponent {
62
+ private static _componentPool;
63
+ /**
64
+ * 创建该组件
65
+ * @returns
66
+ */
67
+ static create<T extends Component>(): T;
68
+ /**
69
+ * 释放组件
70
+ * @param component
71
+ */
72
+ protected static release(component: Component): void;
73
+ private static nextId;
74
+ /**
75
+ * 指定创建组件时携带的数据
76
+ * @param data 数据
77
+ * @returns
78
+ */
79
+ static meta(...data: any[]): ComponentMate;
80
+ private _id;
81
+ /**
82
+ * 组件ID
83
+ */
84
+ get id(): number;
85
+ private _type;
86
+ /**
87
+ * 组件类型
88
+ */
89
+ get type(): ComponentType;
90
+ private _name;
91
+ /**
92
+ * 组件名称
93
+ */
94
+ get name(): string;
95
+ protected _entity: EntityID;
96
+ /**
97
+ * 拥有该组件的实体
98
+ */
99
+ get entity(): EntityID;
100
+ constructor();
101
+ /**
102
+ * 组件被创建时
103
+ * @param type
104
+ * @param name
105
+ * @param datas 其他数据
106
+ */
107
+ onCreate(type: number, name: string, ...datas: any[]): void;
108
+ /**
109
+ * 组件被添加到实体上时调用
110
+ * @param entity
111
+ */
112
+ onAdd(entity: EntityID): void;
113
+ /**
114
+ * 组件被移除时调用
115
+ */
116
+ onRemove(): void;
117
+ /**
118
+ * 释放组件,并存放到缓存中.组件未从entity移除时,什么都不会发生.
119
+ */
120
+ release(): void;
121
+ /**
122
+ * 组件被释放时调用
123
+ */
124
+ onRelease(): void;
125
+ }
@@ -0,0 +1,162 @@
1
+ import { ComponentClass, IComponent, ComponentMate, Component } from "./Component";
2
+ import { EntityID } from "./Entity";
3
+ import { Mask } from "./Mask";
4
+ import { System, SystemClass } from "./System";
5
+ export type ComponentType = number;
6
+ /**
7
+ * 注册组件
8
+ * @returns
9
+ */
10
+ export declare function component(name?: string): any;
11
+ /**
12
+ * ECS
13
+ */
14
+ export declare class ECS {
15
+ private _name;
16
+ private _running;
17
+ private _frameCount;
18
+ private _entityCount;
19
+ private _systemCount;
20
+ private _entities;
21
+ private _components;
22
+ private _systems;
23
+ get name(): string;
24
+ /**
25
+ * 是否在运行中
26
+ */
27
+ get isRunning(): boolean;
28
+ constructor(name: string);
29
+ /**
30
+ * 开始ECS的主循环
31
+ */
32
+ launch(): void;
33
+ private _tick;
34
+ /**
35
+ * 停止ECS
36
+ */
37
+ shutdown(): void;
38
+ /**
39
+ * 停止并重置ECS
40
+ */
41
+ reset(): void;
42
+ private _getComponentMapOfType;
43
+ /**
44
+ * 创建实体
45
+ * @param components 实体所附带的若干组件
46
+ * @returns 返回实体ID
47
+ */
48
+ createEntity(...components: ComponentMate[]): EntityID;
49
+ /**
50
+ * 创建实体
51
+ * @param components
52
+ */
53
+ createEntity(...components: ComponentMate[]): EntityID;
54
+ /**
55
+ * 释放实体,同时会销毁相关Component
56
+ * @param entityId 实体ID
57
+ * @returns
58
+ */
59
+ releaseEntity(entityId: EntityID): boolean;
60
+ /**
61
+ * 通过掩码查询实体
62
+ * @param mask
63
+ */
64
+ getEntities(mask: Mask): EntityID[];
65
+ /**
66
+ * 通过组件匹配查询实体
67
+ * @param components
68
+ * @returns
69
+ */
70
+ getEntities(component: {
71
+ new (): IComponent;
72
+ }, ...components: {
73
+ new (): IComponent;
74
+ }[]): EntityID[];
75
+ /**
76
+ * 添加组件到实体
77
+ * @param entityId 实体ID
78
+ * @param component 组件Class
79
+ * @param data 若干个组件数据
80
+ */
81
+ addComponents<T extends Component>(entityId: EntityID, component: ComponentMate): T | null;
82
+ /**
83
+ * 添加组件到实体
84
+ * @param entityId 实体ID
85
+ * @param components 一个或多个组件
86
+ */
87
+ addComponents(entityId: EntityID, ...components: ComponentMate[]): Component[] | null;
88
+ /**
89
+ * 添加组件到实体
90
+ * @param entityId 实体ID
91
+ * @param clazz 组件class
92
+ * @param datas 组件数据
93
+ * @returns
94
+ */
95
+ private _addComponent;
96
+ /**
97
+ * 添加组件对象到实体,可用于外部引擎自动实例化的组件.
98
+ * @param entityId 实体ID
99
+ * @param component 组件对象
100
+ * @param datas 传到组件onCreate函数的的参数列表
101
+ */
102
+ addComponent(entityId: EntityID, component: IComponent, ...datas: any[]): void;
103
+ /**
104
+ * 移除实体的组件
105
+ * @param component 组件对象
106
+ */
107
+ removeComponent(component: IComponent): IComponent;
108
+ /**
109
+ * 批量移除实体的组件
110
+ * @param components 若干个组件对象
111
+ */
112
+ removeComponent(...components: IComponent[]): IComponent[];
113
+ /**
114
+ * 移除实体的组件
115
+ * @param entityId 组件ID
116
+ * @param componentClass 组件class
117
+ */
118
+ removeComponentWithClass(entityId: EntityID, componentClass: ComponentClass): IComponent;
119
+ /**
120
+ * 批量移除实体的组件
121
+ * @param entityId 组件ID
122
+ * @param componentClasses 组件Class列表
123
+ */
124
+ removeComponentWithClass(entityId: EntityID, ...componentClasses: ComponentClass[]): IComponent[];
125
+ /**
126
+ * 实体是否包含组件mask
127
+ * @param mask 组件mask
128
+ */
129
+ containComponent(entityId: EntityID, mask: Mask): boolean;
130
+ /**
131
+ * 实体是否包含组件
132
+ * @param components 系列组件,全部包含才返回true.
133
+ */
134
+ containComponent(entityId: EntityID, ...components: ComponentClass[]): boolean;
135
+ /**
136
+ * 获取实体组件
137
+ * @param componentClass 组件class
138
+ * @returns `T` or `null`
139
+ */
140
+ getComponent<T extends IComponent>(entityId: EntityID, componentClass: ComponentClass | {
141
+ new (): IComponent;
142
+ }): T | null;
143
+ /**
144
+ * 获取指定类型的所有组件
145
+ * @param type
146
+ * @returns
147
+ */
148
+ getComponents<T extends IComponent>(componentClass: ComponentClass | {
149
+ new (): IComponent;
150
+ }): T[];
151
+ /**
152
+ * 添加系统
153
+ * @param systems 若干系统Class
154
+ */
155
+ addSystem(...systems: SystemClass[]): void;
156
+ /**
157
+ * 移除系统
158
+ * @param system
159
+ * @returns
160
+ */
161
+ removeSystem(system: System): boolean;
162
+ }
@@ -0,0 +1,56 @@
1
+ import { ECS } from "./ECS";
2
+ /**
3
+ * 注册系统
4
+ * @param ecsName 系统所属的ECS名称
5
+ * @returns
6
+ */
7
+ export declare function system(ecsName?: string): any;
8
+ declare class ECSManager {
9
+ private _ecss;
10
+ private static created;
11
+ constructor();
12
+ /**
13
+ * 现存的ECS数量
14
+ */
15
+ get count(): number;
16
+ /**
17
+ * 是否存在ECS
18
+ * @param name ECS名称
19
+ * @returns
20
+ */
21
+ has(name: string): boolean;
22
+ /**
23
+ * 获取ECS
24
+ * @param name
25
+ * @returns
26
+ */
27
+ get(name: string): ECS | undefined;
28
+ /**
29
+ * 获取现存的ECS
30
+ * @returns
31
+ */
32
+ getAll(): ECS[];
33
+ /**
34
+ * 创建ECS
35
+ * @param name ECS名称,默认为default
36
+ * @returns
37
+ */
38
+ create(name?: string): ECS;
39
+ /**
40
+ * 释放ECS
41
+ * @param ecs ECS对象
42
+ */
43
+ release(ecs: ECS): boolean;
44
+ /**
45
+ * 销毁ECS
46
+ * @param name ECS名称
47
+ */
48
+ release(name: string): boolean;
49
+ private _releaseByName;
50
+ private _release;
51
+ }
52
+ /**
53
+ * ECS管理器
54
+ */
55
+ export declare const manager: ECSManager;
56
+ export {};
@@ -0,0 +1 @@
1
+ export type EntityID = number;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 掩码
3
+ */
4
+ export declare class Mask {
5
+ private _mask;
6
+ constructor();
7
+ set(type: number): void;
8
+ unset(type: number): void;
9
+ has(type: number): boolean;
10
+ has(otherMask: Mask): boolean;
11
+ clear(): void;
12
+ }
@@ -0,0 +1,54 @@
1
+ import { ECS } from "./ECS";
2
+ export type SystemClass = {
3
+ new (ecs: ECS): System;
4
+ };
5
+ /**
6
+ * ECS 系统基类
7
+ */
8
+ export declare abstract class System {
9
+ /**
10
+ * 系统优先级,数字越大越优先执行,默认为0
11
+ */
12
+ priority: number;
13
+ /**
14
+ * 系统运行的条件,默认为无限制运行
15
+ */
16
+ condition(frameCount: number): boolean;
17
+ /**
18
+ * 系统运行的频率,指定了每隔几帧运行一次,默认为1,表示每帧都运行
19
+ */
20
+ frequency: number;
21
+ /**
22
+ * 系统是否已经启动
23
+ */
24
+ protected _isRunning: boolean;
25
+ /**
26
+ * 系统所属的ECS实例
27
+ */
28
+ protected _ecs: ECS | null;
29
+ constructor(ecs: ECS);
30
+ /**
31
+ * 启动系统
32
+ */
33
+ start(): void;
34
+ /**
35
+ * 停止系统
36
+ */
37
+ stop(): void;
38
+ /**
39
+ * 系统是否正在运行中
40
+ */
41
+ get isRunning(): boolean;
42
+ /**
43
+ * 系统开始的调用
44
+ */
45
+ protected abstract onStart?(): void;
46
+ /**
47
+ * 系统结束的调用
48
+ */
49
+ protected abstract onStop?(): void;
50
+ /**
51
+ * 系统更新的调用
52
+ */
53
+ abstract onUpdate(deltaTime: number): void;
54
+ }
@@ -0,0 +1,44 @@
1
+ import { IRecoverable } from "../../base/pool/IRecoverable";
2
+ import { FsmBase } from "./FsmBase";
3
+ import { IFsm } from "./IFsm";
4
+ import { IFsmState } from "./IFsmState";
5
+ /**
6
+ * 有限状态机
7
+ * @type 有限状态机持有者类型
8
+ */
9
+ export declare class Fsm<OwnerT, DataT> extends FsmBase implements IFsm<OwnerT, DataT>, IRecoverable {
10
+ private static pool;
11
+ protected _owner: OwnerT | null;
12
+ protected _states: Map<string, IFsmState<OwnerT, DataT>>;
13
+ protected _data: DataT;
14
+ protected _currentSate: IFsmState<OwnerT, DataT> | null;
15
+ protected _currentStateTime: number;
16
+ protected _isDestroyed: boolean;
17
+ constructor();
18
+ get ownerType(): string;
19
+ protected _tick(dt: number): void;
20
+ get owner(): OwnerT | null;
21
+ get fmsStateCount(): number;
22
+ get isRunning(): boolean;
23
+ get isDestroyed(): boolean;
24
+ get currentState(): IFsmState<OwnerT, DataT> | null;
25
+ get currentStateTime(): number;
26
+ get currentStateName(): string;
27
+ /**
28
+ * 创建有限状态机
29
+ * @param name 有限状态机名称
30
+ * @param owner 有限状态机持有者
31
+ * @param states 有限状态机集合
32
+ * @returns 创建的有限状态机
33
+ */
34
+ static create<T, DataT>(name: string, owner: T, states: IFsmState<T, DataT>[], data?: DataT): Fsm<T, DataT>;
35
+ start(stateName: string): void;
36
+ hasState(stateName: string): boolean;
37
+ getState<T extends IFsmState<OwnerT, DataT>>(stateName: string): T | undefined;
38
+ getAllStates(): IFsmState<OwnerT, DataT>[];
39
+ changeState(stateName: string): void;
40
+ get data(): DataT;
41
+ shutdown(): void;
42
+ reset(): void;
43
+ destroy(): void;
44
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 有限状态机基类
3
+ */
4
+ export declare abstract class FsmBase {
5
+ protected _name: string;
6
+ get name(): string;
7
+ get fullName(): string;
8
+ abstract readonly ownerType: string;
9
+ /**
10
+ * 有限状态机更新
11
+ * @param dt 间隔时间(秒)
12
+ */
13
+ protected abstract _tick(dt: number): void;
14
+ /**
15
+ * 开启有限状态机
16
+ * @param stateName
17
+ */
18
+ abstract start(stateName: string): void;
19
+ /**
20
+ * 关闭并清理有限状态机
21
+ */
22
+ abstract shutdown(): void;
23
+ abstract readonly fmsStateCount: number;
24
+ abstract readonly isRunning: boolean;
25
+ abstract readonly isDestroyed: boolean;
26
+ abstract readonly currentStateTime: number;
27
+ abstract readonly currentStateName: string;
28
+ }
@@ -0,0 +1,67 @@
1
+ import { FsmBase } from "./FsmBase";
2
+ import { IFsm } from "./IFsm";
3
+ import { IFsmState } from "./IFsmState";
4
+ /**
5
+ * 有限状态机管理器
6
+ */
7
+ declare class FsmManager {
8
+ private static created;
9
+ constructor();
10
+ private _fsms;
11
+ /**
12
+ * 获取有限状态机数量
13
+ */
14
+ get count(): number;
15
+ /**
16
+ * 是否存在有限状态机
17
+ * @param name 有限状态机名称
18
+ * @returns
19
+ */
20
+ hasFsm(name: string): boolean;
21
+ /**
22
+ * 根据名称获取有限状态机
23
+ * @param name 有限状态机名称
24
+ * @returns
25
+ */
26
+ getFsm<T extends FsmBase>(name: string): T;
27
+ /**
28
+ * 获取所有存在的Fsm
29
+ * @returns
30
+ */
31
+ getAllFsms(): FsmBase[];
32
+ /**
33
+ * 创建一个有限状态机
34
+ * @param owner 有限状态机拥有者
35
+ * @param states 状态列表
36
+ * @param name 有限状态机名称,默认:default
37
+ * @returns
38
+ */
39
+ createFsm<OwnerT, DataT>(owner: OwnerT, states: IFsmState<OwnerT, DataT>[], name?: string, data?: DataT): IFsm<OwnerT, DataT>;
40
+ /**
41
+ * 销毁有限状态机
42
+ * @param fsmName
43
+ * @returns
44
+ */
45
+ destroyFsmByName(fsmName: string): boolean;
46
+ /**
47
+ * 销毁有限状态机
48
+ * @param fsm 状态机
49
+ * @returns
50
+ */
51
+ destroyFsm(fsm: FsmBase): boolean;
52
+ /**
53
+ * 销毁有限状态机
54
+ * @param owner 有限状态机持有者
55
+ * @returns
56
+ */
57
+ destroyFsmByOwner(owner: any): boolean;
58
+ /**
59
+ * 关闭并清理有限状态机管理器
60
+ */
61
+ shutdown(): void;
62
+ }
63
+ /**
64
+ * 有限状态机管理器
65
+ */
66
+ export declare const fsmManager: FsmManager;
67
+ export {};