Elin Decompiled Documentation EA 23.306 Nightly
Loading...
Searching...
No Matches
SourceThingV.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5
6public class SourceThingV : SourceDataString<SourceThingV.Row>
7{
8 [Serializable]
9 public class Row : SourceThing.Row
10 {
11 public string[] parse;
12
13 public override bool UseAlias => false;
14
15 public override string GetAlias => "n";
16 }
17
18 public static readonly IReadOnlyDictionary<string, int> RowMapping = new Dictionary<string, int>
19 {
20 ["id"] = 0,
21 ["_origin"] = 1,
22 ["name_JP"] = 2,
23 ["unit_JP"] = 3,
24 ["name"] = 4,
25 ["unit"] = 5,
26 ["tiles"] = 6,
27 ["skins"] = 7,
28 ["parse"] = 8,
29 ["vals"] = 9,
30 ["trait"] = 11,
31 ["LV"] = 12,
32 ["chance"] = 13,
33 ["value"] = 14,
34 ["weight"] = 15,
35 ["recipeKey"] = 16,
36 ["factory"] = 17,
37 ["components"] = 18,
38 ["defMat"] = 19,
39 ["category"] = 20,
40 ["tag"] = 21,
41 ["detail_JP"] = 22,
42 ["detail"] = 23
43 };
44
45 public override string[] ImportFields => new string[1] { "unit" };
46
47 public override Row CreateRow()
48 {
49 return new Row
50 {
51 id = SourceData.GetString(0),
52 _origin = SourceData.GetString(1),
53 name_JP = SourceData.GetString(2),
54 unit_JP = SourceData.GetString(3),
55 name = SourceData.GetString(4),
56 unit = SourceData.GetString(5),
57 tiles = SourceData.GetIntArray(6),
58 skins = SourceData.GetIntArray(7),
59 parse = SourceData.GetStringArray(8),
60 vals = SourceData.GetStringArray(9),
61 trait = SourceData.GetStringArray(11),
62 LV = SourceData.GetInt(12),
63 chance = SourceData.GetInt(13),
64 value = SourceData.GetInt(14),
65 weight = SourceData.GetInt(15),
66 recipeKey = SourceData.GetStringArray(16),
67 factory = SourceData.GetStringArray(17),
68 components = SourceData.GetStringArray(18),
69 defMat = SourceData.GetString(19),
70 category = SourceData.GetString(20),
71 tag = SourceData.GetStringArray(21),
72 detail_JP = SourceData.GetString(22),
73 detail = SourceData.GetString(23)
74 };
75 }
76
77 public override Row CreateRowByMapping(IReadOnlyDictionary<string, int> mapping)
78 {
79 return new Row
80 {
81 id = SourceData.GetString(mapping["id"]),
82 _origin = SourceData.GetString(mapping["_origin"]),
83 name_JP = SourceData.GetString(mapping["name_JP"]),
84 unit_JP = SourceData.GetString(mapping["unit_JP"]),
85 name = SourceData.GetString(mapping["name"]),
86 unit = SourceData.GetString(mapping["unit"]),
87 tiles = SourceData.GetIntArray(mapping["tiles"]),
88 skins = SourceData.GetIntArray(mapping["skins"]),
89 parse = SourceData.GetStringArray(mapping["parse"]),
90 vals = SourceData.GetStringArray(mapping["vals"]),
91 trait = SourceData.GetStringArray(mapping["trait"]),
92 LV = SourceData.GetInt(mapping["LV"]),
93 chance = SourceData.GetInt(mapping["chance"]),
94 value = SourceData.GetInt(mapping["value"]),
95 weight = SourceData.GetInt(mapping["weight"]),
96 recipeKey = SourceData.GetStringArray(mapping["recipeKey"]),
97 factory = SourceData.GetStringArray(mapping["factory"]),
98 components = SourceData.GetStringArray(mapping["components"]),
99 defMat = SourceData.GetString(mapping["defMat"]),
100 category = SourceData.GetString(mapping["category"]),
101 tag = SourceData.GetStringArray(mapping["tag"]),
102 detail_JP = SourceData.GetString(mapping["detail_JP"]),
103 detail = SourceData.GetString(mapping["detail"])
104 };
105 }
106
107 public override void SetRow(Row r)
108 {
109 map[r.id] = r;
110 }
111
112 public override IReadOnlyDictionary<string, int> GetRowMapping()
113 {
114 return RowMapping;
115 }
116
117 public override void RestorePref()
118 {
119 foreach (SourceThing.Row row2 in EClass.sources.things.rows)
120 {
121 SourcePref sourcePref = EClass.sources.things._rows.TryGetValue(row2.id)?.pref;
122 if (sourcePref == null && EClass.sources.asset.renames.ContainsKey(row2.id))
123 {
124 sourcePref = EClass.sources.things._rows.TryGetValue(EClass.sources.asset.renames[row2.id])?.pref;
125 }
126 row2.pref = sourcePref ?? new SourcePref();
127 }
128 Dictionary<string, SourceThing.Row> dictionary = new Dictionary<string, SourceThing.Row>();
129 foreach (SourceThing.Row row3 in EClass.sources.things.rows)
130 {
131 dictionary[row3.id] = row3;
132 }
133 foreach (SourceThing.Row row4 in EClass.sources.things.rows)
134 {
135 if (!row4.pref.UsePref && !row4._origin.IsEmpty())
136 {
137 SourceThing.Row row = dictionary[row4._origin];
138 row4.pref = IO.DeepCopy(row.pref);
139 row4.pref.flags |= PrefFlag.UsePref;
140 }
141 }
142 }
143
144 public override void ValidatePref()
145 {
146 foreach (SourceThing.Row row in EClass.sources.things.rows)
147 {
148 row.pref.Validate();
149 }
150 }
151
152 public override void Reset()
153 {
154 base.Reset();
155 EClass.sources.things.Reset();
156 }
157
158 public override void OnAfterImportData()
159 {
160 Dictionary<string, SourceThing.Row> dictionary = new Dictionary<string, SourceThing.Row>();
161 foreach (SourceThing.Row row2 in EClass.sources.things.rows)
162 {
163 dictionary[row2.id] = row2;
164 }
165 Dictionary<string, System.Reflection.FieldInfo> rowFields = new SourceThing.Row().GetRowFields();
166 foreach (Row row3 in rows)
167 {
168 SourceThing.Row row = new SourceThing.Row();
169 SourceThing.Row obj = dictionary[row3._origin];
170 string key;
171 foreach (KeyValuePair<string, System.Reflection.FieldInfo> item in rowFields)
172 {
173 item.Deconstruct(out key, out var value);
174 string text = key;
175 System.Reflection.FieldInfo fieldInfo = value;
176 if (!(text == "parse"))
177 {
178 fieldInfo.SetValue(row, fieldInfo.GetValue(obj));
179 }
180 }
181 row.id = row3.id;
182 row._origin = row3._origin;
183 if (row3.LV != 0)
184 {
185 row.LV = row3.LV;
186 }
187 if (row3.chance != -1)
188 {
189 row.chance = row3.chance;
190 }
191 if (row3.value != -1)
192 {
193 row.value = row3.value;
194 }
195 else
196 {
197 row.value += EClass.rnd(row.value / 2);
198 }
199 if (row3.weight != -1)
200 {
201 row.weight = row3.weight;
202 }
203 if (!row3.tiles.IsEmpty())
204 {
205 row.tiles = row3.tiles;
206 }
207 if (!row3.skins.IsEmpty())
208 {
209 row.skins = row3.skins;
210 }
211 if (!row3.name.IsEmpty())
212 {
213 row.name = row3.name;
214 }
215 if (!row3.name_JP.IsEmpty())
216 {
217 row.name_JP = row3.name_JP;
218 }
219 if (!row3.detail.IsEmpty())
220 {
221 row.detail = row3.detail;
222 }
223 if (!row3.detail_JP.IsEmpty())
224 {
225 row.detail_JP = row3.detail_JP;
226 }
227 if (!row3.unit.IsEmpty())
228 {
229 row.unit = row3.unit;
230 }
231 if (!row3.unit_JP.IsEmpty())
232 {
233 row.unit_JP = row3.unit_JP;
234 }
235 if (!row3.vals.IsEmpty())
236 {
237 row.vals = row3.vals;
238 }
239 if (!row3.components.IsEmpty())
240 {
241 row.components = row3.components;
242 }
243 if (!row3.defMat.IsEmpty())
244 {
245 row.defMat = row3.defMat;
246 }
247 if (!row3.trait.IsEmpty())
248 {
249 row.trait = row3.trait;
250 }
251 if (!row3.category.IsEmpty())
252 {
253 row.category = row3.category;
254 }
255 if (!row3.factory.IsEmpty())
256 {
257 row.factory = row3.factory;
258 }
259 if (!row3.tag.IsEmpty())
260 {
261 row.tag = row3.tag;
262 }
263 row.recipeKey = row3.recipeKey;
264 if (!row3.parse.IsEmpty())
265 {
266 key = row3._origin;
267 switch (key)
268 {
269 case "lamp_ceil2":
270 case "window":
271 case "windowL":
272 row.idExtra = row3.parse[0];
273 break;
274 default:
275 {
276 string[] parse = row3.parse;
277 for (int i = 0; i < parse.Length; i++)
278 {
279 string[] array = parse[i].Split('/');
280 switch (array[0])
281 {
282 case "elec":
283 row.electricity = array[1].ToInt();
284 break;
285 case "render":
286 row._idRenderData = array[1];
287 break;
288 case "tiletype":
289 row._tileType = array[1];
290 break;
291 case "anime":
292 row.anime = ((array.Length <= 4) ? ((array.Length <= 3) ? new int[2]
293 {
294 array[1].ToInt(),
295 array[2].ToInt()
296 } : new int[3]
297 {
298 array[1].ToInt(),
299 array[2].ToInt(),
300 array[3].ToInt()
301 }) : new int[4]
302 {
303 array[1].ToInt(),
304 array[2].ToInt(),
305 array[3].ToInt(),
306 array[4].ToInt()
307 });
308 break;
309 case "skin":
310 {
311 string[] array3 = array[1].Split('|');
312 row.skins = new int[array3.Length];
313 for (int k = 0; k < array3.Length; k++)
314 {
315 row.skins[k] = array3[k].ToInt();
316 }
317 break;
318 }
319 case "alt":
320 {
321 string[] array2 = array[1].Split('|');
322 row.altTiles = new int[array2.Length];
323 for (int j = 0; j < array2.Length; j++)
324 {
325 row.altTiles[j] = array2[j].ToInt();
326 }
327 row.ignoreAltFix = true;
328 break;
329 }
330 case "naming":
331 row.naming = array[1];
332 break;
333 case "ex":
334 row.idActorEx = array[1];
335 break;
336 case "sound":
337 row.idSound = array[1];
338 break;
339 case "color":
340 row.colorMod = 100;
341 break;
342 case "no_color":
343 row.colorMod = 0;
344 break;
345 case "unique":
346 row.quality = 4;
347 break;
348 case "ele":
349 {
350 int[] second = new int[2]
351 {
352 Core.GetCurrent().sources.elements.alias[array[1]].id,
353 array[2].ToInt()
354 };
355 row.elements = row.elements.Concat(second).ToArray();
356 break;
357 }
358 }
359 }
360 break;
361 }
362 }
363 }
364 OnImportRow(row3, row);
365 row.OnImportData(EClass.sources.things);
366 EClass.sources.things.rows.Add(row);
367 }
368 rows.Clear();
369 }
370
371 public virtual void OnImportRow(Row _r, SourceThing.Row c)
372 {
373 }
374}
PrefFlag
Definition: PrefFlag.cs:5
string[] trait
Definition: CardRow.cs:33
string _origin
Definition: CardRow.cs:15
string id
Definition: CardRow.cs:7
string[] vals
Definition: CardRow.cs:37
Definition: Core.cs:14
SourceManager sources
Definition: Core.cs:33
static Core GetCurrent()
Definition: Core.cs:606
Definition: EClass.cs:6
static int rnd(long a)
Definition: EClass.cs:59
static SourceManager sources
Definition: EClass.cs:43
string detail_JP
Definition: RenderRow.cs:36
string[] tag
Definition: RenderRow.cs:58
string[] factory
Definition: RenderRow.cs:54
string detail
Definition: RenderRow.cs:34
SourcePref pref
Definition: RenderRow.cs:68
string defMat
Definition: RenderRow.cs:42
string category
Definition: RenderRow.cs:46
string name
Definition: RenderRow.cs:30
string[] components
Definition: RenderRow.cs:52
int[] skins
Definition: RenderRow.cs:14
int[] tiles
Definition: RenderRow.cs:10
string[] recipeKey
Definition: RenderRow.cs:56
int value
Definition: RenderRow.cs:20
int chance
Definition: RenderRow.cs:24
int LV
Definition: RenderRow.cs:22
string name_JP
Definition: RenderRow.cs:32
UD_String_String renames
Definition: SourceAsset.cs:23
Dictionary< string, FieldInfo > GetRowFields()
Definition: SourceData.cs:634
static string[] GetStringArray(int id)
Definition: SourceData.cs:978
static string GetString(int id)
Definition: SourceData.cs:983
static int GetInt(int id)
Definition: SourceData.cs:948
static int[] GetIntArray(int id)
Definition: SourceData.cs:973
SourceThing things
SourceAsset asset
SourceElement elements
override bool UseAlias
Definition: SourceThingV.cs:13
override string GetAlias
Definition: SourceThingV.cs:15
override IReadOnlyDictionary< string, int > GetRowMapping()
override string[] ImportFields
Definition: SourceThingV.cs:45
override void RestorePref()
override Row CreateRowByMapping(IReadOnlyDictionary< string, int > mapping)
Definition: SourceThingV.cs:77
override void OnAfterImportData()
static readonly IReadOnlyDictionary< string, int > RowMapping
Definition: SourceThingV.cs:18
virtual void OnImportRow(Row _r, SourceThing.Row c)
override Row CreateRow()
Definition: SourceThingV.cs:47
override void Reset()
override void SetRow(Row r)
override void ValidatePref()
Dictionary< string, Row > _rows
Definition: SourceThing.cs:202
bool ContainsKey(TKey key)
Definition: UDictionary.cs:151