Elin Modding Docs Doc
Loading...
Searching...
No Matches
ElementContainer.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.CompilerServices;
5using System.Runtime.Serialization;
6using Newtonsoft.Json;
7using UnityEngine;
8using UnityEngine.UI;
9
10// Token: 0x0200030A RID: 778
12{
13 // Token: 0x170006C5 RID: 1733
14 // (get) Token: 0x06001833 RID: 6195 RVA: 0x0009CCE9 File Offset: 0x0009AEE9
15 public virtual Card Card
16 {
17 get
18 {
19 return null;
20 }
21 }
22
23 // Token: 0x170006C6 RID: 1734
24 // (get) Token: 0x06001834 RID: 6196 RVA: 0x0009CCEC File Offset: 0x0009AEEC
25 public virtual Chara Chara
26 {
27 get
28 {
29 return null;
30 }
31 }
32
33 // Token: 0x170006C7 RID: 1735
34 // (get) Token: 0x06001835 RID: 6197 RVA: 0x0009CCEF File Offset: 0x0009AEEF
35 public virtual bool IsMeleeWeapon
36 {
37 get
38 {
39 return false;
40 }
41 }
42
43 // Token: 0x06001836 RID: 6198 RVA: 0x0009CCF4 File Offset: 0x0009AEF4
44 [OnSerializing]
45 private void OnSerializing(StreamingContext context)
46 {
47 this.list = new List<int>();
48 foreach (Element element in this.dict.Values)
49 {
50 if (element.vBase != 0 || element.vExp != 0 || element.vPotential != 0 || element.vTempPotential != 0)
51 {
52 this.list.AddRange(new int[]
53 {
54 element.id,
55 element.vBase,
56 element.vExp,
57 element.vPotential,
58 element.vTempPotential
59 });
60 }
61 }
62 if (this.list.Count == 0)
63 {
64 this.list = null;
65 }
66 }
67
68 // Token: 0x06001837 RID: 6199 RVA: 0x0009CDC4 File Offset: 0x0009AFC4
69 [OnDeserialized]
70 private void OnDeserialized(StreamingContext context)
71 {
72 if (this.list != null)
73 {
74 for (int i = 0; i < this.list.Count; i += 5)
75 {
76 Element orCreateElement = this.GetOrCreateElement(this.list[i]);
77 if (orCreateElement != null)
78 {
79 orCreateElement.vBase += this.list[i + 1];
80 orCreateElement.vExp += this.list[i + 2];
81 orCreateElement.vPotential += this.list[i + 3];
82 orCreateElement.vTempPotential = this.list[i + 4];
83 orCreateElement.owner = this;
84 }
85 }
86 }
87 }
88
89 // Token: 0x06001838 RID: 6200 RVA: 0x0009CE7C File Offset: 0x0009B07C
90 public void ApplyElementMap(int uid, SourceValueType type, Dictionary<int, int> map, int lv, bool invert = false, bool applyFeat = false)
91 {
92 int num = invert ? -1 : 1;
93 Rand.SetSeed(uid);
94 foreach (KeyValuePair<int, int> keyValuePair in map)
95 {
96 Element orCreateElement = this.GetOrCreateElement(keyValuePair.Key);
97 int value = keyValuePair.Value;
98 if (value != 0)
99 {
100 if (orCreateElement.source.category == "skill")
101 {
102 orCreateElement.vSourcePotential += orCreateElement.GetSourcePotential(value) * num;
103 }
104 int num2 = orCreateElement.GetSourceValue(value, lv, type) * num;
105 orCreateElement.vSource += num2;
106 if (applyFeat && orCreateElement is Feat)
107 {
108 (orCreateElement as Feat).Apply(num2, this, false);
109 }
110 }
111 }
112 Rand.SetSeed(-1);
113 }
114
115 // Token: 0x06001839 RID: 6201 RVA: 0x0009CF64 File Offset: 0x0009B164
116 public void ApplyMaterialElementMap(Thing t, bool invert = false)
117 {
118 int num = invert ? -1 : 1;
119 SourceMaterial.Row material = t.material;
120 Rand.SetSeed(t.uid);
121 foreach (KeyValuePair<int, int> keyValuePair in material.elementMap)
122 {
123 int value = keyValuePair.Value;
124 if (value != 0)
125 {
126 Element orCreateElement = this.GetOrCreateElement(keyValuePair.Key);
127 if (!orCreateElement.source.IsEncAppliable(t))
128 {
129 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vExp == 0 && orCreateElement.vPotential == 0)
130 {
131 this.Remove(orCreateElement.id);
132 }
133 }
134 else
135 {
136 int num2 = orCreateElement.GetMaterialSourceValue(t, value) * num;
137 orCreateElement.vSource += num2;
138 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vExp == 0 && orCreateElement.vPotential == 0)
139 {
140 this.Remove(orCreateElement.id);
141 }
142 }
143 }
144 }
145 Rand.SetSeed(-1);
146 }
147
148 // Token: 0x0600183A RID: 6202 RVA: 0x0009D09C File Offset: 0x0009B29C
149 public void ImportElementMap(Dictionary<int, int> map)
150 {
151 foreach (KeyValuePair<int, int> keyValuePair in map)
152 {
153 this.GetOrCreateElement(keyValuePair.Key).vSource += keyValuePair.Value;
154 }
155 }
156
157 // Token: 0x0600183B RID: 6203 RVA: 0x0009D104 File Offset: 0x0009B304
158 public ElementContainer ImportElementMap(int[] ints)
159 {
160 for (int i = 0; i < ints.Length; i += 2)
161 {
162 this.GetOrCreateElement(ints[i]).vSource += ints[i + 1];
163 }
164 return this;
165 }
166
167 // Token: 0x0600183C RID: 6204 RVA: 0x0009D13C File Offset: 0x0009B33C
168 public void ApplyPotential(int mode = 0)
169 {
170 foreach (Element element in this.dict.Values)
171 {
172 if (element.HasTag("primary"))
173 {
174 element.vTempPotential = (element.ValueWithoutLink - ((mode == 2) ? 0 : 7)) * 5;
175 }
176 }
177 }
178
179 // Token: 0x0600183D RID: 6205 RVA: 0x0009D1B4 File Offset: 0x0009B3B4
180 public int Value(int ele)
181 {
182 Element element = this.GetElement(ele);
183 if (element != null)
184 {
185 return element.Value;
186 }
187 if (EClass.core.game == null || this.Card == null || !this.Card.IsPCFactionOrMinion)
188 {
189 return 0;
190 }
191 if (ele != 78)
192 {
193 return EClass.pc.faction.charaElements.Value(ele);
194 }
195 return this.GetOrCreateElement(ele).Value;
196 }
197
198 // Token: 0x0600183E RID: 6206 RVA: 0x0009D21C File Offset: 0x0009B41C
199 public virtual int ValueBonus(Element e)
200 {
201 return 0;
202 }
203
204 // Token: 0x0600183F RID: 6207 RVA: 0x0009D21F File Offset: 0x0009B41F
205 public int ValueWithoutLink(int ele)
206 {
207 Element element = this.GetElement(ele);
208 if (element == null)
209 {
210 return 0;
211 }
212 return element.ValueWithoutLink;
213 }
214
215 // Token: 0x06001840 RID: 6208 RVA: 0x0009D233 File Offset: 0x0009B433
216 public int ValueWithoutLink(string alias)
217 {
218 Element element = this.GetElement(alias);
219 if (element == null)
220 {
221 return 0;
222 }
223 return element.ValueWithoutLink;
224 }
225
226 // Token: 0x06001841 RID: 6209 RVA: 0x0009D248 File Offset: 0x0009B448
227 public int GetFeatRef(int ele, int idx = 0)
228 {
229 Feat feat = this.GetElement(ele) as Feat;
230 if (feat == null)
231 {
232 return 0;
233 }
234 feat.Apply(feat.Value, this, false);
235 return Feat.featRef[idx].ToInt();
236 }
237
238 // Token: 0x06001842 RID: 6210 RVA: 0x0009D282 File Offset: 0x0009B482
239 public int Exp(int ele)
240 {
241 Element element = this.GetElement(ele);
242 if (element == null)
243 {
244 return 0;
245 }
246 return element.vExp;
247 }
248
249 // Token: 0x06001843 RID: 6211 RVA: 0x0009D296 File Offset: 0x0009B496
250 public bool Has(int ele)
251 {
252 Element element = this.GetElement(ele);
253 return element != null && element.Value > 0;
254 }
255
256 // Token: 0x06001844 RID: 6212 RVA: 0x0009D2AD File Offset: 0x0009B4AD
257 public bool Has(SourceElement.Row row)
258 {
259 return this.Has(row.id);
260 }
261
262 // Token: 0x06001845 RID: 6213 RVA: 0x0009D2BB File Offset: 0x0009B4BB
263 public bool Has(string alias)
264 {
265 return this.Has(EClass.sources.elements.alias[alias].id);
266 }
267
268 // Token: 0x06001846 RID: 6214 RVA: 0x0009D2E0 File Offset: 0x0009B4E0
269 public bool HasBase(int ele)
270 {
271 Element element = this.GetElement(ele);
272 if (element == null)
273 {
274 return false;
275 }
276 int num = element.ValueWithoutLink;
277 if (ele != 300)
278 {
279 if (ele == 307)
280 {
281 num += this.Value(1524) * -4;
282 num += this.Value(1525) * 4;
283 }
284 }
285 else
286 {
287 num += this.Value(1516) * -4;
288 num += this.Value(1517) * 4;
289 }
290 return num != 0;
291 }
292
293 // Token: 0x06001847 RID: 6215 RVA: 0x0009D35B File Offset: 0x0009B55B
294 public int Base(int ele)
295 {
296 Element element = this.GetElement(ele);
297 if (element == null)
298 {
299 return 0;
300 }
301 return element.ValueWithoutLink;
302 }
303
304 // Token: 0x06001848 RID: 6216 RVA: 0x0009D36F File Offset: 0x0009B56F
305 public void Learn(int ele, int v = 1)
306 {
307 this.ModBase(ele, v);
308 this.OnLearn(ele);
309 }
310
311 // Token: 0x06001849 RID: 6217 RVA: 0x0009D381 File Offset: 0x0009B581
312 public void Train(int ele, int a = 10)
313 {
314 this.OnTrain(ele);
315 this.ModTempPotential(ele, a, 0);
316 }
317
318 // Token: 0x0600184A RID: 6218 RVA: 0x0009D394 File Offset: 0x0009B594
319 public void ModExp(int ele, int a, bool chain = false)
320 {
321 if (this.Card != null && this.Card.isChara && this.Card.Chara.isDead)
322 {
323 return;
324 }
325 if (a == 0)
326 {
327 return;
328 }
329 Element element = this.GetElement(ele);
330 if (element == null || !element.CanGainExp)
331 {
332 return;
333 }
334 int value = element.UsePotential ? element.Potential : 100;
335 if (element.UseExpMod)
336 {
337 a = a * Mathf.Clamp(value, 10, 1000) / (100 + Mathf.Max(0, element.ValueWithoutLink) * 25);
338 if (a >= 0 && EClass.rnd(element.ValueWithoutLink + 1) < 10)
339 {
340 a++;
341 }
342 }
343 element.vExp += a;
344 if (!chain && element.source.parentFactor > 0f && this.Card != null && !element.source.aliasParent.IsEmpty())
345 {
346 Element element2 = element.GetParent(this.Card);
347 if (element2.CanGainExp)
348 {
349 this.ModExp(element2.id, (int)Math.Max(1f, (float)a * element.source.parentFactor / 100f), true);
350 }
351 }
352 if (element.vExp >= element.ExpToNext)
353 {
354 int num = element.vExp - element.ExpToNext;
355 int vBase = element.vBase;
356 this.ModBase(ele, 1);
357 this.OnLevelUp(element, vBase);
358 element.vExp = Mathf.Clamp(num / 2, 0, element.ExpToNext / 2);
359 if (element.vTempPotential > 0)
360 {
361 element.vTempPotential -= element.vTempPotential / 4 + EClass.rnd(5) + 5;
362 if (element.vTempPotential < 0)
363 {
364 element.vTempPotential = 0;
365 return;
366 }
367 }
368 else if (element.vTempPotential < 0)
369 {
370 element.vTempPotential += -element.vTempPotential / 4 + EClass.rnd(5) + 5;
371 if (element.vTempPotential > 0)
372 {
373 element.vTempPotential = 0;
374 return;
375 }
376 }
377 }
378 else if (element.vExp < 0)
379 {
380 if (element.ValueWithoutLink <= 1)
381 {
382 element.vExp = 0;
383 return;
384 }
385 int vBase2 = element.vBase;
386 this.ModBase(ele, -1);
387 this.OnLevelDown(element, vBase2);
388 element.vExp = Mathf.Max(element.ExpToNext / 2, element.ExpToNext + element.vExp);
389 }
390 }
391
392 // Token: 0x0600184B RID: 6219 RVA: 0x0009D5D3 File Offset: 0x0009B7D3
393 public virtual void OnLearn(int ele)
394 {
395 }
396
397 // Token: 0x0600184C RID: 6220 RVA: 0x0009D5D5 File Offset: 0x0009B7D5
398 public virtual void OnTrain(int ele)
399 {
400 }
401
402 // Token: 0x0600184D RID: 6221 RVA: 0x0009D5D7 File Offset: 0x0009B7D7
403 public virtual void OnLevelUp(Element e, int lastValue)
404 {
405 }
406
407 // Token: 0x0600184E RID: 6222 RVA: 0x0009D5D9 File Offset: 0x0009B7D9
408 public virtual void OnLevelDown(Element e, int lastValue)
409 {
410 }
411
412 // Token: 0x0600184F RID: 6223 RVA: 0x0009D5DB File Offset: 0x0009B7DB
413 public Element SetBase(string alias, int v, int potential = 0)
414 {
415 return this.SetBase(EClass.sources.elements.alias[alias].id, v, potential);
416 }
417
418 // Token: 0x06001850 RID: 6224 RVA: 0x0009D600 File Offset: 0x0009B800
419 public Element SetBase(int id, int v, int potential = 0)
420 {
421 Element orCreateElement = this.GetOrCreateElement(id);
422 if (this.parent != null && orCreateElement.CanLink(this))
423 {
424 this.parent.ModLink(id, -orCreateElement.vBase + v);
425 }
426 orCreateElement.vBase = v;
427 orCreateElement.vExp = 0;
428 orCreateElement.vPotential = potential;
429 orCreateElement.OnChangeValue();
430 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
431 {
432 this.Remove(orCreateElement.id);
433 }
434 return orCreateElement;
435 }
436
437 // Token: 0x06001851 RID: 6225 RVA: 0x0009D68C File Offset: 0x0009B88C
438 public void SetTo(int id, int v)
439 {
440 Element orCreateElement = this.GetOrCreateElement(id);
441 int num = v - (orCreateElement.vBase + orCreateElement.vSource);
442 if (num != 0)
443 {
444 this.ModBase(id, num);
445 }
446 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
447 {
448 this.Remove(orCreateElement.id);
449 }
450 }
451
452 // Token: 0x06001852 RID: 6226 RVA: 0x0009D6F4 File Offset: 0x0009B8F4
453 public void Remove(int id)
454 {
455 Element element = this.GetElement(id);
456 if (element == null)
457 {
458 return;
459 }
460 if (this.parent != null && element.CanLink(this))
461 {
462 this.parent.ModLink(id, -element.Value);
463 }
464 this.dict.Remove(id);
465 }
466
467 // Token: 0x06001853 RID: 6227 RVA: 0x0009D740 File Offset: 0x0009B940
468 public Element ModBase(int ele, int v)
469 {
470 Element orCreateElement = this.GetOrCreateElement(ele);
471 orCreateElement.vBase += v;
472 if (this.parent != null && orCreateElement.CanLink(this))
473 {
474 this.parent.ModLink(ele, v);
475 }
476 orCreateElement.CheckLevelBonus(this, null);
477 orCreateElement.OnChangeValue();
478 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
479 {
480 this.Remove(orCreateElement.id);
481 }
482 return orCreateElement;
483 }
484
485 // Token: 0x06001854 RID: 6228 RVA: 0x0009D7C5 File Offset: 0x0009B9C5
486 public virtual void OnChangeValue()
487 {
488 }
489
490 // Token: 0x06001855 RID: 6229 RVA: 0x0009D7C8 File Offset: 0x0009B9C8
491 public Element ModPotential(int ele, int v)
492 {
493 Element orCreateElement = this.GetOrCreateElement(ele);
494 orCreateElement.vPotential += v;
495 if (orCreateElement.vPotential > 1000)
496 {
497 orCreateElement.vPotential = 1000;
498 }
499 return orCreateElement;
500 }
501
502 // Token: 0x06001856 RID: 6230 RVA: 0x0009D804 File Offset: 0x0009BA04
503 public Element ModTempPotential(int ele, int v, int threshMsg = 0)
504 {
505 Element orCreateElement = this.GetOrCreateElement(ele);
506 orCreateElement.vTempPotential += v;
507 if (orCreateElement.vTempPotential > 1000)
508 {
509 orCreateElement.vTempPotential = 1000;
510 }
511 this.OnModTempPotential(orCreateElement, v, threshMsg);
512 return orCreateElement;
513 }
514
515 // Token: 0x06001857 RID: 6231 RVA: 0x0009D849 File Offset: 0x0009BA49
516 public virtual void OnModTempPotential(Element e, int v, int threshMsg)
517 {
518 }
519
520 // Token: 0x06001858 RID: 6232 RVA: 0x0009D84C File Offset: 0x0009BA4C
521 private Element ModLink(int id, int v)
522 {
523 Element orCreateElement = this.GetOrCreateElement(id);
524 orCreateElement.vLink += v;
525 orCreateElement.OnChangeValue();
526 if (this.parent != null && orCreateElement.CanLink(this))
527 {
528 this.parent.ModLink(id, v);
529 }
530 return orCreateElement;
531 }
532
533 // Token: 0x06001859 RID: 6233 RVA: 0x0009D898 File Offset: 0x0009BA98
534 public int GetSpellExp(Chara c, Element e, int costMod = 100)
535 {
536 Act.Cost cost = e.GetCost(c);
537 int num = cost.cost * ((cost.type == Act.CostType.SP) ? 20 : 5) * (100 + c.Evalue(1208) * 30) / 100 + 10;
538 num = num * costMod / 100;
539 if (!e.source.aliasParent.IsEmpty())
540 {
541 int num2 = this.ValueWithoutLink(e.source.aliasParent) - this.ValueWithoutLink(e.source.id);
542 if (num2 >= 0)
543 {
544 num = num * (100 + num2 * 5) / 100;
545 }
546 else
547 {
548 num = num * 100 / (100 - num2 * 25);
549 }
550 }
551 if (num < 0)
552 {
553 num = 0;
554 }
555 return num;
556 }
557
558 // Token: 0x0600185A RID: 6234 RVA: 0x0009D93E File Offset: 0x0009BB3E
559 public Element GetElement(string alias)
560 {
561 return this.GetElement(EClass.sources.elements.alias[alias].id);
562 }
563
564 // Token: 0x0600185B RID: 6235 RVA: 0x0009D960 File Offset: 0x0009BB60
565 public Element GetElement(int id)
566 {
567 return this.dict.TryGetValue(id, null);
568 }
569
570 // Token: 0x0600185C RID: 6236 RVA: 0x0009D970 File Offset: 0x0009BB70
571 public Element CreateElement(int id)
572 {
573 Element element = Element.Create(id, 0);
574 if (element == null)
575 {
576 return null;
577 }
578 element.owner = this;
579 this.dict.Add(id, element);
580 return element;
581 }
582
583 // Token: 0x0600185D RID: 6237 RVA: 0x0009D99F File Offset: 0x0009BB9F
584 public Element GetOrCreateElement(Element ele)
585 {
586 return this.GetOrCreateElement(ele.id);
587 }
588
589 // Token: 0x0600185E RID: 6238 RVA: 0x0009D9AD File Offset: 0x0009BBAD
590 public Element GetOrCreateElement(string alias)
591 {
592 return this.GetOrCreateElement(EClass.sources.elements.alias[alias].id);
593 }
594
595 // Token: 0x0600185F RID: 6239 RVA: 0x0009D9D0 File Offset: 0x0009BBD0
596 public Element GetOrCreateElement(int id)
597 {
598 Element result = null;
599 if (!this.dict.TryGetValue(id, out result))
600 {
601 result = this.CreateElement(id);
602 }
603 return result;
604 }
605
606 // Token: 0x06001860 RID: 6240 RVA: 0x0009D9F8 File Offset: 0x0009BBF8
607 public void SetParent(Card c)
608 {
609 this.SetParent((c != null) ? c.elements : null);
610 }
611
612 // Token: 0x06001861 RID: 6241 RVA: 0x0009DA0C File Offset: 0x0009BC0C
613 public void SetParent(ElementContainer newParent = null)
614 {
615 if (this.parent != null)
616 {
617 foreach (Element element in this.dict.Values)
618 {
619 if (element.CanLink(this))
620 {
621 this.parent.ModLink(element.id, -(element.vBase + element.vSource));
622 }
623 }
624 }
625 if (newParent != null)
626 {
627 foreach (Element element2 in this.dict.Values)
628 {
629 if (element2.CanLink(this))
630 {
631 newParent.ModLink(element2.id, element2.vBase + element2.vSource);
632 }
633 }
634 }
635 this.parent = newParent;
636 }
637
638 // Token: 0x06001862 RID: 6242 RVA: 0x0009DAFC File Offset: 0x0009BCFC
639 public List<Element> ListElements(Func<Element, bool> shoudList = null, Comparison<Element> comparison = null)
640 {
641 List<Element> list = new List<Element>();
642 ElementContainer.<>c__DisplayClass55_0 CS$<>8__locals1;
643 CS$<>8__locals1.eles = this.dict.Values.ToList<Element>();
644 if (this.Card != null && this.Card.Chara != null)
645 {
646 if (this.Card.Chara.IsPCFaction)
647 {
648 ElementContainer.<ListElements>g__AddElements|55_0(EClass.pc.faction.charaElements, ref CS$<>8__locals1);
649 }
650 ElementContainer.<ListElements>g__AddElements|55_0(this.Card.Chara.faithElements, ref CS$<>8__locals1);
651 }
652 foreach (Element element in CS$<>8__locals1.eles)
653 {
654 if (shoudList == null || shoudList(element))
655 {
656 list.Add(element);
657 }
658 }
659 if (comparison != null)
660 {
661 list.Sort(comparison);
662 }
663 return list;
664 }
665
666 // Token: 0x06001863 RID: 6243 RVA: 0x0009DBD8 File Offset: 0x0009BDD8
667 public List<Element> ListBestAttributes()
668 {
669 List<Element> list = this.ListElements((Element a) => a.HasTag("primary"), null);
670 list.Sort((Element a, Element b) => (b.ValueWithoutLink - a.ValueWithoutLink) * 100000 + a.id - b.id);
671 return list;
672 }
673
674 // Token: 0x06001864 RID: 6244 RVA: 0x0009DC30 File Offset: 0x0009BE30
675 public List<Element> ListBestSkills()
676 {
677 List<Element> list = this.ListElements((Element a) => a.source.category == "skill", null);
678 list.Sort((Element a, Element b) => (b.ValueWithoutLink - a.ValueWithoutLink) * 100000 + a.id - b.id);
679 return list;
680 }
681
682 // Token: 0x06001865 RID: 6245 RVA: 0x0009DC88 File Offset: 0x0009BE88
683 public List<Element> ListGeneFeats()
684 {
685 return this.ListElements((Element a) => a.Value > 0 && a.source.category == "feat" && a.source.cost.Length != 0 && a.source.cost[0] > 0, null);
686 }
687
688 // Token: 0x06001866 RID: 6246 RVA: 0x0009DCB0 File Offset: 0x0009BEB0
689 public List<Element> ListLearnable(Chara c)
690 {
691 List<Element> list = new List<Element>();
692 foreach (KeyValuePair<int, Element> keyValuePair in c.elements.dict)
693 {
694 if (!this.dict.ContainsKey(keyValuePair.Key))
695 {
696 list.Add(keyValuePair.Value);
697 }
698 }
699 return list;
700 }
701
702 // Token: 0x06001867 RID: 6247 RVA: 0x0009DD2C File Offset: 0x0009BF2C
703 public void CopyTo(ElementContainer container)
704 {
705 container.dict.Clear();
706 foreach (KeyValuePair<int, Element> keyValuePair in this.dict)
707 {
708 Element element = container.CreateElement(keyValuePair.Key);
709 element.vBase = keyValuePair.Value.vBase;
710 element.vExp = keyValuePair.Value.vExp;
711 element.vSource = keyValuePair.Value.vSource;
712 }
713 }
714
715 // Token: 0x06001868 RID: 6248 RVA: 0x0009DDC8 File Offset: 0x0009BFC8
716 public static int GetSortVal(Element a)
717 {
718 int num = a.Value;
719 if (a.source.textAlt.Length <= 2 || a.Value < 0)
720 {
721 num -= 100000;
722 }
723 if (a.id == 2)
724 {
725 num += 20000;
726 }
727 if (a.IsFoodTraitMain)
728 {
729 num += 10000;
730 }
731 return num;
732 }
733
734 // Token: 0x06001869 RID: 6249 RVA: 0x0009DE20 File Offset: 0x0009C020
735 public void AddNote(UINote n, Func<Element, bool> isValid = null, Action onAdd = null, ElementContainer.NoteMode mode = ElementContainer.NoteMode.Default, bool addRaceFeat = false, Func<Element, string, string> funcText = null, Action<UINote, Element> onAddNote = null)
736 {
737 List<Element> list = new List<Element>();
738 foreach (Element element in this.dict.Values)
739 {
740 if ((isValid == null || isValid(element)) && (mode != ElementContainer.NoteMode.CharaMake || element.ValueWithoutLink != 0) && (element.Value != 0 || mode == ElementContainer.NoteMode.CharaMakeAttributes) && (!element.HasTag("hidden") || EClass.debug.showExtra))
741 {
742 list.Add(element);
743 }
744 }
745 if (addRaceFeat)
746 {
747 Element element2 = Element.Create(29, 1);
748 element2.owner = this;
749 list.Add(element2);
750 }
751 if (list.Count == 0)
752 {
753 return;
754 }
755 if (onAdd != null)
756 {
757 onAdd();
758 }
759 if (mode - ElementContainer.NoteMode.CharaMake > 1)
760 {
761 if (mode != ElementContainer.NoteMode.Trait)
762 {
763 list.Sort((Element a, Element b) => a.SortVal(false) - b.SortVal(false));
764 }
765 else
766 {
767 list.Sort((Element a, Element b) => ElementContainer.GetSortVal(b) - ElementContainer.GetSortVal(a));
768 }
769 }
770 else
771 {
772 list.Sort((Element a, Element b) => a.GetSortVal(UIList.SortMode.ByElementParent) - b.GetSortVal(UIList.SortMode.ByElementParent));
773 }
774 using (List<Element>.Enumerator enumerator2 = list.GetEnumerator())
775 {
776 while (enumerator2.MoveNext())
777 {
778 Element e = enumerator2.Current;
779 switch (mode)
780 {
781 case ElementContainer.NoteMode.Default:
782 case ElementContainer.NoteMode.Trait:
783 {
784 bool flag = e.source.tag.Contains("common");
785 string categorySub = e.source.categorySub;
786 bool flag2 = false;
787 bool flag3 = e.source.tag.Contains("neg") ? (e.Value > 0) : (e.Value < 0);
788 int num = Mathf.Abs(e.Value);
789 bool flag4 = this.Card != null && this.Card.ShowFoodEnc;
790 bool flag5 = this.Card != null && this.Card.IsWeapon && e is Ability;
791 string text;
792 if (e.IsTrait || (flag4 && e.IsFoodTrait))
793 {
794 string[] textArray = e.source.GetTextArray("textAlt");
795 int num2 = Mathf.Clamp(e.Value / 10 + 1, (e.Value >= 0 && textArray.Length > 2) ? 2 : 1, textArray.Length - 1);
796 text = "altEnc".lang(textArray[0].IsEmpty(e.Name), textArray[num2], EClass.debug.showExtra ? (e.Value.ToString() + " " + e.Name) : "", null, null);
797 flag3 = (num2 <= 1 || textArray.Length <= 2);
798 flag2 = true;
799 }
800 else if (flag5)
801 {
802 text = "isProc".lang(e.Name, null, null, null, null);
803 flag3 = false;
804 }
805 else if (categorySub == "resist")
806 {
807 text = ("isResist" + (flag3 ? "Neg" : "")).lang(e.Name, null, null, null, null);
808 }
809 else if (categorySub == "eleAttack")
810 {
811 text = "isEleAttack".lang(e.Name, null, null, null, null);
812 }
813 else if (!e.source.textPhase.IsEmpty() && e.Value > 0)
814 {
815 text = e.source.GetText("textPhase", false);
816 }
817 else
818 {
819 string name = e.Name;
820 bool flag6 = e.source.category == "skill" || (e.source.category == "attribute" && !e.source.textPhase.IsEmpty());
821 bool flag7 = e.source.category == "enchant";
822 if (e.source.tag.Contains("multiplier"))
823 {
824 flag7 = (flag6 = false);
825 name = EClass.sources.elements.alias[e.source.aliasRef].GetName();
826 }
827 flag2 = (!flag6 && !flag7);
828 text = (flag6 ? "textEncSkill" : (flag7 ? "textEncEnc" : "textEnc")).lang(name, num.ToString() + (e.source.tag.Contains("ratio") ? "%" : ""), ((e.Value > 0) ? "encIncrease" : "encDecrease").lang(), null, null);
829 }
830 int num3 = (e is Resistance) ? 0 : 1;
831 if (!flag && !flag2 && !e.source.tag.Contains("flag"))
832 {
833 text = string.Concat(new string[]
834 {
835 text,
836 " [",
837 "*".Repeat(Mathf.Clamp(num * e.source.mtp / 5 + num3, 1, 5)),
838 (num * e.source.mtp / 5 + num3 > 5) ? "+" : "",
839 "]"
840 });
841 }
842 if (e.HasTag("hidden"))
843 {
844 text = "(debug)" + text;
845 }
846 FontColor color = flag ? FontColor.Default : (flag3 ? FontColor.Bad : FontColor.Good);
847 if (e.IsGlobalElement)
848 {
849 text = text + " " + (e.IsFactionWideElement ? "_factionWide" : "_partyWide").lang();
850 if (this.Card != null && !this.Card.c_idDeity.IsEmpty() && this.Card.c_idDeity != EClass.pc.idFaith)
851 {
852 continue;
853 }
854 color = FontColor.Myth;
855 }
856 if (flag4 && e.IsFoodTrait && !e.IsFoodTraitMain)
857 {
858 color = FontColor.FoodMisc;
859 }
860 if (e.id == 2 && e.Value >= 0)
861 {
862 color = FontColor.FoodQuality;
863 }
864 if (funcText != null)
865 {
866 text = funcText(e, text);
867 }
868 n.AddText("NoteText_prefwidth", text, color);
869 if (onAddNote != null)
870 {
871 onAddNote(n, e);
872 continue;
873 }
874 continue;
875 }
876 case ElementContainer.NoteMode.Domain:
877 n.AddText(e.Name, FontColor.Default);
878 continue;
879 }
880 UIItem uiitem = n.AddTopic("TopicAttribute", e.Name, "".TagColor((e.ValueWithoutLink > 0) ? SkinManager.CurrentColors.textGood : SkinManager.CurrentColors.textBad, e.ValueWithoutLink.ToString() ?? ""));
881 if (uiitem.button1)
882 {
883 uiitem.button1.tooltip.onShowTooltip = delegate(UITooltip t)
884 {
885 e.WriteNote(t.note, EClass.pc.elements, null);
886 };
887 }
888 e.SetImage(uiitem.image1);
889 Image image = uiitem.image2;
890 int value = (e.Potential - 80) / 20;
891 image.enabled = (e.Potential != 80);
892 image.sprite = EClass.core.refs.spritesPotential[Mathf.Clamp(Mathf.Abs(value), 0, EClass.core.refs.spritesPotential.Count - 1)];
893 image.color = ((e.Potential - 80 >= 0) ? Color.white : new Color(1f, 0.7f, 0.7f));
894 }
895 }
896 }
897
898 // Token: 0x0600186A RID: 6250 RVA: 0x0009E72C File Offset: 0x0009C92C
899 public void AddNoteAll(UINote n)
900 {
901 Transform transform = n.AddExtra<Transform>("noteRace");
902 UINote n2 = transform.Find("note1").GetComponent<UINote>();
903 UINote n3 = transform.Find("note2").GetComponent<UINote>();
904 this.AddNote(n3, (Element e) => e.HasTag("primary"), delegate
905 {
906 n3.AddHeader("HeaderNoteSmall", "attributes", null);
907 }, ElementContainer.NoteMode.CharaMakeAttributes, false, null, null);
908 this.AddNote(n2, (Element e) => e.source.category == "skill" && !e.HasTag("hidden") && e.ValueWithoutLink > 1 && e.source.categorySub != "weapon", delegate
909 {
910 n2.AddHeader("HeaderNoteSmall", "skills", null);
911 }, ElementContainer.NoteMode.CharaMake, false, null, null);
912 this.AddNote(n2, (Element e) => e is Feat, delegate
913 {
914 n2.AddHeader("HeaderNoteSmall", "feats", null);
915 }, ElementContainer.NoteMode.CharaMake, false, null, null);
916 }
917
918 // Token: 0x0600186C RID: 6252 RVA: 0x0009E83C File Offset: 0x0009CA3C
919 [CompilerGenerated]
920 internal static void <ListElements>g__AddElements|55_0(ElementContainer container, ref ElementContainer.<>c__DisplayClass55_0 A_1)
921 {
922 if (container == null)
923 {
924 return;
925 }
926 foreach (Element element in container.dict.Values)
927 {
928 bool flag = true;
929 foreach (Element element2 in A_1.eles)
930 {
931 if (element.id == element2.id)
932 {
933 flag = false;
934 break;
935 }
936 }
937 if (flag && element.Value != 0)
938 {
939 A_1.eles.Add(element);
940 }
941 }
942 }
943
944 // Token: 0x040010A1 RID: 4257
945 public Dictionary<int, Element> dict = new Dictionary<int, Element>();
946
947 // Token: 0x040010A2 RID: 4258
948 public ElementContainer parent;
949
950 // Token: 0x040010A3 RID: 4259
951 public const int sizeElement = 5;
952
953 // Token: 0x040010A4 RID: 4260
954 [JsonProperty(PropertyName = "A")]
955 public List<int> list;
956
957 // Token: 0x02000983 RID: 2435
958 public enum NoteMode
959 {
960 // Token: 0x040027CF RID: 10191
961 Default,
962 // Token: 0x040027D0 RID: 10192
963 CharaMake,
964 // Token: 0x040027D1 RID: 10193
965 CharaMakeAttributes,
966 // Token: 0x040027D2 RID: 10194
967 Domain,
968 // Token: 0x040027D3 RID: 10195
969 Trait
970 }
971}
Definition Act.2.cs:7
Definition Card.cs:13
Definition Chara.cs:12
Definition Feat.2.cs:8
Definition Thing.cs:10
Definition Trait.cs:9