Elin Decompiled Documentation EA 23.340.2 Nightly
Loading...
Searching...
No Matches
SourceElement.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using UnityEngine;
5using UnityEngine.UI;
6
7public class SourceElement : SourceDataInt<SourceElement.Row>
8{
9 [Serializable]
10 public class Row : BaseRow
11 {
12 public int id;
13
14 public string alias;
15
16 public string name_JP;
17
18 public string name;
19
20 public string altname_JP;
21
22 public string altname;
23
24 public string aliasParent;
25
26 public string aliasRef;
27
28 public string aliasMtp;
29
30 public float parentFactor;
31
32 public int lvFactor;
33
34 public int encFactor;
35
36 public string encSlot;
37
38 public int mtp;
39
40 public int LV;
41
42 public int chance;
43
44 public int value;
45
46 public int[] cost;
47
48 public int geneSlot;
49
50 public int sort;
51
52 public string target;
53
54 public string[] proc;
55
56 public string type;
57
58 public string group;
59
60 public string category;
61
62 public string categorySub;
63
64 public string[] abilityType;
65
66 public string[] tag;
67
68 public string thing;
69
70 public int eleP;
71
72 public int cooldown;
73
74 public int charge;
75
76 public float radius;
77
78 public int max;
79
80 public string[] req;
81
82 public string idTrainer;
83
84 public int partySkill;
85
86 public string tagTrainer;
87
88 public string levelBonus_JP;
89
90 public string levelBonus;
91
92 public string[] foodEffect;
93
94 public string[] langAct;
95
96 public string detail_JP;
97
98 public string detail;
99
100 public string textPhase_JP;
101
102 public string textPhase;
103
104 public string textExtra_JP;
105
106 public string textExtra;
107
108 public string textInc_JP;
109
110 public string textInc;
111
112 public string textDec_JP;
113
114 public string textDec;
115
116 public string[] textAlt_JP;
117
118 public string[] textAlt;
119
120 public string[] adjective_JP;
121
122 public string[] adjective;
123
124 [NonSerialized]
125 public bool isAttribute;
126
127 [NonSerialized]
129
130 [NonSerialized]
131 public bool isSkill;
132
133 [NonSerialized]
134 public bool isSpell;
135
136 [NonSerialized]
137 public bool isTrait;
138
139 public int idMold;
140
141 [NonSerialized]
142 public string name_L;
143
144 [NonSerialized]
145 public string altname_L;
146
147 [NonSerialized]
148 public string detail_L;
149
150 [NonSerialized]
151 public string textPhase_L;
152
153 [NonSerialized]
154 public string textExtra_L;
155
156 [NonSerialized]
157 public string textInc_L;
158
159 [NonSerialized]
160 public string textDec_L;
161
162 [NonSerialized]
163 public string levelBonus_L;
164
165 [NonSerialized]
166 public string[] textAlt_L;
167
168 [NonSerialized]
169 public string[] adjective_L;
170
171 public override bool UseAlias => true;
172
173 public override string GetAlias => alias;
174
175 public bool IsWeaponEnc
176 {
177 get
178 {
179 if (!tag.Contains("weaponEnc") && !(categorySub == "eleConvert") && !(categorySub == "eleAttack"))
180 {
181 return category == "ability";
182 }
183 return true;
184 }
185 }
186
187 public bool IsShieldEnc => encSlot == "shield";
188
189 public override string GetName()
190 {
191 if (idMold != 0)
192 {
193 int i = 0;
194 if (idMold == 7011 || idMold == 7010 || idMold == 7012)
195 {
196 i = 3;
197 }
198 return EClass.sources.elements.map[idMold].alias.lang(EClass.sources.elements.alias[aliasRef].GetAltname(i));
199 }
200 return base.GetName();
201 }
202
203 public Sprite GetSprite()
204 {
205 return SpriteSheet.Get("Media/Graphics/Icon/Element/icon_ability", alias) ?? SpriteSheet.Get("Media/Graphics/Icon/Element/icon_ability", type) ?? EClass.core.refs.icons.defaultAbility;
206 }
207
208 public void SetImage(Image image)
209 {
210 image.sprite = GetSprite() ?? EClass.core.refs.icons.defaultAbility;
211 if (!aliasRef.IsEmpty())
212 {
213 image.color = EClass.setting.elements[aliasRef].colorSprite;
214 }
215 else
216 {
217 image.color = Color.white;
218 }
219 }
220
221 public string GetAltname(int i)
222 {
223 return GetText("altname").Split(',').TryGet(i);
224 }
225
227 {
228 if (id == 10)
229 {
230 return true;
231 }
232 if (isTrait)
233 {
235 {
236 return false;
237 }
238 return true;
239 }
241 {
242 return false;
243 }
244 if (!t.IsEquipment)
245 {
246 return IsWeaponEnc;
247 }
248 return true;
249 }
250
252 {
253 if (encSlot.IsEmpty())
254 {
255 return false;
256 }
257 if (encSlot == "global")
258 {
259 return true;
260 }
261 int slot = cat.slot;
262 if (slot == 0)
263 {
264 return IsWeaponEnc;
265 }
266 switch (encSlot)
267 {
268 case "all":
269 return true;
270 case "weapon":
271 return cat.IsChildOf("weapon");
272 case "shield":
273 if (!cat.IsChildOf("shield"))
274 {
275 return cat.IsChildOf("martial");
276 }
277 return true;
278 default:
279 return encSlot.Contains(EClass.sources.elements.map[slot].alias);
280 }
281 }
282 }
283
284 public static readonly IReadOnlyDictionary<string, int> RowMapping = new Dictionary<string, int>
285 {
286 ["id"] = 0,
287 ["alias"] = 1,
288 ["name_JP"] = 2,
289 ["name"] = 3,
290 ["altname_JP"] = 4,
291 ["altname"] = 5,
292 ["aliasParent"] = 6,
293 ["aliasRef"] = 7,
294 ["aliasMtp"] = 8,
295 ["parentFactor"] = 9,
296 ["lvFactor"] = 10,
297 ["encFactor"] = 11,
298 ["encSlot"] = 12,
299 ["mtp"] = 13,
300 ["LV"] = 14,
301 ["chance"] = 15,
302 ["value"] = 16,
303 ["cost"] = 17,
304 ["geneSlot"] = 18,
305 ["sort"] = 19,
306 ["target"] = 20,
307 ["proc"] = 21,
308 ["type"] = 22,
309 ["group"] = 23,
310 ["category"] = 24,
311 ["categorySub"] = 25,
312 ["abilityType"] = 26,
313 ["tag"] = 27,
314 ["thing"] = 28,
315 ["eleP"] = 29,
316 ["cooldown"] = 30,
317 ["charge"] = 31,
318 ["radius"] = 32,
319 ["max"] = 33,
320 ["req"] = 34,
321 ["idTrainer"] = 35,
322 ["partySkill"] = 36,
323 ["tagTrainer"] = 37,
324 ["levelBonus_JP"] = 38,
325 ["levelBonus"] = 39,
326 ["foodEffect"] = 40,
327 ["langAct"] = 42,
328 ["detail_JP"] = 43,
329 ["detail"] = 44,
330 ["textPhase_JP"] = 45,
331 ["textPhase"] = 46,
332 ["textExtra_JP"] = 47,
333 ["textExtra"] = 48,
334 ["textInc_JP"] = 49,
335 ["textInc"] = 50,
336 ["textDec_JP"] = 51,
337 ["textDec"] = 52,
338 ["textAlt_JP"] = 53,
339 ["textAlt"] = 54,
340 ["adjective_JP"] = 55,
341 ["adjective"] = 56
342 };
343
344 public static readonly IReadOnlyDictionary<string, string> TypeMapping = new Dictionary<string, string>
345 {
346 ["id"] = "int",
347 ["alias"] = "string",
348 ["name_JP"] = "string",
349 ["name"] = "string",
350 ["altname_JP"] = "string",
351 ["altname"] = "string",
352 ["aliasParent"] = "string",
353 ["aliasRef"] = "string",
354 ["aliasMtp"] = "string",
355 ["parentFactor"] = "float",
356 ["lvFactor"] = "int",
357 ["encFactor"] = "int",
358 ["encSlot"] = "string",
359 ["mtp"] = "int",
360 ["LV"] = "int",
361 ["chance"] = "int",
362 ["value"] = "int",
363 ["cost"] = "int[]",
364 ["geneSlot"] = "int",
365 ["sort"] = "int",
366 ["target"] = "string",
367 ["proc"] = "string[]",
368 ["type"] = "string",
369 ["group"] = "string",
370 ["category"] = "string",
371 ["categorySub"] = "string",
372 ["abilityType"] = "string[]",
373 ["tag"] = "string[]",
374 ["thing"] = "string",
375 ["eleP"] = "int",
376 ["cooldown"] = "int",
377 ["charge"] = "int",
378 ["radius"] = "float",
379 ["max"] = "int",
380 ["req"] = "string[]",
381 ["idTrainer"] = "string",
382 ["partySkill"] = "int",
383 ["tagTrainer"] = "string",
384 ["levelBonus_JP"] = "string",
385 ["levelBonus"] = "string",
386 ["foodEffect"] = "string[]",
387 ["langAct"] = "string[]",
388 ["detail_JP"] = "string",
389 ["detail"] = "string",
390 ["textPhase_JP"] = "string",
391 ["textPhase"] = "string",
392 ["textExtra_JP"] = "string",
393 ["textExtra"] = "string",
394 ["textInc_JP"] = "string",
395 ["textInc"] = "string",
396 ["textDec_JP"] = "string",
397 ["textDec"] = "string",
398 ["textAlt_JP"] = "string[]",
399 ["textAlt"] = "string[]",
400 ["adjective_JP"] = "string[]",
401 ["adjective"] = "string[]"
402 };
403
404 [NonSerialized]
405 public List<Row> hobbies = new List<Row>();
406
407 [NonSerialized]
408 public Dictionary<string, string> fuzzyAlias = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
409
410 public override string[] ImportFields => new string[8] { "altname", "textPhase", "textExtra", "textInc", "textDec", "textAlt", "adjective", "levelBonus" };
411
412 public override Row CreateRow()
413 {
414 return new Row
415 {
416 id = SourceData.GetInt(0),
417 alias = SourceData.GetString(1),
418 name_JP = SourceData.GetString(2),
419 name = SourceData.GetString(3),
420 altname_JP = SourceData.GetString(4),
421 altname = SourceData.GetString(5),
422 aliasParent = SourceData.GetString(6),
423 aliasRef = SourceData.GetString(7),
424 aliasMtp = SourceData.GetString(8),
425 parentFactor = SourceData.GetFloat(9),
426 lvFactor = SourceData.GetInt(10),
427 encFactor = SourceData.GetInt(11),
428 encSlot = SourceData.GetString(12),
429 mtp = SourceData.GetInt(13),
430 LV = SourceData.GetInt(14),
431 chance = SourceData.GetInt(15),
432 value = SourceData.GetInt(16),
433 cost = SourceData.GetIntArray(17),
434 geneSlot = SourceData.GetInt(18),
435 sort = SourceData.GetInt(19),
436 target = SourceData.GetString(20),
437 proc = SourceData.GetStringArray(21),
438 type = SourceData.GetString(22),
439 group = SourceData.GetString(23),
440 category = SourceData.GetString(24),
441 categorySub = SourceData.GetString(25),
442 abilityType = SourceData.GetStringArray(26),
443 tag = SourceData.GetStringArray(27),
444 thing = SourceData.GetString(28),
445 eleP = SourceData.GetInt(29),
446 cooldown = SourceData.GetInt(30),
447 charge = SourceData.GetInt(31),
448 radius = SourceData.GetFloat(32),
449 max = SourceData.GetInt(33),
450 req = SourceData.GetStringArray(34),
451 idTrainer = SourceData.GetString(35),
452 partySkill = SourceData.GetInt(36),
453 tagTrainer = SourceData.GetString(37),
454 levelBonus_JP = SourceData.GetString(38),
455 levelBonus = SourceData.GetString(39),
456 foodEffect = SourceData.GetStringArray(40),
457 langAct = SourceData.GetStringArray(42),
458 detail_JP = SourceData.GetString(43),
459 detail = SourceData.GetString(44),
460 textPhase_JP = SourceData.GetString(45),
461 textPhase = SourceData.GetString(46),
462 textExtra_JP = SourceData.GetString(47),
463 textExtra = SourceData.GetString(48),
464 textInc_JP = SourceData.GetString(49),
465 textInc = SourceData.GetString(50),
466 textDec_JP = SourceData.GetString(51),
467 textDec = SourceData.GetString(52),
468 textAlt_JP = SourceData.GetStringArray(53),
469 textAlt = SourceData.GetStringArray(54),
470 adjective_JP = SourceData.GetStringArray(55),
471 adjective = SourceData.GetStringArray(56)
472 };
473 }
474
475 public override Row CreateRowByMapping(IReadOnlyDictionary<string, int> mapping)
476 {
477 return new Row
478 {
479 id = SourceData.GetInt(mapping["id"]),
480 alias = SourceData.GetString(mapping["alias"]),
481 name_JP = SourceData.GetString(mapping["name_JP"]),
482 name = SourceData.GetString(mapping["name"]),
483 altname_JP = SourceData.GetString(mapping["altname_JP"]),
484 altname = SourceData.GetString(mapping["altname"]),
485 aliasParent = SourceData.GetString(mapping["aliasParent"]),
486 aliasRef = SourceData.GetString(mapping["aliasRef"]),
487 aliasMtp = SourceData.GetString(mapping["aliasMtp"]),
488 parentFactor = SourceData.GetFloat(mapping["parentFactor"]),
489 lvFactor = SourceData.GetInt(mapping["lvFactor"]),
490 encFactor = SourceData.GetInt(mapping["encFactor"]),
491 encSlot = SourceData.GetString(mapping["encSlot"]),
492 mtp = SourceData.GetInt(mapping["mtp"]),
493 LV = SourceData.GetInt(mapping["LV"]),
494 chance = SourceData.GetInt(mapping["chance"]),
495 value = SourceData.GetInt(mapping["value"]),
496 cost = SourceData.GetIntArray(mapping["cost"]),
497 geneSlot = SourceData.GetInt(mapping["geneSlot"]),
498 sort = SourceData.GetInt(mapping["sort"]),
499 target = SourceData.GetString(mapping["target"]),
500 proc = SourceData.GetStringArray(mapping["proc"]),
501 type = SourceData.GetString(mapping["type"]),
502 group = SourceData.GetString(mapping["group"]),
503 category = SourceData.GetString(mapping["category"]),
504 categorySub = SourceData.GetString(mapping["categorySub"]),
505 abilityType = SourceData.GetStringArray(mapping["abilityType"]),
506 tag = SourceData.GetStringArray(mapping["tag"]),
507 thing = SourceData.GetString(mapping["thing"]),
508 eleP = SourceData.GetInt(mapping["eleP"]),
509 cooldown = SourceData.GetInt(mapping["cooldown"]),
510 charge = SourceData.GetInt(mapping["charge"]),
511 radius = SourceData.GetFloat(mapping["radius"]),
512 max = SourceData.GetInt(mapping["max"]),
513 req = SourceData.GetStringArray(mapping["req"]),
514 idTrainer = SourceData.GetString(mapping["idTrainer"]),
515 partySkill = SourceData.GetInt(mapping["partySkill"]),
516 tagTrainer = SourceData.GetString(mapping["tagTrainer"]),
517 levelBonus_JP = SourceData.GetString(mapping["levelBonus_JP"]),
518 levelBonus = SourceData.GetString(mapping["levelBonus"]),
519 foodEffect = SourceData.GetStringArray(mapping["foodEffect"]),
520 langAct = SourceData.GetStringArray(mapping["langAct"]),
521 detail_JP = SourceData.GetString(mapping["detail_JP"]),
522 detail = SourceData.GetString(mapping["detail"]),
523 textPhase_JP = SourceData.GetString(mapping["textPhase_JP"]),
524 textPhase = SourceData.GetString(mapping["textPhase"]),
525 textExtra_JP = SourceData.GetString(mapping["textExtra_JP"]),
526 textExtra = SourceData.GetString(mapping["textExtra"]),
527 textInc_JP = SourceData.GetString(mapping["textInc_JP"]),
528 textInc = SourceData.GetString(mapping["textInc"]),
529 textDec_JP = SourceData.GetString(mapping["textDec_JP"]),
530 textDec = SourceData.GetString(mapping["textDec"]),
531 textAlt_JP = SourceData.GetStringArray(mapping["textAlt_JP"]),
532 textAlt = SourceData.GetStringArray(mapping["textAlt"]),
533 adjective_JP = SourceData.GetStringArray(mapping["adjective_JP"]),
534 adjective = SourceData.GetStringArray(mapping["adjective"])
535 };
536 }
537
538 public override void SetRow(Row r)
539 {
540 map[r.id] = r;
541 }
542
543 public override IReadOnlyDictionary<string, int> GetRowMapping()
544 {
545 return RowMapping;
546 }
547
548 public override IReadOnlyDictionary<string, string> GetTypeMapping()
549 {
550 return TypeMapping;
551 }
552
553 public override void OnInit()
554 {
555 hobbies.Clear();
556 foreach (Row row in rows)
557 {
558 if (row.id >= 100 && row.id < 400)
559 {
560 hobbies.Add(row);
561 }
562 row.isAttribute = row.category == "attribute";
563 row.isPrimaryAttribute = row.isAttribute && row.tag.Contains("primary");
564 row.isSkill = row.category == "skill";
565 row.isSpell = row.categorySub == "spell";
566 row.isTrait = row.tag.Contains("trait");
567 }
568 fuzzyAlias.Clear();
569 foreach (string key in alias.Keys)
570 {
571 fuzzyAlias[key] = key;
572 }
573 }
574
575 public override void OnAfterImportData()
576 {
578 map.Clear();
579 alias.Clear();
580 foreach (Row row in rows)
581 {
582 map[row.id] = row;
583 alias[row.GetAlias] = row;
584 }
585 int num = 50000;
586 int num2 = 0;
587 for (int i = 910; i < 927; i++)
588 {
589 Row ele = EClass.sources.elements.map[i];
590 AddRow(ele, num + num2 + 100, "ball_");
591 AddRow(ele, num + num2 + 200, "breathe_");
592 AddRow(ele, num + num2 + 300, "bolt_");
593 AddRow(ele, num + num2 + 400, "hand_");
594 AddRow(ele, num + num2 + 500, "arrow_");
595 AddRow(ele, num + num2 + 600, "funnel_");
596 AddRow(ele, num + num2 + 700, "miasma_");
597 AddRow(ele, num + num2 + 800, "weapon_");
598 AddRow(ele, num + num2 + 900, "puddle_");
599 AddRow(ele, num + num2 + 1000, "sword_");
600 AddRow(ele, num + num2 + 1100, "bit_");
601 AddRow(ele, num + num2 + 1200, "flare_");
602 AddRow(ele, num + num2 + 1300, "comet_");
603 AddRow(ele, num + num2 + 1400, "missile_");
604 num2++;
605 }
606 initialized = false;
607 }
608
609 public void AddRow(Row ele, int id, string idOrg)
610 {
611 if (map.ContainsKey(id))
612 {
613 return;
614 }
615 Row row = EClass.sources.elements.alias[idOrg];
616 Dictionary<string, System.Reflection.FieldInfo> rowFields = row.GetRowFields();
617 Row row2 = new Row();
618 foreach (System.Reflection.FieldInfo value in rowFields.Values)
619 {
620 value.SetValue(row2, value.GetValue(row));
621 }
622 row2.id = id;
623 row2.idMold = row.id;
624 row2.alias = row.alias + ele.alias.Remove(0, 3);
625 row2.aliasRef = ele.alias;
626 row2.aliasParent = ele.aliasParent;
627 row2.chance = row.chance * ele.chance / 100;
628 row2.LV = row.LV;
629 row2.OnImportData(EClass.sources.elements);
630 rows.Add(row2);
631 }
632}
bool IsThrownWeapon
Definition: Card.cs:2299
bool IsEquipmentOrRangedOrAmmo
Definition: Card.cs:2284
Trait trait
Definition: Card.cs:54
bool IsEquipment
Definition: Card.cs:2227
Sprite defaultAbility
Definition: CoreRef.cs:121
Icons icons
Definition: CoreRef.cs:358
Definition: Core.cs:14
CoreRef refs
Definition: Core.cs:51
static Core SetCurrent(Core _current=null)
Definition: Core.cs:585
Definition: EClass.cs:6
static Core core
Definition: EClass.cs:7
static SourceManager sources
Definition: EClass.cs:43
static GameSetting setting
Definition: EClass.cs:35
UD_String_ElementRef elements
Definition: GameSetting.cs:360
static float GetFloat(int id)
Definition: SourceData.cs:996
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
override string GetAlias
bool IsEncAppliable(SourceCategory.Row cat)
string[] abilityType
override string GetName()
override bool UseAlias
void SetImage(Image image)
bool IsMaterialEncAppliable(Thing t)
string GetAltname(int i)
override void OnInit()
override Row CreateRowByMapping(IReadOnlyDictionary< string, int > mapping)
override void OnAfterImportData()
List< Row > hobbies
static readonly IReadOnlyDictionary< string, int > RowMapping
override IReadOnlyDictionary< string, int > GetRowMapping()
static readonly IReadOnlyDictionary< string, string > TypeMapping
override Row CreateRow()
void AddRow(Row ele, int id, string idOrg)
override void SetRow(Row r)
Dictionary< string, string > fuzzyAlias
override string[] ImportFields
override IReadOnlyDictionary< string, string > GetTypeMapping()
SourceElement elements
static Sprite Get(string id)
Definition: SpriteSheet.cs:28
Definition: Thing.cs:8