Elin Decompiled Documentation EA 23.293 Nightly
Loading...
Searching...
No Matches
ElementContainer Class Reference
Inheritance diagram for ElementContainer:
EClass ElementContainerCard ElementContainerCondition ElementContainerFaction ElementContainerField 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, float 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 (long a)
 
static int rnd (int a)
 
static int curve (long _a, int start, int step, int rate=75)
 
static int sqrt (int a)
 
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 693 of file ElementContainer.cs.

694 {
695 List<Element> list = new List<Element>();
696 foreach (Element value in dict.Values)
697 {
698 if ((isValid == null || isValid(value)) && (mode != NoteMode.CharaMake || value.ValueWithoutLink != 0) && (value.Value != 0 || mode == NoteMode.CharaMakeAttributes) && (!value.HasTag("hidden") || EClass.debug.showExtra))
699 {
700 list.Add(value);
701 }
702 }
703 if (addRaceFeat)
704 {
705 Element element = Element.Create(29, 1);
706 element.owner = this;
707 list.Add(element);
708 }
709 if (list.Count == 0)
710 {
711 return;
712 }
713 onAdd?.Invoke();
714 switch (mode)
715 {
716 case NoteMode.CharaMake:
717 case NoteMode.CharaMakeAttributes:
718 list.Sort((Element a, Element b) => a.GetSortVal(UIList.SortMode.ByElementParent) - b.GetSortVal(UIList.SortMode.ByElementParent));
719 break;
720 case NoteMode.BonusTrait:
721 list.Sort((Element a, Element b) => GetSortVal(b) - GetSortVal(a));
722 break;
723 default:
724 list.Sort((Element a, Element b) => a.SortVal() - b.SortVal());
725 break;
726 }
727 foreach (Element item in list)
728 {
729 item.AddEncNote(n, Card, mode, funcText, onAddNote);
730 }
731 }
Definition: Card.cs:11
bool showExtra
Definition: CoreDebug.cs:168
Definition: EClass.cs:6
static CoreDebug debug
Definition: EClass.cs:49
static int GetSortVal(Element a)
Dictionary< int, Element > dict
int ValueWithoutLink
Definition: ELEMENT.cs:299
bool HasTag(string tag)
Definition: ELEMENT.cs:478
int GetSortVal(UIList.SortMode m)
Definition: ELEMENT.cs:1022
int Value
Definition: ELEMENT.cs:297
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1115
int SortVal(bool charaSheet=false)
Definition: ELEMENT.cs:467
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 733 of file ElementContainer.cs.

734 {
735 Transform transform = n.AddExtra<Transform>("noteRace");
736 UINote n2 = transform.Find("note1").GetComponent<UINote>();
737 UINote n3 = transform.Find("note2").GetComponent<UINote>();
738 AddNote(n3, (Element e) => e.HasTag("primary"), delegate
739 {
740 n3.AddHeader("HeaderNoteSmall", "attributes");
741 }, NoteMode.CharaMakeAttributes);
742 AddNote(n2, (Element e) => e.source.category == "skill" && !e.HasTag("hidden") && e.ValueWithoutLink > 1 && e.source.categorySub != "weapon", delegate
743 {
744 n2.AddHeader("HeaderNoteSmall", "skills");
745 }, NoteMode.CharaMake);
746 AddNote(n2, (Element e) => e is Feat, delegate
747 {
748 n2.AddHeader("HeaderNoteSmall", "feats");
749 }, NoteMode.CharaMake);
750 }
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:278
Definition: FEAT.cs:322
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 if (lv > 10000000)
89 {
90 lv = 10000000;
91 }
92 long num2 = orCreateElement.GetSourceValue(value, lv, type) * num;
93 if (num2 >= 99999999)
94 {
95 num2 = 99999999L;
96 }
97 orCreateElement.vSource += (int)num2;
98 if (applyFeat && orCreateElement is Feat)
99 {
100 (orCreateElement as Feat).Apply((int)num2, this);
101 }
102 }
103 }
104 Rand.SetSeed();
105 }
Element GetOrCreateElement(Element ele)
virtual long GetSourceValue(long v, int lv, SourceValueType type)
Definition: ELEMENT.cs:443
virtual int GetSourcePotential(int v)
Definition: ELEMENT.cs:416
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:44

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

108 {
109 int num = ((!invert) ? 1 : (-1));
111 Rand.SetSeed(t.uid);
112 foreach (KeyValuePair<int, int> item in material.elementMap)
113 {
114 int value = item.Value;
115 if (value == 0)
116 {
117 continue;
118 }
119 Element orCreateElement = GetOrCreateElement(item.Key);
120 if (!orCreateElement.source.IsMaterialEncAppliable(t))
121 {
122 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vExp == 0 && orCreateElement.vPotential == 0)
123 {
124 Remove(orCreateElement.id);
125 }
126 continue;
127 }
128 int num2 = orCreateElement.GetMaterialSourceValue(t, value) * num;
129 orCreateElement.vSource += num2;
130 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vExp == 0 && orCreateElement.vPotential == 0)
131 {
132 Remove(orCreateElement.id);
133 }
134 }
135 Rand.SetSeed();
136 }
SourceMaterial.Row material
Definition: Card.cs:2089
int uid
Definition: Card.cs:123
void Remove(int id)
int GetMaterialSourceValue(Thing t, int v)
Definition: ELEMENT.cs:426
int id
Definition: ELEMENT.cs:255
int vBase
Definition: ELEMENT.cs:257
int vExp
Definition: ELEMENT.cs:259
int vPotential
Definition: ELEMENT.cs:261
int vLink
Definition: ELEMENT.cs:265
int vSource
Definition: ELEMENT.cs:267

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

156 {
157 foreach (Element value in dict.Values)
158 {
159 if (value.HasTag("primary"))
160 {
161 value.vTempPotential = Mathf.Max(30, (value.ValueWithoutLink - ((mode != 2) ? 8 : 0)) * 7);
162 }
163 }
164 }

References dict, Element.HasTag(), and Element.ValueWithoutLink.

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

◆ Base()

int ElementContainer.Base ( int  ele)
inline

Definition at line 260 of file ElementContainer.cs.

261 {
262 return GetElement(ele)?.ValueWithoutLink ?? 0;
263 }
Element GetElement(string alias)

References GetElement(), and Element.ValueWithoutLink.

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

◆ CopyTo()

void ElementContainer.CopyTo ( ElementContainer  container)
inline

Definition at line 663 of file ElementContainer.cs.

664 {
665 container.dict.Clear();
666 foreach (KeyValuePair<int, Element> item in dict)
667 {
668 Element element = container.CreateElement(item.Key);
669 element.vBase = item.Value.vBase;
670 element.vExp = item.Value.vExp;
671 element.vSource = item.Value.vSource;
672 }
673 }
Element CreateElement(int id)

References dict, and item.

Referenced by Card.Duplicate().

◆ CreateElement()

Element ElementContainer.CreateElement ( int  id)
inline

Definition at line 507 of file ElementContainer.cs.

508 {
509 Element element = Element.Create(id);
510 if (element == null)
511 {
512 return null;
513 }
514 element.owner = this;
515 dict.Add(id, element);
516 return element;
517 }

References Element.Create(), and dict.

Referenced by GetOrCreateElement(), and ListElements().

◆ Exp()

int ElementContainer.Exp ( int  ele)
inline

Definition at line 213 of file ElementContainer.cs.

214 {
215 return GetElement(ele)?.vExp ?? 0;
216 }

References GetElement(), and Element.vExp.

◆ GetElement() [1/2]

Element ElementContainer.GetElement ( int  id)
inline

Definition at line 502 of file ElementContainer.cs.

503 {
504 return dict.TryGetValue(id);
505 }

References dict.

◆ GetElement() [2/2]

◆ GetFeatRef()

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

Definition at line 203 of file ElementContainer.cs.

204 {
205 if (!(GetElement(ele) is Feat feat))
206 {
207 return 0;
208 }
209 feat.Apply(feat.Value, this);
210 return Feat.featRef[idx].ToInt();
211 }
static string[] featRef
Definition: FEAT.cs:325

References Feat.featRef, and GetElement().

◆ GetOrCreateElement() [1/3]

◆ GetOrCreateElement() [2/3]

Element ElementContainer.GetOrCreateElement ( int  id)
inline

Definition at line 529 of file ElementContainer.cs.

530 {
531 Element value = null;
532 if (!dict.TryGetValue(id, out value))
533 {
534 value = CreateElement(id);
535 }
536 return value;
537 }

References CreateElement(), and dict.

◆ GetOrCreateElement() [3/3]

Element ElementContainer.GetOrCreateElement ( string  alias)
inline

Definition at line 524 of file ElementContainer.cs.

525 {
526 return GetOrCreateElement(EClass.sources.elements.alias[alias].id);
527 }

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

◆ GetSortVal()

static int ElementContainer.GetSortVal ( Element  a)
inlinestatic

Definition at line 675 of file ElementContainer.cs.

676 {
677 int num = a.Value;
678 if (a.source.textAlt.Length <= 2 || a.Value < 0)
679 {
680 num -= 100000;
681 }
682 if (a.id == 2)
683 {
684 num += 20000;
685 }
686 if (a.IsFoodTraitMain)
687 {
688 num += 10000;
689 }
690 return num;
691 }
bool IsFoodTraitMain
Definition: ELEMENT.cs:372

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

477 {
478 Act.Cost cost = e.GetCost(c);
479 int num = cost.cost * ((cost.type == Act.CostType.SP) ? 20 : 5) * (100 + c.Evalue(1208) * 30) / 100 + 10;
480 num = num * costMod / 100;
481 if (!e.source.aliasParent.IsEmpty())
482 {
483 int num2 = ValueWithoutLink(e.source.aliasParent) - ValueWithoutLink(e.source.id);
484 if (num2 > 10000)
485 {
486 num2 = 10000;
487 }
488 num = ((num2 < 0) ? (num * 100 / (100 - num2 * 25)) : (num * (100 + num2 * 5) / 100));
489 }
490 if (num < 0)
491 {
492 num = 0;
493 }
494 return num;
495 }
Definition: ACT.cs:62
CostType
Definition: ACT.cs:64
int Evalue(int ele)
Definition: Card.cs:2611
int ValueWithoutLink(int ele)
virtual Act.Cost GetCost(Chara c)
Definition: ELEMENT.cs:1045
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

◆ Has() [2/3]

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

Definition at line 228 of file ElementContainer.cs.

229 {
230 return Has(row.id);
231 }
bool Has(int ele)

References Has().

◆ Has() [3/3]

bool ElementContainer.Has ( string  alias)
inline

Definition at line 233 of file ElementContainer.cs.

234 {
235 return Has(EClass.sources.elements.alias[alias].id);
236 }

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

◆ HasBase()

bool ElementContainer.HasBase ( int  ele)
inline

Definition at line 238 of file ElementContainer.cs.

239 {
240 Element element = GetElement(ele);
241 if (element == null)
242 {
243 return false;
244 }
245 int num = element.ValueWithoutLink;
246 switch (ele)
247 {
248 case 300:
249 num += Value(1516) * -4;
250 num += Value(1517) * 4;
251 break;
252 case 307:
253 num += Value(1524) * -4;
254 num += Value(1525) * 4;
255 break;
256 }
257 return num != 0;
258 }
int Value(int ele)

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

Referenced by LayerSleep.Advance(), ElementContainerCard.CheckSkillActions(), Trait.OnBarter(), TraitBookSkill.OnRead(), TraitBookSkill.SetName(), TraitBookPlan.WriteNote(), and TraitBookSkill.WriteNote().

◆ ImportElementMap() [1/2]

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

Definition at line 138 of file ElementContainer.cs.

139 {
140 foreach (KeyValuePair<int, int> item in map)
141 {
142 GetOrCreateElement(item.Key).vSource += item.Value;
143 }
144 }

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

Referenced by WindowChara.RefreshNote().

◆ ImportElementMap() [2/2]

ElementContainer ElementContainer.ImportElementMap ( int[]  ints)
inline

Definition at line 146 of file ElementContainer.cs.

147 {
148 for (int i = 0; i < ints.Length; i += 2)
149 {
150 GetOrCreateElement(ints[i]).vSource += ints[i + 1];
151 }
152 return this;
153 }

References GetOrCreateElement(), and Element.vSource.

◆ Learn()

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

Definition at line 265 of file ElementContainer.cs.

266 {
267 ModBase(ele, v);
268 OnLearn(ele);
269 }
Element ModBase(int ele, int v)
virtual void OnLearn(int ele)

References ModBase(), and OnLearn().

Referenced by LayerSleep.Advance(), DNA.Apply(), Element.CheckLevelBonus(), Religion.JoinFaith(), QuestWedding.OnDropReward(), and TraitBookSkill.OnRead().

◆ ListBestAttributes()

List< Element > ElementContainer.ListBestAttributes ( )
inline

Definition at line 626 of file ElementContainer.cs.

627 {
628 List<Element> obj = ListElements((Element a) => a.HasTag("primary"));
629 obj.Sort((Element a, Element b) => (b.ValueWithoutLink != a.ValueWithoutLink) ? (b.ValueWithoutLink - a.ValueWithoutLink) : (a.id - b.id));
630 return obj;
631 }
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 633 of file ElementContainer.cs.

634 {
635 List<Element> obj = ListElements((Element a) => a.source.category == "skill");
636 obj.Sort((Element a, Element b) => (b.ValueWithoutLink != a.ValueWithoutLink) ? (b.ValueWithoutLink - a.ValueWithoutLink) : (a.id - b.id));
637 return obj;
638 }

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

570 {
571 List<Element> list = new List<Element>();
572 List<Element> eles = dict.Values.ToList();
573 if (Card != null && Card.Chara != null)
574 {
576 {
577 AddElements(EClass.pc.faction.charaElements, isGlobal: true);
578 }
579 AddElements(Card.Chara.faithElements, isGlobal: false);
580 }
581 foreach (Element item2 in eles)
582 {
583 if (shoudList == null || shoudList(item2))
584 {
585 list.Add(item2);
586 }
587 }
588 if (comparison != null)
589 {
590 list.Sort(comparison);
591 }
592 return list;
593 void AddElements(ElementContainer container, bool isGlobal)
594 {
595 if (container == null)
596 {
597 return;
598 }
599 foreach (Element value in container.dict.Values)
600 {
601 bool flag = true;
602 foreach (Element item3 in eles)
603 {
604 if (value.id == item3.id)
605 {
606 flag = false;
607 break;
608 }
609 }
610 if (flag && value.Value != 0)
611 {
612 if (isGlobal)
613 {
615 eles.Add(item);
616 }
617 else
618 {
619 eles.Add(value);
620 }
621 }
622 }
623 }
624 }
virtual Chara Chara
Definition: Card.cs:2108
ElementContainerCard elements
Definition: Card.cs:42
Faction faction
Definition: Chara.cs:429
override bool IsPCFaction
Definition: Chara.cs:685
ElementContainer faithElements
Definition: Chara.cs:38
static Chara pc
Definition: EClass.cs:15
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 640 of file ElementContainer.cs.

641 {
642 return ListElements((Element a) => a.ValueWithoutLink > 0 && a.source.category == "feat" && a.source.cost.Length != 0 && a.source.cost[0] > 0 && a.source.geneSlot >= 0);
643 }

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

◆ ListLearnable()

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

Definition at line 645 of file ElementContainer.cs.

646 {
647 List<Element> list = new List<Element>();
648 foreach (KeyValuePair<int, Element> item in c.elements.dict)
649 {
650 if (!dict.ContainsKey(item.Key))
651 {
652 list.Add(item.Value);
653 }
654 }
655 return list;
656 }

References dict, item, and list.

◆ ListRune()

List< Element > ElementContainer.ListRune ( )
inline

Definition at line 658 of file ElementContainer.cs.

659 {
660 return ListElements((Element a) => !a.source.encSlot.IsEmpty() && a.vBase + a.vSource != 0);
661 }

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

417 {
418 Element orCreateElement = GetOrCreateElement(ele);
419 orCreateElement.vBase += v;
420 if (parent != null && (!LimitLink || orCreateElement.CanLink(this)))
421 {
422 parent.ModLink(ele, v);
423 }
424 orCreateElement.CheckLevelBonus(this);
425 orCreateElement.OnChangeValue();
426 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
427 {
428 Remove(orCreateElement.id);
429 }
430 return orCreateElement;
431 }
virtual bool LimitLink
ElementContainer parent
Element ModLink(int id, int v)
virtual void OnChangeValue()
Definition: ELEMENT.cs:977
void CheckLevelBonus(ElementContainer owner, UINote n=null)
Definition: ELEMENT.cs:981
virtual bool CanLink(ElementContainer owner)
Definition: ELEMENT.cs:473

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 Card._OnDeserialized(), CharaAbility.Add(), DNA.Apply(), Feat.Apply(), Thing.ApplyMaterial(), Card.ApplySocket(), TraitDrink.BlendLove(), TraitDrink.BlendPoison(), CoreDebug.COM_MaxConstruction(), Card.Decay(), Card.EjectSockets(), AI_Fuck.Finish(), CoreDebug.Fix_EtherDisease(), AI_Shear.GetFur(), Learn(), CraftUtil.MakeBloodMeal(), Card.MakeFoodFrom(), CraftUtil.MixIngredients(), Card.ModEncLv(), ModExp(), Chara.ModTempElement(), TraitDrinkMilkMother.OnDrink(), ElementContainerFaction.OnEquip(), FactionBranch.OnUnclaimZone(), ElementContainerFaction.OnUnequip(), ZoneEventWedding.OnVisit(), ActEffect.Proc(), CoreDebug.QuickStart(), Chara.RefreshWorkElements(), AI_Idle.Run(), Card.SetBlessedState(), Card.SetLv(), Chara.SetMainElement(), SetTo(), ConDisease.Tick(), ConPeaky.Tick(), ConVampire.Tick(), Map.TryShatter(), TraitFoodEgg.Update(), and FactionBranch.Upgrade().

◆ ModExp()

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

Definition at line 277 of file ElementContainer.cs.

278 {
279 if ((Card != null && Card.isChara && Card.Chara.isDead) || a == 0f)
280 {
281 return;
282 }
283 Element element = GetElement(ele);
284 if (element == null || !element.CanGainExp)
285 {
286 return;
287 }
288 if (a > 0f)
289 {
290 if (!chain && Card != null && Card.isChara)
291 {
292 a = a * (float)Card.Chara.GetDaysTogetherBonus() / 100f;
293 }
294 if (element.UseExpMod)
295 {
296 a = a * (float)Mathf.Clamp(element.UsePotential ? element.Potential : 100, 10, 1000) / (float)(100 + Mathf.Max(0, element.ValueWithoutLink) * 25);
297 if (EClass.rndf(1f) < a % 1f)
298 {
299 a += 1f;
300 }
301 }
302 if (!chain && element.source.parentFactor > 0f && Card != null && !element.source.aliasParent.IsEmpty())
303 {
304 Element element2 = element.GetParent(Card);
305 if (element2.CanGainExp)
306 {
307 ModExp(element2.id, Mathf.Clamp(a * element.source.parentFactor / 100f, 1f, 1000f), chain: true);
308 }
309 }
310 }
311 element.vExp += (int)a;
312 if (element.vExp >= element.ExpToNext)
313 {
314 int num = element.vExp - element.ExpToNext;
315 int vBase = element.vBase;
316 ModBase(ele, 1);
317 OnLevelUp(element, vBase);
318 element.vExp = Mathf.Clamp(num / 2, 0, element.ExpToNext / 2);
319 if (element.vTempPotential > 0)
320 {
321 element.vTempPotential -= element.vTempPotential / 4 + EClass.rnd(5) + 5;
322 if (element.vTempPotential < 0)
323 {
324 element.vTempPotential = 0;
325 }
326 }
327 else if (element.vTempPotential < 0)
328 {
329 element.vTempPotential += -element.vTempPotential / 4 + EClass.rnd(5) + 5;
330 if (element.vTempPotential > 0)
331 {
332 element.vTempPotential = 0;
333 }
334 }
335 }
336 else if (element.vExp < 0)
337 {
338 if (element.ValueWithoutLink <= 1)
339 {
340 element.vExp = 0;
341 return;
342 }
343 int vBase2 = element.vBase;
344 ModBase(ele, -1);
345 OnLevelDown(element, vBase2);
346 element.vExp = Mathf.Max(element.ExpToNext / 2, element.ExpToNext + element.vExp);
347 }
348 }
virtual bool isChara
Definition: Card.cs:2121
int GetDaysTogetherBonus()
Definition: Card.cs:3060
bool isDead
Definition: Chara.cs:391
static int rnd(long a)
Definition: EClass.cs:59
static float rndf(float a)
Definition: EClass.cs:102
void ModExp(int ele, float a, bool chain=false)
virtual void OnLevelDown(Element e, int lastValue)
virtual void OnLevelUp(Element e, int lastValue)
virtual bool CanGainExp
Definition: ELEMENT.cs:305
virtual bool UseExpMod
Definition: ELEMENT.cs:315
int Potential
Definition: ELEMENT.cs:303
int vTempPotential
Definition: ELEMENT.cs:263
virtual bool UsePotential
Definition: ELEMENT.cs:339
Element GetParent(Card c)
Definition: ELEMENT.cs:527
virtual int ExpToNext
Definition: ELEMENT.cs:313

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

Referenced by TraitAltar._OnOffer(), LayerSleep.Advance(), Chara.ApplyDeathPenalty(), AI_Fuck.Finish(), StatsMana.Mod(), ModExp(), Card.ModExp(), Card.ModExpParty(), 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(), Card.SpawnLoot(), and BaseSong.Tick().

◆ ModLink()

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

Definition at line 464 of file ElementContainer.cs.

465 {
466 Element orCreateElement = GetOrCreateElement(id);
467 orCreateElement.vLink += v;
468 orCreateElement.OnChangeValue();
469 if (parent != null && (!LimitLink || orCreateElement.CanLink(this)))
470 {
471 parent.ModLink(id, v);
472 }
473 return orCreateElement;
474 }

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

438 {
439 Element orCreateElement = GetOrCreateElement(ele);
440 orCreateElement.vPotential += v;
441 if (orCreateElement.vPotential > 1000)
442 {
443 orCreateElement.vPotential = 1000;
444 }
445 return orCreateElement;
446 }

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

449 {
450 Element orCreateElement = GetOrCreateElement(ele);
451 orCreateElement.vTempPotential += v;
452 if (orCreateElement.vTempPotential > 1000)
453 {
454 orCreateElement.vTempPotential = 1000;
455 }
456 OnModTempPotential(orCreateElement, v, threshMsg);
457 return orCreateElement;
458 }
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 433 of file ElementContainer.cs.

434 {
435 }

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

351 {
352 }

Referenced by Learn().

◆ OnLevelDown()

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

Reimplemented in ElementContainerCard.

Definition at line 362 of file ElementContainer.cs.

363 {
364 }

Referenced by ModExp().

◆ OnLevelUp()

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

Reimplemented in ElementContainerCard, and ElementContainerZone.

Definition at line 358 of file ElementContainer.cs.

359 {
360 }

Referenced by ModExp().

◆ OnModTempPotential()

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

Reimplemented in ElementContainerCard.

Definition at line 460 of file ElementContainer.cs.

461 {
462 }

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

355 {
356 }

Referenced by Train().

◆ Remove()

void ElementContainer.Remove ( int  id)
inline

Definition at line 403 of file ElementContainer.cs.

404 {
405 Element element = GetElement(id);
406 if (element != null)
407 {
408 if (parent != null && (!LimitLink || element.CanLink(this)))
409 {
410 parent.ModLink(id, -element.Value);
411 }
412 dict.Remove(id);
413 }
414 }

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

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

◆ SetBase() [1/2]

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

Definition at line 371 of file ElementContainer.cs.

372 {
373 Element orCreateElement = GetOrCreateElement(id);
374 if (parent != null && (!LimitLink || orCreateElement.CanLink(this)))
375 {
376 parent.ModLink(id, -orCreateElement.vBase + v);
377 }
378 orCreateElement.vBase = v;
379 orCreateElement.vExp = 0;
380 orCreateElement.vPotential = potential;
381 orCreateElement.OnChangeValue();
382 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
383 {
384 Remove(orCreateElement.id);
385 }
386 return orCreateElement;
387 }

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

545 {
546 if (parent != null)
547 {
548 foreach (Element value in dict.Values)
549 {
550 if (!LimitLink || value.CanLink(this))
551 {
552 parent.ModLink(value.id, -(value.vBase + value.vSource));
553 }
554 }
555 }
556 if (newParent != null)
557 {
558 foreach (Element value2 in dict.Values)
559 {
560 if (!LimitLink || value2.CanLink(this))
561 {
562 newParent.ModLink(value2.id, value2.vBase + value2.vSource);
563 }
564 }
565 }
566 parent = newParent;
567 }

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

390 {
391 Element orCreateElement = GetOrCreateElement(id);
392 int num = v - (orCreateElement.vBase + orCreateElement.vSource);
393 if (num != 0)
394 {
395 ModBase(id, num);
396 }
397 if (orCreateElement.vBase == 0 && orCreateElement.vSource == 0 && orCreateElement.vLink == 0 && orCreateElement.vPotential == 0 && orCreateElement.vExp == 0)
398 {
399 Remove(orCreateElement.id);
400 }
401 }

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(), CraftUtil.MakeBloodMeal(), CraftUtil.MakeBloodSample(), TraitSeed.MakeSeed(), CraftUtil.MixIngredients(), TraitAgingShelf.OnProduce(), TraitDryBrick.OnProduce(), Chara.RestockEquip(), and Card.SetTier().

◆ Train()

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

Definition at line 271 of file ElementContainer.cs.

272 {
273 OnTrain(ele);
274 ModTempPotential(ele, a);
275 }
virtual void OnTrain(int ele)
Element ModTempPotential(int ele, int v, int threshMsg=0)

References ModTempPotential(), and OnTrain().

◆ Value()

◆ ValueBonus()

virtual int ElementContainer.ValueBonus ( Element  e)
inlinevirtual

Reimplemented in ElementContainerCard.

Definition at line 188 of file ElementContainer.cs.

189 {
190 return 0;
191 }

◆ ValueWithoutLink() [1/2]

int ElementContainer.ValueWithoutLink ( int  ele)
inline

◆ ValueWithoutLink() [2/2]

int ElementContainer.ValueWithoutLink ( string  alias)
inline

Definition at line 198 of file ElementContainer.cs.

199 {
200 return GetElement(alias)?.ValueWithoutLink ?? 0;
201 }

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

◆ 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: