17 return this.ints[0].ToEnum<
DNA.Type>();
21 this.ints[0] = (int)value;
71 public static Thing GenerateGene(
Chara c,
DNA.Type? type =
null)
73 DNA.Type? type2 = type;
74 DNA.Type type3 =
DNA.Type.Brain;
75 Thing thing =
ThingGen.Create((type2.GetValueOrDefault() == type3 & type2 !=
null) ?
"gene_brain" :
"gene", -1, -1);
77 thing.MakeRefFrom(c,
null);
80 dna.seed =
EClass.rnd(20000);
82 dna.GenerateWithGene(type ?? dna.GetRandomType(), thing, c);
87 public static Thing GenerateGene(
CardRow r,
DNA.Type? type =
null,
int lv = -1,
int seed = -1)
89 DNA.Type? type2 = type;
90 DNA.Type type3 =
DNA.Type.Brain;
91 Thing thing =
ThingGen.Create((type2.GetValueOrDefault() == type3 & type2 !=
null) ?
"gene_brain" :
"gene", -1, -1);
93 thing.MakeRefFrom(r.id);
95 dna.lv = ((lv == -1) ? r.LV : lv);
96 dna.seed = ((seed == -1) ?
EClass.rnd(20000) : seed);
98 dna.GenerateWithGene(type ?? dna.GetRandomType(), thing,
null);
103 public void Apply(
Chara c)
105 if (c.c_genes ==
null)
110 if (this.type ==
DNA.Type.Inferior)
112 c.c_genes.inferior++;
116 this.Apply(c,
false);
117 c_genes.items.Add(
this);
121 public void Apply(
Chara c,
bool reverse)
123 if (this.type ==
DNA.Type.Brain)
128 for (
int i = 0; i < this.vals.Count; i += 2)
130 int num = this.vals[i];
131 int num2 = this.vals[i + 1];
133 string category = row.category;
134 if (!(category ==
"slot"))
136 if (!(category ==
"feat"))
138 if (!(category ==
"ability"))
140 if (!reverse && c.elements.ValueWithoutLink(row.id) == 0)
142 c.elements.Learn(row.id, num2);
146 c.elements.ModBase(num, reverse ? (-num2) : num2);
151 c.ability.Remove(num * ((num2 < 0) ? -1 : 1));
155 c.ability.Add(num, Mathf.Abs(num2), num2 < 0);
160 c.SetFeat(num, c.elements.ValueWithoutLink(num) + (reverse ? -1 : 1),
true);
167 c.body.RemoveBodyPart(row.id);
171 c.body.AddBodyPart(row.id,
null);
173 c.body.RefreshBodyParts();
179 public void GenerateWithGene(
DNA.Type _type,
Card gene,
Chara model =
null)
181 this.Generate(_type, model);
182 gene.ChangeMaterial(this.GetMaterialId(this.type));
183 gene.elements.SetTo(10, 0);
187 public void Generate(
DNA.Type _type,
Chara model =
null)
189 DNA.<>c__DisplayClass21_0 CS$<>8__locals1;
190 CS$<>8__locals1.<>4__this =
this;
191 CS$<>8__locals1.model = model;
195 Debug.Log(this.seed);
196 Rand.SetSeed(this.seed);
197 if (CS$<>8__locals1.model ==
null)
199 CS$<>8__locals1.model =
CharaGen.Create(this.
id, this.lv);
201 if (this.type ==
DNA.Type.Inferior || CS$<>8__locals1.model ==
null)
203 this.type =
DNA.Type.Inferior;
206 if (this.type ==
DNA.Type.Brain)
211 CS$<>8__locals1.body = 0;
212 CS$<>8__locals1.action = 0;
213 CS$<>8__locals1.feat = 0;
214 CS$<>8__locals1.listAttb = CS$<>8__locals1.model.elements.ListBestAttributes();
215 CS$<>8__locals1.listSkill = CS$<>8__locals1.model.elements.ListBestSkills();
216 CS$<>8__locals1.listFeat = CS$<>8__locals1.model.elements.ListGeneFeats();
217 Rand.SetSeed(this.seed);
218 if (CS$<>8__locals1.listFeat.Count == 0)
220 CS$<>8__locals1.listFeat = CS$<>8__locals1.model.ListAvailabeFeats(
true);
222 Rand.SetSeed(this.seed);
223 DNA.Type type = this.type;
224 if (type !=
DNA.Type.Default)
226 if (type ==
DNA.Type.Superior)
228 this.<Generate>g__AddRandom|21_6(
EClass.rnd(
EClass.rnd(4)) + 3, ref CS$<>8__locals1);
231 this.<Generate>g__AddSpecial|21_7(ref CS$<>8__locals1);
233 this.<Generate>g__AddSpecial|21_7(ref CS$<>8__locals1);
238 this.<Generate>g__AddRandom|21_6(
EClass.rnd(
EClass.rnd(4)) + 1, ref CS$<>8__locals1);
239 if (
EClass.rnd(3) == 0 ||
this.vals.Count == 0)
241 this.<Generate>g__AddSpecial|21_7(ref CS$<>8__locals1);
244 if (this.vals.Count == 0)
246 for (
int i = 0; i < 10; i++)
250 this.<Generate>g__AddSpecial|21_7(ref CS$<>8__locals1);
254 this.<Generate>g__AddRandom|21_6(1, ref CS$<>8__locals1);
256 if (this.vals.Count > 0)
267 public void CalcCost()
269 for (
int i = 0; i < this.vals.Count; i += 2)
271 Element.Create(this.vals[i], this.vals[i + 1]);
276 public static DNA.Type GetType(
string idMat)
278 if (idMat ==
"jelly")
280 return DNA.Type.Default;
284 return DNA.Type.Superior;
286 if (!(idMat ==
"amethyst"))
288 return DNA.Type.Inferior;
290 return DNA.Type.Brain;
294 public string GetMaterialId(
DNA.Type type)
296 if (type ==
DNA.Type.Default)
300 if (type ==
DNA.Type.Superior)
304 if (type !=
DNA.Type.Brain)
312 public int GetDurationHour()
314 return this.cost * this.cost / 2;
318 public DNA.Type GetRandomType()
322 return DNA.Type.Superior;
326 return DNA.Type.Inferior;
328 return DNA.Type.Default;
332 public string GetText()
335 CardRow cardRow =
EClass.sources.cards.map.TryGetValue(this.
id,
null);
336 return s.lang((((cardRow !=
null) ? cardRow.GetName() :
null) ??
"???").ToTitleCase(
false),
this.cost.ToString() ??
"",
null,
null,
null);
340 public void WriteNote(UINote n)
342 if (this.type ==
DNA.Type.Brain)
347 string tactics = row.tactics;
350 if ((defaultStr = ((row2 !=
null) ? row2.id :
null)) ==
null)
353 defaultStr = (((row3 !=
null) ? row3.id :
null) ??
"predator");
355 string key = tactics.IsEmpty(defaultStr);
356 n.AddText(
"gene_info".lang(
EClass.sources.tactics.map[key].GetName().ToTitleCase(
false),
"",
null,
null,
null), FontColor.ButtonGeneral);
358 for (
int i = 0; i < this.vals.Count; i += 2)
360 int num = this.vals[i];
361 int num2 = this.vals[i + 1];
362 FontColor color = (num2 >= 0) ? FontColor.Good : FontColor.Bad;
363 string @ref = (num + 1).ToString() ??
"";
365 num2 = Mathf.Abs(num2 / 20) + 1;
366 text =
string.Concat(
new string[]
370 "*".Repeat(Mathf.Clamp(num2, 1, 5)),
371 (num2 > 5) ?
"+" :
"",
374 n.AddText(
"gene_info_brain".lang(@ref, text,
null,
null,
null), color);
378 for (
int j = 0; j < this.vals.Count; j += 2)
382 int num3 = element.Value / 10;
383 FontColor color2 = FontColor.Good;
384 string category = element.source.category;
385 if (!(category ==
"slot"))
387 if (!(category ==
"feat"))
389 if (category ==
"ability")
391 color2 = FontColor.Topic2;
397 color2 = FontColor.FoodMisc;
403 color2 = FontColor.Myth;
408 text2 =
string.Concat(
new string[]
412 "*".Repeat(Mathf.Clamp(num3, 1, 5)),
413 (num3 > 5) ?
"+" :
"",
417 if (
EClass.debug.showExtra)
419 text2 = text2 +
" " + element.Value.ToString();
421 n.AddText(
"gene_info".lang(element.Name.ToTitleCase(
true), text2,
null,
null,
null), color2);
428 for (
int i = 0; i < this.vals.Count; i += 2)
431 if (element.source.category ==
"feat" && c.Evalue(element.id) >= element.source.max)
442 for (
int i = 0; i < this.vals.Count; i += 2)
445 if (element.source.category ==
"ability")
447 using (List<
ActList.
Item>.Enumerator enumerator = c.ability.list.items.GetEnumerator())
449 while (enumerator.MoveNext())
451 if (enumerator.Current.act.source.id == element.id)
464 private void <Generate>g__AddVal|21_0(
int id,
int v,
bool allowStack, Func<int, int> funcCost, ref
DNA.<>c__DisplayClass21_0 A_5)
467 int num =
EClass.curve(v, 20, 10, 90);
468 v =
EClass.curve(v, 20, 10, 80);
470 while (i < this.vals.Count)
472 if (this.vals[i] ==
id)
480 List<int> list = this.vals;
483 Debug.Log(
string.Concat(
new string[]
485 this.vals[i + 1].ToString(),
508 this.cost += funcCost(num);
513 private void <Generate>g__AddSkill|21_1(ref
DNA.<>c__DisplayClass21_0 A_1)
515 Element element = A_1.listSkill[Mathf.Clamp(
EClass.rnd(6), 0, A_1.listSkill.Count - 1)];
516 this.<Generate>g__AddVal|21_0(element.id,
EClass.rndHalf(element.ValueWithoutLink / 2),
true, (
int v) => v / 5 + 1, ref A_1);
521 private void <Generate>g__AddAttribute|21_2(ref
DNA.<>c__DisplayClass21_0 A_1)
524 this.<Generate>g__AddVal|21_0(element.id,
EClass.rndHalf(element.ValueWithoutLink / 2),
true, (
int v) => v / 5 + 1, ref A_1);
529 private void <Generate>g__AddFeat|21_3(ref
DNA.<>c__DisplayClass21_0 A_1)
531 if (A_1.listFeat.Count == 0)
538 this.<Generate>g__AddVal|21_0(e.id, 1,
false, (
int v) => e.source.cost[0] * 5, ref A_1);
543 private void <Generate>g__AddBody|21_4(ref
DNA.<>c__DisplayClass21_0 A_1)
550 for (
int i = 0; i < 100; i++)
553 if (bodySlot2 !=
null && bodySlot2.elementId != 40)
555 bodySlot = bodySlot2;
559 if (bodySlot ==
null)
563 this.<Generate>g__AddVal|21_0(bodySlot.elementId, 1,
false, (
int v) => 20, ref A_1);
570 private void <Generate>g__AddAction|21_5(ref
DNA.<>c__DisplayClass21_0 A_1)
572 if (A_1.model.ability.list.items.Count == 0)
577 if (a.act.source.category !=
"ability")
581 this.<Generate>g__AddVal|21_0(a.act.source.id, a.chance * (a.pt ? -1 : 1),
false, (
int v) => 8 + a.act.source.cost[0] / 10 * 2, ref A_1);
582 int action = A_1.action;
583 A_1.action = action + 1;
588 private void <Generate>g__AddRandom|21_6(
int n, ref
DNA.<>c__DisplayClass21_0 A_2)
590 for (
int i = 0; i < n; i++)
594 this.<Generate>g__AddSpecial|21_7(ref A_2);
596 else if (
EClass.rnd(2) == 0)
598 this.<Generate>g__AddSkill|21_1(ref A_2);
602 this.<Generate>g__AddAttribute|21_2(ref A_2);
609 private void <Generate>g__AddSpecial|21_7(ref
DNA.<>c__DisplayClass21_0 A_1)
613 this.<Generate>g__AddAction|21_5(ref A_1);
618 this.<Generate>g__AddBody|21_4(ref A_1);
621 if (A_1.listFeat.Count > 0)
623 this.<Generate>g__AddFeat|21_3(ref A_1);
628 this.<Generate>g__AddSkill|21_1(ref A_1);
631 this.<Generate>g__AddAttribute|21_2(ref A_1);
640 public int[] ints =
new int[4];
644 public List<int> vals =
new List<int>();