Elin Decompiled Documentation EA 23.343 Nightly
Loading...
Searching...
No Matches
DNA Class Reference
Inheritance diagram for DNA:
EClass

Public Types

enum  Type { Inferior = 0 , Default = 3 , Superior = 5 , Brain = 8 }
 

Public Member Functions

void Apply (Chara c)
 
void Apply (Chara c, bool reverse)
 
bool CanRemove (Chara c)
 
void GenerateWithGene (Type _type, Card gene, Chara model=null)
 
void Generate (Type _type, Chara model=null)
 
void CalcCost ()
 
void CalcSlot ()
 
string GetMaterialId (Type type)
 
int GetDurationHour ()
 
Type GetRandomType ()
 
string GetText ()
 
void WriteNote (UINote n, Thing owner=null, Chara tg=null)
 
void WriteNoteExtra (UINote n, Thing owner, Chara tg)
 
Element GetInvalidFeat (Chara c)
 
Element GetInvalidAction (Chara c)
 
int GetBodySlot ()
 
Element GetElement (int id)
 
void ReplaceBodySlot (int slot)
 
void MakeSlimeFood (Chara c)
 
DNA Relicize ()
 

Static Public Member Functions

static Thing GenerateGene (Chara c, Type? type=null)
 
static Thing GenerateGene (CardRow r, Type? type=null, int lv=-1, int seed=-1)
 
static Thing CopyDNA (Thing from, Thing to)
 
static Thing GenerateRandomGene (int lv=-1, int seed=-1)
 
static Thing GenerateManiGene (Card owner)
 
static Type GetType (string idMat)
 
- 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

string id
 
int[] ints = new int[6]
 
List< int > vals = new List<int>()
 
BitArray32 bits
 

Properties

Type type [get, set]
 
int cost [get, set]
 
int lv [get, set]
 
int seed [get, set]
 
int slot [get, set]
 
bool isManiGene [get, set]
 
- 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)
 

Additional Inherited Members

- Static Public Attributes inherited from EClass
static Core core
 

Detailed Description

Definition at line 7 of file DNA.cs.

Member Enumeration Documentation

◆ Type

enum DNA.Type
Enumerator
Inferior 
Default 
Superior 
Brain 

Definition at line 9 of file DNA.cs.

10 {
11 Inferior = 0,
12 Default = 3,
13 Superior = 5,
14 Brain = 8
15 }

Member Function Documentation

◆ _OnDeserialized()

void DNA._OnDeserialized ( StreamingContext  context)
inlineprivate

Definition at line 107 of file DNA.cs.

108 {
109 if (ints.Length < 6)
110 {
111 Array.Resize(ref ints, 6);
112 slot = 1;
113 }
114 }
int slot
Definition: DNA.cs:77
int[] ints
Definition: DNA.cs:21

References ints, and slot.

◆ _OnSerializing()

void DNA._OnSerializing ( StreamingContext  context)
inlineprivate

Definition at line 101 of file DNA.cs.

102 {
103 ints[4] = bits.ToInt();
104 }
BitArray32 bits
Definition: DNA.cs:26
int ToInt()
Definition: BitArray32.cs:84

References bits, ints, and BitArray32.ToInt().

◆ Apply() [1/2]

void DNA.Apply ( Chara  c)
inline

Definition at line 178 of file DNA.cs.

179 {
180 if (c.c_genes == null)
181 {
182 c.c_genes = new CharaGenes();
183 }
184 CharaGenes c_genes = c.c_genes;
185 if (type == Type.Inferior)
186 {
187 c.c_genes.inferior++;
188 return;
189 }
190 c.feat -= cost * c.GeneCostMTP / 100;
191 Apply(c, reverse: false);
192 c_genes.items.Add(this);
193 }
CharaGenes c_genes
Definition: Card.cs:1897
int inferior
Definition: CharaGenes.cs:10
List< DNA > items
Definition: CharaGenes.cs:7
Type type
Definition: DNA.cs:29
int cost
Definition: DNA.cs:41
Type
Definition: DNA.cs:10
void Apply(Chara c)
Definition: DNA.cs:178

References Apply(), Card.c_genes, cost, CharaGenes.inferior, CharaGenes.items, and type.

Referenced by Apply(), CharaBody.Equip(), FoodEffect.Proc(), CharaBody.Unequip(), and DramaOutcome.upgrade_miscreation().

◆ Apply() [2/2]

void DNA.Apply ( Chara  c,
bool  reverse 
)
inline

Definition at line 195 of file DNA.cs.

196 {
197 if (type == Type.Brain)
198 {
199 c._tactics = null;
200 return;
201 }
202 for (int i = 0; i < vals.Count; i += 2)
203 {
204 int num = vals[i];
205 int num2 = vals[i + 1];
207 switch (row.category)
208 {
209 case "slot":
210 if (reverse)
211 {
212 c.body.RemoveBodyPart(row.id);
213 }
214 else
215 {
216 c.body.AddBodyPart(row.id);
217 }
219 if (c.IsPC && (bool)WidgetEquip.Instance)
220 {
222 }
223 break;
224 case "feat":
225 {
226 int num3 = c.elements.ValueWithoutLink(num) + ((!reverse) ? 1 : (-1));
227 if (num3 < 0)
228 {
229 num3 = 0;
230 }
231 c.SetFeat(num, num3, !reverse);
232 if (reverse && num == 1423 && c.GetInt(134) > 0)
233 {
234 int num4 = c.elements.ValueWithoutLink(num) - c.GetInt(134);
235 if (num4 < 0)
236 {
237 num4 = 0;
238 }
239 c.SetFeat(num, num4);
240 c.SetInt(134);
241 }
242 break;
243 }
244 case "ability":
245 if (reverse)
246 {
247 c.ability.Remove(num * ((num2 >= 0) ? 1 : (-1)));
248 }
249 else
250 {
251 c.ability.Add(num, Mathf.Abs(num2), num2 < 0);
252 }
253 break;
254 default:
255 if (!reverse && c.elements.ValueWithoutLink(row.id) == 0)
256 {
257 c.elements.Learn(row.id, num2);
258 }
259 else
260 {
261 c.elements.ModBase(num, reverse ? (-num2) : num2);
262 }
263 break;
264 }
265 }
267 c.Refresh();
268 if (reverse)
269 {
271 }
272 }
ElementContainerCard elements
Definition: Card.cs:42
void SetInt(string id, int value=0)
Definition: Card.cs:2586
int GetInt(string id, int? defaultInt=null)
Definition: Card.cs:2567
void Add(int id, int chance, bool pt)
void Remove(int id)
void AddBodyPart(int ele, Thing thing=null)
Definition: CharaBody.cs:312
void RefreshBodyParts()
Definition: CharaBody.cs:338
void RemoveBodyPart(int ele)
Definition: CharaBody.cs:367
void Refresh(bool calledRecursive=false)
Definition: Chara.cs:1796
CharaBody body
Definition: Chara.cs:94
override bool IsPC
Definition: Chara.cs:630
void RemoveAllStances()
Definition: Chara.cs:10239
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:10517
void RefreshFaithElement()
Definition: Chara.cs:10850
CharaAbility ability
Definition: Chara.cs:428
List< int > vals
Definition: DNA.cs:24
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:43
void Learn(int ele, int v=1)
int ValueWithoutLink(int ele)
Element ModBase(int ele, int v)
SourceElement elements
static WidgetEquip Instance
Definition: WidgetEquip.cs:11
void Rebuild()
Definition: WidgetEquip.cs:61

References Chara.ability, CharaAbility.Add(), CharaBody.AddBodyPart(), Chara.body, SourceElement.Row.category, Card.elements, SourceManager.elements, Card.GetInt(), SourceElement.Row.id, WidgetEquip.Instance, Chara.IsPC, ElementContainer.Learn(), ElementContainer.ModBase(), WidgetEquip.Rebuild(), Chara.Refresh(), CharaBody.RefreshBodyParts(), Chara.RefreshFaithElement(), CharaAbility.Remove(), Chara.RemoveAllStances(), CharaBody.RemoveBodyPart(), Chara.SetFeat(), Card.SetInt(), EClass.sources, type, vals, and ElementContainer.ValueWithoutLink().

◆ CalcCost()

void DNA.CalcCost ( )
inline

Definition at line 519 of file DNA.cs.

520 {
521 if (cost < 0)
522 {
523 cost = 0;
524 }
525 }

References cost.

Referenced by Generate().

◆ CalcSlot()

void DNA.CalcSlot ( )
inline

Definition at line 527 of file DNA.cs.

528 {
529 slot = 0;
530 for (int i = 0; i < vals.Count; i += 2)
531 {
532 Element element = Element.Create(vals[i], vals[i + 1]);
533 if (element.source.geneSlot < 0)
534 {
535 slot = 99;
536 }
537 if (element.source.geneSlot > slot)
538 {
539 slot = element.source.geneSlot;
540 }
541 }
542 if (slot < 0)
543 {
544 slot = 0;
545 }
546 }
SourceElement.Row source
Definition: ELEMENT.cs:282
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1163

References Element.Create(), slot, Element.source, and vals.

Referenced by Generate().

◆ CanRemove()

bool DNA.CanRemove ( Chara  c)
inline

Definition at line 274 of file DNA.cs.

275 {
276 for (int i = 0; i < vals.Count; i += 2)
277 {
278 if (EClass.sources.elements.map[vals[i]].tag.Contains("permaGene"))
279 {
280 return false;
281 }
282 int num = vals[i];
283 if (num == 1228 || num == 1414)
284 {
285 if (c != null)
286 {
287 return !c.IsPC;
288 }
289 return true;
290 }
291 }
292 return true;
293 }

References SourceManager.elements, Chara.IsPC, EClass.sources, and vals.

Referenced by GetInvalidFeat(), WindowCharaMini.Refresh(), and WriteNote().

◆ CopyDNA()

static Thing DNA.CopyDNA ( Thing  from,
Thing  to 
)
inlinestatic

Definition at line 142 of file DNA.cs.

143 {
144 to.c_DNA = from.c_DNA;
145 to.c_idRefCard = from.c_idRefCard;
146 to.ChangeMaterial(from.material);
147 return to;
148 }
SourceMaterial.Row material
Definition: Card.cs:2103
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3217
DNA c_DNA
Definition: Card.cs:1933
string c_idRefCard
Definition: Card.cs:1777

References Card.c_DNA, Card.c_idRefCard, Card.ChangeMaterial(), and Card.material.

Referenced by Card.TryMakeRandomItem().

◆ Generate()

void DNA.Generate ( Type  _type,
Chara  model = null 
)
inline

Definition at line 302 of file DNA.cs.

303 {
304 type = _type;
305 cost = 0;
306 slot = 0;
307 vals.Clear();
309 if (model == null)
310 {
311 model = CharaGen.Create(id);
312 if (lv > model.LV)
313 {
314 model.SetLv(lv);
315 }
316 }
317 if (type == Type.Inferior || model == null)
318 {
319 type = Type.Inferior;
320 return;
321 }
322 if (type == Type.Brain)
323 {
324 cost = 4;
325 return;
326 }
327 int body = 0;
328 int action = 0;
329 int feat = 0;
330 int maxSlot = 1;
331 List<Element> listAttb = model.elements.ListBestAttributes();
332 List<Element> listSkill = model.elements.ListBestSkills();
333 List<Element> listFeat = model.elements.ListGeneFeats();
335 if (listFeat.Count == 0)
336 {
337 listFeat = model.ListAvailabeFeats(pet: true);
338 }
340 switch (type)
341 {
342 case Type.Default:
343 AddRandom(EClass.rnd(EClass.rnd(4)) + 1);
344 if (EClass.rnd(3) == 0 || vals.Count == 0)
345 {
346 AddSpecial();
347 }
348 break;
349 case Type.Superior:
350 AddRandom(EClass.rnd(EClass.rnd(4)) + 3);
351 if (EClass.rnd(3) == 0)
352 {
353 AddSpecial();
354 }
355 AddSpecial();
356 break;
357 }
358 if (vals.Count == 0)
359 {
360 for (int i = 0; i < 10; i++)
361 {
362 if (EClass.rnd(4) == 0)
363 {
364 AddSpecial();
365 }
366 else
367 {
368 AddRandom(1);
369 }
370 if (vals.Count > 0)
371 {
372 break;
373 }
374 }
375 }
376 Rand.SetSeed();
377 CalcCost();
378 CalcSlot();
379 void AddAction()
380 {
381 if (model.ability.list.items.Count != 0)
382 {
383 ActList.Item a = model.ability.list.items.RandomItem();
384 if (!(a.act.source.category != "ability") && a.act.source.geneSlot >= 0)
385 {
386 AddVal(a.act.source.id, a.chance * ((!a.pt) ? 1 : (-1)), allowStack: false, (int v) => 8 + a.act.source.cost[0] / 10 * 2, allowNegative: true);
387 action++;
388 }
389 }
390 }
391 void AddAttribute()
392 {
393 Element element = listAttb[EClass.rnd(3)];
394 AddVal(element.id, EClass.rndHalf(element.ValueWithoutLink / 2), allowStack: true, (int v) => v / 5 + 1, allowNegative: false);
395 }
396 void AddBody()
397 {
398 if (body == 0)
399 {
400 BodySlot bodySlot = null;
401 for (int j = 0; j < 100; j++)
402 {
403 BodySlot bodySlot2 = model.body.slots.RandomItem();
404 if (bodySlot2 != null && bodySlot2.elementId != 40 && bodySlot2.elementId != 44 && bodySlot2.elementId != 46)
405 {
406 bodySlot = bodySlot2;
407 break;
408 }
409 }
410 if (bodySlot != null)
411 {
412 AddVal(bodySlot.elementId, 1, allowStack: false, (int v) => 20, allowNegative: false);
413 body++;
414 }
415 }
416 }
417 void AddFeat()
418 {
419 if (listFeat.Count != 0)
420 {
421 feat++;
422 Element e = listFeat.RandomItem();
423 if (maxSlot <= 1 || e.source.geneSlot <= 1)
424 {
425 if (e.source.geneSlot > maxSlot)
426 {
427 maxSlot = e.source.geneSlot;
428 }
429 AddVal(e.id, 1, allowStack: false, (int v) => e.source.cost[0] * 5, allowNegative: false);
430 }
431 }
432 }
433 void AddRandom(int n)
434 {
435 for (int j = 0; j < n; j++)
436 {
437 if (EClass.debug.enable && EClass.rnd(2) == 0)
438 {
439 AddSpecial();
440 }
441 else if (EClass.rnd(2) == 0)
442 {
443 AddSkill();
444 }
445 else
446 {
447 AddAttribute();
448 }
449 }
450 }
451 void AddSkill()
452 {
453 Element element = listSkill[Mathf.Clamp(EClass.rnd(6), 0, listSkill.Count - 1)];
454 AddVal(element.id, EClass.rndHalf(element.ValueWithoutLink / 2), allowStack: true, (int v) => v / 5 + 1, allowNegative: false);
455 }
456 void AddSpecial()
457 {
458 if (EClass.rnd(3) == 0)
459 {
460 AddAction();
461 }
462 else if (EClass.rnd(5) == 0)
463 {
464 AddBody();
465 }
466 else if (listFeat.Count > 0)
467 {
468 AddFeat();
469 }
470 else if (EClass.rnd(2) == 0)
471 {
472 AddSkill();
473 }
474 else
475 {
476 AddAttribute();
477 }
478 }
479 void AddVal(int id, int v, bool allowStack, Func<int, int> funcCost, bool allowNegative)
480 {
481 if (v >= 0 || allowNegative)
482 {
483 bool flag = false;
484 int num = EClass.curve(v, 20, 10, 90);
485 if (v < -100)
486 {
487 num = EClass.curve(Mathf.Abs(v + 100), 20, 10, 90);
488 }
489 v = EClass.curve(v, 20, 10, 80);
490 for (int j = 0; j < vals.Count; j += 2)
491 {
492 if (vals[j] == id)
493 {
494 if (allowStack)
495 {
496 v /= 2;
497 num /= 2;
498 vals[j + 1] += v;
499 Debug.Log(vals[j + 1] + ": " + v + "/" + num);
500 flag = true;
501 break;
502 }
503 return;
504 }
505 }
506 if (v != 0)
507 {
508 if (!flag)
509 {
510 vals.Add(id);
511 vals.Add(v);
512 }
513 cost += Mathf.Max(0, funcCost(num));
514 }
515 }
516 }
517 }
int chance
Definition: ActList.cs:9
bool pt
Definition: ActList.cs:11
Act act
Definition: ActList.cs:7
List< Item > items
Definition: ActList.cs:14
int elementId
Definition: BodySlot.cs:6
Card SetLv(int a)
Definition: Card.cs:3070
int LV
Definition: Card.cs:389
ActList list
Definition: CharaAbility.cs:13
List< BodySlot > slots
Definition: CharaBody.cs:8
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
List< Element > ListAvailabeFeats(bool pet=false, bool showAll=false, bool purchaseFeat=false)
Definition: Chara.cs:10498
bool enable
Definition: CoreDebug.cs:302
int seed
Definition: DNA.cs:65
void CalcSlot()
Definition: DNA.cs:527
void CalcCost()
Definition: DNA.cs:519
int lv
Definition: DNA.cs:53
static int curve(long _a, int start, int step, int rate=75)
Definition: EClass.cs:69
static int rnd(long a)
Definition: EClass.cs:59
static int rndHalf(int a)
Definition: EClass.cs:97
static CoreDebug debug
Definition: EClass.cs:49
List< Element > ListBestSkills()
List< Element > ListBestAttributes()
List< Element > ListGeneFeats()
int ValueWithoutLink
Definition: ELEMENT.cs:303
int id
Definition: ELEMENT.cs:259
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:44

References ActList.Item.act, CalcCost(), CalcSlot(), ActList.Item.chance, cost, CharaGen.Create(), EClass.curve(), EClass.debug, Debug, BodySlot.elementId, CoreDebug.enable, Element.id, lv, ActList.Item.pt, EClass.rnd(), EClass.rndHalf(), seed, Card.SetLv(), Rand.SetSeed(), slot, Element.source, type, vals, and Element.ValueWithoutLink.

Referenced by GenerateWithGene(), and ActEffect.Proc().

◆ GenerateGene() [1/2]

static Thing DNA.GenerateGene ( CardRow  r,
Type type = null,
int  lv = -1,
int  seed = -1 
)
inlinestatic

Definition at line 129 of file DNA.cs.

130 {
131 Thing thing = ThingGen.Create((type == Type.Brain) ? "gene_brain" : "gene");
132 DNA dNA = new DNA();
133 thing.MakeRefFrom(r.id);
134 dNA.id = r.id;
135 dNA.lv = ((lv == -1) ? r.LV : lv);
136 dNA.seed = ((seed == -1) ? EClass.rnd(20000) : seed);
137 thing.c_DNA = dNA;
138 dNA.GenerateWithGene(type ?? dNA.GetRandomType(), thing);
139 return thing;
140 }
string id
Definition: CardRow.cs:7
Card MakeRefFrom(string id)
Definition: Card.cs:6023
Definition: DNA.cs:8
void GenerateWithGene(Type _type, Card gene, Chara model=null)
Definition: DNA.cs:295
Type GetRandomType()
Definition: DNA.cs:575
int LV
Definition: RenderRow.cs:22
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8

References ThingGen.Create(), GenerateWithGene(), GetRandomType(), CardRow.id, lv, RenderRow.LV, Card.MakeRefFrom(), EClass.rnd(), seed, and type.

◆ GenerateGene() [2/2]

static Thing DNA.GenerateGene ( Chara  c,
Type type = null 
)
inlinestatic

Definition at line 116 of file DNA.cs.

117 {
118 Thing thing = ThingGen.Create((type == Type.Brain) ? "gene_brain" : "gene");
119 DNA dNA = new DNA();
120 thing.MakeRefFrom(c);
121 dNA.id = c.id;
122 dNA.lv = c.LV;
123 dNA.seed = EClass.rnd(20000);
124 thing.c_DNA = dNA;
125 dNA.GenerateWithGene(type ?? dNA.GetRandomType(), thing, c);
126 return thing;
127 }
string id
Definition: Card.cs:36

References ThingGen.Create(), GenerateWithGene(), GetRandomType(), Card.id, Card.LV, Card.MakeRefFrom(), EClass.rnd(), and type.

Referenced by Trait.CreateStock(), GenerateManiGene(), GenerateRandomGene(), Chara.MakeBraineCell(), and Chara.MakeGene().

◆ GenerateManiGene()

static Thing DNA.GenerateManiGene ( Card  owner)
inlinestatic

Definition at line 162 of file DNA.cs.

163 {
164 owner.things.DestroyAll();
165 Debug.Log("Mani:" + owner.c_seed);
166 Rand.SetSeed(owner.c_seed);
167 CardRow r = SpawnList.Get("chara").Select(100);
168 Rand.SetSeed(owner.c_seed);
169 Thing thing = GenerateGene(r, Type.Superior, owner.LV, owner.c_seed);
170 thing.c_DNA.cost = thing.c_DNA.cost / 2;
171 thing.c_DNA.isManiGene = true;
172 thing.MakeRefFrom("mani");
173 Rand.SetSeed();
174 owner.c_seed++;
175 return thing;
176 }
int c_seed
Definition: Card.cs:1345
ThingContainer things
Definition: Card.cs:39
static Thing GenerateGene(Chara c, Type? type=null)
Definition: DNA.cs:116
static SpawnList Get(string id, string parent=null, CardFilter filter=null)
Definition: SpawnList.cs:18
CardRow Select(int lv=-1, int levelRange=-1)
Definition: SpawnList.cs:139
void DestroyAll(Func< Thing, bool > funcExclude=null)

References Card.c_seed, Debug, ThingContainer.DestroyAll(), GenerateGene(), SpawnList.Get(), Card.LV, Card.MakeRefFrom(), SpawnList.Select(), Rand.SetSeed(), and Card.things.

Referenced by TraitGodStatue._OnUse(), and TraitGodStatue.OnChangeMaterial().

◆ GenerateRandomGene()

static Thing DNA.GenerateRandomGene ( int  lv = -1,
int  seed = -1 
)
inlinestatic

Definition at line 150 of file DNA.cs.

151 {
152 if (lv == -1)
153 {
155 }
157 CardRow r = SpawnList.Get("chara").Select(100);
158 Rand.SetSeed();
159 return GenerateGene(r, Type.Superior, lv, seed);
160 }
static Zone _zone
Definition: EClass.cs:21
override int ContentLv
Definition: Zone.cs:103

References EClass._zone, Zone.ContentLv, GenerateGene(), SpawnList.Get(), lv, seed, SpawnList.Select(), and Rand.SetSeed().

Referenced by Card.TryMakeRandomItem(), and DramaOutcome.upgrade_miscreation().

◆ GenerateWithGene()

void DNA.GenerateWithGene ( Type  _type,
Card  gene,
Chara  model = null 
)
inline

Definition at line 295 of file DNA.cs.

296 {
297 Generate(_type, model);
299 gene.elements.SetTo(10, 0);
300 }
string GetMaterialId(Type type)
Definition: DNA.cs:559
void Generate(Type _type, Chara model=null)
Definition: DNA.cs:302
void SetTo(int id, int v)

References Card.ChangeMaterial(), Card.elements, Generate(), GetMaterialId(), ElementContainer.SetTo(), and type.

Referenced by TraitCrafter.Craft(), and GenerateGene().

◆ GetBodySlot()

int DNA.GetBodySlot ( )
inline

Definition at line 735 of file DNA.cs.

736 {
737 for (int i = 0; i < vals.Count; i += 2)
738 {
739 Element element = Element.Create(vals[i], vals[i + 1]);
740 if (element.source.category == "slot")
741 {
742 return element.id;
743 }
744 }
745 return -1;
746 }

References Element.Create(), Element.id, Element.source, and vals.

Referenced by AI_Fuck.Finish().

◆ GetDurationHour()

int DNA.GetDurationHour ( )
inline

Definition at line 570 of file DNA.cs.

571 {
572 return Mathf.Min(cost, 5000) * Mathf.Min(cost, 5000) / 2;
573 }

References cost.

Referenced by InvOwnerGene._OnProcess().

◆ GetElement()

Element DNA.GetElement ( int  id)
inline

Definition at line 748 of file DNA.cs.

749 {
750 for (int i = 0; i < vals.Count; i += 2)
751 {
752 if (vals[i] == id)
753 {
754 return Element.Create(vals[i], vals[i + 1]);
755 }
756 }
757 return null;
758 }

References Element.Create(), and vals.

Referenced by Element.GetDNABonus().

◆ GetInvalidAction()

Element DNA.GetInvalidAction ( Chara  c)
inline

Definition at line 715 of file DNA.cs.

716 {
717 for (int i = 0; i < vals.Count; i += 2)
718 {
719 Element element = Element.Create(vals[i], vals[i + 1]);
720 if (!(element.source.category == "ability"))
721 {
722 continue;
723 }
724 foreach (ActList.Item item in c.ability.list.items)
725 {
726 if (item.act.source.id == element.id)
727 {
728 return element;
729 }
730 }
731 }
732 return null;
733 }

References Chara.ability, Element.Create(), Element.id, item, ActList.items, CharaAbility.list, Element.source, and vals.

Referenced by InvOwnerGene._OnProcess(), AI_Fuck.Finish(), TraitGene.TrySetHeldAct(), and DramaOutcome.upgrade_miscreation().

◆ GetInvalidFeat()

Element DNA.GetInvalidFeat ( Chara  c)
inline

Definition at line 689 of file DNA.cs.

690 {
691 for (int i = 0; i < vals.Count; i += 2)
692 {
693 Element element = Element.Create(vals[i], vals[i + 1]);
694 if (c.IsPC && !CanRemove(c))
695 {
696 return element;
697 }
698 if (!(element.source.category == "feat"))
699 {
700 continue;
701 }
702 if (c.Evalue(element.id) < element.source.max)
703 {
704 Element orCreateElement = c.elements.GetOrCreateElement(element.id);
705 if (orCreateElement != null && orCreateElement.vLink == 0)
706 {
707 continue;
708 }
709 }
710 return element;
711 }
712 return null;
713 }
int Evalue(int ele)
Definition: Card.cs:2704
bool CanRemove(Chara c)
Definition: DNA.cs:274
Element GetOrCreateElement(Element ele)
int vLink
Definition: ELEMENT.cs:269

References CanRemove(), Element.Create(), Card.elements, Card.Evalue(), ElementContainer.GetOrCreateElement(), Element.id, Chara.IsPC, Element.source, vals, and Element.vLink.

Referenced by InvOwnerGene._OnProcess(), AI_Fuck.Finish(), TraitGene.TrySetHeldAct(), and DramaOutcome.upgrade_miscreation().

◆ GetMaterialId()

string DNA.GetMaterialId ( Type  type)
inline

Definition at line 559 of file DNA.cs.

560 {
561 return type switch
562 {
563 Type.Default => "jelly",
564 Type.Superior => "gold",
565 Type.Brain => "amethyst",
566 _ => "process",
567 };
568 }

References type.

Referenced by GenerateWithGene().

◆ GetRandomType()

Type DNA.GetRandomType ( )
inline

Definition at line 575 of file DNA.cs.

576 {
577 if (EClass.rnd(5) == 0)
578 {
579 return Type.Superior;
580 }
581 if (EClass.rnd(10) == 0)
582 {
583 return Type.Inferior;
584 }
585 return Type.Default;
586 }

References EClass.rnd().

Referenced by GenerateGene().

◆ GetText()

string DNA.GetText ( )
inline

Definition at line 588 of file DNA.cs.

589 {
590 string text = EClass.sources.cards.map.TryGetValue(id)?.GetName() ?? "???";
591 if (text == "*r")
592 {
593 text = "???";
594 }
595 return "gene".lang(text.ToTitleCase(), (cost == 0) ? "" : (cost.ToString() ?? ""));
596 }
Dictionary< string, CardRow > map
Definition: SourceCard.cs:9
SourceCard cards

References SourceManager.cards, cost, SourceCard.map, and EClass.sources.

Referenced by WindowCharaMini.Refresh(), and WindowChara.RefreshSkill().

◆ GetType()

static Type DNA.GetType ( string  idMat)
inlinestatic

Definition at line 548 of file DNA.cs.

549 {
550 return idMat switch
551 {
552 "jelly" => Type.Default,
553 "gold" => Type.Superior,
554 "amethyst" => Type.Brain,
555 _ => Type.Inferior,
556 };
557 }

Referenced by ActEffect.Proc().

◆ MakeSlimeFood()

void DNA.MakeSlimeFood ( Chara  c)
inline

Definition at line 771 of file DNA.cs.

772 {
773 int num = c.Evalue(6608) + 10;
774 for (int i = 0; i < vals.Count; i += 2)
775 {
776 Element element = Element.Create(vals[i], vals[i + 1]);
777 if ((element.source.category == "attribute" || element.source.category == "skill") && vals[i + 1] > num)
778 {
779 vals[i + 1] = num;
780 }
781 }
782 cost = 0;
783 }

References cost, Element.Create(), Card.Evalue(), Element.source, and vals.

Referenced by AI_Fuck.Finish().

◆ Relicize()

DNA DNA.Relicize ( )
inline

Definition at line 785 of file DNA.cs.

786 {
787 for (int i = 0; i < vals.Count; i += 2)
788 {
789 Element element = Element.Create(vals[i], vals[i + 1]);
790 if (element.source.category == "slot" || element.HasTag("noRelic") || element.HasTag("permaGene"))
791 {
792 vals.RemoveRange(i, 2);
793 i -= 2;
794 }
795 }
796 cost = cost * Mathf.Clamp(slot, 1, 10) / 10;
797 return this;
798 }
bool HasTag(string tag)
Definition: ELEMENT.cs:482

References cost, Element.Create(), Element.HasTag(), slot, Element.source, and vals.

◆ ReplaceBodySlot()

void DNA.ReplaceBodySlot ( int  slot)
inline

Definition at line 760 of file DNA.cs.

761 {
762 for (int i = 0; i < vals.Count; i += 2)
763 {
764 if (Element.Create(vals[i], vals[i + 1]).source.category == "slot")
765 {
766 vals[i] = slot;
767 }
768 }
769 }

References Element.Create(), slot, Element.source, and vals.

Referenced by AI_Fuck.Finish().

◆ WriteNote()

void DNA.WriteNote ( UINote  n,
Thing  owner = null,
Chara  tg = null 
)
inline

Definition at line 598 of file DNA.cs.

599 {
600 if (slot >= 1 && (owner == null || !(owner.category.id == "relic")))
601 {
602 n.AddText("NoteText_enc", "isGeneReqSlots".lang(slot.ToString() ?? ""), FontColor.Warning);
603 }
604 if (!CanRemove(tg))
605 {
606 n.AddText("NoteText_enc", "isPermaGene".lang(), FontColor.Warning);
607 }
608 n.Space(4);
609 if (type == Type.Brain)
610 {
611 SourceChara.Row row = EClass.sources.charas.map.TryGetValue(id);
612 if (row != null)
613 {
614 string key = row.tactics.IsEmpty(EClass.sources.tactics.map.TryGetValue(row.id)?.id ?? EClass.sources.tactics.map.TryGetValue(row.job)?.id ?? "predator");
615 n.AddText("NoteText_enc", "gene_info".lang(EClass.sources.tactics.map[key].GetName().ToTitleCase(), ""), FontColor.ButtonGeneral);
616 }
617 for (int i = 0; i < vals.Count; i += 2)
618 {
619 int num = vals[i];
620 int num2 = vals[i + 1];
621 FontColor color = ((num2 >= 0) ? FontColor.Good : FontColor.Bad);
622 string @ref = (num + 1).ToString() ?? "";
623 string text = "";
624 num2 = Mathf.Abs(num2 / 20) + 1;
625 text = text + "[" + "*".Repeat(Mathf.Clamp(num2, 1, 5)) + ((num2 > 5) ? "+" : "") + "]";
626 n.AddText("NoteText_enc", "gene_info_brain".lang(@ref, text), color);
627 }
628 return;
629 }
630 for (int j = 0; j < vals.Count; j += 2)
631 {
632 Element element = Element.Create(vals[j], vals[j + 1]);
633 string text2 = "";
634 int num3 = element.Value / 10;
635 FontColor color2 = FontColor.Good;
636 bool flag = false;
637 switch (element.source.category)
638 {
639 case "slot":
640 color2 = FontColor.Myth;
641 num3 = -1;
642 break;
643 case "feat":
644 color2 = FontColor.FoodMisc;
645 num3 = -1;
646 break;
647 case "ability":
648 color2 = FontColor.Topic2;
649 num3 = -1;
650 break;
651 default:
652 flag = true;
653 break;
654 }
655 if (num3 >= 0)
656 {
657 text2 = text2 + "[" + "*".Repeat(Mathf.Clamp(num3, 1, 5)) + ((num3 > 5) ? "+" : "") + "]";
658 }
659 if (flag)
660 {
661 text2 = text2 + " (" + element.Value + ")";
662 }
663 if ((bool)LayerCraft.Instance && (element.source.category == "slot" || element.HasTag("noRelic") || element.HasTag("permaGene")))
664 {
665 color2 = FontColor.Bad;
666 }
667 n.AddText("NoteText_enc", "gene_info".lang(element.Name.ToTitleCase(wholeText: true), text2), color2);
668 }
669 }
FontColor
Definition: FontColor.cs:2
SourceCategory.Row category
Definition: Card.cs:2101
virtual string Name
Definition: ELEMENT.cs:313
SourceChara charas
SourceTactics tactics
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62

References UINote.AddText(), CanRemove(), SourceManager.charas, Element.Create(), Element.HasTag(), CardRow.id, SourceChara.Row.job, Element.Name, slot, Element.source, EClass.sources, UINote.Space(), SourceChara.Row.tactics, SourceManager.tactics, type, and vals.

Referenced by WindowCharaMini.Refresh(), and WindowChara.RefreshSkill().

◆ WriteNoteExtra()

void DNA.WriteNoteExtra ( UINote  n,
Thing  owner,
Chara  tg 
)
inline

Definition at line 671 of file DNA.cs.

672 {
673 n.AddHeader("HeaderAdditionalTrait", "gene_hint");
674 _ = tg.c_genes;
675 int num = slot;
676 if (num > 1 && tg.HasElement(1237))
677 {
678 num--;
679 }
680 int num2 = tg.MaxGeneSlot - tg.CurrentGeneSlot;
681 int num3 = num2 - num;
682 int maxGeneSlot = tg.MaxGeneSlot;
683 n.AddText("gene_hint_slot".lang(num2.ToString() ?? "", num3.ToString() ?? "", maxGeneSlot.ToString() ?? ""), (num3 >= 0) ? FontColor.Good : FontColor.Bad);
684 int num4 = cost * tg.GeneCostMTP / 100;
685 int num5 = tg.feat - num4;
686 n.AddText("gene_hint_cost".lang(tg.feat.ToString() ?? "", num4 + ((num4 == cost) ? "" : ("(" + cost + ")")), num5.ToString() ?? ""), (num5 >= 0) ? FontColor.Good : FontColor.Bad);
687 }
int feat
Definition: Card.cs:377
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6379
int MaxGeneSlot
Definition: Chara.cs:1115
int CurrentGeneSlot
Definition: Chara.cs:1130
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79

References UINote.AddHeader(), UINote.AddText(), Card.c_genes, cost, Chara.CurrentGeneSlot, Card.feat, Card.HasElement(), Chara.MaxGeneSlot, and slot.

Referenced by InvOwnerGene.OnWriteNote().

Member Data Documentation

◆ bits

BitArray32 DNA.bits

Definition at line 26 of file DNA.cs.

Referenced by _OnSerializing().

◆ id

string DNA.id

Definition at line 18 of file DNA.cs.

◆ ints

int [] DNA.ints = new int[6]

Definition at line 21 of file DNA.cs.

Referenced by _OnDeserialized(), and _OnSerializing().

◆ vals

Property Documentation

◆ cost

int DNA.cost
getset

◆ isManiGene

bool DNA.isManiGene
getset

Definition at line 88 of file DNA.cs.

89 {
90 get
91 {
92 return bits[0];
93 }
94 set
95 {
96 bits[0] = value;
97 }
98 }

◆ lv

int DNA.lv
getset

Definition at line 52 of file DNA.cs.

53 {
54 get
55 {
56 return ints[2];
57 }
58 set
59 {
60 ints[2] = value;
61 }
62 }

Referenced by Generate(), GenerateGene(), and GenerateRandomGene().

◆ seed

int DNA.seed
getset

Definition at line 64 of file DNA.cs.

65 {
66 get
67 {
68 return ints[3];
69 }
70 set
71 {
72 ints[3] = value;
73 }
74 }

Referenced by Generate(), GenerateGene(), and GenerateRandomGene().

◆ slot

int DNA.slot
getset

Definition at line 76 of file DNA.cs.

77 {
78 get
79 {
80 return ints[5];
81 }
82 set
83 {
84 ints[5] = value;
85 }
86 }

Referenced by _OnDeserialized(), InvOwnerGene._OnProcess(), CalcSlot(), Generate(), FoodEffect.Proc(), Relicize(), ReplaceBodySlot(), WriteNote(), and WriteNoteExtra().

◆ type

Type DNA.type
getset

Definition at line 28 of file DNA.cs.

29 {
30 get
31 {
32 return ints[0].ToEnum<Type>();
33 }
34 set
35 {
36 ints[0] = (int)value;
37 }
38 }

Referenced by InvOwnerGene._OnProcess(), Apply(), Generate(), GenerateGene(), GenerateWithGene(), GetMaterialId(), TraitGene.GetName(), Thing.MatchEncSearch(), FoodEffect.Proc(), and WriteNote().


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