2using System.Collections.Generic;
9 public static Dictionary<string, SpriteReplacer>
dictSkins =
new Dictionary<string, SpriteReplacer>();
11 public static Dictionary<string, string>
dictModItems =
new Dictionary<string, string>();
19 public Dictionary<string, SpriteData>
suffixes =
new Dictionary<string, SpriteData>();
21 public Dictionary<string, bool>
isChecked =
new Dictionary<string, bool>();
23 public static Dictionary<string, SpriteReplacer>
ListSkins()
25 List<string> list =
new List<string>();
26 foreach (KeyValuePair<string, SpriteReplacer> dictSkin
in dictSkins)
28 if (!File.Exists(dictSkin.Value.data.path +
".png"))
30 list.Add(dictSkin.Key);
33 foreach (
string item in list)
38 List<string> sortedIds = dictionary.Keys.OrderBy((
string k) => k).ToList();
39 foreach (KeyValuePair<string, string> item2
in dictionary)
41 item2.Deconstruct(out var key, out var value);
52 if (spriteReplacer.
suffixes.TryGetValue(
"", out var value2))
54 spriteReplacer.data = value2;
67 List<DirectoryInfo> list =
new List<DirectoryInfo>();
69 list.AddRange(PackageIterator.GetDirectories(
"Skin", useCache:
false));
70 IEnumerable<FileInfo> enumerable = list.SelectMany((DirectoryInfo d) => from f in d.GetFiles(
"*.png", SearchOption.TopDirectoryOnly)
73 Dictionary<string, string> dictionary =
new Dictionary<string, string>();
74 foreach (FileInfo
item in enumerable)
76 string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(
item.Name);
77 string value = Path.ChangeExtension(
item.FullName,
null);
78 dictionary[fileNameWithoutExtension] = value;
85 if (!
suffixes.TryGetValue(suffix, out var value))
89 return value.GetSprite();
92 public Sprite
GetSprite(
int dir,
int skin,
bool snow)
94 foreach (
string item in new List<string>
96 $"_skin{skin}_dir{dir}",
102 Sprite sprite =
null;
107 if ((
object)sprite ==
null)
128 public void BuildSuffixData(
string id, IReadOnlyDictionary<string, string> dictTexItems, List<string> sortedIds =
null)
130 List<string> list = sortedIds ?? dictTexItems.Keys.OrderBy((
string k) => k).ToList();
131 int num = list.BinarySearch(
id);
136 for (
int num2 = num; num2 < list.Count; num2++)
138 string text = list[num2];
139 if (text.StartsWith(
id))
141 string text2 = text[
id.Length..];
144 path = dictTexItems[text]
148 Debug.Log(
"#sprite replacer " + text2.IsEmpty(
"<base>") +
"/" + dictTexItems[text].ShortPath());
175 else if (renderData !=
null &&
dictModItems.ContainsKey(
"Item/" +
id))
187 Debug.LogError(
"#sprite error fetching sprite replacer '" +
id +
"' : " + ex);
Dictionary< string, SpriteData > suffixes
bool HasSprite(string id, RenderData renderData=null)
Dictionary< string, bool > isChecked
static Dictionary< string, string > ListSkinItems()
Sprite GetSprite(string suffix="")
static Dictionary< string, SpriteReplacer > dictSkins
void Reload(string id, RenderData renderData=null)
static Dictionary< string, string > dictModItems
static List< string > sortedModIds
Sprite GetSprite(int dir, int skin, bool snow)
void BuildSuffixData(string id, IReadOnlyDictionary< string, string > dictTexItems, List< string > sortedIds=null)
static Dictionary< string, SpriteReplacer > ListSkins()