diff --git a/.gitignore b/.gitignore
index ea8cb77..d3d9df0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
*.userprefs
bin
obj
+Libraries/*
+!Libraries/README.md
\ No newline at end of file
diff --git a/EdBPrepareCarefully.csproj b/EdBPrepareCarefully.csproj
index 1aa4c87..4f03040 100644
--- a/EdBPrepareCarefully.csproj
+++ b/EdBPrepareCarefully.csproj
@@ -7,7 +7,7 @@
Library
EdB.PrepareCarefully
EdBPrepareCarefully
- 0.14.2.1
+ 0.15.0.1
False
v3.5
ScenPart_PlayerPawnsArriveMethodCarefully.manifest
@@ -39,6 +39,12 @@
+
+ Libraries\Assembly-CSharp.dll
+
+
+ Libraries\UnityEngine.dll
+
@@ -107,7 +113,7 @@
-
+
@@ -129,6 +135,10 @@
+
+
+
+
diff --git a/EdBPrepareCarefully.sln b/EdBPrepareCarefully.sln
index 68aa448..58d2d2c 100644
--- a/EdBPrepareCarefully.sln
+++ b/EdBPrepareCarefully.sln
@@ -23,9 +23,9 @@ Global
$2.FileWidth = 120
$2.TabsToSpaces = False
$2.EolMarker = Unix
- $2.inheritsSet = VisualStudio
+ $2.inheritsSet = null
$2.inheritsScope = text/plain
- $2.scope = text/plain
+ $2.scope = application/xml
$0.CSharpFormattingPolicy = $3
$3.IndentSwitchBody = True
$3.ElseNewLinePlacement = NewLine
@@ -195,6 +195,6 @@ Global
$29.IncludeStaticEntities = True
$0.VersionControlPolicy = $31
$31.inheritsSet = Mono
- version = 0.14.2.1
+ version = 0.15.0.1
EndGlobalSection
EndGlobal
diff --git a/LICENSE b/LICENSE
index b43fe76..9cf4e60 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2016 edbmods
+Copyright (c) 2016 edbmods and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Libraries/README.md b/Libraries/README.md
new file mode 100644
index 0000000..ec39614
--- /dev/null
+++ b/Libraries/README.md
@@ -0,0 +1,7 @@
+This directory should contain the DLL dependencies required to build the mod.
+
+The solution has dependencies on the following two DLLs:
+- Assembly-CSharp.dll
+- UnityEngine.dll
+
+Copy those dependencies from the RimWorld game directory into the "Libraries" directory. Be sure to make _copies_ of the originals--don't accidentally move/delete them from the original game directory.
\ No newline at end of file
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index bafff0a..a2e983e 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -5,7 +5,7 @@
// Change them to the values specific to your project.
[assembly: AssemblyTitle("EdBPrepareCarefully")]
-[assembly: AssemblyDescription("A RimWorld Alpha 14 mod")]
+[assembly: AssemblyDescription("A RimWorld Alpha 15 mod")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EdB Prepare Carefully Mod")]
@@ -17,7 +17,7 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion("0.14.2.1")]
+[assembly: AssemblyVersion("0.15.0.1")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
diff --git a/README.md b/README.md
index deedae9..fa855d7 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Note that the solution has dependencies on the following DLLs:
- Assembly-CSharp.dll
- UnityEngine.dll
-You'll need to add those dependencies to your project. Since they might reference file paths on your local development environment, I did not include them in the project files.
+Copy those dependencies from the RimWorld game directory into the "Libraries" directory. Be sure to make _copies_ of the originals--don't accidentally move/delete them from the original game directory.
The result of the build will be the following DLL:
- EdBPrepareCarefully.dll
diff --git a/Resources/About/About.xml b/Resources/About/About.xml
index f8e4719..0f7dc61 100644
--- a/Resources/About/About.xml
+++ b/Resources/About/About.xml
@@ -3,11 +3,11 @@
EdB Prepare Carefully
EdB
- 0.14.1249
+ 0.15.1272
Customize your colonists, choose your gear and prepare carefully for your crash landing!
If you get a set of starting colonists that you like, save them as a preset so that you can start your game the same way next time.
-[Version 0.14.2.1]
+[Version 0.15.0.1]
\ No newline at end of file
diff --git a/Resources/CHANGELOG.txt b/Resources/CHANGELOG.txt
index a7d9ce9..2a7f04a 100644
--- a/Resources/CHANGELOG.txt
+++ b/Resources/CHANGELOG.txt
@@ -1,3 +1,10 @@
+ _____________________________________________________________________________
+
+ Version 0.15.0.1
+ _____________________________________________________________________________
+
+ - Added support for Alpha 15.
+
_____________________________________________________________________________
Version 0.14.2.1
diff --git a/Resources/Defs/MapGeneratorDefs/MapGenerators.xml b/Resources/Defs/MapGeneratorDefs/MapGenerators.xml
index 6b413fc..d93a147 100644
--- a/Resources/Defs/MapGeneratorDefs/MapGenerators.xml
+++ b/Resources/Defs/MapGeneratorDefs/MapGenerators.xml
@@ -1,61 +1,11 @@
-
- MainMapGenerator
-
+
+ ScenParts
+ MainMapGenerator
+ 700
+
+
-
-
-
-
-
-
-
-
-
-
- 24
-
-
-
-
- 0.120.25
-
-
-
-
- SteamGeyser
- 25
- 4
-
- 0.7
- 1
-
- 30
- Heavy
-
-
- 4
- Heavy
-
-
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml b/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml
index 9f2e6ae..72e77da 100644
--- a/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml
+++ b/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml
@@ -115,7 +115,7 @@ Disable point limits to prepare your starting colonists with no limitations.Select a condition
You must select a condition
{0} ({1})
- Implants
+
Furniture
2 Damage
3 Damage
@@ -139,4 +139,8 @@ Prepare Carefully is a map generation mod. It appears that you have another mod
Your colonist customizations will be ignored.
Accessory
The starting colonists and resources that were randomly generated for this scenario were worth {0} points.
+
+
+ Medical
+
\ No newline at end of file
diff --git a/Source/CustomPawn.cs b/Source/CustomPawn.cs
index f43b150..cf165e6 100644
--- a/Source/CustomPawn.cs
+++ b/Source/CustomPawn.cs
@@ -1005,8 +1005,6 @@ public bool IsApparelConflict()
protected Pawn CopyPawn(Pawn source)
{
- // TODO: Evaluate
- //Pawn result = PawnGenerator.GeneratePawn(PawnKindDefOf.Colonist, Faction.OfColony);
Pawn result = new Randomizer().GenerateColonist();
// Reset health to remove any old injuries.
diff --git a/Source/EquipmentDatabase.cs b/Source/EquipmentDatabase.cs
index 16d4596..2fac541 100644
--- a/Source/EquipmentDatabase.cs
+++ b/Source/EquipmentDatabase.cs
@@ -44,13 +44,16 @@ public int ClassifyThingDef(ThingDef def)
}
}
- if (def.apparel != null) {
+ if (def.IsApparel) {
if (!def.destroyOnDrop) {
return EquipmentDatabaseEntry.TypeApparel;
}
}
if (def.CountAsResource) {
+ if (def.IsDrug || def.IsMedicine) {
+ return EquipmentDatabaseEntry.TypeMedical;
+ }
if (def.ingestible != null) {
return EquipmentDatabaseEntry.TypeFood;
}
@@ -72,7 +75,7 @@ public int ClassifyThingDef(ThingDef def)
}
if (def.isBodyPartOrImplant) {
- return EquipmentDatabaseEntry.TypeImplant;
+ return EquipmentDatabaseEntry.TypeMedical;
}
if (def.race != null && def.race.Animal == true) {
@@ -145,7 +148,7 @@ public List Animals {
public List Implants {
get {
List result = entries.Values.ToList().FindAll((EquipmentDatabaseEntry e) => {
- return e.type == EquipmentDatabaseEntry.TypeImplant;
+ return e.type == EquipmentDatabaseEntry.TypeMedical;
});
result.Sort((EquipmentDatabaseEntry a, EquipmentDatabaseEntry b) => {
return a.Label.CompareTo(b.Label);
diff --git a/Source/EquipmentDatabaseEntry.cs b/Source/EquipmentDatabaseEntry.cs
index 6cff8a0..b478795 100644
--- a/Source/EquipmentDatabaseEntry.cs
+++ b/Source/EquipmentDatabaseEntry.cs
@@ -13,7 +13,7 @@ public class EquipmentDatabaseEntry
public static readonly int TypeWeapon = 3;
public static readonly int TypeApparel = 4;
public static readonly int TypeAnimal = 5;
- public static readonly int TypeImplant = 6;
+ public static readonly int TypeMedical = 6;
public static readonly int TypeBuilding = 7;
public ThingDef def;
diff --git a/Source/Genstep_ScenParts.cs b/Source/GenStep_ScenParts.cs
similarity index 99%
rename from Source/Genstep_ScenParts.cs
rename to Source/GenStep_ScenParts.cs
index ba17413..390f812 100644
--- a/Source/Genstep_ScenParts.cs
+++ b/Source/GenStep_ScenParts.cs
@@ -9,9 +9,9 @@
namespace EdB.PrepareCarefully
{
// Alternate map generation to include customized pawn, equipment and resources.
- public class Genstep_ScenParts : Genstep
+ public class GenStep_ScenParts : GenStep
{
- public Genstep_ScenParts()
+ public GenStep_ScenParts()
{
}
@@ -305,7 +305,7 @@ public void SpawnStartingResources()
// exceptionally large number of a given resource, would the numbers for those parameters
// need to be increased to allow the scatterer to find a place on the map?
if (!entry.gear && !entry.animal) {
- new Genstep_ScatterThings {
+ new GenStep_ScatterThings {
nearPlayerStart = true,
thingDef = e.def,
stuff = e.stuffDef,
diff --git a/Source/Injury.cs b/Source/Injury.cs
index 7747fb7..07714d6 100644
--- a/Source/Injury.cs
+++ b/Source/Injury.cs
@@ -29,7 +29,7 @@ public InjuryOption Option {
}
}
- protected float severity = 2;
+ protected float severity = 0;
protected string stageLabel = null;
diff --git a/Source/InjuryOption.cs b/Source/InjuryOption.cs
index 102371e..9acfd18 100644
--- a/Source/InjuryOption.cs
+++ b/Source/InjuryOption.cs
@@ -35,6 +35,15 @@ public bool IsOldInjury {
set { oldInjury = value; }
}
+ public bool IsAddiction {
+ get {
+ if (hediffDef.hediffClass != null && typeof(Hediff_Addiction).IsAssignableFrom(hediffDef.hediffClass)) {
+ return true;
+ }
+ return false;
+ }
+ }
+
public bool RemovesPart {
get { return removesPart; }
set { removesPart = value; }
@@ -57,7 +66,13 @@ public List ValidParts {
public bool HasStageLabel {
get {
- return (hediffDef.stages != null && hediffDef.stages.Count > 1);
+ if (hediffDef.stages == null || hediffDef.stages.Count <= 1) {
+ return false;
+ }
+ if (IsAddiction) {
+ return false;
+ }
+ return true;
}
}
diff --git a/Source/ModController.cs b/Source/ModController.cs
index d3989da..5076e1b 100644
--- a/Source/ModController.cs
+++ b/Source/ModController.cs
@@ -12,7 +12,7 @@ namespace EdB.PrepareCarefully
class ModController : UnityEngine.MonoBehaviour
{
public static readonly string ModName = "EdB Prepare Carefully";
- public static readonly string Version = "0.14.2.1";
+ public static readonly string Version = "0.15.0.1";
Window currentLayer = null;
bool gameplay = false;
diff --git a/Source/Page_ConfigureStartingPawns.cs b/Source/Page_ConfigureStartingPawns.cs
index d719cf1..92693f2 100644
--- a/Source/Page_ConfigureStartingPawns.cs
+++ b/Source/Page_ConfigureStartingPawns.cs
@@ -7,18 +7,20 @@
namespace EdB.PrepareCarefully
{
+ // EdB: Copy of the RimWorld.Page_ConfigureStartingPawns with changes to add the middle "Prepare Carefully" button.
+ // Updated for Alpha 15. TODO: Replace with a new copy and re-do changes when Alpha 16 comes out.
public class Page_ConfigureStartingPawns : Page
{
//
// Static Fields
//
- private const float TabAreaHeight = 30;
+ private const float TabAreaHeight = 30f;
- private const float RectAreaWidth = 100;
+ private const float RectAreaWidth = 100f;
- private const float RightRectLeftPadding = 5;
+ private const float RightRectLeftPadding = 5f;
- private static readonly Vector2 PawnPortraitSize = new Vector2(100, 140);
+ private static readonly Vector2 PawnPortraitSize = new Vector2(100f, 140f);
//
// Fields
@@ -28,8 +30,6 @@ public class Page_ConfigureStartingPawns : Page
//
// Properties
//
- // EdB: Copy of the RimWorld.Page_ConfigureStartingPawns.PageTitle
- // Updated for Alpha 14.
public override string PageTitle {
get {
return "CreateCharacters".Translate();
@@ -39,50 +39,71 @@ public override string PageTitle {
//
// Methods
//
+ protected override bool CanDoNext()
+ {
+ if (!base.CanDoNext()) {
+ return false;
+ }
+ foreach (Pawn current in Find.GameInitData.startingPawns) {
+ if (!current.Name.IsValid) {
+ Messages.Message("EveryoneNeedsValidName".Translate(), MessageSound.RejectInput);
+ return false;
+ }
+ }
+ PortraitsCache.Clear();
+ return true;
+ }
+
public override void DoWindowContents(Rect rect)
{
base.DrawPageTitle(rect);
- Rect mainRect = base.GetMainRect(rect, 30, false);
+ Rect mainRect = base.GetMainRect(rect, 30f, false);
Widgets.DrawMenuSection(mainRect, true);
TabDrawer.DrawTabs(mainRect, from c in Find.GameInitData.startingPawns
- select new TabRecord(c.LabelCap, delegate {
- this.SelectPawn(c);
- }, c == this.curPawn));
- Rect rect2 = mainRect.ContractedBy(17);
+ select new TabRecord(c.LabelCap, delegate {
+ this.SelectPawn(c);
+ }, c == this.curPawn));
+ Rect rect2 = mainRect.ContractedBy(17f);
Rect rect3 = rect2;
- rect3.width = 100;
- GUI.DrawTexture(new Rect(rect3.xMin + (rect3.width - Page_ConfigureStartingPawns.PawnPortraitSize.x) / 2 - 10, rect3.yMin + 20, Page_ConfigureStartingPawns.PawnPortraitSize.x, Page_ConfigureStartingPawns.PawnPortraitSize.y), PortraitsCache.Get(this.curPawn, Page_ConfigureStartingPawns.PawnPortraitSize, default(Vector3), 1));
+ rect3.width = 100f;
+ GUI.DrawTexture(new Rect(rect3.xMin + (rect3.width - Page_ConfigureStartingPawns.PawnPortraitSize.x) / 2f - 10f, rect3.yMin + 20f, Page_ConfigureStartingPawns.PawnPortraitSize.x, Page_ConfigureStartingPawns.PawnPortraitSize.y), PortraitsCache.Get(this.curPawn, Page_ConfigureStartingPawns.PawnPortraitSize, default(Vector3), 1f));
Rect rect4 = rect2;
rect4.xMin = rect3.xMax;
Rect rect5 = rect4;
- rect5.width = 475;
+ rect5.width = 475f;
CharacterCardUtility.DrawCharacterCard(rect5, this.curPawn, new Action(this.RandomizeCurPawn));
- Rect rect6 = new Rect(rect5.xMax + 5, rect4.y + 100, rect4.width - rect5.width - 5, 200);
+ Rect rect6 = new Rect(rect5.xMax + 5f, rect4.y + 100f, rect4.width - rect5.width - 5f, 200f);
Text.Font = GameFont.Medium;
Widgets.Label(rect6, "Health".Translate());
Text.Font = GameFont.Small;
- rect6.yMin += 35;
+ rect6.yMin += 35f;
HealthCardUtility.DrawHediffListing(rect6, this.curPawn, true);
- Rect rect7 = new Rect(rect6.x, rect6.yMax, rect6.width, 200);
+ Rect rect7 = new Rect(rect6.x, rect6.yMax, rect6.width, 200f);
Text.Font = GameFont.Medium;
Widgets.Label(rect7, "Relations".Translate());
Text.Font = GameFont.Small;
- rect7.yMin += 35;
+ rect7.yMin += 35f;
SocialCardUtility.DrawRelationsAndOpinions(rect7, this.curPawn);
+
// EdB: Add a middle "Prepare Carefully" button.
+ // base.DoBottomButtons(rect, "Start".Translate(), null, null, true);
Action prepareCarefullyAction = () => {
PrepareCarefully.Instance.Initialize();
Find.WindowStack.Add(new Page_ConfigureStartingPawnsCarefully());
if (!PrepareCarefully.Instance.FindScenPart()) {
Find.WindowStack.Add(new Dialog_Confirm("EdB.PrepareCarefully.ModConfigProblem.Description".Translate(),
- delegate {}, true, "EdB.PrepareCarefully.ModConfigProblem.Title".Translate(), false));
+ delegate { }, true, "EdB.PrepareCarefully.ModConfigProblem.Title".Translate(), false));
}
};
base.DoBottomButtons(rect, "Start".Translate(), "EdB.PrepareCarefully".Translate(), prepareCarefullyAction, true);
}
- // EdB: Copy of the RimWorld.Page_ConfigureStartingPawns.PreOpen()
- // Updated for Alpha 14.
+ public override void PostOpen()
+ {
+ base.PostOpen();
+ TutorSystem.Notify_Event("PageStart-ConfigureStartingPawns");
+ }
+
public override void PreOpen()
{
base.PreOpen();
@@ -91,37 +112,23 @@ public override void PreOpen()
}
}
- // EdB: Copy of the RimWorld.Page_ConfigureStartingPawns.RandomizeCurPawn()
- // Updated for Alpha 14.
private void RandomizeCurPawn()
{
+ if (!TutorSystem.AllowAction("RandomizePawn")) {
+ return;
+ }
do {
this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
}
- while (!StartingPawnUtility.AnyoneCanDoRequiredWorkTypes());
+ while (!StartingPawnUtility.WorkTypeRequirementsSatisfied());
+ TutorSystem.Notify_Event("RandomizePawn");
}
- // EdB: Copy of the RimWorld.Page_ConfigureStartingPawns.SelectPawn()
- // Updated for Alpha 14.
public void SelectPawn(Pawn c)
{
if (c != this.curPawn) {
this.curPawn = c;
}
}
-
- // EdB: Copy of the RimWorld.Page_ConfigureStartingPawns.TryNext()
- // Updated for Alpha 14.
- protected override bool TryNext()
- {
- foreach (Pawn current in Find.GameInitData.startingPawns) {
- if (!current.Name.IsValid) {
- Messages.Message("EveryoneNeedsValidName".Translate(), MessageSound.RejectInput);
- return false;
- }
- }
- PortraitsCache.Clear();
- return true;
- }
}
}
diff --git a/Source/Page_Equipment.cs b/Source/Page_Equipment.cs
index 732d159..e6d32e1 100644
--- a/Source/Page_Equipment.cs
+++ b/Source/Page_Equipment.cs
@@ -53,7 +53,7 @@ public Page_Equipment()
tabs.Add(new TabRecord("EdB.EquipmentTab.Food".Translate(), delegate { this.ChangeTab(1); }, false));
tabs.Add(new TabRecord("EdB.EquipmentTab.Weapons".Translate(), delegate { this.ChangeTab(2); }, false));
tabs.Add(new TabRecord("EdB.EquipmentTab.Apparel".Translate(), delegate { this.ChangeTab(3); }, false));
- tabs.Add(new TabRecord("EdB.PrepareCarefully.EquipmentTab.Implants".Translate(), delegate { this.ChangeTab(4); }, false));
+ tabs.Add(new TabRecord("EdB.PrepareCarefully.EquipmentTab.Medical".Translate(), delegate { this.ChangeTab(4); }, false));
tabs.Add(new TabRecord("EdB.PrepareCarefully.EquipmentTab.Buildings".Translate(), delegate { this.ChangeTab(5); }, false));
tabs.Add(new TabRecord("EdB.PrepareCarefully.EquipmentTab.Animals".Translate(), delegate { this.ChangeTab(6); }, false));
diff --git a/Source/Panel_Health.cs b/Source/Panel_Health.cs
index 2dd16bc..947292c 100644
--- a/Source/Panel_Health.cs
+++ b/Source/Panel_Health.cs
@@ -143,26 +143,14 @@ public void DrawHeader()
Action addInjuryAction = () => {
if (bodyPartSelectionRequired) {
- Injury injury = new Injury();
- injury.BodyPartRecord = selectedBodyPart;
- injury.Option = selectedInjury;
- if (selectedSeverity != null) {
- injury.Severity = selectedSeverity.Value;
- }
- customPawn.AddInjury(injury);
+ AddInjuryToPawn(customPawn, selectedInjury, selectedSeverity, selectedBodyPart);
}
else {
if (selectedInjury.ValidParts.Count > 0) {
foreach (var p in selectedInjury.ValidParts) {
BodyPartRecord record = PrepareCarefully.Instance.HealthManager.FirstBodyPartRecord(p);
if (record != null) {
- Injury injury = new Injury();
- injury.BodyPartRecord = record;
- injury.Option = selectedInjury;
- if (selectedSeverity != null) {
- injury.Severity = selectedSeverity.Value;
- }
- customPawn.AddInjury(injury);
+ AddInjuryToPawn(customPawn, selectedInjury, selectedSeverity, record);
}
else {
Log.Warning("Could not find body part record for definition: " + p.defName);
@@ -170,13 +158,7 @@ public void DrawHeader()
}
}
else {
- Injury injury = new Injury();
- injury.BodyPartRecord = null;
- injury.Option = selectedInjury;
- if (selectedSeverity != null) {
- injury.Severity = selectedSeverity.Value;
- }
- customPawn.AddInjury(injury);
+ AddInjuryToPawn(customPawn, selectedInjury, selectedSeverity, null);
}
}
};
@@ -186,7 +168,12 @@ public void DrawHeader()
CancelButtonLabel = "EdB.PrepareCarefully.Cancel",
HeaderLabel = "EdB.PrepareCarefully.SelectSeverity",
NameFunc = (InjurySeverity option) => {
- return option.Label;
+ if (!string.IsNullOrEmpty(option.Label)) {
+ return option.Label;
+ }
+ else {
+ return selectedInjury.HediffDef.LabelCap;
+ }
},
SelectedFunc = (InjurySeverity option) => {
return option == selectedSeverity;
@@ -237,6 +224,9 @@ public void DrawHeader()
Find.WindowStack.Add(severityDialog);
}
else {
+ if (severityOptions.Count > 0) {
+ selectedSeverity = this.severityOptions[0];
+ }
addInjuryAction();
}
}
@@ -277,7 +267,6 @@ Dialog_Options injuryOptionDialog
},
CloseAction = () => {
ResetSeverityOptions(selectedInjury);
- selectedSeverity = this.severityOptions[0];
if (bodyPartSelectionRequired) {
bodyPartDialog.Options = PrepareCarefully.Instance.HealthManager.AllSkinCoveredBodyParts;
ResetBodyPartEnabledState(bodyPartDialog.Options, customPawn);
@@ -287,6 +276,9 @@ Dialog_Options injuryOptionDialog
Find.WindowStack.Add(severityDialog);
}
else {
+ if (severityOptions.Count > 0) {
+ selectedSeverity = this.severityOptions[0];
+ }
addInjuryAction();
}
}
@@ -389,6 +381,20 @@ Dialog_Options injuryOptionDialog
GUI.EndGroup();
}
+ protected void AddInjuryToPawn(CustomPawn pawn, InjuryOption option, InjurySeverity severity, BodyPartRecord bodyPart)
+ {
+ Injury injury = new Injury();
+ injury.BodyPartRecord = bodyPart;
+ injury.Option = option;
+ if (severity != null) {
+ injury.Severity = severity.Value;
+ }
+ else {
+ injury.Severity = option.HediffDef.initialSeverity;
+ }
+ pawn.AddInjury(injury);
+ }
+
protected void ResetInjuryOptionEnabledState(CustomPawn pawn)
{
disabledInjuryOptions.Clear();
@@ -421,6 +427,14 @@ protected void ResetBodyPartEnabledState(IEnumerable parts, Cust
protected void ResetSeverityOptions(InjuryOption injuryOption)
{
severityOptions.Clear();
+
+ // Don't add stages for addictions since they are handled sort of differently.
+ if (injuryOption.HediffDef.hediffClass != null && typeof(Hediff_Addiction).IsAssignableFrom(injuryOption.HediffDef.hediffClass)) {
+ return;
+ }
+
+ // If the injury has no stages, add the old injury severity options.
+ // TODO: Is this right?
if (injuryOption.HediffDef.stages == null || injuryOption.HediffDef.stages.Count == 0) {
severityOptions.AddRange(oldInjurySeverities);
return;
@@ -436,9 +450,14 @@ protected void ResetSeverityOptions(InjuryOption injuryOption)
continue;
}
+ if (!stage.everVisible) {
+ continue;
+ }
+
InjurySeverity value = null;
if (stage.minSeverity == 0) {
- value = new InjurySeverity(0.001f, stage);
+ float severity = injuryOption.HediffDef.initialSeverity > 0 ? injuryOption.HediffDef.initialSeverity : 0.001f;
+ value = new InjurySeverity(severity, stage);
}
else {
value = new InjurySeverity(stage.minSeverity, stage);
diff --git a/Source/PawnRelationWorker_Sibling.cs b/Source/PawnRelationWorker_Sibling.cs
index 8335cf7..fa5706e 100644
--- a/Source/PawnRelationWorker_Sibling.cs
+++ b/Source/PawnRelationWorker_Sibling.cs
@@ -6,6 +6,7 @@
namespace EdB.PrepareCarefully
{
+ // EdB: Copy of RimWorld.PawnRelationWorker_Sibling with changes to
public class PawnRelationWorker_Sibling : PawnRelationWorker
{
//
@@ -15,9 +16,9 @@ private static Pawn GenerateParent(Pawn generatedChild, Pawn existingChild, Gend
{
float ageChronologicalYearsFloat = generatedChild.ageTracker.AgeChronologicalYearsFloat;
float ageChronologicalYearsFloat2 = existingChild.ageTracker.AgeChronologicalYearsFloat;
- float num = (genderToGenerate != Gender.Male) ? 16 : 14;
- float num2 = (genderToGenerate != Gender.Male) ? 45 : 50;
- float num3 = (genderToGenerate != Gender.Male) ? 27 : 30;
+ float num = (genderToGenerate != Gender.Male) ? 16f : 14f;
+ float num2 = (genderToGenerate != Gender.Male) ? 45f : 50f;
+ float num3 = (genderToGenerate != Gender.Male) ? 27f : 30f;
float num4 = Mathf.Max(ageChronologicalYearsFloat, ageChronologicalYearsFloat2) + num;
float maxChronologicalAge = num4 + (num2 - num);
float midChronologicalAge = num4 + (num3 - num);
@@ -27,7 +28,7 @@ private static Pawn GenerateParent(Pawn generatedChild, Pawn existingChild, Gend
string last;
PawnRelationWorker_Sibling.GenerateParentParams(num4, maxChronologicalAge, midChronologicalAge, num, generatedChild, existingChild, childRequest, out value, out value2, out value3, out last);
bool allowGay = true;
- if (newlyGeneratedParentsWillBeSpousesIfNotGay && last.NullOrEmpty() && Rand.Value < 0.8) {
+ if (newlyGeneratedParentsWillBeSpousesIfNotGay && last.NullOrEmpty() && Rand.Value < 0.8f) {
if (genderToGenerate == Gender.Male && existingChild.GetMother() != null && !existingChild.GetMother().story.traits.HasTrait(TraitDefOf.Gay)) {
last = ((NameTriple)existingChild.GetMother().Name).Last;
allowGay = false;
@@ -45,7 +46,7 @@ private static Pawn GenerateParent(Pawn generatedChild, Pawn existingChild, Gend
float? fixedChronologicalAge = new float?(value2);
Gender? fixedGender = new Gender?(genderToGenerate);
float? fixedSkinWhiteness = new float?(value3);
- PawnGenerationRequest request = new PawnGenerationRequest(existingChild.kindDef, faction, PawnGenerationContext.NonPlayer, true, false, true, true, false, false, 1, false, allowGay, null, new float?(value), fixedChronologicalAge, fixedGender, fixedSkinWhiteness, last);
+ PawnGenerationRequest request = new PawnGenerationRequest(existingChild.kindDef, faction, PawnGenerationContext.NonPlayer, true, false, true, true, false, false, 1f, false, allowGay, true, null, new float?(value), fixedChronologicalAge, fixedGender, fixedSkinWhiteness, last);
Pawn pawn = PawnGenerator.GeneratePawn(request);
if (!Find.WorldPawns.Contains(pawn)) {
Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Keep);
@@ -55,7 +56,7 @@ private static Pawn GenerateParent(Pawn generatedChild, Pawn existingChild, Gend
private static void GenerateParentParams(float minChronologicalAge, float maxChronologicalAge, float midChronologicalAge, float minBioAgeToHaveChildren, Pawn generatedChild, Pawn existingChild, PawnGenerationRequest childRequest, out float biologicalAge, out float chronologicalAge, out float skinWhiteness, out string lastName)
{
- chronologicalAge = Rand.GaussianAsymmetric(midChronologicalAge, (midChronologicalAge - minChronologicalAge) / 2, (maxChronologicalAge - midChronologicalAge) / 2);
+ chronologicalAge = Rand.GaussianAsymmetric(midChronologicalAge, (midChronologicalAge - minChronologicalAge) / 2f, (maxChronologicalAge - midChronologicalAge) / 2f);
chronologicalAge = Mathf.Clamp(chronologicalAge, minChronologicalAge, maxChronologicalAge);
biologicalAge = Rand.Range(minBioAgeToHaveChildren, Mathf.Min(existingChild.RaceProps.lifeExpectancy, chronologicalAge));
if (existingChild.GetFather() != null) {
@@ -65,22 +66,22 @@ private static void GenerateParentParams(float minChronologicalAge, float maxChr
skinWhiteness = ParentRelationUtility.GetRandomSecondParentSkinColor(existingChild.GetMother().story.skinWhiteness, existingChild.story.skinWhiteness, childRequest.FixedSkinWhiteness);
}
else if (!childRequest.FixedSkinWhiteness.HasValue) {
- skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(existingChild.story.skinWhiteness, 0, 1);
+ skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(existingChild.story.skinWhiteness, 0f, 1f);
}
else {
float num = Mathf.Min(childRequest.FixedSkinWhiteness.Value, existingChild.story.skinWhiteness);
float num2 = Mathf.Max(childRequest.FixedSkinWhiteness.Value, existingChild.story.skinWhiteness);
- if (Rand.Value < 0.5) {
- skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(num, 0, num);
+ if (Rand.Value < 0.5f) {
+ skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(num, 0f, num);
}
else {
- skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(num2, num2, 1);
+ skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(num2, num2, 1f);
}
}
lastName = null;
if (!ChildRelationUtility.DefinitelyHasNotBirthName(existingChild) && ChildRelationUtility.ChildWantsNameOfAnyParent(existingChild)) {
if (existingChild.GetMother() == null && existingChild.GetFather() == null) {
- if (Rand.Value < 0.5) {
+ if (Rand.Value < 0.5f) {
lastName = ((NameTriple)existingChild.Name).Last;
}
}
@@ -106,7 +107,7 @@ private static void ResolveMyName(ref PawnGenerationRequest request, Pawn genera
return;
}
if (ChildRelationUtility.ChildWantsNameOfAnyParent(generated)) {
- if (Rand.Value < 0.5) {
+ if (Rand.Value < 0.5f) {
request.SetFixedLastName(((NameTriple)generated.GetFather().Name).Last);
}
else {
@@ -126,55 +127,60 @@ private static void ResolveMySkinColor(ref PawnGenerationRequest request, Pawn g
//
// Methods
//
+ // EdB: Copy of CreateRelation() with changes to assign the other pawn's mother or father to this sibling if
+ // they exist. The logic that's in there already seems to take this into account, but doing it this
+ // results in more predictable behavior in the context of Prepare Carefully customization.
public override void CreateRelation(Pawn generated, Pawn other, ref PawnGenerationRequest request)
{
+ // EdB: Added this block to immediately assign the other pawn's parent to the sibling.
bool otherPawnHasMother = other.GetMother() != null;
bool otherPawnHasFather = other.GetFather() != null;
if (generated.GetMother() != null && generated.GetFather() != null && !otherPawnHasMother && !otherPawnHasFather) {
other.SetMother(generated.GetMother());
other.SetFather(generated.GetFather());
+ return;
}
- else {
- bool flag = other.GetMother() != null;
- bool flag2 = other.GetFather() != null;
- bool flag3 = Rand.Value < 0.85;
- if (flag && LovePartnerRelationUtility.HasAnyLovePartner(other.GetMother())) {
- flag3 = false;
- }
- if (flag2 && LovePartnerRelationUtility.HasAnyLovePartner(other.GetFather())) {
- flag3 = false;
- }
- if (!flag) {
- Pawn newMother = PawnRelationWorker_Sibling.GenerateParent(generated, other, Gender.Female, request, flag3);
- other.SetMother(newMother);
+ // EdB: This is the end of the change. Everything after this is the original implementation.
+
+ bool flag = other.GetMother() != null;
+ bool flag2 = other.GetFather() != null;
+ bool flag3 = Rand.Value < 0.85f;
+ if (flag && LovePartnerRelationUtility.HasAnyLovePartner(other.GetMother())) {
+ flag3 = false;
+ }
+ if (flag2 && LovePartnerRelationUtility.HasAnyLovePartner(other.GetFather())) {
+ flag3 = false;
+ }
+ if (!flag) {
+ Pawn newMother = PawnRelationWorker_Sibling.GenerateParent(generated, other, Gender.Female, request, flag3);
+ other.SetMother(newMother);
+ }
+ generated.SetMother(other.GetMother());
+ if (!flag2) {
+ Pawn newFather = PawnRelationWorker_Sibling.GenerateParent(generated, other, Gender.Male, request, flag3);
+ other.SetFather(newFather);
+ }
+ generated.SetFather(other.GetFather());
+ if (!flag || !flag2) {
+ bool flag4 = other.GetMother().story.traits.HasTrait(TraitDefOf.Gay) || other.GetFather().story.traits.HasTrait(TraitDefOf.Gay);
+ if (flag4) {
+ other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.ExLover, other.GetMother());
}
- generated.SetMother(other.GetMother());
- if (!flag2) {
- Pawn newFather = PawnRelationWorker_Sibling.GenerateParent(generated, other, Gender.Male, request, flag3);
- other.SetFather(newFather);
+ else if (flag3) {
+ other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.Spouse, other.GetMother());
}
- generated.SetFather(other.GetFather());
- if (!flag || !flag2) {
- bool flag4 = other.GetMother().story.traits.HasTrait(TraitDefOf.Gay) || other.GetFather().story.traits.HasTrait(TraitDefOf.Gay);
- if (flag4) {
- other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.ExLover, other.GetMother());
- }
- else if (flag3) {
- other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.Spouse, other.GetMother());
- }
- else {
- LovePartnerRelationUtility.GiveRandomExLoverOrExSpouseRelation(other.GetFather(), other.GetMother());
- }
+ else {
+ LovePartnerRelationUtility.GiveRandomExLoverOrExSpouseRelation(other.GetFather(), other.GetMother());
}
- PawnRelationWorker_Sibling.ResolveMyName(ref request, generated);
- PawnRelationWorker_Sibling.ResolveMySkinColor(ref request, generated);
}
+ PawnRelationWorker_Sibling.ResolveMyName(ref request, generated);
+ PawnRelationWorker_Sibling.ResolveMySkinColor(ref request, generated);
}
public override float GenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request)
{
- float num = 1;
- float num2 = 1;
+ float num = 1f;
+ float num2 = 1f;
if (other.GetFather() != null || other.GetMother() != null) {
num = ChildRelationUtility.ChanceOfBecomingChildOf(generated, other.GetFather(), other.GetMother(), new PawnGenerationRequest?(request), null, null);
}
@@ -185,11 +191,11 @@ public override float GenerationChance(Pawn generated, Pawn other, PawnGeneratio
num2 = PawnSkinColors.GetWhitenessCommonalityFactor(other.story.skinWhiteness);
}
float num3 = Mathf.Abs(generated.ageTracker.AgeChronologicalYearsFloat - other.ageTracker.AgeChronologicalYearsFloat);
- float num4 = 1;
- if (num3 > 40) {
+ float num4 = 1f;
+ if (num3 > 40f) {
num4 = 0.2f;
}
- else if (num3 > 10) {
+ else if (num3 > 10f) {
num4 = 0.65f;
}
return num * num2 * num4 * base.BaseGenerationChanceFactor(generated, other, request);
diff --git a/Source/PrepareCarefully.cs b/Source/PrepareCarefully.cs
index 61a3172..3839dd8 100644
--- a/Source/PrepareCarefully.cs
+++ b/Source/PrepareCarefully.cs
@@ -150,8 +150,8 @@ public void Clear()
this.equipment.Clear();
}
- protected Dictionary facadeToPawnMap = new Dictionary();
- protected Dictionary pawnToFacadeMap = new Dictionary();
+ protected Dictionary customPawnToOriginalPawnMap = new Dictionary();
+ protected Dictionary originalPawnToCustomPawnMap = new Dictionary();
public void Initialize()
{
@@ -448,24 +448,24 @@ public CostDetails Cost
public void InitializePawns()
{
- this.facadeToPawnMap.Clear();
- this.pawnToFacadeMap.Clear();
- foreach (Pawn p in Verse.Find.GameInitData.startingPawns) {
- CustomPawn f = new CustomPawn(p);
- facadeToPawnMap.Add(f, p);
- pawnToFacadeMap.Add(p, f);
- this.pawns.Add(f);
- healthManager.InjuryManager.InitializePawnInjuries(p, f);
+ this.customPawnToOriginalPawnMap.Clear();
+ this.originalPawnToCustomPawnMap.Clear();
+ foreach (Pawn originalPawn in Verse.Find.GameInitData.startingPawns) {
+ CustomPawn customPawn = new CustomPawn(originalPawn);
+ customPawnToOriginalPawnMap.Add(customPawn, originalPawn);
+ originalPawnToCustomPawnMap.Add(originalPawn, customPawn);
+ this.pawns.Add(customPawn);
+ healthManager.InjuryManager.InitializePawnInjuries(originalPawn, customPawn);
}
}
public void InitializeRelationshipManager(List pawns)
{
- List facades = new List();
+ List customPawns = new List();
foreach (Pawn pawn in Verse.Find.GameInitData.startingPawns) {
- facades.Add(pawnToFacadeMap[pawn]);
+ customPawns.Add(originalPawnToCustomPawnMap[pawn]);
}
- relationshipManager = new RelationshipManager(Verse.Find.GameInitData.startingPawns, facades);
+ relationshipManager = new RelationshipManager(Verse.Find.GameInitData.startingPawns, customPawns);
}
public bool FindScenPart()
@@ -473,8 +473,8 @@ public bool FindScenPart()
if (DefDatabase.AllDefs.Count() == 1) {
MapGeneratorDef def = DefDatabase.AllDefs.First();
if (def != null) {
- foreach (var g in def.genSteps) {
- if (g.GetType().FullName.Equals("EdB.PrepareCarefully.Genstep_ScenParts")) {
+ foreach (var g in def.GenStepsInOrder) {
+ if (g.genStep != null && g.genStep.GetType().FullName.Equals(typeof(EdB.PrepareCarefully.GenStep_ScenParts).FullName)) {
return true;
}
}