Elin Decompiled Documentation EA 23.130 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 ()
 
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)
 
Element GetInvalidFeat (Chara c)
 
Element GetInvalidAction (Chara c)
 

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 (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Public Attributes

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

96 {
97 if (ints.Length < 6)
98 {
99 Array.Resize(ref ints, 6);
100 slot = 1;
101 }
102 }
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 89 of file DNA.cs.

90 {
91 ints[4] = bits.ToInt();
92 }
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 165 of file DNA.cs.

166 {
167 if (c.c_genes == null)
168 {
169 c.c_genes = new CharaGenes();
170 }
171 CharaGenes c_genes = c.c_genes;
172 if (type == Type.Inferior)
173 {
174 c.c_genes.inferior++;
175 return;
176 }
177 c.feat -= cost;
178 Apply(c, reverse: false);
179 c_genes.items.Add(this);
180 }
CharaGenes c_genes
Definition: Card.cs:1769
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:165

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

Referenced by Apply().

◆ Apply() [2/2]

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

Definition at line 182 of file DNA.cs.

183 {
184 if (type == Type.Brain)
185 {
186 c._tactics = null;
187 return;
188 }
189 for (int i = 0; i < vals.Count; i += 2)
190 {
191 int num = vals[i];
192 int num2 = vals[i + 1];
194 switch (row.category)
195 {
196 case "slot":
197 if (reverse)
198 {
199 c.body.RemoveBodyPart(row.id);
200 }
201 else
202 {
203 c.body.AddBodyPart(row.id);
204 }
206 break;
207 case "feat":
208 c.SetFeat(num, c.elements.ValueWithoutLink(num) + ((!reverse) ? 1 : (-1)), !reverse);
209 break;
210 case "ability":
211 if (reverse)
212 {
213 c.ability.Remove(num * ((num2 >= 0) ? 1 : (-1)));
214 }
215 else
216 {
217 c.ability.Add(num, Mathf.Abs(num2), num2 < 0);
218 }
219 break;
220 default:
221 if (!reverse && c.elements.ValueWithoutLink(row.id) == 0)
222 {
223 c.elements.Learn(row.id, num2);
224 }
225 else
226 {
227 c.elements.ModBase(num, reverse ? (-num2) : num2);
228 }
229 break;
230 }
231 }
232 }
ElementContainerCard elements
Definition: Card.cs:37
void Add(int id, int chance, bool pt)
void Remove(int id)
void AddBodyPart(int ele, Thing thing=null)
Definition: CharaBody.cs:261
void RefreshBodyParts()
Definition: CharaBody.cs:287
void RemoveBodyPart(int ele)
Definition: CharaBody.cs:316
CharaBody body
Definition: Chara.cs:94
void SetFeat(int id, int value=1, bool msg=false)
Definition: Chara.cs:9063
CharaAbility ability
Definition: Chara.cs:414
List< int > vals
Definition: DNA.cs:24
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
void Learn(int ele, int v=1)
int ValueWithoutLink(int ele)
Element ModBase(int ele, int v)
SourceElement elements

References Chara.ability, CharaAbility.Add(), CharaBody.AddBodyPart(), Chara.body, SourceElement.Row.category, Card.elements, SourceManager.elements, SourceElement.Row.id, ElementContainer.Learn(), ElementContainer.ModBase(), CharaBody.RefreshBodyParts(), CharaAbility.Remove(), CharaBody.RemoveBodyPart(), Chara.SetFeat(), EClass.sources, type, vals, and ElementContainer.ValueWithoutLink().

◆ CalcCost()

void DNA.CalcCost ( )
inline

Definition at line 469 of file DNA.cs.

470 {
471 if (cost < 0)
472 {
473 cost = 0;
474 }
475 }

References cost.

Referenced by Generate().

◆ CalcSlot()

void DNA.CalcSlot ( )
inline

Definition at line 477 of file DNA.cs.

478 {
479 slot = 0;
480 for (int i = 0; i < vals.Count; i += 2)
481 {
482 Element element = Element.Create(vals[i], vals[i + 1]);
483 if (element.source.geneSlot < 0)
484 {
485 slot = 99;
486 }
487 if (element.source.geneSlot > slot)
488 {
489 slot = element.source.geneSlot;
490 }
491 }
492 if (slot < 0)
493 {
494 slot = 0;
495 }
496 }
SourceElement.Row source
Definition: ELEMENT.cs:269
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1094

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

Referenced by Generate().

◆ CanRemove()

bool DNA.CanRemove ( )
inline

Definition at line 234 of file DNA.cs.

235 {
236 for (int i = 0; i < vals.Count; i += 2)
237 {
238 int num = vals[i];
239 if (num == 1237 || num == 1415)
240 {
241 return false;
242 }
243 }
244 return true;
245 }

References vals.

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

◆ CopyDNA()

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

Definition at line 130 of file DNA.cs.

131 {
132 to.c_DNA = from.c_DNA;
133 to.c_idRefCard = from.c_idRefCard;
134 to.ChangeMaterial(from.material);
135 return to;
136 }
SourceMaterial.Row material
Definition: Card.cs:1951
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:2887
DNA c_DNA
Definition: Card.cs:1805
string c_idRefCard
Definition: Card.cs:1661

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

255 {
256 type = _type;
257 cost = 0;
258 slot = 0;
259 vals.Clear();
260 Debug.Log(seed);
262 if (model == null)
263 {
264 model = CharaGen.Create(id);
265 if (lv > model.LV)
266 {
267 model.SetLv(lv);
268 }
269 }
270 if (type == Type.Inferior || model == null)
271 {
272 type = Type.Inferior;
273 return;
274 }
275 if (type == Type.Brain)
276 {
277 cost = 4;
278 return;
279 }
280 int body = 0;
281 int action = 0;
282 int feat = 0;
283 int maxSlot = 1;
284 List<Element> listAttb = model.elements.ListBestAttributes();
285 List<Element> listSkill = model.elements.ListBestSkills();
286 List<Element> listFeat = model.elements.ListGeneFeats();
288 if (listFeat.Count == 0)
289 {
290 listFeat = model.ListAvailabeFeats(pet: true);
291 }
293 switch (type)
294 {
295 case Type.Default:
296 AddRandom(EClass.rnd(EClass.rnd(4)) + 1);
297 if (EClass.rnd(3) == 0 || vals.Count == 0)
298 {
299 AddSpecial();
300 }
301 break;
302 case Type.Superior:
303 AddRandom(EClass.rnd(EClass.rnd(4)) + 3);
304 if (EClass.rnd(3) == 0)
305 {
306 AddSpecial();
307 }
308 AddSpecial();
309 break;
310 }
311 if (vals.Count == 0)
312 {
313 for (int i = 0; i < 10; i++)
314 {
315 if (EClass.rnd(4) == 0)
316 {
317 AddSpecial();
318 }
319 else
320 {
321 AddRandom(1);
322 }
323 if (vals.Count > 0)
324 {
325 break;
326 }
327 }
328 }
329 Rand.SetSeed();
330 CalcCost();
331 CalcSlot();
332 void AddAction()
333 {
334 if (model.ability.list.items.Count != 0)
335 {
336 ActList.Item a = model.ability.list.items.RandomItem();
337 if (!(a.act.source.category != "ability"))
338 {
339 AddVal(a.act.source.id, a.chance * ((!a.pt) ? 1 : (-1)), allowStack: false, (int v) => 8 + a.act.source.cost[0] / 10 * 2);
340 action++;
341 }
342 }
343 }
344 void AddAttribute()
345 {
346 Element element = listAttb[EClass.rnd(3)];
347 AddVal(element.id, EClass.rndHalf(element.ValueWithoutLink / 2), allowStack: true, (int v) => v / 5 + 1);
348 }
349 void AddBody()
350 {
351 if (body == 0)
352 {
353 BodySlot bodySlot = null;
354 for (int j = 0; j < 100; j++)
355 {
356 BodySlot bodySlot2 = model.body.slots.RandomItem();
357 if (bodySlot2 != null && bodySlot2.elementId != 40)
358 {
359 bodySlot = bodySlot2;
360 break;
361 }
362 }
363 if (bodySlot != null)
364 {
365 AddVal(bodySlot.elementId, 1, allowStack: false, (int v) => 20);
366 body++;
367 }
368 }
369 }
370 void AddFeat()
371 {
372 if (listFeat.Count != 0)
373 {
374 feat++;
375 Element e = listFeat.RandomItem();
376 if (maxSlot <= 1 || e.source.geneSlot <= 1)
377 {
378 if (e.source.geneSlot > maxSlot)
379 {
380 maxSlot = e.source.geneSlot;
381 }
382 AddVal(e.id, 1, allowStack: false, (int v) => e.source.cost[0] * 5);
383 }
384 }
385 }
386 void AddRandom(int n)
387 {
388 for (int l = 0; l < n; l++)
389 {
390 if (EClass.debug.enable && EClass.rnd(2) == 0)
391 {
392 AddSpecial();
393 }
394 else if (EClass.rnd(2) == 0)
395 {
396 AddSkill();
397 }
398 else
399 {
400 AddAttribute();
401 }
402 }
403 }
404 void AddSkill()
405 {
406 Element element2 = listSkill[Mathf.Clamp(EClass.rnd(6), 0, listSkill.Count - 1)];
407 AddVal(element2.id, EClass.rndHalf(element2.ValueWithoutLink / 2), allowStack: true, (int v) => v / 5 + 1);
408 }
409 void AddSpecial()
410 {
411 if (EClass.rnd(3) == 0)
412 {
413 AddAction();
414 }
415 else if (EClass.rnd(5) == 0)
416 {
417 AddBody();
418 }
419 else if (listFeat.Count > 0)
420 {
421 AddFeat();
422 }
423 else if (EClass.rnd(2) == 0)
424 {
425 AddSkill();
426 }
427 else
428 {
429 AddAttribute();
430 }
431 }
432 void AddVal(int id, int v, bool allowStack, Func<int, int> funcCost)
433 {
434 bool flag = false;
435 int num = EClass.curve(v, 20, 10, 90);
436 if (v < -100)
437 {
438 num = EClass.curve(Mathf.Abs(v + 100), 20, 10, 90);
439 }
440 v = EClass.curve(v, 20, 10, 80);
441 for (int k = 0; k < vals.Count; k += 2)
442 {
443 if (vals[k] == id)
444 {
445 if (allowStack)
446 {
447 v /= 2;
448 num /= 2;
449 vals[k + 1] += v;
450 Debug.Log(vals[k + 1] + ": " + v + "/" + num);
451 flag = true;
452 break;
453 }
454 return;
455 }
456 }
457 if (v != 0)
458 {
459 if (!flag)
460 {
461 vals.Add(id);
462 vals.Add(v);
463 }
464 cost += Mathf.Max(0, funcCost(num));
465 }
466 }
467 }
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:2784
int LV
Definition: Card.cs:370
ActList list
Definition: CharaAbility.cs:12
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)
Definition: Chara.cs:9048
bool enable
Definition: CoreDebug.cs:285
int seed
Definition: DNA.cs:65
void CalcSlot()
Definition: DNA.cs:477
void CalcCost()
Definition: DNA.cs:469
int lv
Definition: DNA.cs:53
static int curve(int a, int start, int step, int rate=75)
Definition: EClass.cs:63
static int rnd(int a)
Definition: EClass.cs:58
static int rndHalf(int a)
Definition: EClass.cs:82
static CoreDebug debug
Definition: EClass.cs:48
List< Element > ListBestSkills()
List< Element > ListBestAttributes()
List< Element > ListGeneFeats()
int ValueWithoutLink
Definition: ELEMENT.cs:290
int id
Definition: ELEMENT.cs:246
Definition: Rand.cs:4
static void SetSeed(int a=-1)
Definition: Rand.cs:37

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

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

105 {
106 Thing thing = ThingGen.Create((type == Type.Brain) ? "gene_brain" : "gene");
107 DNA dNA = new DNA();
108 thing.MakeRefFrom(c);
109 dNA.id = c.id;
110 dNA.lv = c.LV;
111 dNA.seed = EClass.rnd(20000);
112 thing.c_DNA = dNA;
113 dNA.GenerateWithGene(type ?? dNA.GetRandomType(), thing, c);
114 return thing;
115 }
string id
Definition: Card.cs:31

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

151 {
152 owner.things.DestroyAll();
153 Debug.Log("Mani:" + owner.c_seed);
154 Rand.SetSeed(owner.c_seed);
155 CardRow r = SpawnList.Get("chara").Select(100);
156 Rand.SetSeed(owner.c_seed);
157 Thing thing = GenerateGene(r, Type.Superior, owner.LV, owner.c_seed);
158 thing.c_DNA.cost = thing.c_DNA.cost / 2;
159 thing.MakeRefFrom("mani");
160 Rand.SetSeed();
161 owner.c_seed++;
162 return thing;
163 }
int c_seed
Definition: Card.cs:1265
ThingContainer things
Definition: Card.cs:34
static Thing GenerateGene(Chara c, Type? type=null)
Definition: DNA.cs:104
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 138 of file DNA.cs.

139 {
140 if (lv == -1)
141 {
143 }
145 CardRow r = SpawnList.Get("chara").Select(100);
146 Rand.SetSeed();
147 return GenerateGene(r, Type.Superior, lv, seed);
148 }
static Zone _zone
Definition: EClass.cs:20
override int ContentLv
Definition: Zone.cs:95

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

Referenced by Card.TryMakeRandomItem().

◆ GenerateWithGene()

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

Definition at line 247 of file DNA.cs.

248 {
249 Generate(_type, model);
251 gene.elements.SetTo(10, 0);
252 }
string GetMaterialId(Type type)
Definition: DNA.cs:509
void Generate(Type _type, Chara model=null)
Definition: DNA.cs:254
void SetTo(int id, int v)

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

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

◆ GetDurationHour()

int DNA.GetDurationHour ( )
inline

Definition at line 520 of file DNA.cs.

521 {
522 return cost * cost / 2;
523 }

References cost.

Referenced by InvOwnerGene._OnProcess(), and TraitGene.WriteNote().

◆ GetInvalidAction()

Element DNA.GetInvalidAction ( Chara  c)
inline

Definition at line 621 of file DNA.cs.

622 {
623 for (int i = 0; i < vals.Count; i += 2)
624 {
625 Element element = Element.Create(vals[i], vals[i + 1]);
626 if (!(element.source.category == "ability"))
627 {
628 continue;
629 }
630 foreach (ActList.Item item in c.ability.list.items)
631 {
632 if (item.act.source.id == element.id)
633 {
634 return element;
635 }
636 }
637 }
638 return null;
639 }

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

Referenced by InvOwnerGene._OnProcess().

◆ GetInvalidFeat()

Element DNA.GetInvalidFeat ( Chara  c)
inline

Definition at line 608 of file DNA.cs.

609 {
610 for (int i = 0; i < vals.Count; i += 2)
611 {
612 Element element = Element.Create(vals[i], vals[i + 1]);
613 if (element.source.category == "feat" && c.Evalue(element.id) >= element.source.max)
614 {
615 return element;
616 }
617 }
618 return null;
619 }
int Evalue(int ele)
Definition: Card.cs:2471

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

Referenced by InvOwnerGene._OnProcess().

◆ GetMaterialId()

string DNA.GetMaterialId ( Type  type)
inline

Definition at line 509 of file DNA.cs.

510 {
511 return type switch
512 {
513 Type.Default => "jelly",
514 Type.Superior => "gold",
515 Type.Brain => "amethyst",
516 _ => "process",
517 };
518 }

References type.

Referenced by GenerateWithGene().

◆ GetRandomType()

Type DNA.GetRandomType ( )
inline

Definition at line 525 of file DNA.cs.

526 {
527 if (EClass.rnd(5) == 0)
528 {
529 return Type.Superior;
530 }
531 if (EClass.rnd(10) == 0)
532 {
533 return Type.Inferior;
534 }
535 return Type.Default;
536 }

References EClass.rnd().

Referenced by GenerateGene().

◆ GetText()

string DNA.GetText ( )
inline

Definition at line 538 of file DNA.cs.

539 {
540 return "gene".lang((EClass.sources.cards.map.TryGetValue(id)?.GetName() ?? "???").ToTitleCase(), cost.ToString() ?? "");
541 }
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
SourceCard cards

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

Referenced by WindowCharaMini.Refresh().

◆ GetType()

static Type DNA.GetType ( string  idMat)
inlinestatic

Definition at line 498 of file DNA.cs.

499 {
500 return idMat switch
501 {
502 "jelly" => Type.Default,
503 "gold" => Type.Superior,
504 "amethyst" => Type.Brain,
505 _ => Type.Inferior,
506 };
507 }

Referenced by ActEffect.Proc().

◆ WriteNote()

void DNA.WriteNote ( UINote  n)
inline

Definition at line 543 of file DNA.cs.

544 {
545 if (slot >= 1)
546 {
547 n.AddText("isGeneReqSlots".lang(slot.ToString() ?? ""), FontColor.Warning);
548 }
549 if (!CanRemove())
550 {
551 n.AddText("isPermaGene".lang(), FontColor.Warning);
552 }
553 n.Space(4);
554 if (type == Type.Brain)
555 {
556 SourceChara.Row row = EClass.sources.charas.map.TryGetValue(id);
557 if (row != null)
558 {
559 string key = row.tactics.IsEmpty(EClass.sources.tactics.map.TryGetValue(row.id)?.id ?? EClass.sources.tactics.map.TryGetValue(row.job)?.id ?? "predator");
560 n.AddText("gene_info".lang(EClass.sources.tactics.map[key].GetName().ToTitleCase(), ""), FontColor.ButtonGeneral);
561 }
562 for (int i = 0; i < vals.Count; i += 2)
563 {
564 int num = vals[i];
565 int num2 = vals[i + 1];
566 FontColor color = ((num2 >= 0) ? FontColor.Good : FontColor.Bad);
567 string @ref = (num + 1).ToString() ?? "";
568 string text = "";
569 num2 = Mathf.Abs(num2 / 20) + 1;
570 text = text + "[" + "*".Repeat(Mathf.Clamp(num2, 1, 5)) + ((num2 > 5) ? "+" : "") + "]";
571 n.AddText("gene_info_brain".lang(@ref, text), color);
572 }
573 return;
574 }
575 for (int j = 0; j < vals.Count; j += 2)
576 {
577 Element element = Element.Create(vals[j], vals[j + 1]);
578 string text2 = "";
579 int num3 = element.Value / 10;
580 FontColor color2 = FontColor.Good;
581 switch (element.source.category)
582 {
583 case "slot":
584 color2 = FontColor.Myth;
585 num3 = -1;
586 break;
587 case "feat":
588 color2 = FontColor.FoodMisc;
589 num3 = -1;
590 break;
591 case "ability":
592 color2 = FontColor.Topic2;
593 num3 = -1;
594 break;
595 }
596 if (num3 >= 0)
597 {
598 text2 = text2 + "[" + "*".Repeat(Mathf.Clamp(num3, 1, 5)) + ((num3 > 5) ? "+" : "") + "]";
599 }
601 {
602 text2 = text2 + " " + element.Value;
603 }
604 n.AddText("gene_info".lang(element.Name.ToTitleCase(wholeText: true), text2), color2);
605 }
606 }
FontColor
Definition: FontColor.cs:2
bool showExtra
Definition: CoreDebug.cs:167
bool CanRemove()
Definition: DNA.cs:234
int Value
Definition: ELEMENT.cs:288
virtual string Name
Definition: ELEMENT.cs:300
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(), EClass.debug, CardRow.id, SourceChara.Row.job, Element.Name, CoreDebug.showExtra, slot, Element.source, EClass.sources, UINote.Space(), SourceChara.Row.tactics, SourceManager.tactics, type, vals, and Element.Value.

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

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

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

Property Documentation

◆ cost

int DNA.cost
getset

Definition at line 40 of file DNA.cs.

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

Referenced by Apply(), CalcCost(), Generate(), GetDurationHour(), GetText(), TraitGene.GetValue(), InvOwnerGene.OnWriteNote(), InvOwnerGene.ShouldShowGuide(), and TraitGene.WriteNote().

◆ 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(), InvOwnerGene.OnWriteNote(), and WriteNote().

◆ 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(), and WriteNote().


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