Elin Decompiled Documentation EA 23.287 Stable Patch 3
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 override string[] ImportFields => new string[1] { "unit" };
19
20 public override Row CreateRow()
21 {
22 return new Row
23 {
24 id = SourceData.GetString(0),
25 _origin = SourceData.GetString(1),
26 name_JP = SourceData.GetString(2),
27 unit_JP = SourceData.GetString(3),
28 name = SourceData.GetString(4),
29 unit = SourceData.GetString(5),
30 tiles = SourceData.GetIntArray(6),
31 skins = SourceData.GetIntArray(7),
32 parse = SourceData.GetStringArray(8),
33 vals = SourceData.GetStringArray(9),
34 trait = SourceData.GetStringArray(11),
35 LV = SourceData.GetInt(12),
36 chance = SourceData.GetInt(13),
37 value = SourceData.GetInt(14),
38 weight = SourceData.GetInt(15),
39 recipeKey = SourceData.GetStringArray(16),
40 factory = SourceData.GetStringArray(17),
41 components = SourceData.GetStringArray(18),
42 defMat = SourceData.GetString(19),
43 category = SourceData.GetString(20),
44 tag = SourceData.GetStringArray(21),
45 detail_JP = SourceData.GetString(22),
46 detail = SourceData.GetString(23)
47 };
48 }
49
50 public override void SetRow(Row r)
51 {
52 map[r.id] = r;
53 }
54
55 public override void RestorePref()
56 {
57 foreach (SourceThing.Row row2 in EClass.sources.things.rows)
58 {
59 SourcePref sourcePref = EClass.sources.things._rows.TryGetValue(row2.id)?.pref;
60 if (sourcePref == null && EClass.sources.asset.renames.ContainsKey(row2.id))
61 {
62 sourcePref = EClass.sources.things._rows.TryGetValue(EClass.sources.asset.renames[row2.id])?.pref;
63 }
64 row2.pref = sourcePref ?? new SourcePref();
65 }
66 Dictionary<string, SourceThing.Row> dictionary = new Dictionary<string, SourceThing.Row>();
67 foreach (SourceThing.Row row3 in EClass.sources.things.rows)
68 {
69 dictionary[row3.id] = row3;
70 }
71 foreach (SourceThing.Row row4 in EClass.sources.things.rows)
72 {
73 if (!row4.pref.UsePref && !row4._origin.IsEmpty())
74 {
75 SourceThing.Row row = dictionary[row4._origin];
76 row4.pref = IO.DeepCopy(row.pref);
77 row4.pref.flags |= PrefFlag.UsePref;
78 }
79 }
80 }
81
82 public override void ValidatePref()
83 {
84 foreach (SourceThing.Row row in EClass.sources.things.rows)
85 {
86 row.pref.Validate();
87 }
88 }
89
90 public override void Reset()
91 {
92 base.Reset();
93 EClass.sources.things.Reset();
94 }
95
96 public override void OnAfterImportData()
97 {
98 Dictionary<string, SourceThing.Row> dictionary = new Dictionary<string, SourceThing.Row>();
99 foreach (SourceThing.Row row2 in EClass.sources.things.rows)
100 {
101 dictionary[row2.id] = row2;
102 }
103 Dictionary<string, System.Reflection.FieldInfo> rowFields = new SourceThing.Row().GetRowFields();
104 foreach (Row row3 in rows)
105 {
106 SourceThing.Row row = new SourceThing.Row();
107 SourceThing.Row obj = dictionary[row3._origin];
108 string key;
109 foreach (KeyValuePair<string, System.Reflection.FieldInfo> item in rowFields)
110 {
111 item.Deconstruct(out key, out var value);
112 string text = key;
113 System.Reflection.FieldInfo fieldInfo = value;
114 if (!(text == "parse"))
115 {
116 fieldInfo.SetValue(row, fieldInfo.GetValue(obj));
117 }
118 }
119 row.id = row3.id;
120 row._origin = row3._origin;
121 if (row3.LV != 0)
122 {
123 row.LV = row3.LV;
124 }
125 if (row3.chance != -1)
126 {
127 row.chance = row3.chance;
128 }
129 if (row3.value != -1)
130 {
131 row.value = row3.value;
132 }
133 else
134 {
135 row.value += EClass.rnd(row.value / 2);
136 }
137 if (row3.weight != -1)
138 {
139 row.weight = row3.weight;
140 }
141 if (!row3.tiles.IsEmpty())
142 {
143 row.tiles = row3.tiles;
144 }
145 if (!row3.skins.IsEmpty())
146 {
147 row.skins = row3.skins;
148 }
149 if (!row3.name.IsEmpty())
150 {
151 row.name = row3.name;
152 }
153 if (!row3.name_JP.IsEmpty())
154 {
155 row.name_JP = row3.name_JP;
156 }
157 if (!row3.detail.IsEmpty())
158 {
159 row.detail = row3.detail;
160 }
161 if (!row3.detail_JP.IsEmpty())
162 {
163 row.detail_JP = row3.detail_JP;
164 }
165 if (!row3.unit.IsEmpty())
166 {
167 row.unit = row3.unit;
168 }
169 if (!row3.unit_JP.IsEmpty())
170 {
171 row.unit_JP = row3.unit_JP;
172 }
173 if (!row3.vals.IsEmpty())
174 {
175 row.vals = row3.vals;
176 }
177 if (!row3.components.IsEmpty())
178 {
179 row.components = row3.components;
180 }
181 if (!row3.defMat.IsEmpty())
182 {
183 row.defMat = row3.defMat;
184 }
185 if (!row3.trait.IsEmpty())
186 {
187 row.trait = row3.trait;
188 }
189 if (!row3.category.IsEmpty())
190 {
191 row.category = row3.category;
192 }
193 if (!row3.factory.IsEmpty())
194 {
195 row.factory = row3.factory;
196 }
197 if (!row3.tag.IsEmpty())
198 {
199 row.tag = row3.tag;
200 }
201 row.recipeKey = row3.recipeKey;
202 if (!row3.parse.IsEmpty())
203 {
204 key = row3._origin;
205 switch (key)
206 {
207 case "lamp_ceil2":
208 case "window":
209 case "windowL":
210 row.idExtra = row3.parse[0];
211 break;
212 default:
213 {
214 string[] parse = row3.parse;
215 for (int i = 0; i < parse.Length; i++)
216 {
217 string[] array = parse[i].Split('/');
218 switch (array[0])
219 {
220 case "elec":
221 row.electricity = array[1].ToInt();
222 break;
223 case "render":
224 row._idRenderData = array[1];
225 break;
226 case "tiletype":
227 row._tileType = array[1];
228 break;
229 case "anime":
230 row.anime = ((array.Length <= 4) ? ((array.Length <= 3) ? new int[2]
231 {
232 array[1].ToInt(),
233 array[2].ToInt()
234 } : new int[3]
235 {
236 array[1].ToInt(),
237 array[2].ToInt(),
238 array[3].ToInt()
239 }) : new int[4]
240 {
241 array[1].ToInt(),
242 array[2].ToInt(),
243 array[3].ToInt(),
244 array[4].ToInt()
245 });
246 break;
247 case "skin":
248 {
249 string[] array2 = array[1].Split('|');
250 row.skins = new int[array2.Length];
251 for (int j = 0; j < array2.Length; j++)
252 {
253 row.skins[j] = array2[j].ToInt();
254 }
255 break;
256 }
257 case "alt":
258 row.altTiles = new int[1] { array[1].ToInt() };
259 row.ignoreAltFix = true;
260 break;
261 case "naming":
262 row.naming = array[1];
263 break;
264 case "ex":
265 row.idActorEx = array[1];
266 break;
267 case "sound":
268 row.idSound = array[1];
269 break;
270 case "color":
271 row.colorMod = 100;
272 break;
273 case "no_color":
274 row.colorMod = 0;
275 break;
276 case "unique":
277 row.quality = 4;
278 break;
279 case "ele":
280 {
281 int[] second = new int[2]
282 {
283 Core.GetCurrent().sources.elements.alias[array[1]].id,
284 array[2].ToInt()
285 };
286 row.elements = row.elements.Concat(second).ToArray();
287 break;
288 }
289 }
290 }
291 break;
292 }
293 }
294 }
295 OnImportRow(row3, row);
296 row.OnImportData(EClass.sources.things);
297 EClass.sources.things.rows.Add(row);
298 }
299 rows.Clear();
300 }
301
302 public virtual void OnImportRow(Row _r, SourceThing.Row c)
303 {
304 }
305}
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:605
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:595
static string[] GetStringArray(int id)
Definition: SourceData.cs:912
static string GetString(int id)
Definition: SourceData.cs:917
static int GetInt(int id)
Definition: SourceData.cs:882
static int[] GetIntArray(int id)
Definition: SourceData.cs:907
SourceThing things
SourceAsset asset
SourceElement elements
override bool UseAlias
Definition: SourceThingV.cs:13
override string GetAlias
Definition: SourceThingV.cs:15
override string[] ImportFields
Definition: SourceThingV.cs:18
override void RestorePref()
Definition: SourceThingV.cs:55
override void OnAfterImportData()
Definition: SourceThingV.cs:96
virtual void OnImportRow(Row _r, SourceThing.Row c)
override Row CreateRow()
Definition: SourceThingV.cs:20
override void Reset()
Definition: SourceThingV.cs:90
override void SetRow(Row r)
Definition: SourceThingV.cs:50
override void ValidatePref()
Definition: SourceThingV.cs:82
Dictionary< string, Row > _rows
Definition: SourceThing.cs:147
bool ContainsKey(TKey key)
Definition: UDictionary.cs:151