mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Modified how racegenedefs are formatted
This commit is contained in:
parent
33a37f26de
commit
33c0fa3e3b
14 changed files with 188 additions and 231 deletions
14
Source/Animal_Inheritance/GeneChance.cs
Normal file
14
Source/Animal_Inheritance/GeneChance.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RJW_BGS
|
||||
{
|
||||
public class GeneChance
|
||||
{
|
||||
public string defName;
|
||||
public float chance = 1f;
|
||||
}
|
||||
}
|
|
@ -53,18 +53,11 @@ namespace RJW_BGS
|
|||
RaceGeneDef raceGeneDef = RJWcopy.GetRaceGenDefInternal(pawnKindDef);
|
||||
if (raceGeneDef != null)
|
||||
{
|
||||
int num1 = raceGeneDef.genes.Count;
|
||||
int num2 = raceGeneDef.genechances.Count;
|
||||
if (num1 != num2)
|
||||
foreach (GeneChance gene in raceGeneDef.genes)
|
||||
{
|
||||
Log.Error("The amount of genes and genechanches are different in " + raceGeneDef.defName + ". Can't select genes to inherit");
|
||||
return genelist;
|
||||
}
|
||||
for (int i = 0; i<num1; i++)
|
||||
{
|
||||
if (raceGeneDef.genechances[i] > Rand.Range(0.01f, 1f))
|
||||
if (gene.chance >= Rand.Range(0.01f,1f))
|
||||
{
|
||||
genelist.Add(DefDatabase<GeneDef>.GetNamed(raceGeneDef.genes[i]));
|
||||
genelist.Add(DefDatabase<GeneDef>.GetNamed(gene.defName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
36
Source/Animal_Inheritance/RJW_BGSSettings.cs
Normal file
36
Source/Animal_Inheritance/RJW_BGSSettings.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using UnityEngine;
|
||||
namespace RJW_Genes.Animal_Inheritance
|
||||
{
|
||||
public class RJW_BGSSettings : ModSettings
|
||||
{
|
||||
public static void DoWindowContents(Rect inRect)
|
||||
{
|
||||
//Copied from RJW settings mostly
|
||||
Rect outRect = new Rect(0f, 30f, inRect.width, inRect.height - 30f);
|
||||
Rect rect = new Rect(0f, 0f, inRect.width - 16f, inRect.height + 300f);
|
||||
//Widgets.BeginScrollView(outRect, ref RJWSettings.scrollPosition, rect, true);
|
||||
Listing_Standard listing_Standard = new Listing_Standard();
|
||||
listing_Standard.maxOneColumn = true;
|
||||
listing_Standard.ColumnWidth = rect.width / 2.05f;
|
||||
listing_Standard.Begin(rect);
|
||||
listing_Standard.Gap(24f);
|
||||
listing_Standard.CheckboxLabeled("enabled", ref enabled, "no function yet", 0f, 1f);
|
||||
//listing_Standard.CheckboxLabeled("sexfrenzy", ref sexfrenzy, "disable the effects", 0f, 1f);
|
||||
listing_Standard.End();
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
{
|
||||
base.ExposeData();
|
||||
Scribe_Values.Look<bool>(ref RJW_BGSSettings.enabled, "enabled", RJW_BGSSettings.enabled, true);
|
||||
}
|
||||
|
||||
public static bool enabled;
|
||||
}
|
||||
}
|
27
Source/Animal_Inheritance/RJW_BGSSettingsController.cs
Normal file
27
Source/Animal_Inheritance/RJW_BGSSettingsController.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RJW_Genes.Animal_Inheritance
|
||||
{
|
||||
public class RJW_BGSSettingsController : Mod
|
||||
{
|
||||
public RJW_BGSSettingsController(ModContentPack content) : base(content)
|
||||
{
|
||||
base.GetSettings<RJW_BGSSettings>();
|
||||
}
|
||||
|
||||
public override string SettingsCategory()
|
||||
{
|
||||
return "RJW Genes Animal Gene Inheritance";
|
||||
}
|
||||
public override void DoSettingsWindowContents(Rect inRect)
|
||||
{
|
||||
RJW_BGSSettings.DoWindowContents(inRect);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ namespace RJW_BGS
|
|||
return raceGroupDef != null;
|
||||
}
|
||||
|
||||
//slightly modified code so it also works racegroupdefs
|
||||
|
||||
public static RaceGroupDef GetRaceGroupDefInternal(PawnKindDef kindDef)
|
||||
{
|
||||
string raceName = kindDef.race.defName;
|
||||
|
@ -71,6 +71,7 @@ namespace RJW_BGS
|
|||
return result;
|
||||
}
|
||||
|
||||
//slightly modified copy of code above so it also works for racegenedefs
|
||||
public static RaceGeneDef GetRaceGenDefInternal(PawnKindDef kindDef)
|
||||
{
|
||||
if (kindDef == null)
|
||||
|
|
|
@ -10,11 +10,12 @@ namespace RJW_BGS
|
|||
{
|
||||
public class RaceGeneDef : Def
|
||||
{
|
||||
|
||||
public String raceGroup;
|
||||
public List<string> raceNames;
|
||||
public List<string> pawnKindNames;
|
||||
public List<string> genes;
|
||||
public List<float> genechances;
|
||||
public List<GeneChance> genes;
|
||||
//public List<float> genechances;
|
||||
public String hybridName;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue