mirror of
https://github.com/jie65535/GrasscutterCommandGenerator.git
synced 2025-12-18 10:52:38 +08:00
Optimized implementation
This commit is contained in:
@@ -39,12 +39,6 @@ namespace GrasscutterTools.Game
|
||||
WeaponColors = new ItemMap(Resources.WeaponColor);
|
||||
GachaBannerPrefabs = new ItemMap(Resources.GachaBennerPrefab);
|
||||
Quests = new ItemMap(Resources.Quest);
|
||||
|
||||
GOODArtifactCats = new ItemMap(Resources.GOODArtifactCat);
|
||||
GOODArtifactMainAttribution = new ItemMap(Resources.GOODArtifactMainAttribution);
|
||||
GOODArtifactSubAttribution = new ItemMap(Resources.GOODArtifactSubAttribution);
|
||||
GOODAvatars = new ItemMap(Resources.GOODAvatar);
|
||||
GOODWeapons = new ItemMap(Resources.GOODWeapon);
|
||||
}
|
||||
|
||||
public static ItemMap Animals { get; private set; }
|
||||
@@ -76,10 +70,5 @@ namespace GrasscutterTools.Game
|
||||
public static ItemMap GachaBannerPrefabs { get; private set; }
|
||||
|
||||
public static ItemMap Quests { get; private set; }
|
||||
public static ItemMap GOODArtifactCats { get; private set; }
|
||||
public static ItemMap GOODArtifactMainAttribution { get; private set; }
|
||||
public static ItemMap GOODArtifactSubAttribution { get; private set; }
|
||||
public static ItemMap GOODAvatars { get; private set; }
|
||||
public static ItemMap GOODWeapons { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace GrasscutterTools.Game
|
||||
{
|
||||
var lines = idNamePairs.Split('\n');
|
||||
var capacity = lines.Length;
|
||||
IdMap = new Dictionary<int, string>(capacity);
|
||||
NameMap = new Dictionary<string, int>(capacity);
|
||||
//IdMap = new Dictionary<int, string>(capacity);
|
||||
//NameMap = new Dictionary<string, int>(capacity);
|
||||
var IdList = new List<int>(capacity);
|
||||
var NameList = new List<string>(capacity);
|
||||
var lineList = new List<string>(capacity);
|
||||
@@ -38,10 +38,10 @@ namespace GrasscutterTools.Game
|
||||
if (si > 0 && int.TryParse(line.Substring(0, si).Trim(), out int id))
|
||||
{
|
||||
var name = line.Substring(si + 1).Trim();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
if (!string.IsNullOrEmpty(name) && name != "null")
|
||||
{
|
||||
IdMap[id] = name;
|
||||
NameMap[name.Replace(" ", "").Replace("'", "").Replace("\"", "")] = id;
|
||||
//IdMap[id] = name;
|
||||
//NameMap[name] = id;
|
||||
IdList.Add(id);
|
||||
NameList.Add(name);
|
||||
lineList.Add(line);
|
||||
@@ -54,16 +54,16 @@ namespace GrasscutterTools.Game
|
||||
Lines = lineList.ToArray();
|
||||
}
|
||||
|
||||
Dictionary<int, string> IdMap;
|
||||
Dictionary<string, int> NameMap;
|
||||
//Dictionary<int, string> IdMap;
|
||||
//Dictionary<string, int> NameMap;
|
||||
//List<int> IdList;
|
||||
//List<string> NameList;
|
||||
|
||||
public int Count => Ids.Length;
|
||||
|
||||
public string this[int id] => IdMap[id];
|
||||
//public string this[int id] => IdMap[id];
|
||||
|
||||
public int this[string name] => NameMap[name];
|
||||
//public int this[string name] => NameMap[name];
|
||||
|
||||
public int[] Ids { get; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user