2using System.Collections.Generic;
4using System.Runtime.Serialization;
23 public int[]
ints =
new int[6];
26 public List<int>
vals =
new List<int>();
101 Array.Resize(ref
ints, 6);
125 dNA.lv = ((
lv == -1) ? r.
LV :
lv);
134 to.c_DNA = from.
c_DNA;
155 for (
int i = 0; i < 3; i++)
181 c.feat -=
cost * c.GeneCostMTP / 100;
182 Apply(c, reverse:
false);
183 c_genes.
items.Add(
this);
193 for (
int i = 0; i <
vals.Count; i += 2)
196 int num2 =
vals[i + 1];
222 c.
SetFeat(num, num3, !reverse);
223 if (reverse && num == 1423 && c.
GetInt(134) > 0)
242 c.
ability.
Add(num, Mathf.Abs(num2), num2 < 0);
267 for (
int i = 0; i <
vals.Count; i += 2)
274 if (num == 1228 || num == 1414)
308 if (
type ==
Type.Inferior || model ==
null)
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)
328 listFeat = model.ListAvailabeFeats(pet:
true);
348 case Type.Superimani:
363 if (!row.tag.Contains(
"gene_mani"))
371 if (row.aliasRef ==
"mold")
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;
377 if (enumerable.Count() > 0)
380 AddVal(e.
id, (!(e.
category ==
"ability")) ? 1 : 100, allowStack:
false, (
int v) => e.
cost[0], allowNegative:
false);
392 for (
int num = 0; num < 10; num++)
413 if (model.ability.list.items.Count != 0)
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);
433 for (
int i = 0; i < 100; i++)
435 BodySlot bodySlot2 = model.body.slots.RandomItem();
438 bodySlot = bodySlot2;
442 if (bodySlot !=
null)
444 AddVal(bodySlot.
elementId, 1, allowStack:
false, (
int v) => 20, allowNegative:
false);
451 if (listFeat.Count != 0)
454 Element e2 = listFeat.RandomItem();
455 if (maxSlot <= 1 || e2.
source.geneSlot <= 1)
457 if (e2.
source.geneSlot > maxSlot)
459 maxSlot = e2.
source.geneSlot;
461 AddVal(e2.
id, 1, allowStack:
false, (
int v) => e2.
source.cost[0] * 5, allowNegative:
false);
465 void AddRandom(
int n)
467 for (
int i = 0; i < n; i++)
485 Element element = listSkill[Mathf.Clamp(
EClass.
rnd(6), 0, listSkill.Count - 1)];
498 else if (listFeat.Count > 0)
511 void AddVal(
int id,
int v,
bool allowStack, Func<int, int> funcCost,
bool allowNegative)
513 if (v >= 0 || allowNegative)
519 num2 =
EClass.
curve(Mathf.Abs(v + 100), 20, 10, 90);
522 for (
int i = 0; i <
vals.Count; i += 2)
531 Debug.Log(
vals[i + 1] +
": " + v +
"/" + num2);
545 cost += Mathf.Max(0, funcCost(num2));
562 for (
int i = 0; i < vals.Count; i += 2)
565 if (type !=
Type.Superimani || !element.
HasTag(
"gene_mani"))
567 if (element.
source.geneSlot < 0)
571 if (element.
source.geneSlot > slot)
573 slot = element.
source.geneSlot;
577 if (type ==
Type.Brain || type ==
Type.Inferior)
594 "jelly" =>
Type.Default,
595 "gold" =>
Type.Superior,
596 "amethyst" =>
Type.Brain,
597 "lapis" =>
Type.Superimani,
606 Type.Default =>
"jelly",
607 Type.Superior =>
"gold",
608 Type.Superimani =>
"lapis",
609 Type.Brain =>
"amethyst",
616 return Mathf.Min(cost, 5000) * Mathf.Min(cost, 5000) / 2;
623 return Type.Superior;
627 return Type.Inferior;
639 return "gene".lang(text.ToTitleCase(), (cost == 0) ?
"" : (cost.ToString() ??
""));
644 if (slot >= 1 && (owner ==
null || !(owner.category.id ==
"relic")))
646 n.
AddText(
"NoteText_enc",
"isGeneReqSlots".lang(slot.ToString() ??
""),
FontColor.Warning);
653 IList<int> vals = this.vals.Copy();
654 vals = (from i in Enumerable.Range(0, vals.Count / 2)
658 value = vals[i * 2 + 1]
661 select x).SelectMany(x =>
new int[2] { x.id, x.value }).ToList();
662 if (type ==
Type.Brain)
670 for (
int num = 0; num < vals.Count; num += 2)
672 int num2 = vals[num];
673 int num3 = vals[num + 1];
675 string @ref = (num2 + 1).ToString() ??
"";
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);
683 for (
int num4 = 0; num4 < vals.Count; num4 += 2)
687 int num5 = element.Value / 10;
691 switch (element.
source.category)
704 if (element.
Value < 0)
706 text3 =
" (" +
"party".lang() +
") ";
715 text2 = text2 +
"[" +
"*".Repeat(Mathf.Clamp(num5, 1, 5)) + ((num5 > 5) ?
"+" :
"") +
"]";
719 text2 = text2 +
" (" + element.Value +
")";
721 if ((
bool)LayerCraft.Instance && (element.source.category ==
"slot" || element.
HasTag(
"noRelic") || element.
HasTag(
"permaGene")))
725 n.
AddText(
"NoteText_enc",
"gene_info".lang(element.
Name.ToTitleCase(wholeText:
true) + text3, text2), color2);
731 n.
AddHeader(
"HeaderAdditionalTrait",
"gene_hint");
739 int num3 = num2 - num;
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);
749 for (
int i = 0; i < vals.Count; i += 2)
752 if (c.
IsPC && !CanRemove(c))
756 if (!(element.
source.category ==
"feat"))
763 if (orCreateElement !=
null && orCreateElement.
vLink == 0)
775 for (
int i = 0; i < vals.Count; i += 2)
778 if (!(element.
source.category ==
"ability"))
784 if (
item.act.source.id == element.
id)
795 for (
int i = 0; i < vals.Count; i += 2)
798 if (element.
source.category ==
"slot")
808 for (
int i = 0; i < vals.Count; i += 2)
820 for (
int i = 0; i < vals.Count; i += 2)
831 int num = c.
Evalue(6608) + 10;
832 for (
int i = 0; i < vals.Count; i += 2)
835 if ((element.
source.category ==
"attribute" || element.
source.category ==
"skill") && vals[i + 1] > num)
845 for (
int i = 0; i < vals.Count; i += 2)
848 if (element.
source.category ==
"slot" || element.
HasTag(
"noRelic") || element.
HasTag(
"permaGene"))
850 vals.RemoveRange(i, 2);
854 cost = cost * Mathf.Clamp(slot, 1, 10) / 10;
ElementContainerCard elements
SourceMaterial.Row material
Card ChangeMaterial(int idNew, bool ignoreFixedMaterial=false)
void SetInt(string id, int value=0)
Card MakeRefFrom(string id)
int GetInt(string id, int? defaultInt=null)
bool HasElement(int ele, bool includeNagative=false)
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)
void RemoveBodyPart(int ele)
static Chara Create(string id, int lv=-1)
void Refresh(bool calledRecursive=false)
void SetFeat(int id, int value=1, bool msg=false)
void RefreshFaithElement()
void Apply(Chara c, bool reverse)
void WriteNote(UINote n, Thing owner=null, Chara tg=null)
void MakeSlimeFood(Chara c)
void GenerateWithGene(Type _type, Card gene, Chara model=null)
void _OnDeserialized(StreamingContext context)
Element GetInvalidFeat(Chara c)
static Thing GenerateGene(CardRow r, Type? type=null, int lv=-1, int seed=-1)
void _OnSerializing(StreamingContext context)
static Thing CopyDNA(Thing from, Thing to)
static Thing GenerateRandomGene(int lv=-1, int seed=-1)
static Type GetType(string idMat)
static void GenerateManiGene(Card owner)
string GetMaterialId(Type type)
void Generate(Type _type, Chara model=null)
void WriteNoteExtra(UINote n, Thing owner, Chara tg)
Element GetElement(int id)
static Thing GenerateGene(Chara c, Type? type=null)
void ReplaceBodySlot(int slot)
Element GetInvalidAction(Chara c)
static int curve(long _a, int start, int step, int rate=75)
static SourceManager sources
static int rndHalf(int a)
void Learn(int ele, int v=1)
int ValueWithoutLink(int ele)
Element ModBase(int ele, int v)
void SetTo(int id, int v)
Element GetOrCreateElement(Element ele)
static Element Create(int id, int v=0)
static void SetSeed(int a=-1)
Dictionary< string, CardRow > map
static SpawnList Get(string id, string parent=null, CardFilter filter=null)
CardRow Select(int lv=-1, int levelRange=-1)
void DestroyAll(Func< Thing, bool > funcExclude=null)
static Thing Create(string id, int idMat=-1, int lv=-1)
UIItem AddHeader(string text, Sprite sprite=null)
UIItem AddText(string text, FontColor color=FontColor.DontChange)
void Space(int sizeY=0, int sizeX=1)