Elin Decompiled Documentation EA 23.223 Nyaightly
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 (long a)
 
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]
 
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;
191 Apply(c, reverse: false);
192 c_genes.items.Add(this);
193 }
CharaGenes c_genes
Definition: Card.cs:1845
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().

◆ 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 break;
220 case "feat":
221 c.SetFeat(num, c.elements.ValueWithoutLink(num) + ((!reverse) ? 1 : (-1)), !reverse);
222 break;
223 case "ability":
224 if (reverse)
225 {
226 c.ability.Remove(num * ((num2 >= 0) ? 1 : (-1)));
227 }
228 else
229 {
230 c.ability.Add(num, Mathf.Abs(num2), num2 < 0);
231 }
232 break;
233 default:
234 if (!reverse && c.elements.ValueWithoutLink(row.id) == 0)
235 {
236 c.elements.Learn(row.id, num2);
237 }
238 else
239 {
240 c.elements.ModBase(num, reverse ? (-num2) : num2);
241 }
242 break;
243 }
244 }
245 }
ElementContainerCard elements
Definition: Card.cs:41
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:9590
CharaAbility ability
Definition: Chara.cs:422
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 482 of file DNA.cs.

483 {
484 if (cost < 0)
485 {
486 cost = 0;
487 }
488 }

References cost.

Referenced by Generate().

◆ CalcSlot()

void DNA.CalcSlot ( )
inline

Definition at line 490 of file DNA.cs.

491 {
492 slot = 0;
493 for (int i = 0; i < vals.Count; i += 2)
494 {
495 Element element = Element.Create(vals[i], vals[i + 1]);
496 if (element.source.geneSlot < 0)
497 {
498 slot = 99;
499 }
500 if (element.source.geneSlot > slot)
501 {
502 slot = element.source.geneSlot;
503 }
504 }
505 if (slot < 0)
506 {
507 slot = 0;
508 }
509 }
SourceElement.Row source
Definition: ELEMENT.cs:273
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1100

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

Referenced by Generate().

◆ CanRemove()

bool DNA.CanRemove ( )
inline

Definition at line 247 of file DNA.cs.

248 {
249 for (int i = 0; i < vals.Count; i += 2)
250 {
251 int num = vals[i];
252 if (num == 1237 || num == 1415)
253 {
254 return false;
255 }
256 }
257 return true;
258 }

References vals.

Referenced by 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:2039
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
Definition: Card.cs:3022
DNA c_DNA
Definition: Card.cs:1881
string c_idRefCard
Definition: Card.cs:1737

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

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

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:1305
ThingContainer things
Definition: Card.cs:38
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: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 260 of file DNA.cs.

261 {
262 Generate(_type, model);
264 gene.elements.SetTo(10, 0);
265 }
string GetMaterialId(Type type)
Definition: DNA.cs:522
void Generate(Type _type, Chara model=null)
Definition: DNA.cs:267
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 533 of file DNA.cs.

534 {
535 return Mathf.Min(cost, 5000) * Mathf.Min(cost, 5000) / 2;
536 }

References cost.

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

◆ GetInvalidAction()

Element DNA.GetInvalidAction ( Chara  c)
inline

Definition at line 643 of file DNA.cs.

644 {
645 for (int i = 0; i < vals.Count; i += 2)
646 {
647 Element element = Element.Create(vals[i], vals[i + 1]);
648 if (!(element.source.category == "ability"))
649 {
650 continue;
651 }
652 foreach (ActList.Item item in c.ability.list.items)
653 {
654 if (item.act.source.id == element.id)
655 {
656 return element;
657 }
658 }
659 }
660 return null;
661 }

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

631 {
632 for (int i = 0; i < vals.Count; i += 2)
633 {
634 Element element = Element.Create(vals[i], vals[i + 1]);
635 if (element.source.category == "feat" && c.Evalue(element.id) >= element.source.max)
636 {
637 return element;
638 }
639 }
640 return null;
641 }
int Evalue(int ele)
Definition: Card.cs:2559

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

523 {
524 return type switch
525 {
526 Type.Default => "jelly",
527 Type.Superior => "gold",
528 Type.Brain => "amethyst",
529 _ => "process",
530 };
531 }

References type.

Referenced by GenerateWithGene().

◆ GetRandomType()

Type DNA.GetRandomType ( )
inline

Definition at line 538 of file DNA.cs.

539 {
540 if (EClass.rnd(5) == 0)
541 {
542 return Type.Superior;
543 }
544 if (EClass.rnd(10) == 0)
545 {
546 return Type.Inferior;
547 }
548 return Type.Default;
549 }

References EClass.rnd().

Referenced by GenerateGene().

◆ GetText()

string DNA.GetText ( )
inline

Definition at line 551 of file DNA.cs.

552 {
553 string text = EClass.sources.cards.map.TryGetValue(id)?.GetName() ?? "???";
554 if (text == "*r")
555 {
556 text = "???";
557 }
558 return "gene".lang(text.ToTitleCase(), cost.ToString() ?? "");
559 }
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 511 of file DNA.cs.

512 {
513 return idMat switch
514 {
515 "jelly" => Type.Default,
516 "gold" => Type.Superior,
517 "amethyst" => Type.Brain,
518 _ => Type.Inferior,
519 };
520 }

Referenced by ActEffect.Proc().

◆ WriteNote()

void DNA.WriteNote ( UINote  n)
inline

Definition at line 561 of file DNA.cs.

562 {
563 if (slot >= 1)
564 {
565 n.AddText("isGeneReqSlots".lang(slot.ToString() ?? ""), FontColor.Warning);
566 }
567 if (!CanRemove())
568 {
569 n.AddText("isPermaGene".lang(), FontColor.Warning);
570 }
571 n.Space(4);
572 if (type == Type.Brain)
573 {
574 SourceChara.Row row = EClass.sources.charas.map.TryGetValue(id);
575 if (row != null)
576 {
577 string key = row.tactics.IsEmpty(EClass.sources.tactics.map.TryGetValue(row.id)?.id ?? EClass.sources.tactics.map.TryGetValue(row.job)?.id ?? "predator");
578 n.AddText("gene_info".lang(EClass.sources.tactics.map[key].GetName().ToTitleCase(), ""), FontColor.ButtonGeneral);
579 }
580 for (int i = 0; i < vals.Count; i += 2)
581 {
582 int num = vals[i];
583 int num2 = vals[i + 1];
584 FontColor color = ((num2 >= 0) ? FontColor.Good : FontColor.Bad);
585 string @ref = (num + 1).ToString() ?? "";
586 string text = "";
587 num2 = Mathf.Abs(num2 / 20) + 1;
588 text = text + "[" + "*".Repeat(Mathf.Clamp(num2, 1, 5)) + ((num2 > 5) ? "+" : "") + "]";
589 n.AddText("gene_info_brain".lang(@ref, text), color);
590 }
591 return;
592 }
593 for (int j = 0; j < vals.Count; j += 2)
594 {
595 Element element = Element.Create(vals[j], vals[j + 1]);
596 string text2 = "";
597 int num3 = element.Value / 10;
598 FontColor color2 = FontColor.Good;
599 bool flag = false;
600 switch (element.source.category)
601 {
602 case "slot":
603 color2 = FontColor.Myth;
604 num3 = -1;
605 break;
606 case "feat":
607 color2 = FontColor.FoodMisc;
608 num3 = -1;
609 break;
610 case "ability":
611 color2 = FontColor.Topic2;
612 num3 = -1;
613 break;
614 default:
615 flag = true;
616 break;
617 }
618 if (num3 >= 0)
619 {
620 text2 = text2 + "[" + "*".Repeat(Mathf.Clamp(num3, 1, 5)) + ((num3 > 5) ? "+" : "") + "]";
621 }
622 if (flag)
623 {
624 text2 = text2 + " (" + element.Value + ")";
625 }
626 n.AddText("gene_info".lang(element.Name.ToTitleCase(wholeText: true), text2), color2);
627 }
628 }
FontColor
Definition: FontColor.cs:2
bool CanRemove()
Definition: DNA.cs:247
virtual string Name
Definition: ELEMENT.cs:304
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(), 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 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().

◆ 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(), 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: