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