Elin Decompiled Documentation EA 23.130 Nightly
Loading...
Searching...
No Matches
ElementContainer Class Reference
Inheritance diagram for ElementContainer:
EClass ElementContainerCard ElementContainerFaction ElementContainerZone

Public Types

enum  NoteMode {
  Default , CharaMake , CharaMakeAttributes , Domain ,
  BonusTrait
}
 

Public Member Functions

void ApplyElementMap (int uid, SourceValueType type, Dictionary< int, int > map, int lv, bool invert=false, bool applyFeat=false)
 
void ApplyMaterialElementMap (Thing t, bool invert=false)
 
void ImportElementMap (Dictionary< int, int > map)
 
ElementContainer ImportElementMap (int[] ints)
 
void ApplyPotential (int mode=0)
 
int Value (int ele)
 
virtual int ValueBonus (Element e)
 
int ValueWithoutLink (int ele)
 
int ValueWithoutLink (string alias)
 
int GetFeatRef (int ele, int idx=0)
 
int Exp (int ele)
 
bool Has (int ele)
 
bool Has (SourceElement.Row row)
 
bool Has (string alias)
 
bool HasBase (int ele)
 
int Base (int ele)
 
void Learn (int ele, int v=1)
 
void Train (int ele, int a=10)
 
void ModExp (int ele, int a, bool chain=false)
 
virtual void OnLearn (int ele)
 
virtual void OnTrain (int ele)
 
virtual void OnLevelUp (Element e, int lastValue)
 
virtual void OnLevelDown (Element e, int lastValue)
 
Element SetBase (string alias, int v, int potential=0)
 
Element SetBase (int id, int v, int potential=0)
 
void SetTo (int id, int v)
 
void Remove (int id)
 
Element ModBase (int ele, int v)
 
virtual void OnChangeValue ()
 
Element ModPotential (int ele, int v)
 
Element ModTempPotential (int ele, int v, int threshMsg=0)
 
virtual void OnModTempPotential (Element e, int v, int threshMsg)
 
int GetSpellExp (Chara c, Element e, int costMod=100)
 
Element GetElement (string alias)
 
Element GetElement (int id)
 
Element CreateElement (int id)
 
Element GetOrCreateElement (Element ele)
 
Element GetOrCreateElement (string alias)
 
Element GetOrCreateElement (int id)
 
void SetParent (Card c)
 
void SetParent (ElementContainer newParent=null)
 
List< ElementListElements (Func< Element, bool > shoudList=null, Comparison< Element > comparison=null)
 
List< ElementListBestAttributes ()
 
List< ElementListBestSkills ()
 
List< ElementListGeneFeats ()
 
List< ElementListLearnable (Chara c)
 
List< ElementListRune ()
 
void CopyTo (ElementContainer container)
 
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)
 
void AddNoteAll (UINote n)
 

Static Public Member Functions

static int GetSortVal (Element a)
 
- Static Public Member Functions inherited from EClass
static int rndSeed (int a, int seed)
 
static int rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Public Attributes

Dictionary< int, Elementdict = new Dictionary<int, Element>()
 
ElementContainer parent
 
List< int > list
 

Static Public Attributes

const int sizeElement = 5
 
- Static Public Attributes inherited from EClass
static Core core
 

Properties

virtual Card Card [get]
 
virtual Chara Chara [get]
 
virtual bool IsMeleeWeapon [get]
 
- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Private Member Functions

void OnSerializing (StreamingContext context)
 
void OnDeserialized (StreamingContext context)
 
Element ModLink (int id, int v)
 

Detailed Description

Definition at line 8 of file ElementContainer.cs.

Member Enumeration Documentation

◆ NoteMode

Enumerator
Default 
CharaMake 
CharaMakeAttributes 
Domain 
BonusTrait 

Definition at line 10 of file ElementContainer.cs.

Member Function Documentation

◆ AddNote()

void ElementContainer.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 
)
inline

Definition at line 674 of file ElementContainer.cs.

675 {
676 List<Element> list = new List<Element>();
677 foreach (Element value in dict.Values)
678 {
679 if ((isValid == null || isValid(value)) && (mode != NoteMode.CharaMake || value.ValueWithoutLink != 0) && (value.Value != 0 || mode == NoteMode.CharaMakeAttributes) && (!value.HasTag("hidden") || EClass.debug.showExtra))
680 {
681 list.Add(value);
682 }
683 }
684 if (addRaceFeat)
685 {
686 Element element = Element.Create(29, 1);
687 element.owner = this;
688 list.Add(element);
689 }
690 if (list.Count == 0)
691 {
692 return;
693 }
694 onAdd?.Invoke();
695 switch (mode)
696 {
697 case NoteMode.CharaMake:
698 case NoteMode.CharaMakeAttributes:
699 list.Sort((Element a, Element b) => a.GetSortVal(UIList.SortMode.ByElementParent) - b.GetSortVal(UIList.SortMode.ByElementParent));
700 break;
701 case NoteMode.BonusTrait:
702 list.Sort((Element a, Element b) => GetSortVal(b) - GetSortVal(a));
703 break;
704 default:
705 list.Sort((Element a, Element b) => a.SortVal() - b.SortVal());
706 break;
707 }
708 foreach (Element item in list)
709 {
710 item.AddEncNote(n, Card, mode, funcText, onAddNote);
711 }
712 }
Definition: Card.cs:11
bool showExtra
Definition: CoreDebug.cs:167
Definition: EClass.cs:5
static CoreDebug debug
Definition: EClass.cs:48
static int GetSortVal(Element a)
Dictionary< int, Element > dict
int ValueWithoutLink
Definition: ELEMENT.cs:290
bool HasTag(string tag)
Definition: ELEMENT.cs:469
int GetSortVal(UIList.SortMode m)
Definition: ELEMENT.cs:1000
int Value
Definition: ELEMENT.cs:288
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1094
int SortVal(bool charaSheet=false)
Definition: ELEMENT.cs:458
Definition: UIList.cs:9
SortMode
Definition: UIList.cs:27

References Element.Create(), EClass.debug, dict, GetSortVal(), Element.GetSortVal(), Element.HasTag(), item, list, CoreDebug.showExtra, Element.SortVal(), Element.Value, and Element.ValueWithoutLink.

Referenced by AddNoteAll(), UICharaMaker.Refresh(), and RecipeCard.WriteNote().

◆ AddNoteAll()

void ElementContainer.AddNoteAll ( UINote  n)
inline

Definition at line 714 of file ElementContainer.cs.

715 {
716 Transform transform = n.AddExtra<Transform>("noteRace");
717 UINote n2 = transform.Find("note1").GetComponent<UINote>();
718 UINote n3 = transform.Find("note2").GetComponent<UINote>();
719 AddNote(n3, (Element e) => e.HasTag("primary"), delegate
720 {
721 n3.AddHeader("HeaderNoteSmall", "attributes");
722 }, NoteMode.CharaMakeAttributes);
723 AddNote(n2, (Element e) => e.source.category == "skill" && !e.HasTag("hidden") && e.ValueWithoutLink > 1 && e.source.categorySub != "weapon", delegate
724 {
725 n2.AddHeader("HeaderNoteSmall", "skills");
726 }, NoteMode.CharaMake);
727 AddNote(n2, (Element e) => e is Feat, delegate
728 {
729 n2.AddHeader("HeaderNoteSmall", "feats");
730 }, NoteMode.CharaMake);
731 }
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)
SourceElement.Row source
Definition: ELEMENT.cs:269
Definition: FEAT.cs:253
Definition: UINote.cs:6

References AddNote(), Element.HasTag(), Element.source, and Element.ValueWithoutLink.

Referenced by UICharaMaker.ListJob(), and UICharaMaker.ListRace().

◆ ApplyElementMap()

void ElementContainer.ApplyElementMap ( int  uid,
SourceValueType  type,
Dictionary< int, int >  map,
int  lv,
bool  invert = false,
bool  applyFeat = false 
)
inline

Definition at line 72 of file ElementContainer.cs.

73 {
74 int num = ((!invert) ? 1 : (-1));
75 Rand.SetSeed(uid);
76 foreach (KeyValuePair<int, int> item in map)
77 {
78 Element orCreateElement = GetOrCreateElement(item.Key);
79 int value = item.Value;
80 if (value != 0)
81 {
82 if (orCreateElement.source.category == "skill")
83 {
84 orCreateElement.vSourcePotential += orCreateElement.GetSourcePotential(value) * num;
85 }
86 int num2 = orCreateElement.GetSourceValue(value, lv, type) * num;
87 orCreateElement.vSource += num2;
88 if (applyFeat && orCreateElement is Feat)
89 {
90 (orCreateElement as Feat).Apply(num2, this);
91 }
92 }
93 }
94 Rand.SetSeed();
95 }
Element GetOrCreateElement(Element ele)
virtual int GetSourceValue(int v, int lv, SourceValueType type)
Definition: ELEMENT.cs:434
virtual int GetSourcePotential(int v)
Definition: ELEMENT.cs:407
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37

References GetOrCreateElement(), Element.GetSourcePotential(), Element.GetSourceValue(), item, Rand.SetSeed(), and Element.source.

Referenced by Chara.ApplyJob(), Chara.ApplyRace(), UICharaMaker.ListJob(), UICharaMaker.ListRace(), Chara.OnDeserialized(), Card.SetLv(), and ElementContainerCard.SetOwner().

◆ ApplyMaterialElementMap()

void ElementContainer.ApplyMaterialElementMap ( Thing  t,
bool  invert = false 
)
inline

Definition at line 97 of file ElementContainer.cs.

98 {
99 int num = ((!invert) ? 1 : (-1));
101 Rand.SetSeed(t.uid);
102 foreach (KeyValuePair<int, int> item in material.elementMap)
103 {
104 int value = item.Value;
105 if (value == 0)
106 {
107 continue;
108 }
109 Element orCreateElement = GetOrCreateElement(item.Key);
110 if (!orCreateElement.source.IsMaterialEncAppliable(t))
111 {
112 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vExp == 0 && orCreateElement.vPotential == 0)
113 {
114 Remove(orCreateElement.id);
115 }
116 continue;
117 }
118 int num2 = orCreateElement.GetMaterialSourceValue(t, value) * num;
119 orCreateElement.vSource += num2;
120 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vExp == 0 && orCreateElement.vPotential == 0)
121 {
122 Remove(orCreateElement.id);
123 }
124 }
125 Rand.SetSeed();
126 }
SourceMaterial.Row material
Definition: Card.cs:1951
int uid
Definition: Card.cs:118
void Remove(int id)
int GetMaterialSourceValue(Thing t, int v)
Definition: ELEMENT.cs:417
int id
Definition: ELEMENT.cs:246
int vBase
Definition: ELEMENT.cs:248
int vExp
Definition: ELEMENT.cs:250
int vPotential
Definition: ELEMENT.cs:252
int vLink
Definition: ELEMENT.cs:256
int vSource
Definition: ELEMENT.cs:258

References Element.GetMaterialSourceValue(), GetOrCreateElement(), Element.id, item, Card.material, material, Remove(), Rand.SetSeed(), Element.source, Card.uid, Element.vBase, Element.vExp, Element.vLink, Element.vPotential, and Element.vSource.

Referenced by Thing.ApplyMaterialElements().

◆ ApplyPotential()

void ElementContainer.ApplyPotential ( int  mode = 0)
inline

Definition at line 145 of file ElementContainer.cs.

146 {
147 foreach (Element value in dict.Values)
148 {
149 if (value.HasTag("primary"))
150 {
151 value.vTempPotential = (value.ValueWithoutLink - ((mode != 2) ? 7 : 0)) * 5;
152 }
153 }
154 }

References dict, and Element.HasTag().

Referenced by UICharaMaker.ListJob(), UICharaMaker.ListRace(), and UICharaMaker.Refresh().

◆ Base()

int ElementContainer.Base ( int  ele)
inline

Definition at line 250 of file ElementContainer.cs.

251 {
252 return GetElement(ele)?.ValueWithoutLink ?? 0;
253 }
Element GetElement(string alias)

References GetElement(), and Element.ValueWithoutLink.

Referenced by Chara.ModTempElement(), and FoodEffect.Proc().

◆ CopyTo()

void ElementContainer.CopyTo ( ElementContainer  container)
inline

Definition at line 644 of file ElementContainer.cs.

645 {
646 container.dict.Clear();
647 foreach (KeyValuePair<int, Element> item in dict)
648 {
649 Element element = container.CreateElement(item.Key);
650 element.vBase = item.Value.vBase;
651 element.vExp = item.Value.vExp;
652 element.vSource = item.Value.vSource;
653 }
654 }
Element CreateElement(int id)

References dict, and item.

Referenced by Card.Duplicate().

◆ CreateElement()

Element ElementContainer.CreateElement ( int  id)
inline

Definition at line 488 of file ElementContainer.cs.

489 {
490 Element element = Element.Create(id);
491 if (element == null)
492 {
493 return null;
494 }
495 element.owner = this;
496 dict.Add(id, element);
497 return element;
498 }

References Element.Create(), and dict.

Referenced by GetOrCreateElement(), and ListElements().

◆ Exp()

int ElementContainer.Exp ( int  ele)
inline

Definition at line 203 of file ElementContainer.cs.

204 {
205 return GetElement(ele)?.vExp ?? 0;
206 }

References GetElement(), and Element.vExp.

◆ GetElement() [1/2]

Element ElementContainer.GetElement ( int  id)
inline

Definition at line 483 of file ElementContainer.cs.

484 {
485 return dict.TryGetValue(id);
486 }

References dict.

◆ GetElement() [2/2]

◆ GetFeatRef()

int ElementContainer.GetFeatRef ( int  ele,
int  idx = 0 
)
inline

Definition at line 193 of file ElementContainer.cs.

194 {
195 if (!(GetElement(ele) is Feat feat))
196 {
197 return 0;
198 }
199 feat.Apply(feat.Value, this);
200 return Feat.featRef[idx].ToInt();
201 }
static string[] featRef
Definition: FEAT.cs:256

References Feat.featRef, and GetElement().

◆ GetOrCreateElement() [1/3]

◆ GetOrCreateElement() [2/3]

Element ElementContainer.GetOrCreateElement ( int  id)
inline

Definition at line 510 of file ElementContainer.cs.

511 {
512 Element value = null;
513 if (!dict.TryGetValue(id, out value))
514 {
515 value = CreateElement(id);
516 }
517 return value;
518 }

References CreateElement(), and dict.

◆ GetOrCreateElement() [3/3]

Element ElementContainer.GetOrCreateElement ( string  alias)
inline

Definition at line 505 of file ElementContainer.cs.

506 {
507 return GetOrCreateElement(EClass.sources.elements.alias[alias].id);
508 }

References SourceManager.elements, GetOrCreateElement(), and EClass.sources.

◆ GetSortVal()

static int ElementContainer.GetSortVal ( Element  a)
inlinestatic

Definition at line 656 of file ElementContainer.cs.

657 {
658 int num = a.Value;
659 if (a.source.textAlt.Length <= 2 || a.Value < 0)
660 {
661 num -= 100000;
662 }
663 if (a.id == 2)
664 {
665 num += 20000;
666 }
667 if (a.IsFoodTraitMain)
668 {
669 num += 10000;
670 }
671 return num;
672 }
bool IsFoodTraitMain
Definition: ELEMENT.cs:363

References Element.id, Element.IsFoodTraitMain, Element.source, and Element.Value.

Referenced by AddNote(), and Thing.ListLimitedValidTraits().

◆ GetSpellExp()

int ElementContainer.GetSpellExp ( Chara  c,
Element  e,
int  costMod = 100 
)
inline

Definition at line 461 of file ElementContainer.cs.

462 {
463 Act.Cost cost = e.GetCost(c);
464 int num = cost.cost * ((cost.type == Act.CostType.SP) ? 20 : 5) * (100 + c.Evalue(1208) * 30) / 100 + 10;
465 num = num * costMod / 100;
466 if (!e.source.aliasParent.IsEmpty())
467 {
468 int num2 = ValueWithoutLink(e.source.aliasParent) - ValueWithoutLink(e.source.id);
469 num = ((num2 < 0) ? (num * 100 / (100 - num2 * 25)) : (num * (100 + num2 * 5) / 100));
470 }
471 if (num < 0)
472 {
473 num = 0;
474 }
475 return num;
476 }
Definition: ACT.cs:62
CostType
Definition: ACT.cs:64
int Evalue(int ele)
Definition: Card.cs:2471
int ValueWithoutLink(int ele)
virtual Act.Cost GetCost(Chara c)
Definition: ELEMENT.cs:1019
Definition: ACT.cs:71

References Card.Evalue(), Element.GetCost(), Element.source, and ValueWithoutLink().

Referenced by ActMelee.Attack().

◆ Has() [1/3]

bool ElementContainer.Has ( int  ele)
inline

Definition at line 208 of file ElementContainer.cs.

209 {
210 Element element = GetElement(ele);
211 if (element == null)
212 {
213 return false;
214 }
215 return element.Value > 0;
216 }

References GetElement().

Referenced by BaseCondition._WriteNote(), Element.CheckLevelBonus(), Has(), BuildMenu.OnActivate(), HotbarManager.ResetHotbar(), AI_PassTime.Run(), Card.Teleport(), BuildMenu.Toggle(), TraitFoodEgg.Update(), and Element.BonusInfo.WriteNote().

◆ Has() [2/3]

bool ElementContainer.Has ( SourceElement::Row  row)
inline

Definition at line 218 of file ElementContainer.cs.

219 {
220 return Has(row.id);
221 }
bool Has(int ele)

References Has().

◆ Has() [3/3]

bool ElementContainer.Has ( string  alias)
inline

Definition at line 223 of file ElementContainer.cs.

224 {
225 return Has(EClass.sources.elements.alias[alias].id);
226 }

References SourceManager.elements, Has(), and EClass.sources.

◆ HasBase()

bool ElementContainer.HasBase ( int  ele)
inline

Definition at line 228 of file ElementContainer.cs.

229 {
230 Element element = GetElement(ele);
231 if (element == null)
232 {
233 return false;
234 }
235 int num = element.ValueWithoutLink;
236 switch (ele)
237 {
238 case 300:
239 num += Value(1516) * -4;
240 num += Value(1517) * 4;
241 break;
242 case 307:
243 num += Value(1524) * -4;
244 num += Value(1525) * 4;
245 break;
246 }
247 return num != 0;
248 }
int Value(int ele)

References GetElement(), Value(), and Element.ValueWithoutLink.

Referenced by ElementContainerCard.CheckSkillActions(), TraitBookSkill.OnRead(), TraitBookSkill.SetName(), TraitBookPlan.WriteNote(), and TraitBookSkill.WriteNote().

◆ ImportElementMap() [1/2]

void ElementContainer.ImportElementMap ( Dictionary< int, int >  map)
inline

Definition at line 128 of file ElementContainer.cs.

129 {
130 foreach (KeyValuePair<int, int> item in map)
131 {
132 GetOrCreateElement(item.Key).vSource += item.Value;
133 }
134 }

References GetOrCreateElement(), item, and Element.vSource.

Referenced by WindowChara.RefreshNote().

◆ ImportElementMap() [2/2]

ElementContainer ElementContainer.ImportElementMap ( int[]  ints)
inline

Definition at line 136 of file ElementContainer.cs.

137 {
138 for (int i = 0; i < ints.Length; i += 2)
139 {
140 GetOrCreateElement(ints[i]).vSource += ints[i + 1];
141 }
142 return this;
143 }

References GetOrCreateElement(), and Element.vSource.

◆ Learn()

void ElementContainer.Learn ( int  ele,
int  v = 1 
)
inline

Definition at line 255 of file ElementContainer.cs.

256 {
257 ModBase(ele, v);
258 OnLearn(ele);
259 }
Element ModBase(int ele, int v)
virtual void OnLearn(int ele)

References ModBase(), and OnLearn().

Referenced by DNA.Apply(), Element.CheckLevelBonus(), Religion.JoinFaith(), and TraitBookSkill.OnRead().

◆ ListBestAttributes()

List< Element > ElementContainer.ListBestAttributes ( )
inline

Definition at line 607 of file ElementContainer.cs.

608 {
609 List<Element> obj = ListElements((Element a) => a.HasTag("primary"));
610 obj.Sort((Element a, Element b) => (b.ValueWithoutLink - a.ValueWithoutLink) * 100000 + a.id - b.id);
611 return obj;
612 }
List< Element > ListElements(Func< Element, bool > shoudList=null, Comparison< Element > comparison=null)

References Element.HasTag(), Element.id, ListElements(), and Element.ValueWithoutLink.

Referenced by AI_Fuck.Finish(), and TraitDrinkMilkMother.OnDrink().

◆ ListBestSkills()

List< Element > ElementContainer.ListBestSkills ( )
inline

Definition at line 614 of file ElementContainer.cs.

615 {
616 List<Element> obj = ListElements((Element a) => a.source.category == "skill");
617 obj.Sort((Element a, Element b) => (b.ValueWithoutLink - a.ValueWithoutLink) * 100000 + a.id - b.id);
618 return obj;
619 }

References Element.id, ListElements(), Element.source, and Element.ValueWithoutLink.

Referenced by TraitDrinkMilkMother.OnDrink(), and LayerEmbark.RefreshMembers().

◆ ListElements()

List< Element > ElementContainer.ListElements ( Func< Element, bool >  shoudList = null,
Comparison< Element comparison = null 
)
inline

Definition at line 550 of file ElementContainer.cs.

551 {
552 List<Element> list = new List<Element>();
553 List<Element> eles = dict.Values.ToList();
554 if (Card != null && Card.Chara != null)
555 {
557 {
558 AddElements(EClass.pc.faction.charaElements, isGlobal: true);
559 }
560 AddElements(Card.Chara.faithElements, isGlobal: false);
561 }
562 foreach (Element item2 in eles)
563 {
564 if (shoudList == null || shoudList(item2))
565 {
566 list.Add(item2);
567 }
568 }
569 if (comparison != null)
570 {
571 list.Sort(comparison);
572 }
573 return list;
574 void AddElements(ElementContainer container, bool isGlobal)
575 {
576 if (container == null)
577 {
578 return;
579 }
580 foreach (Element value in container.dict.Values)
581 {
582 bool flag = true;
583 foreach (Element item3 in eles)
584 {
585 if (value.id == item3.id)
586 {
587 flag = false;
588 break;
589 }
590 }
591 if (flag && value.Value != 0)
592 {
593 if (isGlobal)
594 {
596 eles.Add(item);
597 }
598 else
599 {
600 eles.Add(value);
601 }
602 }
603 }
604 }
605 }
virtual Chara Chara
Definition: Card.cs:1970
ElementContainerCard elements
Definition: Card.cs:37
Faction faction
Definition: Chara.cs:417
override bool IsPCFaction
Definition: Chara.cs:661
ElementContainer faithElements
Definition: Chara.cs:38
static Chara pc
Definition: EClass.cs:14
ElementContainerFaction charaElements
Definition: FACTION.cs:144

References Card.Chara, Faction.charaElements, CreateElement(), dict, Card.elements, Chara.faction, Chara.faithElements, Element.id, Chara.IsPCFaction, item, list, EClass.pc, and Element.Value.

Referenced by WidgetStatsBar.Build(), Card.CanAddRune(), ListBestAttributes(), ListBestSkills(), ListGeneFeats(), ListRune(), ActEffect.Proc(), WindowCharaMini.Refresh(), WindowChara.RefreshSkill(), and WindowChara.RefreshStatic().

◆ ListGeneFeats()

List< Element > ElementContainer.ListGeneFeats ( )
inline

Definition at line 621 of file ElementContainer.cs.

622 {
623 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);
624 }

References ListElements(), Element.source, and Element.Value.

◆ ListLearnable()

List< Element > ElementContainer.ListLearnable ( Chara  c)
inline

Definition at line 626 of file ElementContainer.cs.

627 {
628 List<Element> list = new List<Element>();
629 foreach (KeyValuePair<int, Element> item in c.elements.dict)
630 {
631 if (!dict.ContainsKey(item.Key))
632 {
633 list.Add(item.Value);
634 }
635 }
636 return list;
637 }

References dict, item, and list.

◆ ListRune()

List< Element > ElementContainer.ListRune ( )
inline

Definition at line 639 of file ElementContainer.cs.

640 {
641 return ListElements((Element a) => !a.source.encSlot.IsEmpty() && a.vBase + a.vSource != 0);
642 }

References ListElements(), Element.source, Element.vBase, and Element.vSource.

Referenced by TraitCrafter.Craft().

◆ ModBase()

Element ElementContainer.ModBase ( int  ele,
int  v 
)
inline

Definition at line 401 of file ElementContainer.cs.

402 {
403 Element orCreateElement = GetOrCreateElement(ele);
404 orCreateElement.vBase += v;
405 if (parent != null && orCreateElement.CanLink(this))
406 {
407 parent.ModLink(ele, v);
408 }
409 orCreateElement.CheckLevelBonus(this);
410 orCreateElement.OnChangeValue();
411 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
412 {
413 Remove(orCreateElement.id);
414 }
415 return orCreateElement;
416 }
ElementContainer parent
Element ModLink(int id, int v)
virtual void OnChangeValue()
Definition: ELEMENT.cs:955
void CheckLevelBonus(ElementContainer owner, UINote n=null)
Definition: ELEMENT.cs:959
virtual bool CanLink(ElementContainer owner)
Definition: ELEMENT.cs:464

References Element.CanLink(), Element.CheckLevelBonus(), GetOrCreateElement(), Element.id, ModLink(), Element.OnChangeValue(), parent, Remove(), Element.vBase, Element.vExp, Element.vLink, Element.vPotential, and Element.vSource.

Referenced by DNA.Apply(), Feat.Apply(), Thing.ApplyMaterial(), Card.ApplySocket(), TraitDrink.BlendLove(), TraitDrink.BlendPoison(), CoreDebug.COM_MaxConstruction(), Card.Decay(), Card.EjectSockets(), CoreDebug.Fix_EtherDisease(), AI_Shear.GetFur(), Learn(), Card.MakeFoodFrom(), CraftUtil.MixIngredients(), Card.ModEncLv(), ModExp(), Chara.ModTempElement(), TraitDrinkMilkMother.OnDrink(), ElementContainerFaction.OnEquip(), FactionBranch.OnUnclaimZone(), ElementContainerFaction.OnUnequip(), ActEffect.Proc(), CoreDebug.QuickStart(), Chara.RefreshWorkElements(), AI_Idle.Run(), Card.SetBlessedState(), Card.SetLv(), Chara.SetMainElement(), SetTo(), ConDisease.Tick(), Map.TryShatter(), TraitFoodEgg.Update(), and FactionBranch.Upgrade().

◆ ModExp()

void ElementContainer.ModExp ( int  ele,
int  a,
bool  chain = false 
)
inline

Definition at line 267 of file ElementContainer.cs.

268 {
269 if ((Card != null && Card.isChara && Card.Chara.isDead) || a == 0)
270 {
271 return;
272 }
273 Element element = GetElement(ele);
274 if (element == null || !element.CanGainExp)
275 {
276 return;
277 }
278 int value = (element.UsePotential ? element.Potential : 100);
279 if (element.UseExpMod && a >= 0)
280 {
281 float num = (float)a * (float)Mathf.Clamp(value, 10, 1000) / (float)(100 + Mathf.Max(0, element.ValueWithoutLink) * 25);
282 a = (int)num;
283 if (EClass.rndf(1f) < num % 1f)
284 {
285 a++;
286 }
287 }
288 element.vExp += a;
289 if (!chain && element.source.parentFactor > 0f && Card != null && !element.source.aliasParent.IsEmpty())
290 {
291 Element element2 = element.GetParent(Card);
292 if (element2.CanGainExp)
293 {
294 ModExp(element2.id, (int)Math.Max(1f, (float)a * element.source.parentFactor / 100f), chain: true);
295 }
296 }
297 if (element.vExp >= element.ExpToNext)
298 {
299 int num2 = element.vExp - element.ExpToNext;
300 int vBase = element.vBase;
301 ModBase(ele, 1);
302 OnLevelUp(element, vBase);
303 element.vExp = Mathf.Clamp(num2 / 2, 0, element.ExpToNext / 2);
304 if (element.vTempPotential > 0)
305 {
306 element.vTempPotential -= element.vTempPotential / 4 + EClass.rnd(5) + 5;
307 if (element.vTempPotential < 0)
308 {
309 element.vTempPotential = 0;
310 }
311 }
312 else if (element.vTempPotential < 0)
313 {
314 element.vTempPotential += -element.vTempPotential / 4 + EClass.rnd(5) + 5;
315 if (element.vTempPotential > 0)
316 {
317 element.vTempPotential = 0;
318 }
319 }
320 }
321 else if (element.vExp < 0)
322 {
323 if (element.ValueWithoutLink <= 1)
324 {
325 element.vExp = 0;
326 return;
327 }
328 int vBase2 = element.vBase;
329 ModBase(ele, -1);
330 OnLevelDown(element, vBase2);
331 element.vExp = Mathf.Max(element.ExpToNext / 2, element.ExpToNext + element.vExp);
332 }
333 }
virtual bool isChara
Definition: Card.cs:1983
bool isDead
Definition: Chara.cs:379
static int rnd(int a)
Definition: EClass.cs:58
static float rndf(float a)
Definition: EClass.cs:87
void ModExp(int ele, int a, bool chain=false)
virtual void OnLevelDown(Element e, int lastValue)
virtual void OnLevelUp(Element e, int lastValue)
virtual bool CanGainExp
Definition: ELEMENT.cs:296
virtual bool UseExpMod
Definition: ELEMENT.cs:306
int vTempPotential
Definition: ELEMENT.cs:254
Element GetParent(Card c)
Definition: ELEMENT.cs:518
virtual int ExpToNext
Definition: ELEMENT.cs:304

References Element.CanGainExp, Card.Chara, Element.ExpToNext, GetElement(), Element.GetParent(), Element.id, Card.isChara, Chara.isDead, ModBase(), ModExp(), OnLevelDown(), OnLevelUp(), EClass.rnd(), EClass.rndf(), Element.source, Element.UseExpMod, Element.ValueWithoutLink, Element.vBase, Element.vExp, and Element.vTempPotential.

Referenced by TraitAltar._OnOffer(), Chara.ApplyDeathPenalty(), StatsMana.Mod(), Card.ModExp(), ModExp(), Player.MoveZone(), Policy.OnAdvanceHour(), TaskChopWood.OnCreateProgress(), TaskDig.OnCreateProgress(), TaskDrawWater.OnCreateProgress(), TaskHarvest.OnCreateProgress(), TaskMine.OnCreateProgress(), TaskPlow.OnCreateProgress(), TaskPourWater.OnCreateProgress(), TaskCraft.OnProgress(), AI_Fish.ProgressFish.OnProgressComplete(), TaskCraft.OnProgressComplete(), TaskDig.OnProgressComplete(), TaskMine.OnProgressComplete(), TraitBookSkill.OnRead(), TraitScrollStatic.OnRead(), FoodEffect.Proc(), AI_Fuck.Run(), AI_PlayMusic.Run(), AI_Shear.Run(), AI_Slaughter.Run(), AI_Steal.Run(), AI_UseCrafter.Run(), and Card.SpawnLoot().

◆ ModLink()

Element ElementContainer.ModLink ( int  id,
int  v 
)
inlineprivate

Definition at line 449 of file ElementContainer.cs.

450 {
451 Element orCreateElement = GetOrCreateElement(id);
452 orCreateElement.vLink += v;
453 orCreateElement.OnChangeValue();
454 if (parent != null && orCreateElement.CanLink(this))
455 {
456 parent.ModLink(id, v);
457 }
458 return orCreateElement;
459 }

References Element.CanLink(), GetOrCreateElement(), ModLink(), Element.OnChangeValue(), and parent.

Referenced by ModBase(), ModLink(), Remove(), SetBase(), and SetParent().

◆ ModPotential()

Element ElementContainer.ModPotential ( int  ele,
int  v 
)
inline

Definition at line 422 of file ElementContainer.cs.

423 {
424 Element orCreateElement = GetOrCreateElement(ele);
425 orCreateElement.vPotential += v;
426 if (orCreateElement.vPotential > 1000)
427 {
428 orCreateElement.vPotential = 1000;
429 }
430 return orCreateElement;
431 }

References GetOrCreateElement(), and Element.vPotential.

Referenced by Feat.Apply(), and FoodEffect.Proc().

◆ ModTempPotential()

Element ElementContainer.ModTempPotential ( int  ele,
int  v,
int  threshMsg = 0 
)
inline

Definition at line 433 of file ElementContainer.cs.

434 {
435 Element orCreateElement = GetOrCreateElement(ele);
436 orCreateElement.vTempPotential += v;
437 if (orCreateElement.vTempPotential > 1000)
438 {
439 orCreateElement.vTempPotential = 1000;
440 }
441 OnModTempPotential(orCreateElement, v, threshMsg);
442 return orCreateElement;
443 }
virtual void OnModTempPotential(Element e, int v, int threshMsg)

References GetOrCreateElement(), OnModTempPotential(), and Element.vTempPotential.

Referenced by AI_Fuck.Finish(), FoodEffect.Proc(), ActEffect.Proc(), AI_Idle.Run(), and Train().

◆ OnChangeValue()

virtual void ElementContainer.OnChangeValue ( )
inlinevirtual

Definition at line 418 of file ElementContainer.cs.

419 {
420 }

◆ OnDeserialized()

void ElementContainer.OnDeserialized ( StreamingContext  context)
inlineprivate

Definition at line 52 of file ElementContainer.cs.

53 {
54 if (list == null)
55 {
56 return;
57 }
58 for (int i = 0; i < list.Count; i += 5)
59 {
60 Element orCreateElement = GetOrCreateElement(list[i]);
61 if (orCreateElement != null)
62 {
63 orCreateElement.vBase += list[i + 1];
64 orCreateElement.vExp += list[i + 2];
65 orCreateElement.vPotential += list[i + 3];
66 orCreateElement.vTempPotential = list[i + 4];
67 orCreateElement.owner = this;
68 }
69 }
70 }

References GetOrCreateElement(), and list.

◆ OnLearn()

virtual void ElementContainer.OnLearn ( int  ele)
inlinevirtual

Reimplemented in ElementContainerCard, and ElementContainerZone.

Definition at line 335 of file ElementContainer.cs.

336 {
337 }

Referenced by Learn().

◆ OnLevelDown()

virtual void ElementContainer.OnLevelDown ( Element  e,
int  lastValue 
)
inlinevirtual

Reimplemented in ElementContainerCard.

Definition at line 347 of file ElementContainer.cs.

348 {
349 }

Referenced by ModExp().

◆ OnLevelUp()

virtual void ElementContainer.OnLevelUp ( Element  e,
int  lastValue 
)
inlinevirtual

Reimplemented in ElementContainerCard, and ElementContainerZone.

Definition at line 343 of file ElementContainer.cs.

344 {
345 }

Referenced by ModExp().

◆ OnModTempPotential()

virtual void ElementContainer.OnModTempPotential ( Element  e,
int  v,
int  threshMsg 
)
inlinevirtual

Reimplemented in ElementContainerCard.

Definition at line 445 of file ElementContainer.cs.

446 {
447 }

Referenced by ModTempPotential().

◆ OnSerializing()

void ElementContainer.OnSerializing ( StreamingContext  context)
inlineprivate

Definition at line 35 of file ElementContainer.cs.

36 {
37 list = new List<int>();
38 foreach (Element value in dict.Values)
39 {
40 if (value.vBase != 0 || value.vExp != 0 || value.vPotential != 0 || value.vTempPotential != 0)
41 {
42 list.AddRange(new int[5] { value.id, value.vBase, value.vExp, value.vPotential, value.vTempPotential });
43 }
44 }
45 if (list.Count == 0)
46 {
47 list = null;
48 }
49 }

References dict, Element.id, list, Element.vBase, Element.vExp, Element.vPotential, and Element.vTempPotential.

◆ OnTrain()

virtual void ElementContainer.OnTrain ( int  ele)
inlinevirtual

Reimplemented in ElementContainerCard.

Definition at line 339 of file ElementContainer.cs.

340 {
341 }

Referenced by Train().

◆ Remove()

void ElementContainer.Remove ( int  id)
inline

Definition at line 388 of file ElementContainer.cs.

389 {
390 Element element = GetElement(id);
391 if (element != null)
392 {
393 if (parent != null && element.CanLink(this))
394 {
395 parent.ModLink(id, -element.Value);
396 }
397 dict.Remove(id);
398 }
399 }

References Element.CanLink(), dict, GetElement(), ModLink(), parent, and Element.Value.

Referenced by ApplyMaterialElementMap(), Card.CheckJustCooked(), ModBase(), Chara.ModTempElement(), Trait.OnBarter(), Player.OnStartNewGame(), SetBase(), and SetTo().

◆ SetBase() [1/2]

Element ElementContainer.SetBase ( int  id,
int  v,
int  potential = 0 
)
inline

Definition at line 356 of file ElementContainer.cs.

357 {
358 Element orCreateElement = GetOrCreateElement(id);
359 if (parent != null && orCreateElement.CanLink(this))
360 {
361 parent.ModLink(id, -orCreateElement.vBase + v);
362 }
363 orCreateElement.vBase = v;
364 orCreateElement.vExp = 0;
365 orCreateElement.vPotential = potential;
366 orCreateElement.OnChangeValue();
367 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
368 {
369 Remove(orCreateElement.id);
370 }
371 return orCreateElement;
372 }

References Element.CanLink(), GetOrCreateElement(), Element.id, ModLink(), Element.OnChangeValue(), parent, Remove(), Element.vBase, Element.vExp, Element.vLink, Element.vPotential, and Element.vSource.

◆ SetBase() [2/2]

◆ SetParent() [1/2]

◆ SetParent() [2/2]

void ElementContainer.SetParent ( ElementContainer  newParent = null)
inline

Definition at line 525 of file ElementContainer.cs.

526 {
527 if (parent != null)
528 {
529 foreach (Element value in dict.Values)
530 {
531 if (value.CanLink(this))
532 {
533 parent.ModLink(value.id, -(value.vBase + value.vSource));
534 }
535 }
536 }
537 if (newParent != null)
538 {
539 foreach (Element value2 in dict.Values)
540 {
541 if (value2.CanLink(this))
542 {
543 newParent.ModLink(value2.id, value2.vBase + value2.vSource);
544 }
545 }
546 }
547 parent = newParent;
548 }

References Element.CanLink(), dict, Element.id, ModLink(), parent, Element.vBase, and Element.vSource.

◆ SetTo()

void ElementContainer.SetTo ( int  id,
int  v 
)
inline

Definition at line 374 of file ElementContainer.cs.

375 {
376 Element orCreateElement = GetOrCreateElement(id);
377 int num = v - (orCreateElement.vBase + orCreateElement.vSource);
378 if (num != 0)
379 {
380 ModBase(id, num);
381 }
382 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
383 {
384 Remove(orCreateElement.id);
385 }
386 }

References GetOrCreateElement(), Element.id, ModBase(), Remove(), Element.vBase, Element.vExp, Element.vLink, Element.vPotential, and Element.vSource.

Referenced by Card.AddRune(), DNA.GenerateWithGene(), TraitSeed.MakeSeed(), CraftUtil.MixIngredients(), TraitAgingShelf.OnProduce(), TraitDryBrick.OnProduce(), and Card.SetTier().

◆ Train()

void ElementContainer.Train ( int  ele,
int  a = 10 
)
inline

Definition at line 261 of file ElementContainer.cs.

262 {
263 OnTrain(ele);
264 ModTempPotential(ele, a);
265 }
virtual void OnTrain(int ele)
Element ModTempPotential(int ele, int v, int threshMsg=0)

References ModTempPotential(), and OnTrain().

◆ Value()

int ElementContainer.Value ( int  ele)
inline

◆ ValueBonus()

virtual int ElementContainer.ValueBonus ( Element  e)
inlinevirtual

Reimplemented in ElementContainerCard.

Definition at line 178 of file ElementContainer.cs.

179 {
180 return 0;
181 }

◆ ValueWithoutLink() [1/2]

int ElementContainer.ValueWithoutLink ( int  ele)
inline

◆ ValueWithoutLink() [2/2]

int ElementContainer.ValueWithoutLink ( string  alias)
inline

Definition at line 188 of file ElementContainer.cs.

189 {
190 return GetElement(alias)?.ValueWithoutLink ?? 0;
191 }

References GetElement(), and Element.ValueWithoutLink.

Member Data Documentation

◆ dict

◆ list

List<int> ElementContainer.list

◆ parent

ElementContainer ElementContainer.parent

Definition at line 21 of file ElementContainer.cs.

Referenced by ModBase(), ModLink(), Remove(), SetBase(), and SetParent().

◆ sizeElement

const int ElementContainer.sizeElement = 5
static

Definition at line 23 of file ElementContainer.cs.

Property Documentation

◆ Card

virtual Card ElementContainer.Card
get

◆ Chara

virtual Chara ElementContainer.Chara
get

◆ IsMeleeWeapon

virtual bool ElementContainer.IsMeleeWeapon
get

Definition at line 32 of file ElementContainer.cs.

Referenced by AttbWeapon.CanLink().


The documentation for this class was generated from the following file: