forked from RazTools/Studio
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGameManager.cs
242 lines (223 loc) · 10.8 KB
/
GameManager.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
using System;
using System.Linq;
using System.Collections.Generic;
using static AssetStudio.Crypto;
namespace AssetStudio
{
public static class GameManager
{
private static Dictionary<int, Game> Games = new Dictionary<int, Game>();
static GameManager()
{
int index = 0;
Games.Add(index++, new(GameType.Normal));
Games.Add(index++, new Game(GameType.FakeHeader));
Games.Add(index++, new(GameType.UnityCN));
Games.Add(index++, new Mhy(GameType.GI, GIMhyShiftRow, GIMhyKey, GIMhyMul, GIExpansionKey, GISBox, GIInitVector, GIInitSeed));
Games.Add(index++, new Mr0k(GameType.GI_Pack, PackExpansionKey, blockKey: PackBlockKey));
Games.Add(index++, new Mr0k(GameType.GI_CB1));
Games.Add(index++, new Blk(GameType.GI_CB2, GI_CBXExpansionKey, initVector: GI_CBXInitVector, initSeed: GI_CBXInitSeed));
Games.Add(index++, new Blk(GameType.GI_CB3, GI_CBXExpansionKey, initVector: GI_CBXInitVector, initSeed: GI_CBXInitSeed));
Games.Add(index++, new Mhy(GameType.GI_CB3Pre, GI_CBXMhyShiftRow, GI_CBXMhyKey, GI_CBXMhyMul, GI_CBXExpansionKey, GI_CBXSBox, GI_CBXInitVector, GI_CBXInitSeed));
Games.Add(index++, new Mr0k(GameType.BH3, BH3ExpansionKey, BH3SBox, BH3InitVector, BH3BlockKey));
Games.Add(index++, new Mr0k(GameType.BH3Pre, PackExpansionKey, blockKey: PackBlockKey));
Games.Add(index++, new Mr0k(GameType.BH3PrePre, PackExpansionKey, blockKey: PackBlockKey));
Games.Add(index++, new Mr0k(GameType.SR_CB2, Mr0kExpansionKey, initVector: Mr0kInitVector, blockKey: Mr0kBlockKey));
Games.Add(index++, new Mr0k(GameType.SR, Mr0kExpansionKey, initVector: Mr0kInitVector, blockKey: Mr0kBlockKey));
Games.Add(index++, new Mr0k(GameType.ZZZ_CB1, Mr0kExpansionKey, initVector: Mr0kInitVector, blockKey: Mr0kBlockKey));
Games.Add(index++, new Mr0k(GameType.TOT, Mr0kExpansionKey, initVector: Mr0kInitVector, blockKey: Mr0kBlockKey, postKey: ToTKey));
Games.Add(index++, new Game(GameType.Naraka));
Games.Add(index++, new Game(GameType.EnsembleStars));
Games.Add(index++, new Game(GameType.OPFP));
Games.Add(index++, new Game(GameType.FantasyOfWind));
Games.Add(index++, new Game(GameType.ShiningNikki));
Games.Add(index++, new Game(GameType.HelixWaltz2));
Games.Add(index++, new Game(GameType.NetEase));
Games.Add(index++, new Game(GameType.AnchorPanic));
Games.Add(index++, new Game(GameType.DreamscapeAlbireo));
Games.Add(index++, new Game(GameType.ImaginaryFest));
Games.Add(index++, new Game(GameType.AliceGearAegis));
Games.Add(index++, new Game(GameType.ProjectSekai));
Games.Add(index++, new Game(GameType.CodenameJump));
Games.Add(index++, new Game(GameType.GirlsFrontline));
Games.Add(index++, new Game(GameType.Reverse1999));
Games.Add(index++, new Game(GameType.ArknightsEndfield));
Games.Add(index++, new Game(GameType.JJKPhantomParade));
Games.Add(index++, new Game(GameType.MuvLuvDimensions));
Games.Add(index++, new Game(GameType.PartyAnimals));
Games.Add(index++, new Game(GameType.LoveAndDeepspace));
Games.Add(index++, new Game(GameType.SchoolGirlStrikers));
Games.Add(index++, new Game(GameType.ExAstris));
Games.Add(index++, new Game(GameType.PerpetualNovelty));
Games.Add(index++, new Game(GameType.GuiLongChao));
Games.Add(index++, new Game(GameType.CounterSide));
}
public static Game GetGame(GameType gameType) => GetGame((int)gameType);
public static Game GetGame(int index)
{
if (!Games.TryGetValue(index, out var format))
{
throw new ArgumentException("Invalid format !!");
}
return format;
}
public static Game GetGame(string name) => Games.FirstOrDefault(x => x.Value.Name == name).Value;
public static Game[] GetGames() => Games.Values.ToArray();
public static string[] GetGameNames() => Games.Values.Select(x => x.Name).ToArray();
public static string SupportedGames() => $"Supported Games:\n{string.Join("\n", Games.Values.Select(x => x.Name))}";
}
public record Game
{
public string Name { get; set; }
public GameType Type { get; }
public Game(GameType type)
{
Name = type.ToString();
Type = type;
}
public sealed override string ToString() => Name;
}
public record Mr0k : Game
{
public byte[] ExpansionKey { get; }
public byte[] SBox { get; }
public byte[] InitVector { get; }
public byte[] BlockKey { get; }
public byte[] PostKey { get; }
public Mr0k(GameType type, byte[] expansionKey = null, byte[] sBox = null, byte[] initVector = null, byte[] blockKey = null, byte[] postKey = null) : base(type)
{
ExpansionKey = expansionKey ?? Array.Empty<byte>();
SBox = sBox ?? Array.Empty<byte>();
InitVector = initVector ?? Array.Empty<byte>();
BlockKey = blockKey ?? Array.Empty<byte>();
PostKey = postKey ?? Array.Empty<byte>();
}
}
public record Blk : Game
{
public byte[] ExpansionKey { get; }
public byte[] SBox { get; }
public byte[] InitVector { get; }
public ulong InitSeed { get; }
public Blk(GameType type, byte[] expansionKey = null, byte[] sBox = null, byte[] initVector = null, ulong initSeed = 0) : base(type)
{
ExpansionKey = expansionKey ?? Array.Empty<byte>();
SBox = sBox ?? Array.Empty<byte>();
InitVector = initVector ?? Array.Empty<byte>();
InitSeed = initSeed;
}
}
public record Mhy : Blk
{
public byte[] MhyShiftRow { get; }
public byte[] MhyKey { get; }
public byte[] MhyMul { get; }
public Mhy(GameType type, byte[] mhyShiftRow, byte[] mhyKey, byte[] mhyMul, byte[] expansionKey = null, byte[] sBox = null, byte[] initVector = null, ulong initSeed = 0) : base(type, expansionKey, sBox, initVector, initSeed)
{
MhyShiftRow = mhyShiftRow;
MhyKey = mhyKey;
MhyMul = mhyMul;
}
}
public enum GameType
{
Normal,
FakeHeader,
UnityCN,
GI,
GI_Pack,
GI_CB1,
GI_CB2,
GI_CB3,
GI_CB3Pre,
BH3,
BH3Pre,
BH3PrePre,
ZZZ_CB1,
SR_CB2,
SR,
TOT,
Naraka,
EnsembleStars,
OPFP,
FantasyOfWind,
ShiningNikki,
HelixWaltz2,
NetEase,
AnchorPanic,
DreamscapeAlbireo,
ImaginaryFest,
AliceGearAegis,
ProjectSekai,
CodenameJump,
GirlsFrontline,
Reverse1999,
ArknightsEndfield,
JJKPhantomParade,
MuvLuvDimensions,
PartyAnimals,
LoveAndDeepspace,
SchoolGirlStrikers,
ExAstris,
PerpetualNovelty,
GuiLongChao,
CounterSide,
}
public static class GameTypes
{
public static bool IsNormal(this GameType type) => type == GameType.Normal;
public static bool IsUnityCN(this GameType type) => type == GameType.UnityCN || type == GameType.GuiLongChao;
public static bool IsGI(this GameType type) => type == GameType.GI;
public static bool IsGIPack(this GameType type) => type == GameType.GI_Pack;
public static bool IsGICB1(this GameType type) => type == GameType.GI_CB1;
public static bool IsGICB2(this GameType type) => type == GameType.GI_CB2;
public static bool IsGICB3(this GameType type) => type == GameType.GI_CB3;
public static bool IsGICB3Pre(this GameType type) => type == GameType.GI_CB3Pre;
public static bool IsBH3(this GameType type) => type == GameType.BH3;
public static bool IsBH3Pre(this GameType type) => type == GameType.BH3Pre;
public static bool IsBH3PrePre(this GameType type) => type == GameType.BH3PrePre;
public static bool IsZZZCB1(this GameType type) => type == GameType.ZZZ_CB1;
public static bool IsSRCB2(this GameType type) => type == GameType.SR_CB2;
public static bool IsSR(this GameType type) => type == GameType.SR;
public static bool IsTOT(this GameType type) => type == GameType.TOT;
public static bool IsNaraka(this GameType type) => type == GameType.Naraka;
public static bool IsOPFP(this GameType type) => type == GameType.OPFP;
public static bool IsNetEase(this GameType type) => type == GameType.NetEase;
public static bool IsArknightsEndfield(this GameType type) => type == GameType.ArknightsEndfield;
public static bool IsLoveAndDeepspace(this GameType type) => type == GameType.LoveAndDeepspace;
public static bool IsExAstris(this GameType type) => type == GameType.ExAstris;
public static bool IsPerpetualNovelty(this GameType type) => type == GameType.PerpetualNovelty;
public static bool IsGuiLongChao(this GameType type) => type == GameType.GuiLongChao;
public static bool IsCounterSide(this GameType type) => type == GameType.CounterSide;
public static bool IsGIGroup(this GameType type) => type switch
{
GameType.GI or GameType.GI_Pack or GameType.GI_CB1 or GameType.GI_CB2 or GameType.GI_CB3 or GameType.GI_CB3Pre => true,
_ => false,
};
public static bool IsGISubGroup(this GameType type) => type switch
{
GameType.GI or GameType.GI_CB2 or GameType.GI_CB3 or GameType.GI_CB3Pre => true,
_ => false,
};
public static bool IsBH3Group(this GameType type) => type switch
{
GameType.BH3 or GameType.BH3Pre => true,
_ => false,
};
public static bool IsSRGroup(this GameType type) => type switch
{
GameType.SR_CB2 or GameType.SR => true,
_ => false,
};
public static bool IsBlockFile(this GameType type) => type switch
{
GameType.BH3 or GameType.BH3Pre or GameType.SR or GameType.GI_Pack or GameType.TOT or GameType.ArknightsEndfield or GameType.GuiLongChao => true,
_ => false,
};
public static bool IsMhyGroup(this GameType type) => type switch
{
GameType.GI or GameType.GI_Pack or GameType.GI_CB1 or GameType.GI_CB2 or GameType.GI_CB3 or GameType.GI_CB3Pre or GameType.BH3 or GameType.BH3Pre or GameType.BH3PrePre or GameType.SR_CB2 or GameType.SR or GameType.ZZZ_CB1 or GameType.TOT => true,
_ => false,
};
}
}