Elin Decompiled Documentation EA 23.310 Nightly Patch 1
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 return EClass.sources.elements.map[idMold].alias.lang(EClass.sources.elements.alias[aliasRef].GetAltname(0));
194 }
195 return base.GetName();
196 }
197
198 public Sprite GetSprite()
199 {
200 return SpriteSheet.Get("Media/Graphics/Icon/Element/icon_ability", alias) ?? SpriteSheet.Get("Media/Graphics/Icon/Element/icon_ability", type) ?? EClass.core.refs.icons.defaultAbility;
201 }
202
203 public void SetImage(Image image)
204 {
205 image.sprite = GetSprite() ?? EClass.core.refs.icons.defaultAbility;
206 if (!aliasRef.IsEmpty())
207 {
208 image.color = EClass.setting.elements[aliasRef].colorSprite;
209 }
210 else
211 {
212 image.color = Color.white;
213 }
214 }
215
216 public string GetAltname(int i)
217 {
218 return GetText("altname").Split(',').TryGet(i);
219 }
220
222 {
223 if (id == 10)
224 {
225 return true;
226 }
227 if (isTrait)
228 {
230 {
231 return false;
232 }
233 return true;
234 }
236 {
237 return false;
238 }
239 if (!t.IsEquipment)
240 {
241 return IsWeaponEnc;
242 }
243 return true;
244 }
245
247 {
248 if (encSlot.IsEmpty())
249 {
250 return false;
251 }
252 if (encSlot == "global")
253 {
254 return true;
255 }
256 int slot = cat.slot;
257 if (slot == 0)
258 {
259 return IsWeaponEnc;
260 }
261 switch (encSlot)
262 {
263 case "all":
264 return true;
265 case "weapon":
266 return cat.IsChildOf("weapon");
267 case "shield":
268 if (!cat.IsChildOf("shield"))
269 {
270 return cat.IsChildOf("martial");
271 }
272 return true;
273 default:
274 return encSlot.Contains(EClass.sources.elements.map[slot].alias);
275 }
276 }
277 }
278
279 public static readonly IReadOnlyDictionary<string, int> RowMapping = new Dictionary<string, int>
280 {
281 ["id"] = 0,
282 ["alias"] = 1,
283 ["name_JP"] = 2,
284 ["name"] = 3,
285 ["altname_JP"] = 4,
286 ["altname"] = 5,
287 ["aliasParent"] = 6,
288 ["aliasRef"] = 7,
289 ["aliasMtp"] = 8,
290 ["parentFactor"] = 9,
291 ["lvFactor"] = 10,
292 ["encFactor"] = 11,
293 ["encSlot"] = 12,
294 ["mtp"] = 13,
295 ["LV"] = 14,
296 ["chance"] = 15,
297 ["value"] = 16,
298 ["cost"] = 17,
299 ["geneSlot"] = 18,
300 ["sort"] = 19,
301 ["target"] = 20,
302 ["proc"] = 21,
303 ["type"] = 22,
304 ["group"] = 23,
305 ["category"] = 24,
306 ["categorySub"] = 25,
307 ["abilityType"] = 26,
308 ["tag"] = 27,
309 ["thing"] = 28,
310 ["eleP"] = 29,
311 ["cooldown"] = 30,
312 ["charge"] = 31,
313 ["radius"] = 32,
314 ["max"] = 33,
315 ["req"] = 34,
316 ["idTrainer"] = 35,
317 ["partySkill"] = 36,
318 ["tagTrainer"] = 37,
319 ["levelBonus_JP"] = 38,
320 ["levelBonus"] = 39,
321 ["foodEffect"] = 40,
322 ["langAct"] = 42,
323 ["detail_JP"] = 43,
324 ["detail"] = 44,
325 ["textPhase_JP"] = 45,
326 ["textPhase"] = 46,
327 ["textExtra_JP"] = 47,
328 ["textExtra"] = 48,
329 ["textInc_JP"] = 49,
330 ["textInc"] = 50,
331 ["textDec_JP"] = 51,
332 ["textDec"] = 52,
333 ["textAlt_JP"] = 53,
334 ["textAlt"] = 54,
335 ["adjective_JP"] = 55,
336 ["adjective"] = 56
337 };
338
339 public static readonly IReadOnlyDictionary<string, string> TypeMapping = new Dictionary<string, string>
340 {
341 ["id"] = "int",
342 ["alias"] = "string",
343 ["name_JP"] = "string",
344 ["name"] = "string",
345 ["altname_JP"] = "string",
346 ["altname"] = "string",
347 ["aliasParent"] = "string",
348 ["aliasRef"] = "string",
349 ["aliasMtp"] = "string",
350 ["parentFactor"] = "float",
351 ["lvFactor"] = "int",
352 ["encFactor"] = "int",
353 ["encSlot"] = "string",
354 ["mtp"] = "int",
355 ["LV"] = "int",
356 ["chance"] = "int",
357 ["value"] = "int",
358 ["cost"] = "int[]",
359 ["geneSlot"] = "int",
360 ["sort"] = "int",
361 ["target"] = "string",
362 ["proc"] = "string[]",
363 ["type"] = "string",
364 ["group"] = "string",
365 ["category"] = "string",
366 ["categorySub"] = "string",
367 ["abilityType"] = "string[]",
368 ["tag"] = "string[]",
369 ["thing"] = "string",
370 ["eleP"] = "int",
371 ["cooldown"] = "int",
372 ["charge"] = "int",
373 ["radius"] = "float",
374 ["max"] = "int",
375 ["req"] = "string[]",
376 ["idTrainer"] = "string",
377 ["partySkill"] = "int",
378 ["tagTrainer"] = "string",
379 ["levelBonus_JP"] = "string",
380 ["levelBonus"] = "string",
381 ["foodEffect"] = "string[]",
382 ["langAct"] = "string[]",
383 ["detail_JP"] = "string",
384 ["detail"] = "string",
385 ["textPhase_JP"] = "string",
386 ["textPhase"] = "string",
387 ["textExtra_JP"] = "string",
388 ["textExtra"] = "string",
389 ["textInc_JP"] = "string",
390 ["textInc"] = "string",
391 ["textDec_JP"] = "string",
392 ["textDec"] = "string",
393 ["textAlt_JP"] = "string[]",
394 ["textAlt"] = "string[]",
395 ["adjective_JP"] = "string[]",
396 ["adjective"] = "string[]"
397 };
398
399 [NonSerialized]
400 public List<Row> hobbies = new List<Row>();
401
402 [NonSerialized]
403 public Dictionary<string, string> fuzzyAlias = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
404
405 public override string[] ImportFields => new string[8] { "altname", "textPhase", "textExtra", "textInc", "textDec", "textAlt", "adjective", "levelBonus" };
406
407 public override Row CreateRow()
408 {
409 return new Row
410 {
411 id = SourceData.GetInt(0),
412 alias = SourceData.GetString(1),
413 name_JP = SourceData.GetString(2),
414 name = SourceData.GetString(3),
415 altname_JP = SourceData.GetString(4),
416 altname = SourceData.GetString(5),
417 aliasParent = SourceData.GetString(6),
418 aliasRef = SourceData.GetString(7),
419 aliasMtp = SourceData.GetString(8),
420 parentFactor = SourceData.GetFloat(9),
421 lvFactor = SourceData.GetInt(10),
422 encFactor = SourceData.GetInt(11),
423 encSlot = SourceData.GetString(12),
424 mtp = SourceData.GetInt(13),
425 LV = SourceData.GetInt(14),
426 chance = SourceData.GetInt(15),
427 value = SourceData.GetInt(16),
428 cost = SourceData.GetIntArray(17),
429 geneSlot = SourceData.GetInt(18),
430 sort = SourceData.GetInt(19),
431 target = SourceData.GetString(20),
432 proc = SourceData.GetStringArray(21),
433 type = SourceData.GetString(22),
434 group = SourceData.GetString(23),
435 category = SourceData.GetString(24),
436 categorySub = SourceData.GetString(25),
437 abilityType = SourceData.GetStringArray(26),
438 tag = SourceData.GetStringArray(27),
439 thing = SourceData.GetString(28),
440 eleP = SourceData.GetInt(29),
441 cooldown = SourceData.GetInt(30),
442 charge = SourceData.GetInt(31),
443 radius = SourceData.GetFloat(32),
444 max = SourceData.GetInt(33),
445 req = SourceData.GetStringArray(34),
446 idTrainer = SourceData.GetString(35),
447 partySkill = SourceData.GetInt(36),
448 tagTrainer = SourceData.GetString(37),
449 levelBonus_JP = SourceData.GetString(38),
450 levelBonus = SourceData.GetString(39),
451 foodEffect = SourceData.GetStringArray(40),
452 langAct = SourceData.GetStringArray(42),
453 detail_JP = SourceData.GetString(43),
454 detail = SourceData.GetString(44),
455 textPhase_JP = SourceData.GetString(45),
456 textPhase = SourceData.GetString(46),
457 textExtra_JP = SourceData.GetString(47),
458 textExtra = SourceData.GetString(48),
459 textInc_JP = SourceData.GetString(49),
460 textInc = SourceData.GetString(50),
461 textDec_JP = SourceData.GetString(51),
462 textDec = SourceData.GetString(52),
463 textAlt_JP = SourceData.GetStringArray(53),
464 textAlt = SourceData.GetStringArray(54),
465 adjective_JP = SourceData.GetStringArray(55),
466 adjective = SourceData.GetStringArray(56)
467 };
468 }
469
470 public override Row CreateRowByMapping(IReadOnlyDictionary<string, int> mapping)
471 {
472 return new Row
473 {
474 id = SourceData.GetInt(mapping["id"]),
475 alias = SourceData.GetString(mapping["alias"]),
476 name_JP = SourceData.GetString(mapping["name_JP"]),
477 name = SourceData.GetString(mapping["name"]),
478 altname_JP = SourceData.GetString(mapping["altname_JP"]),
479 altname = SourceData.GetString(mapping["altname"]),
480 aliasParent = SourceData.GetString(mapping["aliasParent"]),
481 aliasRef = SourceData.GetString(mapping["aliasRef"]),
482 aliasMtp = SourceData.GetString(mapping["aliasMtp"]),
483 parentFactor = SourceData.GetFloat(mapping["parentFactor"]),
484 lvFactor = SourceData.GetInt(mapping["lvFactor"]),
485 encFactor = SourceData.GetInt(mapping["encFactor"]),
486 encSlot = SourceData.GetString(mapping["encSlot"]),
487 mtp = SourceData.GetInt(mapping["mtp"]),
488 LV = SourceData.GetInt(mapping["LV"]),
489 chance = SourceData.GetInt(mapping["chance"]),
490 value = SourceData.GetInt(mapping["value"]),
491 cost = SourceData.GetIntArray(mapping["cost"]),
492 geneSlot = SourceData.GetInt(mapping["geneSlot"]),
493 sort = SourceData.GetInt(mapping["sort"]),
494 target = SourceData.GetString(mapping["target"]),
495 proc = SourceData.GetStringArray(mapping["proc"]),
496 type = SourceData.GetString(mapping["type"]),
497 group = SourceData.GetString(mapping["group"]),
498 category = SourceData.GetString(mapping["category"]),
499 categorySub = SourceData.GetString(mapping["categorySub"]),
500 abilityType = SourceData.GetStringArray(mapping["abilityType"]),
501 tag = SourceData.GetStringArray(mapping["tag"]),
502 thing = SourceData.GetString(mapping["thing"]),
503 eleP = SourceData.GetInt(mapping["eleP"]),
504 cooldown = SourceData.GetInt(mapping["cooldown"]),
505 charge = SourceData.GetInt(mapping["charge"]),
506 radius = SourceData.GetFloat(mapping["radius"]),
507 max = SourceData.GetInt(mapping["max"]),
508 req = SourceData.GetStringArray(mapping["req"]),
509 idTrainer = SourceData.GetString(mapping["idTrainer"]),
510 partySkill = SourceData.GetInt(mapping["partySkill"]),
511 tagTrainer = SourceData.GetString(mapping["tagTrainer"]),
512 levelBonus_JP = SourceData.GetString(mapping["levelBonus_JP"]),
513 levelBonus = SourceData.GetString(mapping["levelBonus"]),
514 foodEffect = SourceData.GetStringArray(mapping["foodEffect"]),
515 langAct = SourceData.GetStringArray(mapping["langAct"]),
516 detail_JP = SourceData.GetString(mapping["detail_JP"]),
517 detail = SourceData.GetString(mapping["detail"]),
518 textPhase_JP = SourceData.GetString(mapping["textPhase_JP"]),
519 textPhase = SourceData.GetString(mapping["textPhase"]),
520 textExtra_JP = SourceData.GetString(mapping["textExtra_JP"]),
521 textExtra = SourceData.GetString(mapping["textExtra"]),
522 textInc_JP = SourceData.GetString(mapping["textInc_JP"]),
523 textInc = SourceData.GetString(mapping["textInc"]),
524 textDec_JP = SourceData.GetString(mapping["textDec_JP"]),
525 textDec = SourceData.GetString(mapping["textDec"]),
526 textAlt_JP = SourceData.GetStringArray(mapping["textAlt_JP"]),
527 textAlt = SourceData.GetStringArray(mapping["textAlt"]),
528 adjective_JP = SourceData.GetStringArray(mapping["adjective_JP"]),
529 adjective = SourceData.GetStringArray(mapping["adjective"])
530 };
531 }
532
533 public override void SetRow(Row r)
534 {
535 map[r.id] = r;
536 }
537
538 public override IReadOnlyDictionary<string, int> GetRowMapping()
539 {
540 return RowMapping;
541 }
542
543 public override IReadOnlyDictionary<string, string> GetTypeMapping()
544 {
545 return TypeMapping;
546 }
547
548 public override void OnInit()
549 {
550 hobbies.Clear();
551 foreach (Row row in rows)
552 {
553 if (row.id >= 100 && row.id < 400)
554 {
555 hobbies.Add(row);
556 }
557 row.isAttribute = row.category == "attribute";
558 row.isPrimaryAttribute = row.isAttribute && row.tag.Contains("primary");
559 row.isSkill = row.category == "skill";
560 row.isSpell = row.categorySub == "spell";
561 row.isTrait = row.tag.Contains("trait");
562 }
563 fuzzyAlias.Clear();
564 foreach (string key in alias.Keys)
565 {
566 fuzzyAlias[key] = key;
567 }
568 }
569
570 public override void OnAfterImportData()
571 {
573 map.Clear();
574 alias.Clear();
575 foreach (Row row in rows)
576 {
577 map[row.id] = row;
578 alias[row.GetAlias] = row;
579 }
580 int num = 50000;
581 int num2 = 0;
582 for (int i = 910; i < 927; i++)
583 {
584 Row ele = EClass.sources.elements.map[i];
585 AddRow(ele, num + num2 + 100, "ball_");
586 AddRow(ele, num + num2 + 200, "breathe_");
587 AddRow(ele, num + num2 + 300, "bolt_");
588 AddRow(ele, num + num2 + 400, "hand_");
589 AddRow(ele, num + num2 + 500, "arrow_");
590 AddRow(ele, num + num2 + 600, "funnel_");
591 AddRow(ele, num + num2 + 700, "miasma_");
592 AddRow(ele, num + num2 + 800, "weapon_");
593 AddRow(ele, num + num2 + 900, "puddle_");
594 AddRow(ele, num + num2 + 1000, "sword_");
595 AddRow(ele, num + num2 + 1100, "bit_");
596 AddRow(ele, num + num2 + 1200, "flare_");
597 num2++;
598 }
599 initialized = false;
600 }
601
602 public void AddRow(Row ele, int id, string idOrg)
603 {
604 if (map.ContainsKey(id))
605 {
606 return;
607 }
608 Row row = EClass.sources.elements.alias[idOrg];
609 Dictionary<string, System.Reflection.FieldInfo> rowFields = row.GetRowFields();
610 Row row2 = new Row();
611 foreach (System.Reflection.FieldInfo value in rowFields.Values)
612 {
613 value.SetValue(row2, value.GetValue(row));
614 }
615 row2.id = id;
616 row2.idMold = row.id;
617 row2.alias = row.alias + ele.alias.Remove(0, 3);
618 row2.aliasRef = ele.alias;
619 row2.aliasParent = ele.aliasParent;
620 row2.chance = row.chance * ele.chance / 100;
621 row2.LV = row.LV;
622 row2.OnImportData(EClass.sources.elements);
623 rows.Add(row2);
624 }
625}
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:119
Icons icons
Definition: CoreRef.cs:356
Definition: Core.cs:14
CoreRef refs
Definition: Core.cs:51
static Core SetCurrent(Core _current=null)
Definition: Core.cs:591
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:317
static float GetFloat(int id)
Definition: SourceData.cs:968
static string[] GetStringArray(int id)
Definition: SourceData.cs:983
static string GetString(int id)
Definition: SourceData.cs:988
static int GetInt(int id)
Definition: SourceData.cs:953
static int[] GetIntArray(int id)
Definition: SourceData.cs:978
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