@cc-component/cc-core 1.5.0 → 1.5.1
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.
- package/assets/core/config/CommonEnum.ts +3 -1
- package/assets/core/home/BaseGameState.ts +114 -103
- package/assets/core/home/EffectSingleCase.ts +267 -0
- package/assets/core/home/EffectSingleCase.ts.meta +9 -0
- package/assets/core/home/ResourceManager.ts +1 -1
- package/assets/core/interface/App.ts +5 -0
- package/assets/core/interface/Interface.ts +4 -0
- package/index.ts +1 -0
- package/package.json +1 -1
|
@@ -1,129 +1,140 @@
|
|
|
1
1
|
import { Component } from "cc";
|
|
2
|
+
|
|
2
3
|
/**状态机 */
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
StartGame(): Promise<string> { return Promise.resolve("开始游戏"); };
|
|
8
|
-
GameOver(): Promise<string> { return Promise.resolve("游戏结束"); };
|
|
9
|
-
GameWin(): Promise<string> { return Promise.resolve("游戏胜利"); };
|
|
10
|
-
GameFail(): Promise<string> { return Promise.resolve("游戏失败"); };
|
|
11
|
-
GameClose(): Promise<string> { return Promise.resolve("关闭游戏界面"); };
|
|
4
|
+
export class BaseGameState extends Component {
|
|
5
|
+
private states: { action: (value?: string) => Promise<string>; name: string; state: string }[] = [];
|
|
6
|
+
nextState: ((value?: string | PromiseLike<string>) => void) | null = null;
|
|
7
|
+
private jumpTarget: string | null = null; // 新增:记录要跳转的目标状态名
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
StartGame(): Promise<string> { return Promise.resolve("开始游戏"); };
|
|
10
|
+
GameOver(): Promise<string> { return Promise.resolve("游戏结束"); };
|
|
11
|
+
GameWin(): Promise<string> { return Promise.resolve("游戏胜利"); };
|
|
12
|
+
GameFail(): Promise<string> { return Promise.resolve("游戏失败"); };
|
|
13
|
+
GameClose(): Promise<string> { return Promise.resolve("关闭游戏界面"); };
|
|
16
14
|
|
|
17
|
-
/**初始化状态 */
|
|
18
|
-
public initStates() {
|
|
19
|
-
this.states = this.registerStates()
|
|
20
|
-
this.addCommonState();
|
|
21
|
-
}
|
|
22
15
|
|
|
23
|
-
|
|
24
|
-
registerStates()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
protected onLoad(): void {
|
|
17
|
+
this.states = this.registerStates()
|
|
18
|
+
this.onInit()
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
/**注册状态-可重写 */
|
|
22
|
+
registerStates() {
|
|
23
|
+
return [
|
|
24
|
+
{ action: this.StartGame, name: "开始游戏", state: "StartGame" },
|
|
25
|
+
{ action: this.GameOver, name: "游戏结束", state: "GameOver" },
|
|
26
|
+
{ action: this.GameWin, name: "游戏胜利", state: "GameWin" },
|
|
27
|
+
{ action: this.GameFail, name: "游戏失败", state: "GameFail" },
|
|
28
|
+
{ action: this.GameClose, name: "关闭游戏界面", state: "GameClose" },
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
onInit() {
|
|
32
|
+
this.addCommonState();
|
|
33
|
+
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
index = targetIndex; // 跳转到目标索引
|
|
49
|
-
} else {
|
|
50
|
-
index++; // 正常顺序执行
|
|
51
|
-
}
|
|
35
|
+
/**运行 */
|
|
36
|
+
public async run() {
|
|
37
|
+
let index = 0;
|
|
38
|
+
const self = this;
|
|
39
|
+
while (index < self.states.length) {
|
|
40
|
+
const currentState = self.states[index];
|
|
41
|
+
this.statesLog(currentState.name)
|
|
42
|
+
// 执行当前状态
|
|
43
|
+
const jumpTarget = await currentState.action.call(self);
|
|
44
|
+
if (jumpTarget) {
|
|
45
|
+
const targetIndex = this.states.findIndex(s => s.state === jumpTarget);
|
|
46
|
+
if (targetIndex !== -1) {
|
|
47
|
+
console.log(`[状态机] 跳转到: ${jumpTarget}`);
|
|
48
|
+
index = targetIndex; // 跳转到目标索引
|
|
52
49
|
} else {
|
|
53
50
|
index++; // 正常顺序执行
|
|
54
51
|
}
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
} else {
|
|
53
|
+
index++; // 正常顺序执行
|
|
57
54
|
}
|
|
58
|
-
this.statesLog("结束")
|
|
59
55
|
}
|
|
56
|
+
}
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
statesLog(name: string) {
|
|
59
|
+
console.log(`状态:${name}`);
|
|
60
|
+
}
|
|
64
61
|
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} else {
|
|
77
|
-
this.states.splice(index, 0, model);
|
|
78
|
-
}
|
|
63
|
+
/**
|
|
64
|
+
* 在指定方法之后插入新的方法
|
|
65
|
+
* @param afterMethod
|
|
66
|
+
* @param newState
|
|
67
|
+
*/
|
|
68
|
+
public insertState(afterMethod: () => Promise<string>, model: { action: () => Promise<string>; name: string; state: string }, isDown: boolean = true) {
|
|
69
|
+
const index = this.states.findIndex((s) => s.action === afterMethod);
|
|
70
|
+
if (index !== -1) {
|
|
71
|
+
if (isDown) {
|
|
72
|
+
this.states.splice(index + 1, 0, model);
|
|
79
73
|
} else {
|
|
80
|
-
|
|
74
|
+
this.states.splice(index, 0, model);
|
|
81
75
|
}
|
|
76
|
+
} else {
|
|
77
|
+
console.error(`没有找到:${String(afterMethod)}`);
|
|
82
78
|
}
|
|
79
|
+
}
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
//#region 添加通用状态
|
|
82
|
+
private addCommonState() {
|
|
83
|
+
//插入this.openEndWindow状态后
|
|
84
|
+
//this.insertState(this.openEndWindow, { action: this.activeState, name: "活动", state: "activeState" });
|
|
85
|
+
}
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
activeState() {
|
|
88
|
+
return new Promise<void>((res) => {
|
|
89
|
+
res();
|
|
90
|
+
// setTimeout(() => {
|
|
91
|
+
// res();
|
|
92
|
+
// }, 2000);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 跳转到指定状态(在下一个状态循环时生效)
|
|
98
|
+
* @param stateName 目标状态的 state 字段值(如 "GameClose")
|
|
99
|
+
*/
|
|
100
|
+
public jumpToState(stateName: string): void {
|
|
101
|
+
const target = this.states.find(s => s.state === stateName);
|
|
102
|
+
if (!target) {
|
|
103
|
+
console.error(`[状态机] 未找到状态: ${stateName}`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.jumpTarget = stateName;
|
|
107
|
+
// 如果当前有 nextState,立即 resolve 以退出当前状态
|
|
108
|
+
if (this.nextState) {
|
|
109
|
+
this.nextState();
|
|
110
|
+
this.nextState = null;
|
|
97
111
|
}
|
|
112
|
+
}
|
|
98
113
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (this.nextState) {
|
|
104
|
-
this.nextState(stateName);
|
|
105
|
-
this.nextState = null;
|
|
106
|
-
}
|
|
114
|
+
next() {
|
|
115
|
+
if (this.nextState) {
|
|
116
|
+
this.nextState();
|
|
117
|
+
this.nextState = null;
|
|
107
118
|
}
|
|
119
|
+
}
|
|
108
120
|
|
|
109
|
-
|
|
121
|
+
// BaseGameState.ts
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
123
|
+
/**
|
|
124
|
+
* 创建一个状态 Promise,并自动绑定 this.nextState
|
|
125
|
+
* 子类只需提供具体的执行逻辑(可选延迟)
|
|
126
|
+
*/
|
|
127
|
+
protected promise(
|
|
128
|
+
executor: (next: (value?: string | PromiseLike<string>) => void) => void,
|
|
129
|
+
delay: number = 0
|
|
130
|
+
): Promise<string> {
|
|
131
|
+
return new Promise<string>((res) => {
|
|
132
|
+
this.nextState = res; // 自动绑定
|
|
133
|
+
if (delay > 0) {
|
|
134
|
+
this.scheduleOnce(() => { executor(res); }, delay);
|
|
135
|
+
} else {
|
|
136
|
+
executor(res);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
128
139
|
}
|
|
129
140
|
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: dgflash
|
|
3
|
+
* @Date: 2021-10-12 14:00:43
|
|
4
|
+
* @LastEditors: dgflash
|
|
5
|
+
* @LastEditTime: 2023-03-06 14:40:34
|
|
6
|
+
*/
|
|
7
|
+
import { Animation, Node, NodePool, ParticleSystem, Prefab, sp, Vec3 } from 'cc';
|
|
8
|
+
import { SystemMessage } from '../config/CommonEnum';
|
|
9
|
+
import { Asset } from 'cc';
|
|
10
|
+
import { instantiate } from 'cc';
|
|
11
|
+
|
|
12
|
+
/** 特效参数 */
|
|
13
|
+
export interface IEffectParams {
|
|
14
|
+
/**路径 */
|
|
15
|
+
path: string;
|
|
16
|
+
/**资源包名 */
|
|
17
|
+
bundle: string;
|
|
18
|
+
/**初始空间坐标 */
|
|
19
|
+
pos?: Vec3,
|
|
20
|
+
/**初始世界坐标 */
|
|
21
|
+
worldPos?: Vec3,
|
|
22
|
+
/** 是否播放完成后删除 */
|
|
23
|
+
isPlayFinishedRelease?: boolean,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 动画特效对象池管理器,加载动画后自动播放,播放完后自动回收到池中
|
|
28
|
+
* 1、支持Spine动画
|
|
29
|
+
* 2、支持Cocos Animation动画
|
|
30
|
+
* 3、支持Cocos ParticleSystem粒子动画
|
|
31
|
+
*/
|
|
32
|
+
export class EffectSingleCase {
|
|
33
|
+
private static _instance: EffectSingleCase;
|
|
34
|
+
static get instance(): EffectSingleCase {
|
|
35
|
+
if (this._instance == null) {
|
|
36
|
+
this._instance = new EffectSingleCase();
|
|
37
|
+
}
|
|
38
|
+
return this._instance;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private _speed: number = 1;
|
|
42
|
+
/** 全局动画播放速度 */
|
|
43
|
+
get speed(): number {
|
|
44
|
+
return this._speed;
|
|
45
|
+
}
|
|
46
|
+
set speed(value: number) {
|
|
47
|
+
this._speed = value;
|
|
48
|
+
this.effects_use.forEach((value: Boolean, key: Node) => {
|
|
49
|
+
this.setSpeed(key);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** 对象池集合 */
|
|
54
|
+
private effects: Map<string, NodePool> = new Map();
|
|
55
|
+
/** 正在使用中的显示对象集合 */
|
|
56
|
+
private effects_use: Map<Node, boolean> = new Map();
|
|
57
|
+
/** 对象池中用到的资源 - 这里只管理本对象加载的资源,预加载资源由其它对象自己施放 */
|
|
58
|
+
private res: Map<string, string> = new Map();
|
|
59
|
+
|
|
60
|
+
constructor() {
|
|
61
|
+
// App.On(SystemMessage.Put, this.onPut, this);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// private onPut(node: Node) {
|
|
65
|
+
// this.put(node);
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 获取指定资源池中对象数量
|
|
70
|
+
* @param path 预制资源路径
|
|
71
|
+
*/
|
|
72
|
+
getCount(path: string): number {
|
|
73
|
+
var np = this.effects.get(path);
|
|
74
|
+
if (np) {
|
|
75
|
+
return np.size();
|
|
76
|
+
}
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** 池中预加载显示对象 */
|
|
81
|
+
preload(count: number, params: IEffectParams): Promise<void> {
|
|
82
|
+
return new Promise(async (resolve, reject) => {
|
|
83
|
+
let np = this.effects.get(params.path);
|
|
84
|
+
if (np == null) {
|
|
85
|
+
np = new NodePool();
|
|
86
|
+
this.effects.set(params.path, np);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.res.set(params.path, params.bundle);
|
|
90
|
+
await App.LoadAsset(params.bundle, params.path, Prefab);
|
|
91
|
+
|
|
92
|
+
for (let i = 0; i < count; i++) {
|
|
93
|
+
let node = instantiate(App.GetAsset(params.bundle, params.path))//ViewUtil.createPrefabNode(path, bundleName);
|
|
94
|
+
np.put(node);
|
|
95
|
+
}
|
|
96
|
+
resolve();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 加载资源并生成节点对象
|
|
102
|
+
* @param path 预制资源路径
|
|
103
|
+
* @param parent 父节点
|
|
104
|
+
* @param params 显示参数
|
|
105
|
+
*/
|
|
106
|
+
loadAndShow(params?: IEffectParams, parent?: Node): Promise<Node> {
|
|
107
|
+
return new Promise(async (resolve, reject) => {
|
|
108
|
+
var np = this.effects.get(params.path);
|
|
109
|
+
if (np == undefined) {
|
|
110
|
+
if (params && params.bundle) {
|
|
111
|
+
this.res.set(params.path, params.bundle);
|
|
112
|
+
await App.LoadAsset(params.bundle, params.path, Prefab);
|
|
113
|
+
//await resLoader.loadAsync(params.bundleName, path, Prefab);
|
|
114
|
+
}
|
|
115
|
+
// else {
|
|
116
|
+
// this.res.set(path, resLoader.defaultBundleName);
|
|
117
|
+
// await resLoader.loadAsync(path, Prefab);
|
|
118
|
+
// }
|
|
119
|
+
const node = this.show(params, parent);
|
|
120
|
+
resolve(node);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const node = this.show(params, parent);
|
|
124
|
+
resolve(node);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 显示预制对象
|
|
131
|
+
* @param path 预制资源路径
|
|
132
|
+
* @param parent 父节点
|
|
133
|
+
* @param params 显示参数
|
|
134
|
+
*/
|
|
135
|
+
show(params: IEffectParams, parent?: Node): Node {
|
|
136
|
+
var np = this.effects.get(params.path);
|
|
137
|
+
if (np == null) {
|
|
138
|
+
np = new NodePool();
|
|
139
|
+
this.effects.set(params.path, np);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var node: Node;
|
|
143
|
+
// 创建池中新显示对象
|
|
144
|
+
if (np.size() == 0) {
|
|
145
|
+
var bundleName = ''
|
|
146
|
+
if (params && params.bundle) bundleName = params.bundle;
|
|
147
|
+
node = instantiate(App.GetAsset(bundleName, params.path))//ViewUtil.createPrefabNode(path, bundleName);
|
|
148
|
+
// //@ts-ignore
|
|
149
|
+
// node.asset_path = path;
|
|
150
|
+
// if (params && params.isPlayFinishedRelease) {
|
|
151
|
+
// node.addComponent(EffectFinishedRelease);
|
|
152
|
+
// }
|
|
153
|
+
}
|
|
154
|
+
// 池中获取没使用的显示对象
|
|
155
|
+
else {
|
|
156
|
+
node = np.get()!;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// 设置动画播放速度
|
|
160
|
+
this.setSpeed(node);
|
|
161
|
+
|
|
162
|
+
// 设置显示对象位置
|
|
163
|
+
if (params) {
|
|
164
|
+
if (params.pos) node.position = params.pos;
|
|
165
|
+
if (params.worldPos) node.worldPosition = params.worldPos;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 显示到屏幕上
|
|
169
|
+
if (parent) node.parent = parent;
|
|
170
|
+
|
|
171
|
+
// 记录缓冲池中放出的节点
|
|
172
|
+
this.effects_use.set(node, true);
|
|
173
|
+
|
|
174
|
+
return node;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 回收对象
|
|
179
|
+
* @param name 预制对象名称
|
|
180
|
+
* @param node 节点
|
|
181
|
+
*/
|
|
182
|
+
put(node: Node) {
|
|
183
|
+
//@ts-ignore
|
|
184
|
+
const name = node.asset_path.split(':').pop();
|
|
185
|
+
if (name) {
|
|
186
|
+
const np = this.effects.get(name);
|
|
187
|
+
if (np) {
|
|
188
|
+
// 回收使用的节点
|
|
189
|
+
this.effects_use.delete(node);
|
|
190
|
+
|
|
191
|
+
// 回到到池中
|
|
192
|
+
np.put(node);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 清除对象池数据
|
|
199
|
+
* @param path 参数为空时,清除所有对象池数据;指定名时,清楚指定数据
|
|
200
|
+
*/
|
|
201
|
+
clear(path?: string) {
|
|
202
|
+
if (path) {
|
|
203
|
+
const np = this.effects.get(path);
|
|
204
|
+
if (np) np.clear();
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
this.effects.forEach(np => {
|
|
208
|
+
np.clear();
|
|
209
|
+
});
|
|
210
|
+
this.effects.clear();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 释放对象池中显示对象的资源内存
|
|
216
|
+
* @param path 资源路径
|
|
217
|
+
*/
|
|
218
|
+
release(path?: string) {
|
|
219
|
+
if (path) {
|
|
220
|
+
this.clear(path);
|
|
221
|
+
const bundleName = this.res.get(path);
|
|
222
|
+
App.ReleaseAssetPath(path, bundleName);
|
|
223
|
+
this.res.delete(path);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
// 施放池中对象内存
|
|
227
|
+
this.clear();
|
|
228
|
+
|
|
229
|
+
// 施放对象资源内存
|
|
230
|
+
this.res.forEach((bundleName: string, path: string) => {
|
|
231
|
+
App.ReleaseAssetPath(path, bundleName);
|
|
232
|
+
});
|
|
233
|
+
this.res.clear()
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** 设置动画速度 */
|
|
238
|
+
private setSpeed(node: Node) {
|
|
239
|
+
// SPINE动画
|
|
240
|
+
let spine = node.getComponent(sp.Skeleton);
|
|
241
|
+
if (spine) {
|
|
242
|
+
spine.timeScale = this.speed;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
// COCOS动画
|
|
246
|
+
const anims: Animation[] = node.getComponentsInChildren(Animation);
|
|
247
|
+
if (anims.length > 0) {
|
|
248
|
+
anims.forEach(animator => {
|
|
249
|
+
let aniName = animator.defaultClip?.name;
|
|
250
|
+
if (aniName) {
|
|
251
|
+
let aniState = animator.getState(aniName);
|
|
252
|
+
if (aniState) {
|
|
253
|
+
aniState.speed = this.speed;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
// 粒子动画
|
|
259
|
+
else if (ParticleSystem) {
|
|
260
|
+
const particles: ParticleSystem[] = node.getComponentsInChildren(ParticleSystem);
|
|
261
|
+
particles.forEach(particle => {
|
|
262
|
+
particle.simulationSpeed = this.speed;
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -187,7 +187,7 @@ export class ResourceManager {
|
|
|
187
187
|
* @param bundleName Bundle 名称
|
|
188
188
|
* @returns 资源的唯一键
|
|
189
189
|
*/
|
|
190
|
-
|
|
190
|
+
public getAssetKey(path: string, bundleName: string): string {
|
|
191
191
|
path = path.replace("/spriteFrame", "")
|
|
192
192
|
return `${bundleName}:${path}`;
|
|
193
193
|
}
|
|
@@ -20,6 +20,7 @@ import { ELoggerLevel } from "../lib/logger/ELoggerLevel";
|
|
|
20
20
|
import { SkeletonAnim } from "../home/BaseSkeleton";
|
|
21
21
|
import { Tools } from "../home/Tools";
|
|
22
22
|
import { ecs } from "../lib/ecs/ECS";
|
|
23
|
+
import { EffectSingleCase } from "../home/EffectSingleCase";
|
|
23
24
|
|
|
24
25
|
export class App {
|
|
25
26
|
/**当前bundle */
|
|
@@ -42,6 +43,8 @@ export class App {
|
|
|
42
43
|
static get sound(): AudioUtil { return this.instance._sound };
|
|
43
44
|
/**声音 */
|
|
44
45
|
static get tools(): Tools { return this.instance._tools };
|
|
46
|
+
/**对象池 */
|
|
47
|
+
static get pool(): EffectSingleCase { return this.instance._pool }
|
|
45
48
|
|
|
46
49
|
_gui: LayerUI;
|
|
47
50
|
_http: HttpManager;
|
|
@@ -52,6 +55,7 @@ export class App {
|
|
|
52
55
|
_message: EventManager;
|
|
53
56
|
_sound: AudioUtil;
|
|
54
57
|
_tools: Tools;
|
|
58
|
+
_pool: EffectSingleCase;
|
|
55
59
|
private static instance: App | null = null;
|
|
56
60
|
public static get Ins(): App {
|
|
57
61
|
if (!App.instance) { App.instance = new App(); }
|
|
@@ -83,6 +87,7 @@ export class App {
|
|
|
83
87
|
self._message = new EventManager();
|
|
84
88
|
self._sound = new AudioUtil();
|
|
85
89
|
self._tools = new Tools();
|
|
90
|
+
self._pool = EffectSingleCase.instance;
|
|
86
91
|
|
|
87
92
|
if (EDITOR) { return }//编辑器环境,不执行下面逻辑
|
|
88
93
|
Logger.setLevel(ELoggerLevel.Error);
|
|
@@ -13,6 +13,7 @@ import { MLogger } from "../lib/logger/MLogger";
|
|
|
13
13
|
import { EventManager } from "../home/EventManager";
|
|
14
14
|
import { AudioUtil } from "../home/AudioUtil";
|
|
15
15
|
import { Tools } from "../home/Tools";
|
|
16
|
+
import { EffectSingleCase } from "../home/EffectSingleCase";
|
|
16
17
|
|
|
17
18
|
declare global {
|
|
18
19
|
/** 日志打印类 */
|
|
@@ -38,6 +39,9 @@ declare global {
|
|
|
38
39
|
const sound: AudioUtil;
|
|
39
40
|
/**工具类 */
|
|
40
41
|
const tools: Tools;
|
|
42
|
+
/**对象池 */
|
|
43
|
+
const pool: EffectSingleCase
|
|
44
|
+
|
|
41
45
|
/**当前所在bundle名称 */
|
|
42
46
|
const bundleName: string;
|
|
43
47
|
/**=====================================⚠️⚠️⚠️ 初始化必须实现的监听======================= */
|
package/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './assets/core/home/BaseLoading';
|
|
|
11
11
|
export * from './assets/core/home/ProgessWindow';
|
|
12
12
|
export * from './assets/core/home/BaseModuleConfig';
|
|
13
13
|
export * from './assets/core/home/BaseGameState';
|
|
14
|
+
export * from './assets/core/home/EffectSingleCase';
|
|
14
15
|
|
|
15
16
|
//日志
|
|
16
17
|
export * from './assets/core/lib/ecs/ECS';
|