Elin Decompiled Documentation EA 23.153 Nightly
Loading...
Searching...
No Matches
ElementContainer Class Reference
Inheritance diagram for ElementContainer:
EClass ElementContainerCard ElementContainerCondition 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 LimitLink [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 680 of file ElementContainer.cs.

681 {
682 List<Element> list = new List<Element>();
683 foreach (Element value in dict.Values)
684 {
685 if ((isValid == null || isValid(value)) && (mode != NoteMode.CharaMake || value.ValueWithoutLink != 0) && (value.Value != 0 || mode == NoteMode.CharaMakeAttributes) && (!value.HasTag("hidden") || EClass.debug.showExtra))
686 {
687 list.Add(value);
688 }
689 }
690 if (addRaceFeat)
691 {
692 Element element = Element.Create(29, 1);
693 element.owner = this;
694 list.Add(element);
695 }
696 if (list.Count == 0)
697 {
698 return;
699 }
700 onAdd?.Invoke();
701 switch (mode)
702 {
703 case NoteMode.CharaMake:
704 case NoteMode.CharaMakeAttributes:
705 list.Sort((Element a, Element b) => a.GetSortVal(UIList.SortMode.ByElementParent) - b.GetSortVal(UIList.SortMode.ByElementParent));
706 break;
707 case NoteMode.BonusTrait:
708 list.Sort((Element a, Element b) => GetSortVal(b) - GetSortVal(a));
709 break;
710 default:
711 list.Sort((Element a, Element b) => a.SortVal() - b.SortVal());
712 break;
713 }
714 foreach (Element item in list)
715 {
716 item.AddEncNote(n, Card, mode, funcText, onAddNote);
717 }
718 }
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:292
bool HasTag(string tag)
Definition: ELEMENT.cs:471
int GetSortVal(UIList.SortMode m)
Definition: ELEMENT.cs:1002
int Value
Definition: ELEMENT.cs:290
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1097
int SortVal(bool charaSheet=false)
Definition: ELEMENT.cs:460
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 720 of file ElementContainer.cs.

721 {
722 Transform transform = n.AddExtra<Transform>("noteRace");
723 UINote n2 = transform.Find("note1").GetComponent<UINote>();
724 UINote n3 = transform.Find("note2").GetComponent<UINote>();
725 AddNote(n3, (Element e) => e.HasTag("primary"), delegate
726 {
727 n3.AddHeader("HeaderNoteSmall", "attributes");
728 }, NoteMode.CharaMakeAttributes);
729 AddNote(n2, (Element e) => e.source.category == "skill" && !e.HasTag("hidden") && e.ValueWithoutLink > 1 && e.source.categorySub != "weapon", delegate
730 {
731 n2.AddHeader("HeaderNoteSmall", "skills");
732 }, NoteMode.CharaMake);
733 AddNote(n2, (Element e) => e is Feat, delegate
734 {
735 n2.AddHeader("HeaderNoteSmall", "feats");
736 }, NoteMode.CharaMake);
737 }
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:271
Definition: FEAT.cs:255
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 74 of file ElementContainer.cs.

75 {
76 int num = ((!invert) ? 1 : (-1));
77 Rand.SetSeed(uid);
78 foreach (KeyValuePair<int, int> item in map)
79 {
80 Element orCreateElement = GetOrCreateElement(item.Key);
81 int value = item.Value;
82 if (value != 0)
83 {
84 if (orCreateElement.source.category == "skill")
85 {
86 orCreateElement.vSourcePotential += orCreateElement.GetSourcePotential(value) * num;
87 }
88 int num2 = orCreateElement.GetSourceValue(value, lv, type) * num;
89 orCreateElement.vSource += num2;
90 if (applyFeat && orCreateElement is Feat)
91 {
92 (orCreateElement as Feat).Apply(num2, this);
93 }
94 }
95 }
96 Rand.SetSeed();
97 }
Element GetOrCreateElement(Element ele)
virtual int GetSourceValue(int v, int lv, SourceValueType type)
Definition: ELEMENT.cs:436
virtual int GetSourcePotential(int v)
Definition: ELEMENT.cs:409
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 99 of file ElementContainer.cs.

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

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 147 of file ElementContainer.cs.

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

References dict, and Element.HasTag().

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

◆ Base()

int ElementContainer.Base ( int  ele)
inline

Definition at line 252 of file ElementContainer.cs.

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

References GetElement(), and Element.ValueWithoutLink.

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

◆ CopyTo()

void ElementContainer.CopyTo ( ElementContainer  container)
inline

Definition at line 650 of file ElementContainer.cs.

651 {
652 container.dict.Clear();
653 foreach (KeyValuePair<int, Element> item in dict)
654 {
655 Element element = container.CreateElement(item.Key);
656 element.vBase = item.Value.vBase;
657 element.vExp = item.Value.vExp;
658 element.vSource = item.Value.vSource;
659 }
660 }
Element CreateElement(int id)

References dict, and item.

Referenced by Card.Duplicate().

◆ CreateElement()

Element ElementContainer.CreateElement ( int  id)
inline

Definition at line 494 of file ElementContainer.cs.

495 {
496 Element element = Element.Create(id);
497 if (element == null)
498 {
499 return null;
500 }
501 element.owner = this;
502 dict.Add(id, element);
503 return element;
504 }

References Element.Create(), and dict.

Referenced by GetOrCreateElement(), and ListElements().

◆ Exp()

int ElementContainer.Exp ( int  ele)
inline

Definition at line 205 of file ElementContainer.cs.

206 {
207 return GetElement(ele)?.vExp ?? 0;
208 }

References GetElement(), and Element.vExp.

◆ GetElement() [1/2]

Element ElementContainer.GetElement ( int  id)
inline

Definition at line 489 of file ElementContainer.cs.

490 {
491 return dict.TryGetValue(id);
492 }

References dict.

◆ GetElement() [2/2]

◆ GetFeatRef()

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

Definition at line 195 of file ElementContainer.cs.

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

References Feat.featRef, and GetElement().

◆ GetOrCreateElement() [1/3]

◆ GetOrCreateElement() [2/3]

Element ElementContainer.GetOrCreateElement ( int  id)
inline

Definition at line 516 of file ElementContainer.cs.

517 {
518 Element value = null;
519 if (!dict.TryGetValue(id, out value))
520 {
521 value = CreateElement(id);
522 }
523 return value;
524 }

References CreateElement(), and dict.

◆ GetOrCreateElement() [3/3]

Element ElementContainer.GetOrCreateElement ( string  alias)
inline

Definition at line 511 of file ElementContainer.cs.

512 {
513 return GetOrCreateElement(EClass.sources.elements.alias[alias].id);
514 }

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

◆ GetSortVal()

static int ElementContainer.GetSortVal ( Element  a)
inlinestatic

Definition at line 662 of file ElementContainer.cs.

663 {
664 int num = a.Value;
665 if (a.source.textAlt.Length <= 2 || a.Value < 0)
666 {
667 num -= 100000;
668 }
669 if (a.id == 2)
670 {
671 num += 20000;
672 }
673 if (a.IsFoodTraitMain)
674 {
675 num += 10000;
676 }
677 return num;
678 }
bool IsFoodTraitMain
Definition: ELEMENT.cs:365

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 467 of file ElementContainer.cs.

468 {
469 Act.Cost cost = e.GetCost(c);
470 int num = cost.cost * ((cost.type == Act.CostType.SP) ? 20 : 5) * (100 + c.Evalue(1208) * 30) / 100 + 10;
471 num = num * costMod / 100;
472 if (!e.source.aliasParent.IsEmpty())
473 {
474 int num2 = ValueWithoutLink(e.source.aliasParent) - ValueWithoutLink(e.source.id);
475 num = ((num2 < 0) ? (num * 100 / (100 - num2 * 25)) : (num * (100 + num2 * 5) / 100));
476 }
477 if (num < 0)
478 {
479 num = 0;
480 }
481 return num;
482 }
Definition: ACT.cs:62
CostType
Definition: ACT.cs:64
int Evalue(int ele)
Definition: Card.cs:2507
int ValueWithoutLink(int ele)
virtual Act.Cost GetCost(Chara c)
Definition: ELEMENT.cs:1021
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 210 of file ElementContainer.cs.

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

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 220 of file ElementContainer.cs.

221 {
222 return Has(row.id);
223 }
bool Has(int ele)

References Has().

◆ Has() [3/3]

bool ElementContainer.Has ( string  alias)
inline

Definition at line 225 of file ElementContainer.cs.

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

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

◆ HasBase()

bool ElementContainer.HasBase ( int  ele)
inline

Definition at line 230 of file ElementContainer.cs.

231 {
232 Element element = GetElement(ele);
233 if (element == null)
234 {
235 return false;
236 }
237 int num = element.ValueWithoutLink;
238 switch (ele)
239 {
240 case 300:
241 num += Value(1516) * -4;
242 num += Value(1517) * 4;
243 break;
244 case 307:
245 num += Value(1524) * -4;
246 num += Value(1525) * 4;
247 break;
248 }
249 return num != 0;
250 }
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 130 of file ElementContainer.cs.

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

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

Referenced by WindowChara.RefreshNote().

◆ ImportElementMap() [2/2]

ElementContainer ElementContainer.ImportElementMap ( int[]  ints)
inline

Definition at line 138 of file ElementContainer.cs.

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

References GetOrCreateElement(), and Element.vSource.

◆ Learn()

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

Definition at line 257 of file ElementContainer.cs.

258 {
259 ModBase(ele, v);
260 OnLearn(ele);
261 }
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 613 of file ElementContainer.cs.

614 {
615 List<Element> obj = ListElements((Element a) => a.HasTag("primary"));
616 obj.Sort((Element a, Element b) => (b.ValueWithoutLink - a.ValueWithoutLink) * 100000 + a.id - b.id);
617 return obj;
618 }
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 620 of file ElementContainer.cs.

621 {
622 List<Element> obj = ListElements((Element a) => a.source.category == "skill");
623 obj.Sort((Element a, Element b) => (b.ValueWithoutLink - a.ValueWithoutLink) * 100000 + a.id - b.id);
624 return obj;
625 }

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 556 of file ElementContainer.cs.

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

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 627 of file ElementContainer.cs.

628 {
629 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);
630 }

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

◆ ListLearnable()

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

Definition at line 632 of file ElementContainer.cs.

633 {
634 List<Element> list = new List<Element>();
635 foreach (KeyValuePair<int, Element> item in c.elements.dict)
636 {
637 if (!dict.ContainsKey(item.Key))
638 {
639 list.Add(item.Value);
640 }
641 }
642 return list;
643 }

References dict, item, and list.

◆ ListRune()

List< Element > ElementContainer.ListRune ( )
inline

Definition at line 645 of file ElementContainer.cs.

646 {
647 return ListElements((Element a) => !a.source.encSlot.IsEmpty() && a.vBase + a.vSource != 0);
648 }

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 407 of file ElementContainer.cs.

408 {
409 Element orCreateElement = GetOrCreateElement(ele);
410 orCreateElement.vBase += v;
411 if (parent != null && (!LimitLink || orCreateElement.CanLink(this)))
412 {
413 parent.ModLink(ele, v);
414 }
415 orCreateElement.CheckLevelBonus(this);
416 orCreateElement.OnChangeValue();
417 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
418 {
419 Remove(orCreateElement.id);
420 }
421 return orCreateElement;
422 }
virtual bool LimitLink
ElementContainer parent
Element ModLink(int id, int v)
virtual void OnChangeValue()
Definition: ELEMENT.cs:957
void CheckLevelBonus(ElementContainer owner, UINote n=null)
Definition: ELEMENT.cs:961
virtual bool CanLink(ElementContainer owner)
Definition: ELEMENT.cs:466

References Element.CanLink(), Element.CheckLevelBonus(), GetOrCreateElement(), Element.id, LimitLink, 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 269 of file ElementContainer.cs.

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

References Element.CanGainExp, Card.Chara, Element.ExpToNext, Card.GetDaysTogetherBonus(), 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 455 of file ElementContainer.cs.

456 {
457 Element orCreateElement = GetOrCreateElement(id);
458 orCreateElement.vLink += v;
459 orCreateElement.OnChangeValue();
460 if (parent != null && (!LimitLink || orCreateElement.CanLink(this)))
461 {
462 parent.ModLink(id, v);
463 }
464 return orCreateElement;
465 }

References Element.CanLink(), GetOrCreateElement(), LimitLink, 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 428 of file ElementContainer.cs.

429 {
430 Element orCreateElement = GetOrCreateElement(ele);
431 orCreateElement.vPotential += v;
432 if (orCreateElement.vPotential > 1000)
433 {
434 orCreateElement.vPotential = 1000;
435 }
436 return orCreateElement;
437 }

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 439 of file ElementContainer.cs.

440 {
441 Element orCreateElement = GetOrCreateElement(ele);
442 orCreateElement.vTempPotential += v;
443 if (orCreateElement.vTempPotential > 1000)
444 {
445 orCreateElement.vTempPotential = 1000;
446 }
447 OnModTempPotential(orCreateElement, v, threshMsg);
448 return orCreateElement;
449 }
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 424 of file ElementContainer.cs.

425 {
426 }

◆ OnDeserialized()

void ElementContainer.OnDeserialized ( StreamingContext  context)
inlineprivate

Definition at line 54 of file ElementContainer.cs.

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

References GetOrCreateElement(), and list.

◆ OnLearn()

virtual void ElementContainer.OnLearn ( int  ele)
inlinevirtual

Reimplemented in ElementContainerCard, and ElementContainerZone.

Definition at line 341 of file ElementContainer.cs.

342 {
343 }

Referenced by Learn().

◆ OnLevelDown()

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

Reimplemented in ElementContainerCard.

Definition at line 353 of file ElementContainer.cs.

354 {
355 }

Referenced by ModExp().

◆ OnLevelUp()

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

Reimplemented in ElementContainerCard, and ElementContainerZone.

Definition at line 349 of file ElementContainer.cs.

350 {
351 }

Referenced by ModExp().

◆ OnModTempPotential()

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

Reimplemented in ElementContainerCard.

Definition at line 451 of file ElementContainer.cs.

452 {
453 }

Referenced by ModTempPotential().

◆ OnSerializing()

void ElementContainer.OnSerializing ( StreamingContext  context)
inlineprivate

Definition at line 37 of file ElementContainer.cs.

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

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 345 of file ElementContainer.cs.

346 {
347 }

Referenced by Train().

◆ Remove()

void ElementContainer.Remove ( int  id)
inline

Definition at line 394 of file ElementContainer.cs.

395 {
396 Element element = GetElement(id);
397 if (element != null)
398 {
399 if (parent != null && (!LimitLink || element.CanLink(this)))
400 {
401 parent.ModLink(id, -element.Value);
402 }
403 dict.Remove(id);
404 }
405 }

References Element.CanLink(), dict, GetElement(), LimitLink, 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 362 of file ElementContainer.cs.

363 {
364 Element orCreateElement = GetOrCreateElement(id);
365 if (parent != null && (!LimitLink || orCreateElement.CanLink(this)))
366 {
367 parent.ModLink(id, -orCreateElement.vBase + v);
368 }
369 orCreateElement.vBase = v;
370 orCreateElement.vExp = 0;
371 orCreateElement.vPotential = potential;
372 orCreateElement.OnChangeValue();
373 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
374 {
375 Remove(orCreateElement.id);
376 }
377 return orCreateElement;
378 }

References Element.CanLink(), GetOrCreateElement(), Element.id, LimitLink, 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 531 of file ElementContainer.cs.

532 {
533 if (parent != null)
534 {
535 foreach (Element value in dict.Values)
536 {
537 if (!LimitLink || value.CanLink(this))
538 {
539 parent.ModLink(value.id, -(value.vBase + value.vSource));
540 }
541 }
542 }
543 if (newParent != null)
544 {
545 foreach (Element value2 in dict.Values)
546 {
547 if (!LimitLink || value2.CanLink(this))
548 {
549 newParent.ModLink(value2.id, value2.vBase + value2.vSource);
550 }
551 }
552 }
553 parent = newParent;
554 }

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

◆ SetTo()

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

Definition at line 380 of file ElementContainer.cs.

381 {
382 Element orCreateElement = GetOrCreateElement(id);
383 int num = v - (orCreateElement.vBase + orCreateElement.vSource);
384 if (num != 0)
385 {
386 ModBase(id, num);
387 }
388 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
389 {
390 Remove(orCreateElement.id);
391 }
392 }

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

Referenced by Card.AddRune(), Card.ClampInitialSkill(), 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 263 of file ElementContainer.cs.

264 {
265 OnTrain(ele);
266 ModTempPotential(ele, a);
267 }
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 180 of file ElementContainer.cs.

181 {
182 return 0;
183 }

◆ ValueWithoutLink() [1/2]

int ElementContainer.ValueWithoutLink ( int  ele)
inline

◆ ValueWithoutLink() [2/2]

int ElementContainer.ValueWithoutLink ( string  alias)
inline

Definition at line 190 of file ElementContainer.cs.

191 {
192 return GetElement(alias)?.ValueWithoutLink ?? 0;
193 }

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 34 of file ElementContainer.cs.

Referenced by AttbWeapon.CanLink().

◆ LimitLink

virtual bool ElementContainer.LimitLink
get

Definition at line 32 of file ElementContainer.cs.

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


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