mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-10-22 20:09:46 +08:00
Update resources to 5.3
Include Achievement, Avatar, Cutscene, Dungeon, BannerTitle, Gadget, Item, Monster, Scene, Weapon...
This commit is contained in:
@@ -128,19 +128,35 @@ namespace GrasscutterTools.Game.Data
|
||||
|
||||
private static object LoadDataFile(Type type, string path)
|
||||
{
|
||||
var list = (IList)JsonConvert.DeserializeObject(File.ReadAllText(path), typeof(List<>).MakeGenericType(type));
|
||||
if (list == null) return null;
|
||||
|
||||
if (!type.IsSubclassOf(typeof(GameResource))) return list;
|
||||
|
||||
var dicType = typeof(Dictionary<,>).MakeGenericType(typeof(int), type);
|
||||
var dic = (IDictionary)Activator.CreateInstance(dicType);
|
||||
foreach (GameResource gameResource in list)
|
||||
IList list = null;
|
||||
try
|
||||
{
|
||||
if (gameResource.Id == 0) continue;
|
||||
dic.Add(gameResource.Id, gameResource);
|
||||
list = (IList)JsonConvert.DeserializeObject(File.ReadAllText(path), typeof(List<>).MakeGenericType(type));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Failed to load \"{path}\", Exception={ex}");
|
||||
}
|
||||
if (type.IsSubclassOf(typeof(GameResource)))
|
||||
{
|
||||
var dicType = typeof(Dictionary<,>).MakeGenericType(typeof(int), type);
|
||||
var dic = (IDictionary)Activator.CreateInstance(dicType);
|
||||
if (list != null)
|
||||
{
|
||||
foreach (GameResource gameResource in list)
|
||||
{
|
||||
if (gameResource.Id == 0) continue;
|
||||
dic.Add(gameResource.Id, gameResource);
|
||||
}
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list == null)
|
||||
list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(type));
|
||||
return list;
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> Languages = new Dictionary<string, string>
|
||||
|
Reference in New Issue
Block a user