@kkarum/framework 2.3.17

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 (171) hide show
  1. package/Framework.ts +337 -0
  2. package/Framework.ts.meta +10 -0
  3. package/FrameworkBase.ts +207 -0
  4. package/FrameworkBase.ts.meta +10 -0
  5. package/FrameworkInitialize.ts +79 -0
  6. package/FrameworkInitialize.ts.meta +10 -0
  7. package/README.md +93 -0
  8. package/README.md.meta +6 -0
  9. package/animation/FWAnimation.ts +13 -0
  10. package/animation/FWAnimation.ts.meta +10 -0
  11. package/animation/FWSkeleton.ts +174 -0
  12. package/animation/FWSkeleton.ts.meta +10 -0
  13. package/animation/FWTween.ts +60 -0
  14. package/animation/FWTween.ts.meta +10 -0
  15. package/animation.meta +13 -0
  16. package/component/FWVirtuaScrollViewComponent.ts +56 -0
  17. package/component/FWVirtuaScrollViewComponent.ts.meta +10 -0
  18. package/component/FWVirtualViewComponent.ts +2212 -0
  19. package/component/FWVirtualViewComponent.ts.meta +10 -0
  20. package/component.meta +13 -0
  21. package/config/FWAssetConfig.ts +7 -0
  22. package/config/FWAssetConfig.ts.meta +10 -0
  23. package/config/FWSystemConfig.ts +29 -0
  24. package/config/FWSystemConfig.ts.meta +10 -0
  25. package/config.meta +13 -0
  26. package/controller/FWLayerController.ts +178 -0
  27. package/controller/FWLayerController.ts.meta +10 -0
  28. package/controller.meta +13 -0
  29. package/data/FWData.ts +6 -0
  30. package/data/FWData.ts.meta +10 -0
  31. package/data.meta +13 -0
  32. package/define/FWEventDefine.ts +28 -0
  33. package/define/FWEventDefine.ts.meta +10 -0
  34. package/define/FWSystemDefine.ts +154 -0
  35. package/define/FWSystemDefine.ts.meta +10 -0
  36. package/define.meta +13 -0
  37. package/entry/FWEntry.ts +219 -0
  38. package/entry/FWEntry.ts.meta +10 -0
  39. package/entry.meta +13 -0
  40. package/expand/FWCocosExpand.ts +73 -0
  41. package/expand/FWCocosExpand.ts.meta +10 -0
  42. package/expand/FWDecorator.ts +366 -0
  43. package/expand/FWDecorator.ts.meta +10 -0
  44. package/expand/FWNodeExpand.ts +147 -0
  45. package/expand/FWNodeExpand.ts.meta +10 -0
  46. package/expand/FWRollingViewNesting.ts +195 -0
  47. package/expand/FWRollingViewNesting.ts.meta +10 -0
  48. package/expand/FWTweenExpand.ts +44 -0
  49. package/expand/FWTweenExpand.ts.meta +10 -0
  50. package/expand.meta +13 -0
  51. package/item/FWVirtualListItem.ts +141 -0
  52. package/item/FWVirtualListItem.ts.meta +10 -0
  53. package/item.meta +13 -0
  54. package/language/FWLanguage.ts +71 -0
  55. package/language/FWLanguage.ts.meta +10 -0
  56. package/language/FWLanguageLabelLocalize.ts +144 -0
  57. package/language/FWLanguageLabelLocalize.ts.meta +10 -0
  58. package/language/FWLanguageSkeletonLocalize.ts +106 -0
  59. package/language/FWLanguageSkeletonLocalize.ts.meta +10 -0
  60. package/language/FWLanguageSpriteLocalize.ts +81 -0
  61. package/language/FWLanguageSpriteLocalize.ts.meta +10 -0
  62. package/language.meta +13 -0
  63. package/layer/FWLayer.ts +14 -0
  64. package/layer/FWLayer.ts.meta +10 -0
  65. package/layer.meta +13 -0
  66. package/log/FWLog.ts +135 -0
  67. package/log/FWLog.ts.meta +10 -0
  68. package/log.meta +13 -0
  69. package/logic/FWLogic.ts +6 -0
  70. package/logic/FWLogic.ts.meta +10 -0
  71. package/logic.meta +13 -0
  72. package/machine/FWAnimationMachine.ts +28 -0
  73. package/machine/FWAnimationMachine.ts.meta +10 -0
  74. package/machine/FWStateMachine.ts +74 -0
  75. package/machine/FWStateMachine.ts.meta +10 -0
  76. package/machine.meta +13 -0
  77. package/manager/FWAnimationManager.ts +89 -0
  78. package/manager/FWAnimationManager.ts.meta +10 -0
  79. package/manager/FWAssetManager.ts +451 -0
  80. package/manager/FWAssetManager.ts.meta +10 -0
  81. package/manager/FWAudioManager.ts +339 -0
  82. package/manager/FWAudioManager.ts.meta +10 -0
  83. package/manager/FWBundleManager.ts +97 -0
  84. package/manager/FWBundleManager.ts.meta +10 -0
  85. package/manager/FWComponentManager.ts +24 -0
  86. package/manager/FWComponentManager.ts.meta +10 -0
  87. package/manager/FWEngineManager.ts +74 -0
  88. package/manager/FWEngineManager.ts.meta +10 -0
  89. package/manager/FWEventManager.ts +361 -0
  90. package/manager/FWEventManager.ts.meta +10 -0
  91. package/manager/FWHotUpdateManager.ts +344 -0
  92. package/manager/FWHotUpdateManager.ts.meta +10 -0
  93. package/manager/FWLanguageManager.ts +114 -0
  94. package/manager/FWLanguageManager.ts.meta +10 -0
  95. package/manager/FWLayerManager.ts +862 -0
  96. package/manager/FWLayerManager.ts.meta +10 -0
  97. package/manager/FWManager.ts +9 -0
  98. package/manager/FWManager.ts.meta +10 -0
  99. package/manager/FWObjectManager.ts +161 -0
  100. package/manager/FWObjectManager.ts.meta +10 -0
  101. package/manager/FWPerformanceManager.ts +198 -0
  102. package/manager/FWPerformanceManager.ts.meta +10 -0
  103. package/manager/FWPromiseManager.ts +504 -0
  104. package/manager/FWPromiseManager.ts.meta +10 -0
  105. package/manager/FWResManager.ts +299 -0
  106. package/manager/FWResManager.ts.meta +10 -0
  107. package/manager/FWSocketManager.ts +93 -0
  108. package/manager/FWSocketManager.ts.meta +10 -0
  109. package/manager/FWStateManager.ts +100 -0
  110. package/manager/FWStateManager.ts.meta +10 -0
  111. package/manager/FWTaskManager.ts +41 -0
  112. package/manager/FWTaskManager.ts.meta +10 -0
  113. package/manager/FWTimeManager.ts +442 -0
  114. package/manager/FWTimeManager.ts.meta +10 -0
  115. package/manager/FWUiManager.ts +217 -0
  116. package/manager/FWUiManager.ts.meta +10 -0
  117. package/manager.meta +13 -0
  118. package/package.json +11 -0
  119. package/package.json.meta +6 -0
  120. package/registry/FWRegistry.ts +62 -0
  121. package/registry/FWRegistry.ts.meta +10 -0
  122. package/registry.meta +13 -0
  123. package/render/FWRenderAssembler.ts +620 -0
  124. package/render/FWRenderAssembler.ts.meta +10 -0
  125. package/render.meta +13 -0
  126. package/scene/FWScene.ts +23 -0
  127. package/scene/FWScene.ts.meta +10 -0
  128. package/scene.meta +13 -0
  129. package/service/FWService.ts +11 -0
  130. package/service/FWService.ts.meta +10 -0
  131. package/service/http/FWHttp.ts +103 -0
  132. package/service/http/FWHttp.ts.meta +10 -0
  133. package/service/http.meta +13 -0
  134. package/service/socket/FWSocket.ts +367 -0
  135. package/service/socket/FWSocket.ts.meta +10 -0
  136. package/service/socket/FWSocketHandle.ts +16 -0
  137. package/service/socket/FWSocketHandle.ts.meta +10 -0
  138. package/service/socket/FWSocketSender.ts +14 -0
  139. package/service/socket/FWSocketSender.ts.meta +10 -0
  140. package/service/socket/mock/FWSocketMock.ts +202 -0
  141. package/service/socket/mock/FWSocketMock.ts.meta +10 -0
  142. package/service/socket/mock.meta +13 -0
  143. package/service/socket.meta +13 -0
  144. package/service.meta +13 -0
  145. package/state/FWState.ts +8 -0
  146. package/state/FWState.ts.meta +10 -0
  147. package/state.meta +13 -0
  148. package/types/Creator.d.ts +121 -0
  149. package/types/Creator.d.ts.meta +6 -0
  150. package/types/FW.d.ts +3016 -0
  151. package/types/FW.d.ts.meta +6 -0
  152. package/types/Global.d.ts +22 -0
  153. package/types/Global.d.ts.meta +10 -0
  154. package/types.meta +13 -0
  155. package/utils/FWLodash.ts +105 -0
  156. package/utils/FWLodash.ts.meta +10 -0
  157. package/utils/FWMask.ts +222 -0
  158. package/utils/FWMask.ts.meta +10 -0
  159. package/utils/FWObject.ts +27 -0
  160. package/utils/FWObject.ts.meta +10 -0
  161. package/utils/FWObjectPool.ts +177 -0
  162. package/utils/FWObjectPool.ts.meta +10 -0
  163. package/utils/FWQueue.ts +55 -0
  164. package/utils/FWQueue.ts.meta +10 -0
  165. package/utils/FWResLoader.ts +139 -0
  166. package/utils/FWResLoader.ts.meta +10 -0
  167. package/utils/FWTask.ts +227 -0
  168. package/utils/FWTask.ts.meta +10 -0
  169. package/utils/FWUtils.ts +15 -0
  170. package/utils/FWUtils.ts.meta +10 -0
  171. package/utils.meta +13 -0
@@ -0,0 +1,6 @@
1
+ {
2
+ "ver": "2.0.2",
3
+ "uuid": "a6ecbab2-9bdf-4b34-a89f-d84013abbcf7",
4
+ "importer": "text",
5
+ "subMetas": {}
6
+ }
@@ -0,0 +1,22 @@
1
+ declare namespace globalThis {
2
+ export var launchScene: string;
3
+ export function PerformanceMonitor(operationName?: string);
4
+ export function FWDeprecated(description?: string);
5
+ export function FWSocketAutoProcessPause();
6
+ export function FWSocketAutoProcessResume();
7
+ export function RegisterEvents(events: FW.RegisterEventArgs[]);
8
+ export function AutoRegisterCCEvent(nodePath: string, eventName?: string);
9
+ export function AutoRegisterFWEvent(eventName: any);
10
+ export function searchChild(node: cc.Node, name: string);
11
+ export function FWPropertyNode($opt?: ParamType): FW.PropertyDecorator;
12
+ export function FWPropertyNodes(...paths: string[]): FW.PropertyDecorator;
13
+ export function FWPropertyComponent(
14
+ $componentClass: FW.Newable<cc.Component>,
15
+ $childName?: string,
16
+ $mute = false,
17
+ ): FW.PropertyDecorator;
18
+ export function FWPropertyComponents(
19
+ $componentClass: FW.Newable<cc.Component>,
20
+ $childName?: string,
21
+ ): FW.PropertyDecorator;
22
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "3c019db9-4849-403e-938c-9b8921731119",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
package/types.meta ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "ver": "1.1.3",
3
+ "uuid": "d7721852-9dd0-4a93-82d4-4752e570c5ac",
4
+ "importer": "folder",
5
+ "isBundle": false,
6
+ "bundleName": "",
7
+ "priority": 1,
8
+ "compressionType": {},
9
+ "optimizeHotUpdate": {},
10
+ "inlineSpriteFrames": {},
11
+ "isRemoteBundle": {},
12
+ "subMetas": {}
13
+ }
@@ -0,0 +1,105 @@
1
+ import Lodash from 'lodash';
2
+
3
+ export namespace FWLodash {
4
+ /**
5
+ * 通过字符串数组创建一个CC的枚举对象
6
+ * @param target
7
+ * @returns
8
+ */
9
+ export function CCEnum(target: string[]) {
10
+ return cc.Enum(
11
+ Lodash.chain(target)
12
+ .map((element, index) => {
13
+ return [`${element}`, index];
14
+ })
15
+ .fromPairs()
16
+ .value(),
17
+ );
18
+ }
19
+ /**
20
+ * 判断值是否为空
21
+ * @param value
22
+ * @returns
23
+ */
24
+ export const isEmpty = (value: any) => Lodash.isEmpty(value);
25
+ /**
26
+ * 递归克隆
27
+ * @param value
28
+ * @returns
29
+ */
30
+ export const cloneDeep = <T>(value: T): T => Lodash.cloneDeep(value);
31
+ /**
32
+ * 递归地将源对象的自身和继承的可枚举属性合并到目标对象中,
33
+ * 跳过解析为undefined的源属性。
34
+ * 数组和普通对象属性递归合并。
35
+ * 其他对象和值类型被赋值覆盖。
36
+ * 源对象从左向右应用。
37
+ * 后续源会覆盖先前源的属性分配。
38
+ * @param object
39
+ * @param source
40
+ * @returns
41
+ */
42
+ export const merge = <T, U>(object: T, source: U): T & U => Lodash.merge(object, source);
43
+ /**
44
+ * 创建一个 debounced(防抖动)函数,该函数会从上一次被调用后,延迟 wait 毫秒后调用 func 方法。
45
+ * @param func
46
+ * @param wait
47
+ * @returns
48
+ */
49
+ export const debounce = <T extends (...args: any[]) => any>(func: T, wait: number) =>
50
+ Lodash.debounce(func, wait);
51
+ /**
52
+ * 创建一个节流函数,在 wait 秒内最多执行 func 一次的函数。
53
+ * @param func
54
+ * @param wait
55
+ * @returns
56
+ */
57
+ export const throttle = <T extends (...args: any[]) => any>(func: T, wait: number) =>
58
+ Lodash.throttle(func, wait);
59
+ /**
60
+ * 创建数组的无重复版本,其中只保留每个元素的第一次出现。
61
+ * @param array
62
+ * @returns
63
+ */
64
+ export const uniq = <T>(array: T[]): T[] => Lodash.uniq(array);
65
+ /**
66
+ * 根据 object对象的path路径获取值
67
+ * @param object
68
+ * @param path
69
+ * @param defaultValue
70
+ * @returns
71
+ */
72
+ export const get = <T, R>(object: T, path: Lodash.PropertyPath, defaultValue?: R): R =>
73
+ Lodash.get(object, path, defaultValue);
74
+ /**
75
+ * 根据 object对象的path路径设置值
76
+ * @param object
77
+ * @param path
78
+ * @param defaultValue
79
+ * @returns
80
+ */
81
+ export const set = <T extends object>(object: T, path: Lodash.PropertyPath, value: any): T =>
82
+ Lodash.set(object, path, value);
83
+ /**
84
+ * 创建一个由通过迭代器运行集合的每个元素的结果生成的键组成的对象。每个键的对应值是负责生成键的元素数组
85
+ * @param array
86
+ * @param iteratee
87
+ * @returns
88
+ */
89
+ export const groupBy = <T>(array: T[], iteratee: Lodash.ValueIteratee<T>) =>
90
+ Lodash.groupBy(array, iteratee);
91
+ /**
92
+ * 创建一个元素数组,根据通过每个迭代器运行集合中每个元素的结果按升序排序。此方法执行稳定排序,即保留相等元素的原始排序顺序。
93
+ * @param array
94
+ * @param iteratee
95
+ * @returns
96
+ */
97
+ export const sortBy = <T>(array: T[], iteratee?: Lodash.Many<Lodash.ListIteratee<T>>) =>
98
+ Lodash.sortBy(array, iteratee);
99
+ /**
100
+ * 创建一个只调用一次的函数
101
+ * @param func
102
+ * @returns
103
+ */
104
+ export const once = (func: any) => Lodash.once(func);
105
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "167711e4-ace5-44f9-8ad3-2689277b6e7c",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,222 @@
1
+ export enum FWMaskType {
2
+ /**
3
+ * !#en Rect mask.
4
+ * !#zh 使用矩形作为遮罩
5
+ * @property {Number} RECT
6
+ */
7
+ RECT = 0,
8
+ /**
9
+ * !#en Ellipse Mask.
10
+ * !#zh 使用椭圆作为遮罩
11
+ * @property {Number} ELLIPSE
12
+ */
13
+ ELLIPSE = 1,
14
+ /**
15
+ * !#en Image Stencil Mask.
16
+ * !#zh 使用图像模版作为遮罩
17
+ * @property {Number} IMAGE_STENCIL
18
+ */
19
+ IMAGE_STENCIL = 2,
20
+
21
+ /**
22
+ * 多边形遮罩
23
+ */
24
+ POLYGON = 3,
25
+ }
26
+
27
+ let _vec2_temp = new cc.Vec2();
28
+ let _mat4_temp = new cc.Mat4();
29
+
30
+ let _circlepoints = [];
31
+ function _calculateCircle(center, radius, segements) {
32
+ _circlepoints.length = 0;
33
+ let anglePerStep = (Math.PI * 2) / segements;
34
+ for (let step = 0; step < segements; ++step) {
35
+ _circlepoints.push(
36
+ cc.v2(
37
+ radius.x * Math.cos(anglePerStep * step) + center.x,
38
+ radius.y * Math.sin(anglePerStep * step) + center.y,
39
+ ),
40
+ );
41
+ }
42
+
43
+ return _circlepoints;
44
+ }
45
+
46
+ class EllipseConfig {
47
+ center: cc.Vec2;
48
+ r: cc.Vec2;
49
+ segments: number;
50
+ }
51
+
52
+ /**
53
+ * 遮罩扩展
54
+ * 自定义多边形遮罩
55
+ */
56
+ const { ccclass, property, executeInEditMode, menu, help, inspector } = cc._decorator;
57
+ @ccclass
58
+ @executeInEditMode
59
+ @inspector('packages://maskplus/inspector.js')
60
+ @menu('CustomComponent/FWMask')
61
+ export default class FWMask extends cc.Mask {
62
+ static Type = FWMaskType;
63
+
64
+ @property({ type: cc.Enum(FWMaskType), override: true })
65
+ _type: FWMaskType = 0;
66
+ @property({ type: cc.Enum(FWMaskType), override: true })
67
+ // @ts-ignore
68
+ get type() {
69
+ return this._type;
70
+ }
71
+ // @ts-ignore
72
+ set type(value) {
73
+ if (this._type !== value) {
74
+ this['_resetAssembler']();
75
+ }
76
+
77
+ this._type = value;
78
+
79
+ if (this._type === FWMaskType.POLYGON) {
80
+ if (this._polygon.length === 0) {
81
+ let [x, y, width, height] = this.getNodeRect();
82
+ this._polygon.push(
83
+ cc.v2(x, y),
84
+ cc.v2(x + width, y),
85
+ cc.v2(x + width, y + height),
86
+ cc.v2(x, y + height),
87
+ );
88
+ }
89
+ }
90
+
91
+ if (this._type !== FWMaskType.IMAGE_STENCIL) {
92
+ this.spriteFrame = null;
93
+ this.alphaThreshold = 0;
94
+ this._updateGraphics();
95
+ }
96
+ this['_activateMaterial']();
97
+ }
98
+
99
+ @property({ type: [cc.Vec2], serializable: true })
100
+ _polygon: cc.Vec2[] = [];
101
+ @property({ type: [cc.Vec2], serializable: true })
102
+ public get polygon() {
103
+ return this._polygon;
104
+ }
105
+ public set polygon(points: cc.Vec2[]) {
106
+ this._polygon = points;
107
+ this._updateGraphics();
108
+ }
109
+
110
+ private ellipse: EllipseConfig = new EllipseConfig();
111
+ public setEllipse(center?: cc.Vec2, r?: cc.Vec2, segments?: number) {
112
+ this.ellipse.center = center;
113
+ this.ellipse.r = r;
114
+ this.ellipse.segments = segments || this.segements;
115
+ }
116
+
117
+ _updateGraphics() {
118
+ let node = this.node;
119
+ let graphics = this['_graphics'];
120
+ // Share render data with graphics content
121
+ graphics.clear(false);
122
+ let [x, y, width, height] = this.getNodeRect();
123
+ if (this['_type'] === FWMaskType.RECT) {
124
+ graphics.rect(x, y, width, height);
125
+ } else if (this['_type'] === FWMaskType.ELLIPSE) {
126
+ let center = this.ellipse.center || cc.v2(x + width / 2, y + height / 2);
127
+ let radius = this.ellipse.r || { x: width / 2, y: height / 2 };
128
+ let segments = this.ellipse.segments || this['_segments'];
129
+ let points = _calculateCircle(center, radius, segments);
130
+ for (let i = 0; i < points.length; ++i) {
131
+ let point = points[i];
132
+ if (i === 0) {
133
+ graphics.moveTo(point.x, point.y);
134
+ } else {
135
+ graphics.lineTo(point.x, point.y);
136
+ }
137
+ }
138
+ graphics.close();
139
+ } else if (this['_type'] === FWMaskType.POLYGON) {
140
+ if (this._polygon.length === 0) this._polygon.push(cc.v2(0, 0));
141
+ graphics.moveTo(this._polygon[0].x, this._polygon[0].y);
142
+ for (let i = 1; i < this._polygon.length; i++) {
143
+ graphics.lineTo(this._polygon[i].x, this._polygon[i].y);
144
+ }
145
+ graphics.lineTo(this._polygon[0].x, this._polygon[0].y);
146
+ }
147
+
148
+ if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
149
+ graphics.stroke();
150
+ } else {
151
+ graphics.fill();
152
+ }
153
+ }
154
+
155
+ _hitTest(cameraPt: cc.Vec2) {
156
+ let node = this.node;
157
+ let size = node.getContentSize(),
158
+ w = size.width,
159
+ h = size.height,
160
+ testPt = _vec2_temp;
161
+
162
+ node['_updateWorldMatrix']();
163
+ if (!cc.Mat4.invert(_mat4_temp, node['_worldMatrix'])) {
164
+ return false;
165
+ }
166
+ let point = cc.v2(0, 0);
167
+ cc.Vec2.transformMat4(point, cameraPt, _mat4_temp);
168
+ testPt.x = point.x + node['_anchorPoint'].x * w;
169
+ testPt.y = point.y + node['_anchorPoint'].y * h;
170
+
171
+ let result = false;
172
+ if (this.type === FWMaskType.RECT || this.type === FWMaskType.IMAGE_STENCIL) {
173
+ result = testPt.x >= 0 && testPt.y >= 0 && testPt.x <= w && testPt.y <= h;
174
+ } else if (this.type === FWMaskType.ELLIPSE) {
175
+ let rx = w / 2,
176
+ ry = h / 2;
177
+ let px = testPt.x - 0.5 * w,
178
+ py = testPt.y - 0.5 * h;
179
+ result = (px * px) / (rx * rx) + (py * py) / (ry * ry) < 1;
180
+ } else if (this.type === FWMaskType.POLYGON) {
181
+ result = this.isInPolygon(point, this.polygon);
182
+ }
183
+ if (this.inverted) {
184
+ result = !result;
185
+ }
186
+ return result;
187
+ }
188
+
189
+ private getNodeRect() {
190
+ let width = this.node['_contentSize'].width;
191
+ let height = this.node['_contentSize'].height;
192
+ let x = -width * this.node['_anchorPoint'].x;
193
+ let y = -height * this.node['_anchorPoint'].y;
194
+ return [x, y, width, height];
195
+ }
196
+
197
+ public isInPolygon(checkPoint: cc.Vec2, polygonPoints: cc.Vec2[]) {
198
+ let counter = 0,
199
+ i: number,
200
+ xinters: number;
201
+ let p1: cc.Vec2, p2: cc.Vec2;
202
+ let pointCount = polygonPoints.length;
203
+ p1 = polygonPoints[0];
204
+
205
+ for (i = 1; i <= pointCount; i++) {
206
+ p2 = polygonPoints[i % pointCount];
207
+ if (checkPoint.x > Math.min(p1.x, p2.x) && checkPoint.x <= Math.max(p1.x, p2.x)) {
208
+ if (checkPoint.y <= Math.max(p1.y, p2.y)) {
209
+ if (p1.x != p2.x) {
210
+ xinters = ((checkPoint.x - p1.x) * (p2.y - p1.y)) / (p2.x - p1.x) + p1.y;
211
+ if (p1.y == p2.y || checkPoint.y <= xinters) {
212
+ counter++;
213
+ }
214
+ }
215
+ }
216
+ }
217
+ p1 = p2;
218
+ }
219
+ return (counter & 1) !== 0;
220
+ }
221
+ }
222
+ cc['FWMask'] = FWMask;
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "d23e2be0-c6e3-43f3-a7f3-fc08342960ac",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,27 @@
1
+ export abstract class FWObject extends cc.Component {
2
+ /** 是否已经初始化 */
3
+ public initialize: boolean;
4
+ /** 对象唯一id */
5
+ public uniqueId: number;
6
+ /** 对象是否启用 */
7
+ public enable: boolean;
8
+
9
+ public readonly entry: FW.Entry = FW.Entry;
10
+
11
+ constructor() {
12
+ super();
13
+ this.initialize = false;
14
+ this.uniqueId = 0;
15
+ this.enable = false;
16
+ }
17
+
18
+ abstract onGet(args: any);
19
+ abstract onPut();
20
+ abstract onInit();
21
+ onDestroy() {
22
+ FW.Entry.timeMgr?.unSchedule(this);
23
+ FW.Entry.evtMgr?.targetOff(this);
24
+ this?.unscheduleAllCallbacks();
25
+ this?.node?.stopAllActions();
26
+ }
27
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "9385d55e-5267-434f-b54c-6a98368a5985",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,177 @@
1
+ const POOL_DISABLE_POSITION: cc.Vec3 = cc.v3(50000, 50000);
2
+
3
+ export class FWObjectPool<T extends FW.Object = FW.Object>
4
+ implements FW.ObjectPool
5
+ {
6
+ private uniqueId: number;
7
+ private type: FW.SystemDefine.FWObjectType;
8
+ private enablePoolMap: Map<number, FW.ObjectProperty>;
9
+ private disablePoolMap: Map<number, FW.ObjectProperty>;
10
+
11
+ constructor(
12
+ protected node: cc.Node,
13
+ protected parent: cc.Node,
14
+ type?: FW.SystemDefine.FWObjectType,
15
+ ) {
16
+ this.uniqueId = 0;
17
+ this.type =
18
+ type !== undefined ? type : FW.SystemDefine.FWObjectType.OPACITY;
19
+ this.enablePoolMap = new Map<number, FW.ObjectProperty>();
20
+ this.disablePoolMap = new Map<number, FW.ObjectProperty>();
21
+ }
22
+
23
+ /**
24
+ * 获取所有已经启用对象
25
+ */
26
+ public getEnableObjectMap() {
27
+ return this.enablePoolMap;
28
+ }
29
+ /**
30
+ * 获取未启用对象
31
+ * @returns
32
+ */
33
+ public getDisableObjectMap() {
34
+ return this.disablePoolMap;
35
+ }
36
+ /**
37
+ * 获取所有已经创建对象
38
+ */
39
+ public getAllObjectMap() {
40
+ return [...this.enablePoolMap, ...this.disablePoolMap];
41
+ }
42
+
43
+ findObjectProperty(node: cc.Node);
44
+ findObjectProperty(component: FW.Object);
45
+ findObjectProperty(uniqueId: number);
46
+ findObjectProperty() {
47
+ const map = new Map([...this.enablePoolMap, ...this.disablePoolMap]);
48
+
49
+ for (const [uniqueId, property] of map) {
50
+ if (arguments[0] instanceof cc.Node) {
51
+ const uuid = arguments[0].uuid;
52
+ if (property.node.uuid == uuid) {
53
+ return property;
54
+ }
55
+ } else if (arguments[0] instanceof FW.Object) {
56
+ if (uniqueId == arguments[0]?.uniqueId) {
57
+ return property;
58
+ }
59
+ } else {
60
+ if (property?.uniqueId == arguments[0]) {
61
+ return property;
62
+ }
63
+ }
64
+ }
65
+ return undefined;
66
+ }
67
+
68
+ /** 是否禁用缓存池中存在剩余对象 */
69
+ public isEmpty() {
70
+ return this.disablePoolMap.size == 0;
71
+ }
72
+
73
+ get(...args: any): FW.ObjectProperty {
74
+ let node: cc.Node;
75
+ let element: T;
76
+ let ObjectProperty: FW.ObjectProperty = {
77
+ uniqueId: -1,
78
+ };
79
+ if (this.isEmpty()) {
80
+ node = cc.instantiate(this.node);
81
+ element = (node.getComponent(FW.Object) as T) || undefined;
82
+ ObjectProperty.uniqueId = ++this.uniqueId;
83
+ ObjectProperty.node = node;
84
+ ObjectProperty.component = element;
85
+ if (ObjectProperty.component) {
86
+ ObjectProperty.component.uniqueId = ObjectProperty.uniqueId;
87
+ }
88
+ } else {
89
+ const entry = this.disablePoolMap.entries().next().value;
90
+ const key = entry[0];
91
+ ObjectProperty = entry[1] as FW.ObjectProperty;
92
+ node = ObjectProperty.node;
93
+ element = ObjectProperty.component as T;
94
+ this.disablePoolMap.delete(key);
95
+ }
96
+
97
+ if (!cc.isValid(node)) {
98
+ return;
99
+ }
100
+
101
+ ObjectProperty.enable = true;
102
+
103
+ this.enablePoolMap.set(ObjectProperty.uniqueId, ObjectProperty);
104
+ if (this.type == FW.SystemDefine.FWObjectType.OPACITY) {
105
+ node.opacity = 255;
106
+ } else {
107
+ node.active = true;
108
+ node.setParent(this.parent);
109
+ }
110
+
111
+ if (element) {
112
+ if (!element.initialize) {
113
+ element.initialize = true;
114
+ element.onInit();
115
+ }
116
+ element.enable = true;
117
+ node.setParent(this.parent);
118
+ element.onGet(args);
119
+ FW.Entry.evtMgr?.targetResume(element);
120
+ } else {
121
+ node.setParent(this.parent);
122
+ }
123
+
124
+ node.resumeSystemEvents(true);
125
+
126
+ return ObjectProperty;
127
+ }
128
+
129
+ puts(nodes: cc.Node[]);
130
+ puts(components: cc.Component[]);
131
+ puts(uniqueId: number[]);
132
+ puts() {
133
+ const arr = (arguments[0] as any[]).concat();
134
+ for (let i = 0; i < arr.length; i++) {
135
+ this.put(arr[i]);
136
+ }
137
+ }
138
+
139
+ put(node: cc.Node);
140
+ put(component: FW.Object);
141
+ put(uniqueId: number);
142
+ put() {
143
+ let property: FW.ObjectProperty = this.findObjectProperty(arguments[0]);
144
+
145
+ const node: cc.Node = property.node;
146
+ const element = (node.getComponent(FW.Object) as T) || undefined;
147
+
148
+ if (!cc.isValid(node)) {
149
+ return;
150
+ }
151
+
152
+ if (this.type == FW.SystemDefine.FWObjectType.OPACITY) {
153
+ node.opacity = 0;
154
+ } else {
155
+ node.active = false;
156
+ node.removeFromParent(false);
157
+ }
158
+ node.pauseSystemEvents(true);
159
+ node.setPosition(POOL_DISABLE_POSITION);
160
+ this.disablePoolMap.set(property.uniqueId, property);
161
+ if (element) {
162
+ FW.Entry.evtMgr?.targetPause(element);
163
+ element.onPut();
164
+ element.enable = false;
165
+ }
166
+ }
167
+
168
+ onDestroy() {
169
+ const map = new Map([...this.enablePoolMap, ...this.disablePoolMap]);
170
+
171
+ for (const [uniqueId, property] of map) {
172
+ property.component?.onDestroy?.();
173
+ }
174
+ this.enablePoolMap.clear();
175
+ this.disablePoolMap.clear();
176
+ }
177
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "570aed3c-115a-4f80-91e7-7c26e4f8f1f4",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }
@@ -0,0 +1,55 @@
1
+ export class FWQueue<T> {
2
+ private queue: T[];
3
+ constructor() {
4
+ this.queue = [];
5
+ }
6
+
7
+ /**
8
+ * 添加元素进入队列末尾
9
+ * @param element
10
+ */
11
+ public add(element: T) {
12
+ this.queue.push(element);
13
+ }
14
+
15
+ /**
16
+ * 删除并返回元素第一个元素
17
+ * */
18
+ public shift() {
19
+ return this.queue.shift();
20
+ }
21
+
22
+ /**
23
+ * 查看并返回元素第一个元素
24
+ * */
25
+ public peek() {
26
+ if (!this.isEmpty()) {
27
+ return undefined;
28
+ }
29
+ return this.queue[0];
30
+ }
31
+
32
+ /**
33
+ * 队列是否为空
34
+ * @returns
35
+ */
36
+ public isEmpty() {
37
+ return this.size() == 0;
38
+ }
39
+
40
+ /**
41
+ * 队列剩余数量
42
+ * @returns
43
+ */
44
+ public size() {
45
+ return this.queue.length;
46
+ }
47
+
48
+ public clear() {
49
+ this.queue = [];
50
+ }
51
+
52
+ public getQueue() {
53
+ return this.queue;
54
+ }
55
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ver": "1.1.0",
3
+ "uuid": "8739c994-9649-44c8-87f3-1d766fff1f54",
4
+ "importer": "typescript",
5
+ "isPlugin": false,
6
+ "loadPluginInWeb": true,
7
+ "loadPluginInNative": true,
8
+ "loadPluginInEditor": false,
9
+ "subMetas": {}
10
+ }