Elin Decompiled Documentation EA 23.102 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 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 System.Reflection.FieldInfo[] fields = EClass.sources.things.rows[0].GetType().GetFields();
104 foreach (Row row3 in rows)
105 {
106 SourceThing.Row row = new SourceThing.Row();
107 SourceThing.Row o = dictionary[row3._origin];
108 System.Reflection.FieldInfo[] array = fields;
109 foreach (System.Reflection.FieldInfo fieldInfo in array)
110 {
111 if (!(fieldInfo.Name == "parse"))
112 {
113 row.SetField(fieldInfo.Name, o.GetField<object>(fieldInfo.Name));
114 }
115 }
116 row.id = row3.id;
117 row._origin = row3._origin;
118 if (row3.LV != 0)
119 {
120 row.LV = row3.LV;
121 }
122 if (row3.chance != -1)
123 {
124 row.chance = row3.chance;
125 }
126 if (row3.value != -1)
127 {
128 row.value = row3.value;
129 }
130 else
131 {
132 row.value += EClass.rnd(row.value / 2);
133 }
134 if (row3.weight != -1)
135 {
136 row.weight = row3.weight;
137 }
138 if (!row3.tiles.IsEmpty())
139 {
140 row.tiles = row3.tiles;
141 }
142 if (!row3.skins.IsEmpty())
143 {
144 row.skins = row3.skins;
145 }
146 if (!row3.name.IsEmpty())
147 {
148 row.name = row3.name;
149 }
150 if (!row3.name_JP.IsEmpty())
151 {
152 row.name_JP = row3.name_JP;
153 }
154 if (!row3.detail.IsEmpty())
155 {
156 row.detail = row3.detail;
157 }
158 if (!row3.detail_JP.IsEmpty())
159 {
160 row.detail_JP = row3.detail_JP;
161 }
162 if (!row3.unit.IsEmpty())
163 {
164 row.unit = row3.unit;
165 }
166 if (!row3.unit_JP.IsEmpty())
167 {
168 row.unit_JP = row3.unit_JP;
169 }
170 if (!row3.vals.IsEmpty())
171 {
172 row.vals = row3.vals;
173 }
174 if (!row3.components.IsEmpty())
175 {
176 row.components = row3.components;
177 }
178 if (!row3.defMat.IsEmpty())
179 {
180 row.defMat = row3.defMat;
181 }
182 if (!row3.trait.IsEmpty())
183 {
184 row.trait = row3.trait;
185 }
186 if (!row3.category.IsEmpty())
187 {
188 row.category = row3.category;
189 }
190 if (!row3.factory.IsEmpty())
191 {
192 row.factory = row3.factory;
193 }
194 if (!row3.tag.IsEmpty())
195 {
196 row.tag = row3.tag;
197 }
198 row.recipeKey = row3.recipeKey;
199 if (!row3.parse.IsEmpty())
200 {
201 switch (row3._origin)
202 {
203 case "lamp_ceil2":
204 case "window":
205 case "windowL":
206 row.idExtra = row3.parse[0];
207 break;
208 default:
209 {
210 string[] parse = row3.parse;
211 for (int i = 0; i < parse.Length; i++)
212 {
213 string[] array2 = parse[i].Split('/');
214 switch (array2[0])
215 {
216 case "render":
217 row._idRenderData = array2[1];
218 break;
219 case "tiletype":
220 row._tileType = array2[1];
221 break;
222 case "anime":
223 row.anime = ((array2.Length <= 4) ? ((array2.Length <= 3) ? new int[2]
224 {
225 array2[1].ToInt(),
226 array2[2].ToInt()
227 } : new int[3]
228 {
229 array2[1].ToInt(),
230 array2[2].ToInt(),
231 array2[3].ToInt()
232 }) : new int[4]
233 {
234 array2[1].ToInt(),
235 array2[2].ToInt(),
236 array2[3].ToInt(),
237 array2[4].ToInt()
238 });
239 break;
240 case "skin":
241 row.skins = new int[1] { array2[1].ToInt() };
242 break;
243 case "alt":
244 row.altTiles = new int[1] { array2[1].ToInt() };
245 row.ignoreAltFix = true;
246 break;
247 case "naming":
248 row.naming = array2[1];
249 break;
250 case "ex":
251 row.idActorEx = array2[1];
252 break;
253 case "sound":
254 row.idSound = array2[1];
255 break;
256 case "color":
257 row.colorMod = 100;
258 break;
259 case "no_color":
260 row.colorMod = 0;
261 break;
262 case "unique":
263 row.quality = 4;
264 break;
265 case "ele":
266 {
267 int[] second = new int[2]
268 {
269 Core.GetCurrent().sources.elements.alias[array2[1]].id,
270 array2[2].ToInt()
271 };
272 row.elements = row.elements.Concat(second).ToArray();
273 break;
274 }
275 }
276 }
277 break;
278 }
279 }
280 }
281 OnImportRow(row3, row);
283 EClass.sources.things.rows.Add(row);
284 }
285 rows.Clear();
286 }
287
288 public virtual void OnImportRow(Row _r, SourceThing.Row c)
289 {
290 }
291}
PrefFlag
Definition: PrefFlag.cs:5
int[] elements
Definition: CardRow.cs:21
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:594
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static SourceManager sources
Definition: EClass.cs:42
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:20
static string[] GetStringArray(int id)
Definition: SourceData.cs:741
static string GetString(int id)
Definition: SourceData.cs:746
static int GetInt(int id)
Definition: SourceData.cs:711
static int[] GetIntArray(int id)
Definition: SourceData.cs:736
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
override void OnImportData(SourceData data)
Definition: SourceThing.cs:79
Dictionary< string, Row > _rows
Definition: SourceThing.cs:144
bool ContainsKey(TKey key)
Definition: UDictionary.cs:151