-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTk2dAnimationSkinable.cs
75 lines (57 loc) · 2.48 KB
/
Tk2dAnimationSkinable.cs
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
using UnityEngine;
using CustomKnightSuperAnimationAddon.Json;
namespace CustomKnightSuperAnimationAddon;
public class Tk2dAnimationSkinable
{
public string name;
public HashSet<string> goNames;
public CustomSkinManager customSkinManager;
public bool isSkinned = false;
public FolderInfo folderInfo;
public Dictionary<string, Texture2D> textures = new();
public Dictionary<string, AnimInfo> animInfos = new();
public Dictionary<string, SimpleInfo> simpleInfos = new();
public Dictionary<string, AdvancedInfo> advancedInfos = new();
public void Log(object o) => CustomKnightSuperAnimationAddon.instance.Log(o);
public Tk2dAnimationSkinable(string name, List<string> goNames)
{
this.name = name;
this.goNames = new(goNames);
}
public void Reset()
{
Log($"Skinable {name} - Updating Skin");
textures.Clear();
animInfos.Clear();
simpleInfos.Clear();
advancedInfos.Clear();
isSkinned = customSkinManager.current.Exists($"{name}/{FolderInfo.FileName}");
Log($"Skinable {name}: isSkinned = {isSkinned}");
if (!isSkinned)
return;
folderInfo = customSkinManager.ReadFromJson<FolderInfo>($"{name}/{FolderInfo.FileName}");
foreach (string anim in folderInfo.Animations)
{
if (!customSkinManager.current.Exists($"{name}/{anim}/{AnimInfo.TextureName}"))
continue;
Texture2D texture = customSkinManager.current.GetTexture($"{name}/{anim}/{AnimInfo.TextureName}");
if (!customSkinManager.current.Exists($"{name}/{anim}/{AnimInfo.FileName}"))
continue;
AnimInfo animInfo = customSkinManager.ReadFromJson<AnimInfo>($"{name}/{anim}/{AnimInfo.FileName}");
if (animInfo.InfoType == DefType.Simple)
{
if (!customSkinManager.current.Exists($"{name}/{anim}/{SimpleInfo.FileName}"))
continue;
simpleInfos[anim] = customSkinManager.ReadFromJson<SimpleInfo>($"{name}/{anim}/{SimpleInfo.FileName}");
}
else
{
if (!customSkinManager.current.Exists($"{name}/{anim}/{SimpleInfo.FileName}"))
continue;
advancedInfos[anim] = customSkinManager.ReadFromJson<AdvancedInfo>($"{name}/{anim}/{AdvancedInfo.FileName}");
}
textures[anim] = texture;
animInfos[anim] = animInfo;
}
}
}