-
-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathassetsScanner.ts
More file actions
77 lines (76 loc) · 1.83 KB
/
assetsScanner.ts
File metadata and controls
77 lines (76 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { arg, commandType, IAsset } from '../interface/sceneInterface';
import { fileType } from '../interface/assets';
/**
* 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
* @param command 语句类型
* @param content 语句内容
* @param args 参数列表
* @return {Array<IAsset>} 语句携带的参数列表
*/
export const assetsScanner = (
command: commandType,
content: string,
args: Array<arg>,
lineNumber: number,
): Array<IAsset> => {
let hasVocalArg = false;
const returnAssetsList: Array<IAsset> = [];
if (command === commandType.say) {
args.forEach((e) => {
if (e.key === 'vocal') {
hasVocalArg = true;
returnAssetsList.push({
name: e.value as string,
url: e.value as string,
lineNumber,
type: fileType.vocal,
});
}
});
}
if (content === 'none' || content === '') {
return returnAssetsList;
}
// 处理语句携带的资源
if (command === commandType.changeBg) {
returnAssetsList.push({
name: content,
url: content,
lineNumber,
type: fileType.background,
});
}
if (command === commandType.changeFigure) {
returnAssetsList.push({
name: content,
url: content,
lineNumber,
type: fileType.figure,
});
}
if (command === commandType.miniAvatar) {
returnAssetsList.push({
name: content,
url: content,
lineNumber,
type: fileType.figure,
});
}
if (command === commandType.video) {
returnAssetsList.push({
name: content,
url: content,
lineNumber,
type: fileType.video,
});
}
if (command === commandType.bgm) {
returnAssetsList.push({
name: content,
url: content,
lineNumber,
type: fileType.bgm,
});
}
return returnAssetsList;
};