From 9479da9693cac1f47946ff00a5122f75e011571a Mon Sep 17 00:00:00 2001 From: edbmods Date: Sun, 21 Aug 2016 16:15:16 -0700 Subject: [PATCH 1/8] Added support for Alpha 15: - Minor refactoring to match code changes in vanilla. - Replaced map generator override with new map generator step. - Renamed the "Implants" tab on the Equipment screen to "Medical". Updated equipment categorization accordingly. Other changes: - Added a Libraries directories to make it easier to get the project up-and-running. Updated the README with instructions of how to use it. - Updated the gitignore file to ignore any DLLs in the Libraries directory. - Tweaked the license to reflect contributors. --- .gitignore | 2 + EdBPrepareCarefully.csproj | 12 ++- EdBPrepareCarefully.sln | 6 +- LICENSE | 2 +- Libraries/README.md | 7 ++ Properties/AssemblyInfo.cs | 4 +- README.md | 2 +- Resources/About/About.xml | 4 +- Resources/CHANGELOG.txt | 7 ++ .../Defs/MapGeneratorDefs/MapGenerators.xml | 62 ++--------- .../English/Keyed/EdBPrepareCarefully.xml | 6 +- Source/EquipmentDatabase.cs | 9 +- Source/EquipmentDatabaseEntry.cs | 2 +- Source/Genstep_ScenParts.cs | 4 +- Source/ModController.cs | 2 +- Source/Page_ConfigureStartingPawns.cs | 87 ++++++++------- Source/Page_Equipment.cs | 2 +- Source/PawnRelationWorker_Sibling.cs | 102 +++++++++--------- Source/PrepareCarefully.cs | 4 +- 19 files changed, 161 insertions(+), 165 deletions(-) create mode 100644 Libraries/README.md 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..6cdaa49 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 + @@ -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..be5f8d5 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/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 index ba17413..da10737 100644 --- a/Source/Genstep_ScenParts.cs +++ b/Source/Genstep_ScenParts.cs @@ -9,7 +9,7 @@ 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() { @@ -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/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/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..d043de9 100644 --- a/Source/PrepareCarefully.cs +++ b/Source/PrepareCarefully.cs @@ -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("EdB.PrepareCarefully.Genstep_ScenParts")) { return true; } } From 0870009fddaab0117c39eadad7ee9ac500f2b4e5 Mon Sep 17 00:00:00 2001 From: edbmods Date: Sun, 21 Aug 2016 19:38:19 -0700 Subject: [PATCH 2/8] Added support for addiction health conditions: - Fixed default severity level in Injury class. - Added better specific logic to exclude addiction/withdrawal stages. - Added logic to exclude "never visible" hediff stages. - Fixed an out-of-range error when selecting a severity option. --- Source/Injury.cs | 2 +- Source/InjuryOption.cs | 17 ++++++++++- Source/Panel_Health.cs | 67 +++++++++++++++++++++++++++--------------- 3 files changed, 60 insertions(+), 26 deletions(-) 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/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); From 12e32b1deb65bbd0e5e00270aa9a4e2f00c628f1 Mon Sep 17 00:00:00 2001 From: edbmods Date: Sun, 21 Aug 2016 19:41:09 -0700 Subject: [PATCH 3/8] Some minor refactoring. Removed an old, no-longer-relevant comment. --- Source/CustomPawn.cs | 2 -- Source/PrepareCarefully.cs | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) 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/PrepareCarefully.cs b/Source/PrepareCarefully.cs index d043de9..eb28ca0 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() From c2b6fd7194b0d307df795ddb245cb870710c9cf9 Mon Sep 17 00:00:00 2001 From: edbmods Date: Sun, 21 Aug 2016 20:57:25 -0700 Subject: [PATCH 4/8] Renamed Genstep_ScenParts to GenStep_ScenParts to match the new naming convention in vanilla. --- EdBPrepareCarefully.csproj | 2 +- Resources/Defs/MapGeneratorDefs/MapGenerators.xml | 2 +- Source/{Genstep_ScenParts.cs => GenStep_ScenParts.cs} | 4 ++-- Source/PrepareCarefully.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename Source/{Genstep_ScenParts.cs => GenStep_ScenParts.cs} (99%) diff --git a/EdBPrepareCarefully.csproj b/EdBPrepareCarefully.csproj index 6cdaa49..4f03040 100644 --- a/EdBPrepareCarefully.csproj +++ b/EdBPrepareCarefully.csproj @@ -113,7 +113,7 @@ - + diff --git a/Resources/Defs/MapGeneratorDefs/MapGenerators.xml b/Resources/Defs/MapGeneratorDefs/MapGenerators.xml index be5f8d5..d93a147 100644 --- a/Resources/Defs/MapGeneratorDefs/MapGenerators.xml +++ b/Resources/Defs/MapGeneratorDefs/MapGenerators.xml @@ -5,7 +5,7 @@ ScenParts MainMapGenerator 700 - + \ No newline at end of file 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 da10737..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() { } diff --git a/Source/PrepareCarefully.cs b/Source/PrepareCarefully.cs index eb28ca0..3839dd8 100644 --- a/Source/PrepareCarefully.cs +++ b/Source/PrepareCarefully.cs @@ -474,7 +474,7 @@ public bool FindScenPart() MapGeneratorDef def = DefDatabase.AllDefs.First(); if (def != null) { foreach (var g in def.GenStepsInOrder) { - if (g.genStep != null && g.genStep.GetType().FullName.Equals("EdB.PrepareCarefully.Genstep_ScenParts")) { + if (g.genStep != null && g.genStep.GetType().FullName.Equals(typeof(EdB.PrepareCarefully.GenStep_ScenParts).FullName)) { return true; } } From f7309f60b45b193e8d5216cf39365f024730c611 Mon Sep 17 00:00:00 2001 From: edbmods Date: Sun, 21 Aug 2016 22:40:16 -0700 Subject: [PATCH 5/8] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index fa855d7..0a8f481 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,21 @@ This DLL should be packaged with the contents of the `Resources` directory, insi The build does not automate the creation of the mod distribution directory. +## Versioning + +Prepare Carefully uses a versioning scheme inspired by [semantic versioning](http://semver.org/) that combines the major/minor version of RimWorld with the major/minor version of the mod to end up with the following format: + +`{RimWorld major version}.{RimWorld minor version}.{mod major version}.{mod minor version}` + +Other conventions used to determine the mod version numbers: +- The mod only uses `0` for major versions that are considered unstable/beta releases (i.e. 0.15.0.1) +- Minor version numbers always start at `1` and never start at `0` +- The mod considers a major release to be a release that adds or removes features +- The mod considers a minor release to be an incremental release that makes bug fixes or otherwise changes existing features. + +Some examples: ++ **0.14.0.5**: The fifth "beta"/unstable release of the mod for RimWorld Alpha 14 ++ **0.14.1.1**: The first stable release of the mod for RimWorld Alpha 14 ++ **0.14.2.1**: The second stable release of the mod for RimWorld Alpha 14. The point system was re-enabled for this version. Since this was a new feature that was not in the previous version, it needed a new major-version number. ++ **0.14.2.2**: If we need one, this will be the version number for the first bug-fix release after the second stable release of the mod for RimwWorld Alpha 14 ++ **0.15.0.1**: The first "beta"/unstable version of the mod for RimWorld Alpha 15 From bdec9bc4b9610d7d0bf43c8ce404af1b113e4163 Mon Sep 17 00:00:00 2001 From: edbmods Date: Tue, 23 Aug 2016 19:10:05 -0700 Subject: [PATCH 6/8] Replaced technique used to inject the Prepare Carefully button. - Removed the old MonoBehavior-based technique used to replace the ConfigureStartingPawns page with a customized version containing the Prepare Carefully button. - Added a simple ScenPart override instead, overriding the default `ConfigPage_ConfigureStartingPawn` step with a version that enables the Prepare Carefully button. --- EdBPrepareCarefully.csproj | 6 +- Resources/Defs/Scenarios/ScenParts_Fixed.xml | 13 ++ .../Defs/ThingDefs/EdBPrepareCarefully.xml | 13 -- Source/ModController.cs | 145 ------------------ Source/ModInitializer.cs | 31 ---- Source/ModNotInstalledException.cs | 12 -- Source/Page_ConfigureStartingPawns.cs | 1 + 7 files changed, 16 insertions(+), 205 deletions(-) create mode 100644 Resources/Defs/Scenarios/ScenParts_Fixed.xml delete mode 100644 Resources/Defs/ThingDefs/EdBPrepareCarefully.xml delete mode 100644 Source/ModController.cs delete mode 100644 Source/ModInitializer.cs delete mode 100644 Source/ModNotInstalledException.cs diff --git a/EdBPrepareCarefully.csproj b/EdBPrepareCarefully.csproj index 4f03040..8acfd6c 100644 --- a/EdBPrepareCarefully.csproj +++ b/EdBPrepareCarefully.csproj @@ -64,9 +64,6 @@ - - - @@ -120,7 +117,6 @@ - @@ -136,9 +132,11 @@ + + diff --git a/Resources/Defs/Scenarios/ScenParts_Fixed.xml b/Resources/Defs/Scenarios/ScenParts_Fixed.xml new file mode 100644 index 0000000..822e60e --- /dev/null +++ b/Resources/Defs/Scenarios/ScenParts_Fixed.xml @@ -0,0 +1,13 @@ + + + + + ConfigPage_ConfigureStartingPawns + + Fixed + ScenPart_ConfigPage_ConfigureStartingPawns + EdB.PrepareCarefully.Page_ConfigureStartingPawns + 500 + + + \ No newline at end of file diff --git a/Resources/Defs/ThingDefs/EdBPrepareCarefully.xml b/Resources/Defs/ThingDefs/EdBPrepareCarefully.xml deleted file mode 100644 index be8a812..0000000 --- a/Resources/Defs/ThingDefs/EdBPrepareCarefully.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - EdBPrepareCarefully - Building - true - - EdB.PrepareCarefully.ModInitializer - -
  • EdB.PrepareCarefully.ModInitializer
  • - - - \ No newline at end of file diff --git a/Source/ModController.cs b/Source/ModController.cs deleted file mode 100644 index 5076e1b..0000000 --- a/Source/ModController.cs +++ /dev/null @@ -1,145 +0,0 @@ -using RimWorld; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using UnityEngine; -using Verse; - -namespace EdB.PrepareCarefully -{ - class ModController : UnityEngine.MonoBehaviour - { - public static readonly string ModName = "EdB Prepare Carefully"; - public static readonly string Version = "0.15.0.1"; - - Window currentLayer = null; - bool gameplay = false; - - public ModController() - { - - } - - // Called when the MonoBehavior first starts up. - public virtual void Start() - { - this.enabled = true; - } - - // Called whenever the game switches from the main menu (level 0) into gameplay - // (level 1). - public void OnLevelWasLoaded(int level) - { - // Level 0 means we're in the game menus. Enable the behavior so that - // it starts checking every frame to see if it needs to inject the custom UI - if (level == 0) { - this.gameplay = false; - this.enabled = true; - PrepareCarefully.Instance.Active = false; - } - // Level 1 means we're in gameplay. Disable the behavior because we don't - // need to check anything every frame. - else if (level == 1) { - this.gameplay = true; - - // Disable this component - this.enabled = false; - } - } - - // Called every frame when the mod is enabled - public virtual void Update() - { - try { - if (!gameplay) { - MenusUpdate(); - } - else { - GameplayUpdate(); - } - } - catch (Exception e) { - this.enabled = false; - Log.Error(e.ToString()); - } - } - - // Check if the top user interface element is the vanilla character creation - // screen. If it is, and if the mod is enabled, swap in the custom version. - public virtual void MenusUpdate() - { - // Keep track of the user interface element that's currently on the - // top of the layer stack. - bool layerChanged = false; - Window layer = this.TopWindow; - if (layer != this.currentLayer) { - //Log.Message("Window changed: " + (layer == null ? "null" : layer.GetType().FullName)); - this.currentLayer = layer; - layerChanged = true; - } - - // Check the class name to see if it's the vanilla character creation screen - if (layer != null) { - if ("RimWorld.Page_ConfigureStartingPawns".Equals(layer.GetType().FullName)) { - if (ModEnabled) { - ResetTextures(); - Page page = layer as Page; - Page_ConfigureStartingPawns replacement = new Page_ConfigureStartingPawns(); - replacement.nextAct = page.nextAct; - replacement.next = page.next; - PrepareCarefully.Instance.OriginalPage = replacement; - Find.WindowStack.TryRemove(layer, true); - Find.WindowStack.Add(replacement); - Log.Message("Swapped in EdB Prepare Carefully Character Creation Page"); - } - else { - if (layerChanged) { - Log.Message("EdB Prepare Carefully not enabled. Did not replace Character Creation Page"); - } - } - } - } - } - - public virtual void GameplayUpdate() - { - } - - // Find the top window in the stack that isn't the Console. If we don't do this, all of our logic - // around swapping in a replacement window will fail when the console is up. - public Window TopWindow - { - get { - // The accessors reference properties that might be null with no null-checks, so we need to do some - // non-obvious null-checks ourselves here. - if (Find.UIRoot != null && Find.UIRoot.windows != null && Find.WindowStack != null && Find.WindowStack.Windows != null) { - // Iterate the layers. - foreach (Window window in Find.WindowStack.Windows.Reverse()) { - if (window != null && window.GetType().FullName != "Verse.ImmediateWindow" - && window.GetType().FullName != "Verse.EditWindow_Log") { - return window; - } - } - } - return null; - } - } - - public void ResetTextures() - { - Textures.Reset(); - } - - public bool ModEnabled - { - get { - ModMetaData mod = ModLister.AllInstalledMods.FirstOrDefault((ModMetaData m) => { - return m.Name.Equals(ModName) && m.Active; - }); - return mod != null; - } - } - } -} diff --git a/Source/ModInitializer.cs b/Source/ModInitializer.cs deleted file mode 100644 index 498c95c..0000000 --- a/Source/ModInitializer.cs +++ /dev/null @@ -1,31 +0,0 @@ - -using RimWorld; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; -using Verse; - -namespace EdB.PrepareCarefully -{ - // This class gets instantiated - public class ModInitializer : ITab - { - protected GameObject gameObject = null; - - public ModInitializer() : base() - { - LongEventHandler.ExecuteWhenFinished(() => { - Log.Message("Initialized the EdB Prepare Carefully mod"); - gameObject = new GameObject("EdBPrepareCarefullyController"); - gameObject.AddComponent(); - MonoBehaviour.DontDestroyOnLoad(gameObject); - }); - } - - protected override void FillTab() { - return; - } - } -} diff --git a/Source/ModNotInstalledException.cs b/Source/ModNotInstalledException.cs deleted file mode 100644 index bcd8f39..0000000 --- a/Source/ModNotInstalledException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace EdB.PrepareCarefully -{ - public class ModNotInstalledException : Exception - { - public ModNotInstalledException() { } - public ModNotInstalledException(String message) : base(message) { } - public ModNotInstalledException(String message, Exception cause) : base(message, cause) { } - } -} - diff --git a/Source/Page_ConfigureStartingPawns.cs b/Source/Page_ConfigureStartingPawns.cs index 92693f2..88dc971 100644 --- a/Source/Page_ConfigureStartingPawns.cs +++ b/Source/Page_ConfigureStartingPawns.cs @@ -89,6 +89,7 @@ public override void DoWindowContents(Rect rect) // base.DoBottomButtons(rect, "Start".Translate(), null, null, true); Action prepareCarefullyAction = () => { PrepareCarefully.Instance.Initialize(); + PrepareCarefully.Instance.OriginalPage = this; Find.WindowStack.Add(new Page_ConfigureStartingPawnsCarefully()); if (!PrepareCarefully.Instance.FindScenPart()) { Find.WindowStack.Add(new Dialog_Confirm("EdB.PrepareCarefully.ModConfigProblem.Description".Translate(), From c99707f27cdb9de3a12ebe9763f9bdd182ef62c1 Mon Sep 17 00:00:00 2001 From: edbmods Date: Wed, 24 Aug 2016 20:17:41 -0700 Subject: [PATCH 7/8] Fixed issue with the initial display for "incapable of" work types --- Source/CustomPawn.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/CustomPawn.cs b/Source/CustomPawn.cs index cf165e6..6fcdc88 100644 --- a/Source/CustomPawn.cs +++ b/Source/CustomPawn.cs @@ -177,6 +177,7 @@ public void InitializeWithPawn(Pawn pawn) } } + ResetIncapableOf(); pawn.health.capacities.Clear(); } @@ -984,6 +985,7 @@ protected void ResetBodyType() public string ResetIncapableOf() { + CustomPawn.ClearCachedDisabledWorkTypes(this.pawn.story); List incapableList = new List(); foreach (var tag in pawn.story.DisabledWorkTags) { incapableList.Add(WorkTypeDefsUtility.LabelTranslated(tag)); @@ -994,7 +996,6 @@ public string ResetIncapableOf() else { incapable = null; } - CustomPawn.ClearCachedDisabledWorkTypes(this.pawn.story); return incapable; } @@ -1003,6 +1004,9 @@ public bool IsApparelConflict() return false; } + // Takes the source pawn and creates a copy of it. It is not a 100% deep copy. It creates a new, random pawn + // and then copies the bits and pieces from the source to create a "good-enough" copy. There could be flaws in + // the result, but doing a true deep copy would be tougher maintain. protected Pawn CopyPawn(Pawn source) { Pawn result = new Randomizer().GenerateColonist(); @@ -1060,6 +1064,7 @@ protected Pawn CopyPawn(Pawn source) return result; } + // Uses the customized settings within the CustomPawn to create a new Pawn. public Pawn ConvertToPawn(bool resolveGraphics) { Pawn result = new Randomizer().GenerateColonist(); From 5dec135b9c2b257a1155b0ac2541e5f74eb29acf Mon Sep 17 00:00:00 2001 From: edbmods Date: Sun, 28 Aug 2016 23:26:47 -0700 Subject: [PATCH 8/8] Updated version numbers for Alpha 15. --- EdBPrepareCarefully.csproj | 2 +- EdBPrepareCarefully.sln | 2 +- Properties/AssemblyInfo.cs | 2 +- Resources/About/About.xml | 4 ++-- Resources/CHANGELOG.txt | 3 ++- Source/CostCalculator.cs | 2 +- Source/CustomPawn.cs | 8 +++++--- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/EdBPrepareCarefully.csproj b/EdBPrepareCarefully.csproj index 8acfd6c..64d5c1b 100644 --- a/EdBPrepareCarefully.csproj +++ b/EdBPrepareCarefully.csproj @@ -7,7 +7,7 @@ Library EdB.PrepareCarefully EdBPrepareCarefully - 0.15.0.1 + 0.15.1.1 False v3.5 ScenPart_PlayerPawnsArriveMethodCarefully.manifest diff --git a/EdBPrepareCarefully.sln b/EdBPrepareCarefully.sln index 58d2d2c..3af9268 100644 --- a/EdBPrepareCarefully.sln +++ b/EdBPrepareCarefully.sln @@ -195,6 +195,6 @@ Global $29.IncludeStaticEntities = True $0.VersionControlPolicy = $31 $31.inheritsSet = Mono - version = 0.15.0.1 + version = 0.15.1.1 EndGlobalSection EndGlobal diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index a2e983e..f3515b7 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -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.15.0.1")] +[assembly: AssemblyVersion("0.15.1.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/Resources/About/About.xml b/Resources/About/About.xml index 0f7dc61..8fb56e8 100644 --- a/Resources/About/About.xml +++ b/Resources/About/About.xml @@ -3,11 +3,11 @@ EdB Prepare Carefully EdB - 0.15.1272 + 0.15.1279 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.15.0.1] +[Version 0.15.1.1] \ No newline at end of file diff --git a/Resources/CHANGELOG.txt b/Resources/CHANGELOG.txt index 2a7f04a..71e93d4 100644 --- a/Resources/CHANGELOG.txt +++ b/Resources/CHANGELOG.txt @@ -1,9 +1,10 @@ _____________________________________________________________________________ - Version 0.15.0.1 + Version 0.15.1.1 _____________________________________________________________________________ - Added support for Alpha 15. + - Re-labeled the "Implants" tab to "Medical" on the Equipment page. _____________________________________________________________________________ diff --git a/Source/CostCalculator.cs b/Source/CostCalculator.cs index e4dce73..fa76e42 100644 --- a/Source/CostCalculator.cs +++ b/Source/CostCalculator.cs @@ -248,7 +248,7 @@ public double GetBaseThingCost(ThingDef def, ThingDef stuffDef) return def.BaseMarketValue; } else { - // TODO: Alpha 15 + // TODO: Alpha 16 // Should look at ThingMaker.MakeThing() to decide which validations we need to do // before calling that method to avoid null pointer exceptions. Should re-evaluate // for each new alpha and then update the todo comment with the next alpha version. diff --git a/Source/CustomPawn.cs b/Source/CustomPawn.cs index 6fcdc88..d40fdb1 100644 --- a/Source/CustomPawn.cs +++ b/Source/CustomPawn.cs @@ -965,19 +965,21 @@ protected void ResetGender() }); } } - ResetHead(); ResetBodyType(); } protected void ResetBodyType() { - graphics[PawnLayers.BodyType] = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(pawn.story.BodyType, ShaderDatabase.Cutout, pawn.story.SkinColor); + BodyType bodyType = pawn.story.BodyType; + Graphic bodyTypeGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(bodyType, ShaderDatabase.Cutout, + pawn.story.SkinColor); + graphics[PawnLayers.BodyType] = bodyTypeGraphic; foreach (ThingDef def in selectedApparel) { if (def != null) { int layer = PawnLayers.ToPawnLayerIndex(def.apparel); if (layer != -1) { - graphics[layer] = GraphicsCache.Instance.GetApparel(def, pawn.story.BodyType); + graphics[layer] = GraphicsCache.Instance.GetApparel(def, bodyType); } } }