Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ElementContainer.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.Serialization;
5using Newtonsoft.Json;
6using UnityEngine;
7using UnityEngine.UI;
8
9public class ElementContainer : EClass
10{
11 public enum NoteMode
12 {
13 Default,
16 Domain,
17 Trait
18 }
19
20 public Dictionary<int, Element> dict = new Dictionary<int, Element>();
21
23
24 public const int sizeElement = 5;
25
26 [JsonProperty(PropertyName = "A")]
27 public List<int> list;
28
29 public virtual Card Card => null;
30
31 public virtual Chara Chara => null;
32
33 public virtual bool IsMeleeWeapon => false;
34
36 private void OnSerializing(StreamingContext context)
37 {
38 list = new List<int>();
39 foreach (Element value in dict.Values)
40 {
41 if (value.vBase != 0 || value.vExp != 0 || value.vPotential != 0 || value.vTempPotential != 0)
42 {
43 list.AddRange(new int[5] { value.id, value.vBase, value.vExp, value.vPotential, value.vTempPotential });
44 }
45 }
46 if (list.Count == 0)
47 {
48 list = null;
49 }
50 }
51
53 private void OnDeserialized(StreamingContext context)
54 {
55 if (list == null)
56 {
57 return;
58 }
59 for (int i = 0; i < list.Count; i += 5)
60 {
61 Element orCreateElement = GetOrCreateElement(list[i]);
62 if (orCreateElement != null)
63 {
64 orCreateElement.vBase += list[i + 1];
65 orCreateElement.vExp += list[i + 2];
66 orCreateElement.vPotential += list[i + 3];
67 orCreateElement.vTempPotential = list[i + 4];
68 orCreateElement.owner = this;
69 }
70 }
71 }
72
73 public void ApplyElementMap(int uid, SourceValueType type, Dictionary<int, int> map, int lv, bool invert = false, bool applyFeat = false)
74 {
75 int num = ((!invert) ? 1 : (-1));
76 Rand.SetSeed(uid);
77 foreach (KeyValuePair<int, int> item in map)
78 {
79 Element orCreateElement = GetOrCreateElement(item.Key);
80 int value = item.Value;
81 if (value != 0)
82 {
83 if (orCreateElement.source.category == "skill")
84 {
85 orCreateElement.vSourcePotential += orCreateElement.GetSourcePotential(value) * num;
86 }
87 int num2 = orCreateElement.GetSourceValue(value, lv, type) * num;
88 orCreateElement.vSource += num2;
89 if (applyFeat && orCreateElement is Feat)
90 {
91 (orCreateElement as Feat).Apply(num2, this);
92 }
93 }
94 }
95 Rand.SetSeed();
96 }
97
98 public void ApplyMaterialElementMap(Thing t, bool invert = false)
99 {
100 int num = ((!invert) ? 1 : (-1));
102 Rand.SetSeed(t.uid);
103 foreach (KeyValuePair<int, int> item in material.elementMap)
104 {
105 int value = item.Value;
106 if (value == 0)
107 {
108 continue;
109 }
110 Element orCreateElement = GetOrCreateElement(item.Key);
111 if (!orCreateElement.source.IsMaterialEncAppliable(t))
112 {
113 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vExp == 0 && orCreateElement.vPotential == 0)
114 {
115 Remove(orCreateElement.id);
116 }
117 continue;
118 }
119 int num2 = orCreateElement.GetMaterialSourceValue(t, value) * num;
120 orCreateElement.vSource += num2;
121 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vExp == 0 && orCreateElement.vPotential == 0)
122 {
123 Remove(orCreateElement.id);
124 }
125 }
126 Rand.SetSeed();
127 }
128
129 public void ImportElementMap(Dictionary<int, int> map)
130 {
131 foreach (KeyValuePair<int, int> item in map)
132 {
133 GetOrCreateElement(item.Key).vSource += item.Value;
134 }
135 }
136
138 {
139 for (int i = 0; i < ints.Length; i += 2)
140 {
141 GetOrCreateElement(ints[i]).vSource += ints[i + 1];
142 }
143 return this;
144 }
145
146 public void ApplyPotential(int mode = 0)
147 {
148 foreach (Element value in dict.Values)
149 {
150 if (value.HasTag("primary"))
151 {
152 value.vTempPotential = (value.ValueWithoutLink - ((mode != 2) ? 7 : 0)) * 5;
153 }
154 }
155 }
156
157 public int Value(int ele)
158 {
159 Element element = GetElement(ele);
160 if (element == null)
161 {
162 if (EClass.core.game == null)
163 {
164 return 0;
165 }
166 if (Card == null || !Card.IsPCFactionOrMinion)
167 {
168 return 0;
169 }
170 if (ele != 78)
171 {
172 return EClass.pc.faction.charaElements.Value(ele);
173 }
174 return GetOrCreateElement(ele).Value;
175 }
176 return element.Value;
177 }
178
179 public virtual int ValueBonus(Element e)
180 {
181 return 0;
182 }
183
184 public int ValueWithoutLink(int ele)
185 {
186 return GetElement(ele)?.ValueWithoutLink ?? 0;
187 }
188
189 public int ValueWithoutLink(string alias)
190 {
191 return GetElement(alias)?.ValueWithoutLink ?? 0;
192 }
193
194 public int GetFeatRef(int ele, int idx = 0)
195 {
196 if (!(GetElement(ele) is Feat feat))
197 {
198 return 0;
199 }
200 feat.Apply(feat.Value, this);
201 return Feat.featRef[idx].ToInt();
202 }
203
204 public int Exp(int ele)
205 {
206 return GetElement(ele)?.vExp ?? 0;
207 }
208
209 public bool Has(int ele)
210 {
211 Element element = GetElement(ele);
212 if (element == null)
213 {
214 return false;
215 }
216 return element.Value > 0;
217 }
218
219 public bool Has(SourceElement.Row row)
220 {
221 return Has(row.id);
222 }
223
224 public bool Has(string alias)
225 {
226 return Has(EClass.sources.elements.alias[alias].id);
227 }
228
229 public bool HasBase(int ele)
230 {
231 Element element = GetElement(ele);
232 if (element == null)
233 {
234 return false;
235 }
236 int num = element.ValueWithoutLink;
237 switch (ele)
238 {
239 case 300:
240 num += Value(1516) * -4;
241 num += Value(1517) * 4;
242 break;
243 case 307:
244 num += Value(1524) * -4;
245 num += Value(1525) * 4;
246 break;
247 }
248 return num != 0;
249 }
250
251 public int Base(int ele)
252 {
253 return GetElement(ele)?.ValueWithoutLink ?? 0;
254 }
255
256 public void Learn(int ele, int v = 1)
257 {
258 ModBase(ele, v);
259 OnLearn(ele);
260 }
261
262 public void Train(int ele, int a = 10)
263 {
264 OnTrain(ele);
265 ModTempPotential(ele, a);
266 }
267
268 public void ModExp(int ele, int a, bool chain = false)
269 {
270 if ((Card != null && Card.isChara && Card.Chara.isDead) || a == 0)
271 {
272 return;
273 }
274 Element element = GetElement(ele);
275 if (element == null || !element.CanGainExp)
276 {
277 return;
278 }
279 int value = (element.UsePotential ? element.Potential : 100);
280 if (element.UseExpMod && a >= 0)
281 {
282 float num = (float)a * (float)Mathf.Clamp(value, 10, 1000) / (float)(100 + Mathf.Max(0, element.ValueWithoutLink) * 25);
283 a = (int)num;
284 if (EClass.rndf(1f) < num % 1f)
285 {
286 a++;
287 }
288 }
289 element.vExp += a;
290 if (!chain && element.source.parentFactor > 0f && Card != null && !element.source.aliasParent.IsEmpty())
291 {
292 Element element2 = element.GetParent(Card);
293 if (element2.CanGainExp)
294 {
295 ModExp(element2.id, (int)Math.Max(1f, (float)a * element.source.parentFactor / 100f), chain: true);
296 }
297 }
298 if (element.vExp >= element.ExpToNext)
299 {
300 int num2 = element.vExp - element.ExpToNext;
301 int vBase = element.vBase;
302 ModBase(ele, 1);
303 OnLevelUp(element, vBase);
304 element.vExp = Mathf.Clamp(num2 / 2, 0, element.ExpToNext / 2);
305 if (element.vTempPotential > 0)
306 {
307 element.vTempPotential -= element.vTempPotential / 4 + EClass.rnd(5) + 5;
308 if (element.vTempPotential < 0)
309 {
310 element.vTempPotential = 0;
311 }
312 }
313 else if (element.vTempPotential < 0)
314 {
315 element.vTempPotential += -element.vTempPotential / 4 + EClass.rnd(5) + 5;
316 if (element.vTempPotential > 0)
317 {
318 element.vTempPotential = 0;
319 }
320 }
321 }
322 else if (element.vExp < 0)
323 {
324 if (element.ValueWithoutLink <= 1)
325 {
326 element.vExp = 0;
327 return;
328 }
329 int vBase2 = element.vBase;
330 ModBase(ele, -1);
331 OnLevelDown(element, vBase2);
332 element.vExp = Mathf.Max(element.ExpToNext / 2, element.ExpToNext + element.vExp);
333 }
334 }
335
336 public virtual void OnLearn(int ele)
337 {
338 }
339
340 public virtual void OnTrain(int ele)
341 {
342 }
343
344 public virtual void OnLevelUp(Element e, int lastValue)
345 {
346 }
347
348 public virtual void OnLevelDown(Element e, int lastValue)
349 {
350 }
351
352 public Element SetBase(string alias, int v, int potential = 0)
353 {
354 return SetBase(EClass.sources.elements.alias[alias].id, v, potential);
355 }
356
357 public Element SetBase(int id, int v, int potential = 0)
358 {
359 Element orCreateElement = GetOrCreateElement(id);
360 if (parent != null && orCreateElement.CanLink(this))
361 {
362 parent.ModLink(id, -orCreateElement.vBase + v);
363 }
364 orCreateElement.vBase = v;
365 orCreateElement.vExp = 0;
366 orCreateElement.vPotential = potential;
367 orCreateElement.OnChangeValue();
368 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
369 {
370 Remove(orCreateElement.id);
371 }
372 return orCreateElement;
373 }
374
375 public void SetTo(int id, int v)
376 {
377 Element orCreateElement = GetOrCreateElement(id);
378 int num = v - (orCreateElement.vBase + orCreateElement.vSource);
379 if (num != 0)
380 {
381 ModBase(id, num);
382 }
383 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
384 {
385 Remove(orCreateElement.id);
386 }
387 }
388
389 public void Remove(int id)
390 {
391 Element element = GetElement(id);
392 if (element != null)
393 {
394 if (parent != null && element.CanLink(this))
395 {
396 parent.ModLink(id, -element.Value);
397 }
398 dict.Remove(id);
399 }
400 }
401
402 public Element ModBase(int ele, int v)
403 {
404 Element orCreateElement = GetOrCreateElement(ele);
405 orCreateElement.vBase += v;
406 if (parent != null && orCreateElement.CanLink(this))
407 {
408 parent.ModLink(ele, v);
409 }
410 orCreateElement.CheckLevelBonus(this);
411 orCreateElement.OnChangeValue();
412 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
413 {
414 Remove(orCreateElement.id);
415 }
416 return orCreateElement;
417 }
418
419 public virtual void OnChangeValue()
420 {
421 }
422
423 public Element ModPotential(int ele, int v)
424 {
425 Element orCreateElement = GetOrCreateElement(ele);
426 orCreateElement.vPotential += v;
427 if (orCreateElement.vPotential > 1000)
428 {
429 orCreateElement.vPotential = 1000;
430 }
431 return orCreateElement;
432 }
433
434 public Element ModTempPotential(int ele, int v, int threshMsg = 0)
435 {
436 Element orCreateElement = GetOrCreateElement(ele);
437 orCreateElement.vTempPotential += v;
438 if (orCreateElement.vTempPotential > 1000)
439 {
440 orCreateElement.vTempPotential = 1000;
441 }
442 OnModTempPotential(orCreateElement, v, threshMsg);
443 return orCreateElement;
444 }
445
446 public virtual void OnModTempPotential(Element e, int v, int threshMsg)
447 {
448 }
449
450 private Element ModLink(int id, int v)
451 {
452 Element orCreateElement = GetOrCreateElement(id);
453 orCreateElement.vLink += v;
454 orCreateElement.OnChangeValue();
455 if (parent != null && orCreateElement.CanLink(this))
456 {
457 parent.ModLink(id, v);
458 }
459 return orCreateElement;
460 }
461
462 public int GetSpellExp(Chara c, Element e, int costMod = 100)
463 {
464 Act.Cost cost = e.GetCost(c);
465 int num = cost.cost * ((cost.type == Act.CostType.SP) ? 20 : 5) * (100 + c.Evalue(1208) * 30) / 100 + 10;
466 num = num * costMod / 100;
467 if (!e.source.aliasParent.IsEmpty())
468 {
469 int num2 = ValueWithoutLink(e.source.aliasParent) - ValueWithoutLink(e.source.id);
470 num = ((num2 < 0) ? (num * 100 / (100 - num2 * 25)) : (num * (100 + num2 * 5) / 100));
471 }
472 if (num < 0)
473 {
474 num = 0;
475 }
476 return num;
477 }
478
479 public Element GetElement(string alias)
480 {
481 return GetElement(EClass.sources.elements.alias.TryGetValue(alias)?.id ?? 0);
482 }
483
484 public Element GetElement(int id)
485 {
486 return dict.TryGetValue(id);
487 }
488
489 public Element CreateElement(int id)
490 {
491 Element element = Element.Create(id);
492 if (element == null)
493 {
494 return null;
495 }
496 element.owner = this;
497 dict.Add(id, element);
498 return element;
499 }
500
502 {
503 return GetOrCreateElement(ele.id);
504 }
505
506 public Element GetOrCreateElement(string alias)
507 {
508 return GetOrCreateElement(EClass.sources.elements.alias[alias].id);
509 }
510
512 {
513 Element value = null;
514 if (!dict.TryGetValue(id, out value))
515 {
516 value = CreateElement(id);
517 }
518 return value;
519 }
520
521 public void SetParent(Card c)
522 {
523 SetParent(c?.elements);
524 }
525
526 public void SetParent(ElementContainer newParent = null)
527 {
528 if (parent != null)
529 {
530 foreach (Element value in dict.Values)
531 {
532 if (value.CanLink(this))
533 {
534 parent.ModLink(value.id, -(value.vBase + value.vSource));
535 }
536 }
537 }
538 if (newParent != null)
539 {
540 foreach (Element value2 in dict.Values)
541 {
542 if (value2.CanLink(this))
543 {
544 newParent.ModLink(value2.id, value2.vBase + value2.vSource);
545 }
546 }
547 }
548 parent = newParent;
549 }
550
551 public List<Element> ListElements(Func<Element, bool> shoudList = null, Comparison<Element> comparison = null)
552 {
553 List<Element> list = new List<Element>();
554 List<Element> eles = dict.Values.ToList();
555 if (Card != null && Card.Chara != null)
556 {
558 {
559 AddElements(EClass.pc.faction.charaElements, isGlobal: true);
560 }
561 AddElements(Card.Chara.faithElements, isGlobal: false);
562 }
563 foreach (Element item2 in eles)
564 {
565 if (shoudList == null || shoudList(item2))
566 {
567 list.Add(item2);
568 }
569 }
570 if (comparison != null)
571 {
572 list.Sort(comparison);
573 }
574 return list;
575 void AddElements(ElementContainer container, bool isGlobal)
576 {
577 if (container == null)
578 {
579 return;
580 }
581 foreach (Element value in container.dict.Values)
582 {
583 bool flag = true;
584 foreach (Element item3 in eles)
585 {
586 if (value.id == item3.id)
587 {
588 flag = false;
589 break;
590 }
591 }
592 if (flag && value.Value != 0)
593 {
594 if (isGlobal)
595 {
597 eles.Add(item);
598 }
599 else
600 {
601 eles.Add(value);
602 }
603 }
604 }
605 }
606 }
607
608 public List<Element> ListBestAttributes()
609 {
610 List<Element> obj = ListElements((Element a) => a.HasTag("primary"));
611 obj.Sort((Element a, Element b) => (b.ValueWithoutLink - a.ValueWithoutLink) * 100000 + a.id - b.id);
612 return obj;
613 }
614
615 public List<Element> ListBestSkills()
616 {
617 List<Element> obj = ListElements((Element a) => a.source.category == "skill");
618 obj.Sort((Element a, Element b) => (b.ValueWithoutLink - a.ValueWithoutLink) * 100000 + a.id - b.id);
619 return obj;
620 }
621
622 public List<Element> ListGeneFeats()
623 {
624 return ListElements((Element a) => a.Value > 0 && a.source.category == "feat" && a.source.cost.Length != 0 && a.source.cost[0] > 0 && a.source.geneSlot >= 0);
625 }
626
627 public List<Element> ListLearnable(Chara c)
628 {
629 List<Element> list = new List<Element>();
630 foreach (KeyValuePair<int, Element> item in c.elements.dict)
631 {
632 if (!dict.ContainsKey(item.Key))
633 {
634 list.Add(item.Value);
635 }
636 }
637 return list;
638 }
639
640 public List<Element> ListRune()
641 {
642 return ListElements((Element a) => !a.source.encSlot.IsEmpty() && a.vBase + a.vSource != 0);
643 }
644
645 public void CopyTo(ElementContainer container)
646 {
647 container.dict.Clear();
648 foreach (KeyValuePair<int, Element> item in dict)
649 {
650 Element element = container.CreateElement(item.Key);
651 element.vBase = item.Value.vBase;
652 element.vExp = item.Value.vExp;
653 element.vSource = item.Value.vSource;
654 }
655 }
656
657 public static int GetSortVal(Element a)
658 {
659 int num = a.Value;
660 if (a.source.textAlt.Length <= 2 || a.Value < 0)
661 {
662 num -= 100000;
663 }
664 if (a.id == 2)
665 {
666 num += 20000;
667 }
668 if (a.IsFoodTraitMain)
669 {
670 num += 10000;
671 }
672 return num;
673 }
674
675 public void AddNote(UINote n, Func<Element, bool> isValid = null, Action onAdd = null, NoteMode mode = NoteMode.Default, bool addRaceFeat = false, Func<Element, string, string> funcText = null, Action<UINote, Element> onAddNote = null)
676 {
677 List<Element> list = new List<Element>();
678 foreach (Element value2 in dict.Values)
679 {
680 if ((isValid == null || isValid(value2)) && (mode != NoteMode.CharaMake || value2.ValueWithoutLink != 0) && (value2.Value != 0 || mode == NoteMode.CharaMakeAttributes) && (!value2.HasTag("hidden") || EClass.debug.showExtra))
681 {
682 list.Add(value2);
683 }
684 }
685 if (addRaceFeat)
686 {
687 Element element = Element.Create(29, 1);
688 element.owner = this;
689 list.Add(element);
690 }
691 if (list.Count == 0)
692 {
693 return;
694 }
695 onAdd?.Invoke();
696 switch (mode)
697 {
698 case NoteMode.CharaMake:
699 case NoteMode.CharaMakeAttributes:
700 list.Sort((Element a, Element b) => a.GetSortVal(UIList.SortMode.ByElementParent) - b.GetSortVal(UIList.SortMode.ByElementParent));
701 break;
702 case NoteMode.Trait:
703 list.Sort((Element a, Element b) => GetSortVal(b) - GetSortVal(a));
704 break;
705 default:
706 list.Sort((Element a, Element b) => a.SortVal() - b.SortVal());
707 break;
708 }
709 string text = "";
710 foreach (Element e in list)
711 {
712 switch (mode)
713 {
714 case NoteMode.Domain:
715 n.AddText(e.Name, FontColor.Default);
716 continue;
717 case NoteMode.Default:
718 case NoteMode.Trait:
719 {
720 bool flag = e.source.tag.Contains("common");
721 string categorySub = e.source.categorySub;
722 bool flag2 = false;
723 bool flag3 = (e.source.tag.Contains("neg") ? (e.Value > 0) : (e.Value < 0));
724 int num = Mathf.Abs(e.Value);
725 bool flag4 = Card != null && Card.ShowFoodEnc;
726 bool flag5 = Card != null && Card.IsWeapon && e is Ability;
727 if (e.IsTrait || (flag4 && e.IsFoodTrait))
728 {
729 string[] textArray = e.source.GetTextArray("textAlt");
730 int num2 = Mathf.Clamp(e.Value / 10 + 1, (e.Value < 0 || textArray.Length <= 2) ? 1 : 2, textArray.Length - 1);
731 text = "altEnc".lang(textArray[0].IsEmpty(e.Name), textArray[num2], EClass.debug.showExtra ? (e.Value + " " + e.Name) : "");
732 flag3 = num2 <= 1 || textArray.Length <= 2;
733 flag2 = true;
734 }
735 else if (flag5)
736 {
737 text = "isProc".lang(e.Name);
738 flag3 = false;
739 }
740 else if (categorySub == "resist")
741 {
742 text = ("isResist" + (flag3 ? "Neg" : "")).lang(e.Name);
743 }
744 else if (categorySub == "eleAttack")
745 {
746 text = "isEleAttack".lang(e.Name);
747 }
748 else if (!e.source.textPhase.IsEmpty() && e.Value > 0)
749 {
750 text = e.source.GetText("textPhase");
751 }
752 else
753 {
754 string name = e.Name;
755 bool flag6 = e.source.category == "skill" || (e.source.category == "attribute" && !e.source.textPhase.IsEmpty());
756 bool flag7 = e.source.category == "enchant";
757 if (e.source.tag.Contains("multiplier"))
758 {
759 flag6 = (flag7 = false);
760 name = EClass.sources.elements.alias[e.source.aliasRef].GetName();
761 }
762 flag2 = !(flag6 || flag7);
763 text = (flag6 ? "textEncSkill" : (flag7 ? "textEncEnc" : "textEnc")).lang(name, num + (e.source.tag.Contains("ratio") ? "%" : ""), ((e.Value > 0) ? "encIncrease" : "encDecrease").lang());
764 }
765 int num3 = ((!(e is Resistance)) ? 1 : 0);
766 int num4 = 5;
767 if (e.id == 484)
768 {
769 num3 = 0;
770 num4 = 1;
771 }
772 if (!flag && !flag2 && !e.source.tag.Contains("flag"))
773 {
774 text = text + " [" + "*".Repeat(Mathf.Clamp(num * e.source.mtp / num4 + num3, 1, 5)) + ((num * e.source.mtp / num4 + num3 > 5) ? "+" : "") + "]";
775 }
776 if (e.HasTag("hidden"))
777 {
778 text = "(debug)" + text;
779 }
780 FontColor color = (flag ? FontColor.Default : (flag3 ? FontColor.Bad : FontColor.Good));
781 if (e.IsGlobalElement)
782 {
783 text = text + " " + (e.IsFactionWideElement ? "_factionWide" : "_partyWide").lang();
784 if (!e.IsActive(Card))
785 {
786 continue;
787 }
788 color = FontColor.Myth;
789 }
790 if (flag4 && e.IsFoodTrait && !e.IsFoodTraitMain)
791 {
792 color = FontColor.FoodMisc;
793 }
794 if (e.id == 2 && e.Value >= 0)
795 {
796 color = FontColor.FoodQuality;
797 }
798 if (funcText != null)
799 {
800 text = funcText(e, text);
801 }
802 UIItem uIItem = n.AddText("NoteText_enc", text, color);
803 Sprite sprite = EClass.core.refs.icons.enc.enc;
804 Thing thing = Card?.Thing;
805 if (thing != null)
806 {
807 if (thing.material.HasEnc(e.id))
808 {
809 sprite = EClass.core.refs.icons.enc.mat;
810 }
811 foreach (int key in thing.source.elementMap.Keys)
812 {
813 if (key == e.id)
814 {
815 sprite = EClass.core.refs.icons.enc.card;
816 }
817 }
818 if (e.id == thing.GetInt(107))
819 {
820 sprite = EClass.core.refs.icons.enc.cat;
821 }
822 if (thing.GetRuneEnc(e.id) != null)
823 {
824 sprite = EClass.core.refs.icons.enc.rune;
825 }
826 }
827 if ((bool)sprite)
828 {
829 uIItem.image1.SetActive(enable: true);
830 uIItem.image1.sprite = sprite;
831 }
832 uIItem.image2.SetActive(e.source.IsWeaponEnc);
833 onAddNote?.Invoke(n, e);
834 continue;
835 }
836 }
837 UIItem uIItem2 = n.AddTopic("TopicAttribute", e.Name, "".TagColor((e.ValueWithoutLink > 0) ? SkinManager.CurrentColors.textGood : SkinManager.CurrentColors.textBad, e.ValueWithoutLink.ToString() ?? ""));
838 if ((bool)uIItem2.button1)
839 {
840 uIItem2.button1.tooltip.onShowTooltip = delegate(UITooltip t)
841 {
843 };
844 }
845 e.SetImage(uIItem2.image1);
846 Image image = uIItem2.image2;
847 int value = (e.Potential - 80) / 20;
848 image.enabled = e.Potential != 80;
849 image.sprite = EClass.core.refs.spritesPotential[Mathf.Clamp(Mathf.Abs(value), 0, EClass.core.refs.spritesPotential.Count - 1)];
850 image.color = ((e.Potential - 80 >= 0) ? Color.white : new Color(1f, 0.7f, 0.7f));
851 }
852 }
853
854 public void AddNoteAll(UINote n)
855 {
856 Transform transform = n.AddExtra<Transform>("noteRace");
857 UINote n2 = transform.Find("note1").GetComponent<UINote>();
858 UINote n3 = transform.Find("note2").GetComponent<UINote>();
859 AddNote(n3, (Element e) => e.HasTag("primary"), delegate
860 {
861 n3.AddHeader("HeaderNoteSmall", "attributes");
862 }, NoteMode.CharaMakeAttributes);
863 AddNote(n2, (Element e) => e.source.category == "skill" && !e.HasTag("hidden") && e.ValueWithoutLink > 1 && e.source.categorySub != "weapon", delegate
864 {
865 n2.AddHeader("HeaderNoteSmall", "skills");
866 }, NoteMode.CharaMake);
867 AddNote(n2, (Element e) => e is Feat, delegate
868 {
869 n2.AddHeader("HeaderNoteSmall", "feats");
870 }, NoteMode.CharaMake);
871 }
872}
FontColor
Definition: FontColor.cs:2
SourceValueType
Definition: ACT.cs:62
CostType
Definition: ACT.cs:64
int GetInt(int id, int? defaultInt=null)
Definition: BaseCard.cs:25
Definition: Card.cs:11
bool IsPCFactionOrMinion
Definition: Card.cs:2132
virtual Chara Chara
Definition: Card.cs:1946
ElementContainerCard elements
Definition: Card.cs:37
SourceMaterial.Row material
Definition: Card.cs:1927
int uid
Definition: Card.cs:118
SocketData GetRuneEnc(int idEle)
Definition: Card.cs:3371
virtual bool isChara
Definition: Card.cs:1959
virtual Thing Thing
Definition: Card.cs:1934
int Evalue(int ele)
Definition: Card.cs:2431
bool ShowFoodEnc
Definition: Card.cs:2054
Definition: Chara.cs:10
Faction faction
Definition: Chara.cs:412
override bool IsPCFaction
Definition: Chara.cs:656
ElementContainer faithElements
Definition: Chara.cs:38
bool isDead
Definition: Chara.cs:374
bool showExtra
Definition: CoreDebug.cs:167
List< Sprite > spritesPotential
Definition: CoreRef.cs:359
Icons icons
Definition: CoreRef.cs:339
CoreRef refs
Definition: Core.cs:51
Game game
Definition: Core.cs:72
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Core core
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:42
static float rndf(float a)
Definition: EClass.cs:79
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
static int GetSortVal(Element a)
List< Element > ListElements(Func< Element, bool > shoudList=null, Comparison< Element > comparison=null)
void Train(int ele, int a=10)
void ApplyPotential(int mode=0)
bool Has(string alias)
Dictionary< int, Element > dict
void SetParent(Card c)
ElementContainer parent
void AddNoteAll(UINote n)
List< Element > ListLearnable(Chara c)
void Learn(int ele, int v=1)
void AddNote(UINote n, Func< Element, bool > isValid=null, Action onAdd=null, NoteMode mode=NoteMode.Default, bool addRaceFeat=false, Func< Element, string, string > funcText=null, Action< UINote, Element > onAddNote=null)
bool Has(int ele)
void ApplyMaterialElementMap(Thing t, bool invert=false)
Element ModLink(int id, int v)
int ValueWithoutLink(string alias)
Element ModPotential(int ele, int v)
Element SetBase(int id, int v, int potential=0)
int Value(int ele)
virtual void OnTrain(int ele)
Element ModTempPotential(int ele, int v, int threshMsg=0)
Element GetOrCreateElement(int id)
void ImportElementMap(Dictionary< int, int > map)
virtual int ValueBonus(Element e)
void OnSerializing(StreamingContext context)
ElementContainer ImportElementMap(int[] ints)
List< Element > ListRune()
void CopyTo(ElementContainer container)
int ValueWithoutLink(int ele)
void ModExp(int ele, int a, bool chain=false)
Element ModBase(int ele, int v)
virtual void OnLevelDown(Element e, int lastValue)
List< Element > ListBestSkills()
virtual bool IsMeleeWeapon
Element GetElement(int id)
int GetFeatRef(int ele, int idx=0)
virtual void OnChangeValue()
void OnDeserialized(StreamingContext context)
void ApplyElementMap(int uid, SourceValueType type, Dictionary< int, int > map, int lv, bool invert=false, bool applyFeat=false)
List< Element > ListBestAttributes()
virtual void OnModTempPotential(Element e, int v, int threshMsg)
virtual void OnLearn(int ele)
void SetTo(int id, int v)
bool Has(SourceElement.Row row)
Element SetBase(string alias, int v, int potential=0)
void Remove(int id)
List< Element > ListGeneFeats()
virtual void OnLevelUp(Element e, int lastValue)
Element GetOrCreateElement(Element ele)
void SetParent(ElementContainer newParent=null)
Element CreateElement(int id)
int GetSpellExp(Chara c, Element e, int costMod=100)
bool HasBase(int ele)
Element GetElement(string alias)
Element GetOrCreateElement(string alias)
virtual bool CanGainExp
Definition: ELEMENT.cs:290
virtual void OnChangeValue()
Definition: ELEMENT.cs:789
int ValueWithoutLink
Definition: ELEMENT.cs:284
virtual bool UseExpMod
Definition: ELEMENT.cs:300
int GetMaterialSourceValue(Thing t, int v)
Definition: ELEMENT.cs:411
int id
Definition: ELEMENT.cs:240
int vBase
Definition: ELEMENT.cs:242
SourceElement.Row source
Definition: ELEMENT.cs:263
int vExp
Definition: ELEMENT.cs:244
virtual int GetSourceValue(int v, int lv, SourceValueType type)
Definition: ELEMENT.cs:428
int vPotential
Definition: ELEMENT.cs:246
virtual int GetSourcePotential(int v)
Definition: ELEMENT.cs:401
bool HasTag(string tag)
Definition: ELEMENT.cs:463
int vTempPotential
Definition: ELEMENT.cs:248
int GetSortVal(UIList.SortMode m)
Definition: ELEMENT.cs:834
void SetImage(Image i)
Definition: ELEMENT.cs:468
int Value
Definition: ELEMENT.cs:282
void CheckLevelBonus(ElementContainer owner, UINote n=null)
Definition: ELEMENT.cs:793
bool IsFoodTrait
Definition: ELEMENT.cs:354
virtual string Name
Definition: ELEMENT.cs:294
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:913
virtual bool CanLink(ElementContainer owner)
Definition: ELEMENT.cs:458
int vLink
Definition: ELEMENT.cs:250
virtual Act.Cost GetCost(Chara c)
Definition: ELEMENT.cs:853
int vSource
Definition: ELEMENT.cs:252
void WriteNote(UINote n, ElementContainer owner=null, Action< UINote > onWriteNote=null)
Definition: ELEMENT.cs:574
bool IsGlobalElement
Definition: ELEMENT.cs:335
bool IsTrait
Definition: ELEMENT.cs:352
Element GetParent(Card c)
Definition: ELEMENT.cs:512
bool IsFoodTraitMain
Definition: ELEMENT.cs:357
virtual int ExpToNext
Definition: ELEMENT.cs:298
bool IsActive(Card c)
Definition: ELEMENT.cs:443
int SortVal(bool charaSheet=false)
Definition: ELEMENT.cs:452
ElementContainerFaction charaElements
Definition: FACTION.cs:144
Definition: FEAT.cs:249
static string[] featRef
Definition: FEAT.cs:252
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37
static SkinColorProfile CurrentColors
Definition: SkinManager.cs:84
SourceElement elements
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
Definition: Trait.cs:7
Definition: UIItem.cs:5
Image image2
Definition: UIItem.cs:16
UIButton button1
Definition: UIItem.cs:18
Image image1
Definition: UIItem.cs:14
Definition: UIList.cs:9
SortMode
Definition: UIList.cs:27
Definition: UINote.cs:6
UINote note
Definition: UITooltip.cs:21
Definition: ACT.cs:71