Elin Decompiled Documentation EA 23.333 Myaightly Patch 1
Loading...
Searching...
No Matches
SpriteReplacer.cs File Reference

Go to the source code of this file.

Classes

class  SpriteReplacer
 

Variables

_skin
 

Variable Documentation

◆ _skin

$ _skin

Definition at line 119 of file SpriteReplacer.cs.

120{
121 data?.Validate();
122 foreach (SpriteData value in suffixes.Values)
123 {
124 value?.Validate();
125 }
126 }
127
128 public void BuildSuffixData(string id, IReadOnlyDictionary<string, string> dictTexItems, List<string> sortedIds = null)
129 {
130 List<string> list = sortedIds ?? dictTexItems.Keys.OrderBy((string k) => k).ToList();
131 int num = list.BinarySearch(id);
132 if (num < 0)
133 {
134 num = ~num;
135 }
136 for (int i = num; i < list.Count; i++)
137 {
138 string text = list[i];
139 if (text.StartsWith(id))
140 {
141 string text2 = text[id.Length..];
142 SpriteData spriteData = new SpriteData
143 {
144 path = dictTexItems[text]
145 };
146 spriteData.Init();
147 suffixes[text2] = spriteData;
148 Debug.Log("#sprite replacer " + text2.IsEmpty("<base>") + "/" + dictTexItems[text].ShortPath());
149 continue;
150 }
151 break;
152 }
153 }
154
155 public void SortModItemIds()
156 {
157 if (sortedModIds.Count != dictModItems.Count || modIdsDirty)
158 {
159 sortedModIds = dictModItems.Keys.OrderBy((string k) => k).ToList();
160 modIdsDirty = false;
161 }
162 }
163
164 public void Reload(string id, RenderData renderData = null)
165 {
166 data = null;
167 suffixes.Clear();
168 try
169 {
170 SortModItemIds();
171 if (dictModItems.ContainsKey(id))
172 {
173 BuildSuffixData(id, dictModItems, sortedModIds);
174 }
175 else if (renderData != null && dictModItems.ContainsKey("Item/" + id))
176 {
177 BuildSuffixData("Item/" + id, dictModItems, sortedModIds);
178 }
179 suffixes.TryGetValue("", out data);
180 if (data != null)
181 {
182 Debug.Log(id + ":" + data.path);
183 }
184 }
185 catch (Exception ex)
186 {
187 Debug.LogError("#sprite error fetching sprite replacer '" + id + "' : " + ex);
188 }
189 isChecked[id] = true;
190 }
191
192 public bool HasSprite(string id, RenderData renderData = null)
193 {
194 if (!isChecked.GetValueOrDefault(id) || (data != null && data.id != id))
195 {
196 Reload(id, renderData);
197 }
198 return data != null;
199 }
200}
void Init()
Definition: SpriteData.cs:34
void Validate()
Definition: SpriteData.cs:129