-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateLayers.ts
71 lines (59 loc) · 1.68 KB
/
generateLayers.ts
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
import glob from 'glob';
import * as fs from 'fs';
const LayerOrder = [
'Background',
'Power',
'Cork',
'Glow',
'Potion',
'Floating Item',
'Trinket',
'Sparkle'
]
const notRequired = (name: string) => {
return [
'Power',
'Glow',
'Sparkle',
].includes(name)
}
(async () => {
try {
const Layers = [];
const layerNames = glob.sync('./layers/*');
layerNames.forEach(layerName => {
const elements = [];
const layerElements = glob.sync(layerName + '/**/*.png');
layerElements.forEach((_, id) => {
const name = _.replace(layerName, '').replace('.png', '').split('/').pop();
elements.push({
id,
name,
filename: _ ,
rarityRating: 0,
});
})
const name = layerName.split('/').pop();
if(LayerOrder.includes(name)) {
console.log(`Layer Included:`, name);
Layers.push({
name,
required: !notRequired(name),
path: ``,
elements
})
}
});
let writeData: any[] = Layers.map(_ => -1);
Layers.forEach(layer => {
writeData[LayerOrder.indexOf(layer.name)] = layer;
})
writeData = writeData.map((layer, id)=> ({id, ...layer}))
fs.writeFileSync(
"./generated/_assetsLayers.json",
JSON.stringify(writeData, null, 4)
);
} catch(err) {
console.log(err)
}
})();