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

Public Types

enum  Type {
  Inferior = 0 , Default = 3 , Superior = 5 , Superimani = 6 ,
  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 void 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]
 
- 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 8 of file DNA.cs.

Member Enumeration Documentation

◆ Type

enum DNA.Type
Enumerator
Inferior 
Default 
Superior 
Superimani 
Brain 

Definition at line 10 of file DNA.cs.

11 {
12 Inferior = 0,
13 Default = 3,
14 Superior = 5,
15 Superimani = 6,
16 Brain = 8
17 }

Member Function Documentation

◆ _OnDeserialized()

void DNA._OnDeserialized ( StreamingContext  context)
inlineprivate

Definition at line 97 of file DNA.cs.

98 {
99 if (ints.Length < 6)
100 {
101 Array.Resize(ref ints, 6);
102 slot = 1;
103 }
104 }
int slot
Definition: DNA.cs:79
int[] ints
Definition: DNA.cs:23

References ints, and slot.

◆ _OnSerializing()

void DNA._OnSerializing ( StreamingContext  context)
inlineprivate

Definition at line 91 of file DNA.cs.

92 {
93 ints[4] = bits.ToInt();
94 }
BitArray32 bits
Definition: DNA.cs:28
int ToInt()
Definition: BitArray32.cs:84

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

◆ Apply() [1/2]

void DNA.Apply ( Chara  c)
inline

Definition at line 169 of file DNA.cs.

170 {
171 if (c.c_genes == null)
172 {
173 c.c_genes = new CharaGenes();
174 }
175 CharaGenes c_genes = c.c_genes;
176 if (type == Type.Inferior)
177 {
178 c.c_genes.inferior++;
179 return;
180 }
181 c.feat -= cost * c.GeneCostMTP / 100;
182 Apply(c, reverse: false);
183 c_genes.items.Add(this);
184 }
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:31
int cost
Definition: DNA.cs:43
Type
Definition: DNA.cs:11
void Apply(Chara c)
Definition: DNA.cs:169

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 186 of file DNA.cs.

187 {
188 if (type == Type.Brain)
189 {
190 c._tactics = null;
191 return;
192 }
193 for (int i = 0; i < vals.Count; i += 2)
194 {
195 int num = vals[i];
196 int num2 = vals[i + 1];
198 switch (row.category)
199 {
200 case "slot":
201 if (reverse)
202 {
203 c.body.RemoveBodyPart(row.id);
204 }
205 else
206 {
207 c.body.AddBodyPart(row.id);
208 }
210 if (c.IsPC && (bool)WidgetEquip.Instance)
211 {
213 }
214 break;
215 case "feat":
216 {
217 int num3 = c.elements.ValueWithoutLink(num) + ((!reverse) ? 1 : (-1));
218 if (num3 < 0)
219 {
220 num3 = 0;
221 }
222 c.SetFeat(num, num3, !reverse);
223 if (reverse && num == 1423 && c.GetInt(134) > 0)
224 {
225 int num4 = c.elements.ValueWithoutLink(num) - c.GetInt(134);
226 if (num4 < 0)
227 {
228 num4 = 0;
229 }
230 c.SetFeat(num, num4);
231 c.SetInt(134);
232 }
233 break;
234 }
235 case "ability":
236 if (reverse)
237 {
238 c.ability.Remove(num * ((num2 >= 0) ? 1 : (-1)));
239 }
240 else
241 {
242 c.ability.Add(num, Mathf.Abs(num2), num2 < 0);
243 }
244 break;
245 default:
246 if (!reverse && c.elements.ValueWithoutLink(row.id) == 0)
247 {
248 c.elements.Learn(row.id, num2);
249 }
250 else
251 {
252 c.elements.ModBase(num, reverse ? (-num2) : num2);
253 }
254 break;
255 }
256 }
258 c.Refresh();
259 if (reverse)
260 {
262 }
263 }
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 Remove(int id, bool permanent=false)
void Add(int id, int chance, bool pt, bool permanent=false)
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:1806
CharaBody body
Definition: Chara.cs:96
override bool IsPC
Definition: Chara.cs:632
void RemoveAllStances()
Definition: Chara.cs:10282
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:10560
void RefreshFaithElement()
Definition: Chara.cs:10877
CharaAbility ability
Definition: Chara.cs:430
List< int > vals
Definition: DNA.cs:26
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 551 of file DNA.cs.

552 {
553 if (cost < 0)
554 {
555 cost = 0;
556 }
557 }

◆ CalcSlot()

void DNA.CalcSlot ( )
inline

Definition at line 559 of file DNA.cs.

560 {
561 slot = 0;
562 for (int i = 0; i < vals.Count; i += 2)
563 {
564 Element element = Element.Create(vals[i], vals[i + 1]);
565 if (type != Type.Superimani || !element.HasTag("gene_mani"))
566 {
567 if (element.source.geneSlot < 0)
568 {
569 slot = 99;
570 }
571 if (element.source.geneSlot > slot)
572 {
573 slot = element.source.geneSlot;
574 }
575 }
576 }
577 if (type == Type.Brain || type == Type.Inferior)
578 {
579 if (slot < 0)
580 {
581 slot = 0;
582 }
583 }
584 else if (slot < 1)
585 {
586 slot = 1;
587 }
588 }
SourceElement.Row source
Definition: ELEMENT.cs:282
bool HasTag(string tag)
Definition: ELEMENT.cs:482
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1163

References Element.Create(), Element.HasTag(), and Element.source.

◆ CanRemove()

bool DNA.CanRemove ( Chara  c)
inline

Definition at line 265 of file DNA.cs.

266 {
267 for (int i = 0; i < vals.Count; i += 2)
268 {
269 if (EClass.sources.elements.map[vals[i]].tag.Contains("permaGene"))
270 {
271 return false;
272 }
273 int num = vals[i];
274 if (num == 1228 || num == 1414)
275 {
276 if (c != null)
277 {
278 return !c.IsPC;
279 }
280 return true;
281 }
282 }
283 return true;
284 }

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

Referenced by WindowCharaMini.Refresh().

◆ CopyDNA()

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

Definition at line 132 of file DNA.cs.

133 {
134 to.c_DNA = from.c_DNA;
135 to.c_idRefCard = from.c_idRefCard;
136 to.ChangeMaterial(from.material);
137 return to;
138 }
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 293 of file DNA.cs.

294 {
295 type = _type;
296 cost = 0;
297 slot = 0;
298 vals.Clear();
300 if (model == null)
301 {
302 model = CharaGen.Create(id);
303 if (lv > model.LV)
304 {
305 model.SetLv(lv);
306 }
307 }
308 if (type == Type.Inferior || model == null)
309 {
310 type = Type.Inferior;
311 return;
312 }
313 if (type == Type.Brain)
314 {
315 cost = 4;
316 return;
317 }
318 int body = 0;
319 int action = 0;
320 int feat = 0;
321 int maxSlot = 1;
322 List<Element> listAttb = model.elements.ListBestAttributes();
323 List<Element> listSkill = model.elements.ListBestSkills();
324 List<Element> listFeat = model.elements.ListGeneFeats();
326 if (listFeat.Count == 0)
327 {
328 listFeat = model.ListAvailabeFeats(pet: true);
329 }
331 switch (type)
332 {
333 case Type.Default:
334 AddRandom(EClass.rnd(EClass.rnd(4)) + 1);
335 if (EClass.rnd(3) == 0 || vals.Count == 0)
336 {
337 AddSpecial();
338 }
339 break;
340 case Type.Superior:
341 AddRandom(EClass.rnd(EClass.rnd(4)) + 3);
342 if (EClass.rnd(3) == 0)
343 {
344 AddSpecial();
345 }
346 AddSpecial();
347 break;
348 case Type.Superimani:
349 AddRandom(EClass.rnd(EClass.rnd(4)) + 3);
350 if (EClass.rnd(3) == 0)
351 {
352 AddSpecial();
353 }
354 AddSpecial();
355 if (EClass.debug.enable)
356 {
357 lv = 100;
358 }
359 if (EClass.rnd(3) != 0 && lv > 10)
360 {
361 IEnumerable<SourceElement.Row> enumerable = EClass.sources.elements.map.Values.Where(delegate(SourceElement.Row row)
362 {
363 if (!row.tag.Contains("gene_mani"))
364 {
365 return false;
366 }
367 if (row.LV > lv)
368 {
369 return false;
370 }
371 if (row.aliasRef == "mold")
372 {
373 return false;
374 }
375 return (!(row.category == "ability") || !(row.aliasRef != "mold") || row.aliasRef.IsEmpty() || row.id <= 10000 || (EClass.sources.elements.alias[row.aliasRef].tag.Contains(row.alias.Split('_')[0]) ? true : false)) ? true : false;
376 });
377 if (enumerable.Count() > 0)
378 {
379 SourceElement.Row e = enumerable.RandomItem();
380 AddVal(e.id, (!(e.category == "ability")) ? 1 : 100, allowStack: false, (int v) => e.cost[0], allowNegative: false);
381 }
382 }
383 else
384 {
385 AddSpecial();
386 }
387 cost = cost / 2 - 10;
388 break;
389 }
390 if (vals.Count == 0)
391 {
392 for (int num = 0; num < 10; num++)
393 {
394 if (EClass.rnd(4) == 0)
395 {
396 AddSpecial();
397 }
398 else
399 {
400 AddRandom(1);
401 }
402 if (vals.Count > 0)
403 {
404 break;
405 }
406 }
407 }
408 Rand.SetSeed();
409 CalcCost();
410 CalcSlot();
411 void AddAction()
412 {
413 if (model.ability.list.items.Count != 0)
414 {
415 ActList.Item a = model.ability.list.items.RandomItem();
416 if (!(a.act.source.category != "ability") && a.act.source.geneSlot >= 0)
417 {
418 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);
419 action++;
420 }
421 }
422 }
423 void AddAttribute()
424 {
425 Element element = listAttb[EClass.rnd(3)];
426 AddVal(element.id, EClass.rndHalf(element.ValueWithoutLink / 2), allowStack: true, (int v) => v / 5 + 1, allowNegative: false);
427 }
428 void AddBody()
429 {
430 if (body == 0)
431 {
432 BodySlot bodySlot = null;
433 for (int i = 0; i < 100; i++)
434 {
435 BodySlot bodySlot2 = model.body.slots.RandomItem();
436 if (bodySlot2 != null && bodySlot2.elementId != 40 && bodySlot2.elementId != 44 && bodySlot2.elementId != 46)
437 {
438 bodySlot = bodySlot2;
439 break;
440 }
441 }
442 if (bodySlot != null)
443 {
444 AddVal(bodySlot.elementId, 1, allowStack: false, (int v) => 20, allowNegative: false);
445 body++;
446 }
447 }
448 }
449 void AddFeat()
450 {
451 if (listFeat.Count != 0)
452 {
453 feat++;
454 Element e2 = listFeat.RandomItem();
455 if (maxSlot <= 1 || e2.source.geneSlot <= 1)
456 {
457 if (e2.source.geneSlot > maxSlot)
458 {
459 maxSlot = e2.source.geneSlot;
460 }
461 AddVal(e2.id, 1, allowStack: false, (int v) => e2.source.cost[0] * 5, allowNegative: false);
462 }
463 }
464 }
465 void AddRandom(int n)
466 {
467 for (int i = 0; i < n; i++)
468 {
469 if (EClass.debug.enable && EClass.rnd(2) == 0)
470 {
471 AddSpecial();
472 }
473 else if (EClass.rnd(2) == 0)
474 {
475 AddSkill();
476 }
477 else
478 {
479 AddAttribute();
480 }
481 }
482 }
483 void AddSkill()
484 {
485 Element element = listSkill[Mathf.Clamp(EClass.rnd(6), 0, listSkill.Count - 1)];
486 AddVal(element.id, EClass.rndHalf(element.ValueWithoutLink / 2), allowStack: true, (int v) => v / 5 + 1, allowNegative: false);
487 }
488 void AddSpecial()
489 {
490 if (EClass.rnd(3) == 0)
491 {
492 AddAction();
493 }
494 else if (EClass.rnd(5) == 0)
495 {
496 AddBody();
497 }
498 else if (listFeat.Count > 0)
499 {
500 AddFeat();
501 }
502 else if (EClass.rnd(2) == 0)
503 {
504 AddSkill();
505 }
506 else
507 {
508 AddAttribute();
509 }
510 }
511 void AddVal(int id, int v, bool allowStack, Func<int, int> funcCost, bool allowNegative)
512 {
513 if (v >= 0 || allowNegative)
514 {
515 bool flag = false;
516 int num2 = EClass.curve(v, 20, 10, 90);
517 if (v < -100)
518 {
519 num2 = EClass.curve(Mathf.Abs(v + 100), 20, 10, 90);
520 }
521 v = EClass.curve(v, 20, 10, 80);
522 for (int i = 0; i < vals.Count; i += 2)
523 {
524 if (vals[i] == id)
525 {
526 if (allowStack)
527 {
528 v /= 2;
529 num2 /= 2;
530 vals[i + 1] += v;
531 Debug.Log(vals[i + 1] + ": " + v + "/" + num2);
532 flag = true;
533 break;
534 }
535 return;
536 }
537 }
538 if (v != 0)
539 {
540 if (!flag)
541 {
542 vals.Add(id);
543 vals.Add(v);
544 }
545 cost += Mathf.Max(0, funcCost(num2));
546 }
547 }
548 }
549 }
if(!match.Success)
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:10541
bool enable
Definition: CoreDebug.cs:302
int seed
Definition: DNA.cs:67
void CalcSlot()
Definition: DNA.cs:559
void CalcCost()
Definition: DNA.cs:551
int lv
Definition: DNA.cs:55
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 SourceElement.Row.category, cost, SourceElement.Row.cost, CharaGen.Create(), EClass.debug, SourceManager.elements, CoreDebug.enable, SourceElement.Row.id, if(), lv, EClass.rnd(), seed, Card.SetLv(), Rand.SetSeed(), slot, EClass.sources, type, and vals.

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 119 of file DNA.cs.

120 {
121 Thing thing = ThingGen.Create((type == Type.Brain) ? "gene_brain" : "gene");
122 DNA dNA = new DNA();
123 thing.MakeRefFrom(r.id);
124 dNA.id = r.id;
125 dNA.lv = ((lv == -1) ? r.LV : lv);
126 dNA.seed = ((seed == -1) ? EClass.rnd(20000) : seed);
127 thing.c_DNA = dNA;
128 dNA.GenerateWithGene(type ?? dNA.GetRandomType(), thing);
129 return thing;
130 }
string id
Definition: CardRow.cs:7
Card MakeRefFrom(string id)
Definition: Card.cs:6027
Definition: DNA.cs:9
void GenerateWithGene(Type _type, Card gene, Chara model=null)
Definition: DNA.cs:286
Type GetRandomType()
Definition: DNA.cs:619
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 106 of file DNA.cs.

107 {
108 Thing thing = ThingGen.Create((type == Type.Brain) ? "gene_brain" : "gene");
109 DNA dNA = new DNA();
110 thing.MakeRefFrom(c);
111 dNA.id = c.id;
112 dNA.lv = c.LV;
113 dNA.seed = EClass.rnd(20000);
114 thing.c_DNA = dNA;
115 dNA.GenerateWithGene(type ?? dNA.GetRandomType(), thing, c);
116 return thing;
117 }
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 void DNA.GenerateManiGene ( Card  owner)
inlinestatic

Definition at line 152 of file DNA.cs.

153 {
154 owner.things.DestroyAll();
155 for (int i = 0; i < 3; i++)
156 {
157 Debug.Log("Mani:" + owner.c_seed);
158 Rand.SetSeed(owner.c_seed);
159 CardRow r = SpawnList.Get("chara").Select(100);
160 Rand.SetSeed(owner.c_seed);
161 Thing thing = GenerateGene(r, Type.Superimani, owner.LV, owner.c_seed);
162 thing.MakeRefFrom("mani");
163 Rand.SetSeed();
164 owner.c_seed++;
165 owner.AddCard(thing);
166 }
167 }
Card AddCard(Card c)
Definition: Card.cs:3266
int c_seed
Definition: Card.cs:1345
ThingContainer things
Definition: Card.cs:39
static Thing GenerateGene(Chara c, Type? type=null)
Definition: DNA.cs:106
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.AddCard(), Card.c_seed, Debug, ThingContainer.DestroyAll(), GenerateGene(), SpawnList.Get(), Card.LV, Card.MakeRefFrom(), SpawnList.Select(), Rand.SetSeed(), and Card.things.

Referenced by TraitGodStatue.OnBarter(), TraitGodStatue.OnChangeMaterial(), and TraitPowerStatue.OnUse().

◆ GenerateRandomGene()

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

Definition at line 140 of file DNA.cs.

141 {
142 if (lv == -1)
143 {
145 }
147 CardRow r = SpawnList.Get("chara").Select(100);
148 Rand.SetSeed();
149 return GenerateGene(r, Type.Superior, lv, seed);
150 }
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 286 of file DNA.cs.

287 {
288 Generate(_type, model);
290 gene.elements.SetTo(10, 0);
291 }
string GetMaterialId(Type type)
Definition: DNA.cs:602
void Generate(Type _type, Chara model=null)
Definition: DNA.cs:293
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 793 of file DNA.cs.

794 {
795 for (int i = 0; i < vals.Count; i += 2)
796 {
797 Element element = Element.Create(vals[i], vals[i + 1]);
798 if (element.source.category == "slot")
799 {
800 return element.id;
801 }
802 }
803 return -1;
804 }

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

Referenced by AI_Fuck.Finish().

◆ GetDurationHour()

int DNA.GetDurationHour ( )
inline

Definition at line 614 of file DNA.cs.

615 {
616 return Mathf.Min(cost, 5000) * Mathf.Min(cost, 5000) / 2;
617 }

Referenced by InvOwnerGene._OnProcess().

◆ GetElement()

Element DNA.GetElement ( int  id)
inline

Definition at line 806 of file DNA.cs.

807 {
808 for (int i = 0; i < vals.Count; i += 2)
809 {
810 if (vals[i] == id)
811 {
812 return Element.Create(vals[i], vals[i + 1]);
813 }
814 }
815 return null;
816 }

References Element.Create().

Referenced by Element.GetDNABonus().

◆ GetInvalidAction()

Element DNA.GetInvalidAction ( Chara  c)
inline

Definition at line 773 of file DNA.cs.

774 {
775 for (int i = 0; i < vals.Count; i += 2)
776 {
777 Element element = Element.Create(vals[i], vals[i + 1]);
778 if (!(element.source.category == "ability"))
779 {
780 continue;
781 }
782 foreach (ActList.Item item in c.ability.list.items)
783 {
784 if (item.act.source.id == element.id)
785 {
786 return element;
787 }
788 }
789 }
790 return null;
791 }

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

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

◆ GetInvalidFeat()

Element DNA.GetInvalidFeat ( Chara  c)
inline

Definition at line 747 of file DNA.cs.

748 {
749 for (int i = 0; i < vals.Count; i += 2)
750 {
751 Element element = Element.Create(vals[i], vals[i + 1]);
752 if (c.IsPC && !CanRemove(c))
753 {
754 return element;
755 }
756 if (!(element.source.category == "feat"))
757 {
758 continue;
759 }
760 if (c.Evalue(element.id) < element.source.max)
761 {
762 Element orCreateElement = c.elements.GetOrCreateElement(element.id);
763 if (orCreateElement != null && orCreateElement.vLink == 0)
764 {
765 continue;
766 }
767 }
768 return element;
769 }
770 return null;
771 }
int Evalue(int ele)
Definition: Card.cs:2704
bool CanRemove(Chara c)
Definition: DNA.cs:265
Element GetOrCreateElement(Element ele)
int vLink
Definition: ELEMENT.cs:269

References Element.Create(), Card.elements, Card.Evalue(), ElementContainer.GetOrCreateElement(), Element.id, Chara.IsPC, Element.source, 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 602 of file DNA.cs.

603 {
604 return type switch
605 {
606 Type.Default => "jelly",
607 Type.Superior => "gold",
608 Type.Superimani => "lapis",
609 Type.Brain => "amethyst",
610 _ => "process",
611 };
612 }

Referenced by GenerateWithGene().

◆ GetRandomType()

Type DNA.GetRandomType ( )
inline

Definition at line 619 of file DNA.cs.

620 {
621 if (EClass.rnd(5) == 0)
622 {
623 return Type.Superior;
624 }
625 if (EClass.rnd(10) == 0)
626 {
627 return Type.Inferior;
628 }
629 return Type.Default;
630 }

References EClass.rnd().

Referenced by GenerateGene().

◆ GetText()

string DNA.GetText ( )
inline

Definition at line 632 of file DNA.cs.

633 {
634 string text = EClass.sources.cards.map.TryGetValue(id)?.GetName() ?? "???";
635 if (text == "*r")
636 {
637 text = "???";
638 }
639 return "gene".lang(text.ToTitleCase(), (cost == 0) ? "" : (cost.ToString() ?? ""));
640 }
Dictionary< string, CardRow > map
Definition: SourceCard.cs:9
SourceCard cards

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

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

◆ GetType()

static Type DNA.GetType ( string  idMat)
inlinestatic

Definition at line 590 of file DNA.cs.

591 {
592 return idMat switch
593 {
594 "jelly" => Type.Default,
595 "gold" => Type.Superior,
596 "amethyst" => Type.Brain,
597 "lapis" => Type.Superimani,
598 _ => Type.Inferior,
599 };
600 }

Referenced by ActEffect.Proc().

◆ MakeSlimeFood()

void DNA.MakeSlimeFood ( Chara  c)
inline

Definition at line 829 of file DNA.cs.

830 {
831 int num = c.Evalue(6608) + 10;
832 for (int i = 0; i < vals.Count; i += 2)
833 {
834 Element element = Element.Create(vals[i], vals[i + 1]);
835 if ((element.source.category == "attribute" || element.source.category == "skill") && vals[i + 1] > num)
836 {
837 vals[i + 1] = num;
838 }
839 }
840 cost = 0;
841 }

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

Referenced by AI_Fuck.Finish().

◆ Relicize()

DNA DNA.Relicize ( )
inline

Definition at line 843 of file DNA.cs.

844 {
845 for (int i = 0; i < vals.Count; i += 2)
846 {
847 Element element = Element.Create(vals[i], vals[i + 1]);
848 if (element.source.category == "slot" || element.HasTag("noRelic") || element.HasTag("permaGene"))
849 {
850 vals.RemoveRange(i, 2);
851 i -= 2;
852 }
853 }
854 cost = cost * Mathf.Clamp(slot, 1, 10) / 10;
855 return this;
856 }

References Element.Create(), Element.HasTag(), and Element.source.

◆ ReplaceBodySlot()

void DNA.ReplaceBodySlot ( int  slot)
inline

Definition at line 818 of file DNA.cs.

819 {
820 for (int i = 0; i < vals.Count; i += 2)
821 {
822 if (Element.Create(vals[i], vals[i + 1]).source.category == "slot")
823 {
824 vals[i] = slot;
825 }
826 }
827 }

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

Referenced by AI_Fuck.Finish().

◆ WriteNote()

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

Definition at line 642 of file DNA.cs.

643 {
644 if (slot >= 1 && (owner == null || !(owner.category.id == "relic")))
645 {
646 n.AddText("NoteText_enc", "isGeneReqSlots".lang(slot.ToString() ?? ""), FontColor.Warning);
647 }
648 if (!CanRemove(tg))
649 {
650 n.AddText("NoteText_enc", "isPermaGene".lang(), FontColor.Warning);
651 }
652 n.Space(4);
653 IList<int> vals = this.vals.Copy();
654 vals = (from i in Enumerable.Range(0, vals.Count / 2)
655 select new
656 {
657 id = vals[i * 2],
658 value = vals[i * 2 + 1]
659 } into x
660 orderby x.id
661 select x).SelectMany(x => new int[2] { x.id, x.value }).ToList();
662 if (type == Type.Brain)
663 {
664 SourceChara.Row row = EClass.sources.charas.map.TryGetValue(id);
665 if (row != null)
666 {
667 string key = row.tactics.IsEmpty(EClass.sources.tactics.map.TryGetValue(row.id)?.id ?? EClass.sources.tactics.map.TryGetValue(row.job)?.id ?? "predator");
668 n.AddText("NoteText_enc", "gene_info".lang(EClass.sources.tactics.map[key].GetName().ToTitleCase(), ""), FontColor.ButtonGeneral);
669 }
670 for (int num = 0; num < vals.Count; num += 2)
671 {
672 int num2 = vals[num];
673 int num3 = vals[num + 1];
674 FontColor color = ((num3 >= 0) ? FontColor.Good : FontColor.Bad);
675 string @ref = (num2 + 1).ToString() ?? "";
676 string text = "";
677 num3 = Mathf.Abs(num3 / 20) + 1;
678 text = text + "[" + "*".Repeat(Mathf.Clamp(num3, 1, 5)) + ((num3 > 5) ? "+" : "") + "]";
679 n.AddText("NoteText_enc", "gene_info_brain".lang(@ref, text), color);
680 }
681 return;
682 }
683 for (int num4 = 0; num4 < vals.Count; num4 += 2)
684 {
685 Element element = Element.Create(vals[num4], vals[num4 + 1]);
686 string text2 = "";
687 int num5 = element.Value / 10;
688 FontColor color2 = FontColor.Good;
689 bool flag = false;
690 string text3 = "";
691 switch (element.source.category)
692 {
693 case "slot":
694 color2 = FontColor.Myth;
695 num5 = -1;
696 break;
697 case "feat":
698 color2 = FontColor.FoodMisc;
699 num5 = -1;
700 break;
701 case "ability":
702 color2 = FontColor.Topic2;
703 num5 = -1;
704 if (element.Value < 0)
705 {
706 text3 = " (" + "party".lang() + ") ";
707 }
708 break;
709 default:
710 flag = true;
711 break;
712 }
713 if (num5 >= 0)
714 {
715 text2 = text2 + "[" + "*".Repeat(Mathf.Clamp(num5, 1, 5)) + ((num5 > 5) ? "+" : "") + "]";
716 }
717 if (flag)
718 {
719 text2 = text2 + " (" + element.Value + ")";
720 }
721 if ((bool)LayerCraft.Instance && (element.source.category == "slot" || element.HasTag("noRelic") || element.HasTag("permaGene")))
722 {
723 color2 = FontColor.Bad;
724 }
725 n.AddText("NoteText_enc", "gene_info".lang(element.Name.ToTitleCase(wholeText: true) + text3, text2), color2);
726 }
727 }
FontColor
Definition: FontColor.cs:2
SourceCategory.Row category
Definition: Card.cs:2101
int Value
Definition: ELEMENT.cs:301
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(), SourceManager.charas, Element.Create(), Element.HasTag(), CardRow.id, SourceChara.Row.job, Element.Name, Element.source, EClass.sources, UINote.Space(), SourceChara.Row.tactics, SourceManager.tactics, and Element.Value.

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

◆ WriteNoteExtra()

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

Definition at line 729 of file DNA.cs.

730 {
731 n.AddHeader("HeaderAdditionalTrait", "gene_hint");
732 _ = tg.c_genes;
733 int num = slot;
734 if (num > 1 && tg.HasElement(1237))
735 {
736 num--;
737 }
738 int num2 = tg.MaxGeneSlot - tg.CurrentGeneSlot;
739 int num3 = num2 - num;
740 int maxGeneSlot = tg.MaxGeneSlot;
741 n.AddText("gene_hint_slot".lang(num2.ToString() ?? "", num3.ToString() ?? "", maxGeneSlot.ToString() ?? ""), (num3 >= 0) ? FontColor.Good : FontColor.Bad);
742 int num4 = cost * tg.GeneCostMTP / 100;
743 int num5 = tg.feat - num4;
744 n.AddText("gene_hint_cost".lang(tg.feat.ToString() ?? "", num4 + ((num4 == cost) ? "" : ("(" + cost + ")")), num5.ToString() ?? ""), (num5 >= 0) ? FontColor.Good : FontColor.Bad);
745 }
int feat
Definition: Card.cs:377
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6383
int MaxGeneSlot
Definition: Chara.cs:1117
int CurrentGeneSlot
Definition: Chara.cs:1132
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79

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

Referenced by InvOwnerGene.OnWriteNote().

Member Data Documentation

◆ bits

BitArray32 DNA.bits

Definition at line 28 of file DNA.cs.

Referenced by _OnSerializing().

◆ id

string DNA.id

Definition at line 20 of file DNA.cs.

◆ ints

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

Definition at line 23 of file DNA.cs.

Referenced by _OnDeserialized(), and _OnSerializing().

◆ vals

List<int> DNA.vals = new List<int>()

Definition at line 26 of file DNA.cs.

Referenced by Apply(), CanRemove(), AI_Fuck.Finish(), Generate(), and Thing.MatchEncSearch().

Property Documentation

◆ cost

int DNA.cost
getset

Definition at line 42 of file DNA.cs.

43 {
44 get
45 {
46 return ints[1];
47 }
48 set
49 {
50 ints[1] = value;
51 }
52 }

Referenced by Apply(), CharaBody.Equip(), Generate(), TraitGene.GetValue(), CharaBody.IsEquippable(), InvOwnerGene.ShouldShowGuide(), TraitGene.TrySetHeldAct(), and CharaBody.Unequip().

◆ lv

int DNA.lv
getset

Definition at line 54 of file DNA.cs.

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

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

◆ seed

int DNA.seed
getset

Definition at line 66 of file DNA.cs.

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

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

◆ slot

int DNA.slot
getset

Definition at line 78 of file DNA.cs.

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

Referenced by _OnDeserialized(), InvOwnerGene._OnProcess(), Generate(), and FoodEffect.Proc().

◆ type

Type DNA.type
getset

Definition at line 30 of file DNA.cs.

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

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


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