diff --git a/About/Manifest.xml b/About/Manifest.xml index 90f7b96..0b0a172 100644 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,7 +1,7 @@ RJW Menstruation - 1.0.1.11 + 1.0.1.12 diff --git a/Assemblies/RJW_Menstruation.dll b/Assemblies/RJW_Menstruation.dll index 219bb7e..96e0961 100644 Binary files a/Assemblies/RJW_Menstruation.dll and b/Assemblies/RJW_Menstruation.dll differ diff --git a/Defs/ThingDefs/Apparel_Absorbers.xml b/Defs/ThingDefs/Apparel_Absorbers.xml index 4fb8c1f..aa7573a 100644 --- a/Defs/ThingDefs/Apparel_Absorbers.xml +++ b/Defs/ThingDefs/Apparel_Absorbers.xml @@ -60,7 +60,7 @@ -
  • +
  • false true 8 @@ -113,7 +113,7 @@ -
  • +
  • false true 8 @@ -181,7 +181,7 @@ -
  • +
  • true false Absorber_Pad_Dirty @@ -233,7 +233,7 @@ -
  • +
  • true false Absorber_Pad_Dirty diff --git a/Languages/English/Keyed/RJW_Menstruation.xml b/Languages/English/Keyed/RJW_Menstruation.xml index 0b1b543..273f16a 100644 --- a/Languages/English/Keyed/RJW_Menstruation.xml +++ b/Languages/English/Keyed/RJW_Menstruation.xml @@ -74,6 +74,11 @@ Hostile Faction target pawns the gizmo and button will appear for these pawns + use hybrid extension + overrides RJW and RaceSupport's hybrid definition Dominant hybrid extension determines whose definition used first. Not recommended to change this + Dominant hybrid extension + Mother + Father Vaginal washing diff --git a/Languages/Korean/Keyed/RJW_Menstruation.xml b/Languages/Korean/Keyed/RJW_Menstruation.xml index fe341d6..8dc34bf 100644 --- a/Languages/Korean/Keyed/RJW_Menstruation.xml +++ b/Languages/Korean/Keyed/RJW_Menstruation.xml @@ -74,6 +74,11 @@ 적대관계 표시 대상 아이콘과 버튼을 표시할 대상입니다. + 잡종 정의 대체 + RJW와 RaceSupport의 잡종정의를 대체합니다. 우선순위는 누구의 잡종 정의를 우선으로 사용할지 정합니다. 변경하지 않는것을 추천합니다. + 우선순위 + + 질세척 diff --git a/Patches/PawnModExtentions.xml b/Patches/PawnModExtentions.xml index 92d0a13..c01f09d 100644 --- a/Patches/PawnModExtentions.xml +++ b/Patches/PawnModExtentions.xml @@ -4,10 +4,22 @@ Defs/ThingDef[defName="Race's defName"] -
  • +
  • Fetus/Fetus_Default (255,255,255,255) 0.2 + + + 1.0 + 5.0 + 7.0 + 2.0 + + + 98.0 + 2.0 + +
  • @@ -17,16 +29,52 @@ Defs/ThingDef[defName="Human"] -
  • +
  • Fetus/Fetus_Default (255,255,255,255) - 0.2 + 0.2 + + + 1.0 + +
  • + + Defs/ThingDef[defName="Horse"] + +
  • + Fetus/Fetus_Default + (255,255,255,255) + 0.2 + + + 1.0 + + +
  • +
    +
    + + + Defs/ThingDef[defName="Donkey"] + +
  • + Fetus/Fetus_Default + (255,255,255,255) + 0.2 + + + 1.0 + + +
  • +
    +
    diff --git a/Textures/Eggs/Egg.psd b/Textures/Eggs/Egg.psd deleted file mode 100644 index b39fffb..0000000 Binary files a/Textures/Eggs/Egg.psd and /dev/null differ diff --git a/Textures/Eggs/Eggs.zip b/Textures/Eggs/Eggs.zip index cf5ac78..7d60763 100644 Binary files a/Textures/Eggs/Eggs.zip and b/Textures/Eggs/Eggs.zip differ diff --git a/Textures/Fetus/Fetus.zip b/Textures/Fetus/Fetus.zip new file mode 100644 index 0000000..90f4e17 Binary files /dev/null and b/Textures/Fetus/Fetus.zip differ diff --git a/Textures/Fetus/Fetus_default.psd b/Textures/Fetus/Fetus_default.psd deleted file mode 100644 index be32b68..0000000 Binary files a/Textures/Fetus/Fetus_default.psd and /dev/null differ diff --git a/Textures/Genitals/BionicAnal.psd b/Textures/Genitals/BionicAnal.psd deleted file mode 100644 index 9167093..0000000 Binary files a/Textures/Genitals/BionicAnal.psd and /dev/null differ diff --git a/Textures/Genitals/BionicVagina.psd b/Textures/Genitals/BionicVagina.psd deleted file mode 100644 index cea937c..0000000 Binary files a/Textures/Genitals/BionicVagina.psd and /dev/null differ diff --git a/Textures/Genitals/Genitals.zip b/Textures/Genitals/Genitals.zip new file mode 100644 index 0000000..bda9dd3 Binary files /dev/null and b/Textures/Genitals/Genitals.zip differ diff --git a/Textures/Womb/Cum.psd b/Textures/Womb/Cum.psd deleted file mode 100644 index f163dfc..0000000 Binary files a/Textures/Womb/Cum.psd and /dev/null differ diff --git a/Textures/Womb/Womb.7z b/Textures/Womb/Womb.7z deleted file mode 100644 index 9041c54..0000000 Binary files a/Textures/Womb/Womb.7z and /dev/null differ diff --git a/Textures/Womb/Womb.zip b/Textures/Womb/Womb.zip new file mode 100644 index 0000000..475b690 Binary files /dev/null and b/Textures/Womb/Womb.zip differ diff --git a/Textures/Womb/Womb_Cum.psd b/Textures/Womb/Womb_Cum.psd deleted file mode 100644 index 5233020..0000000 Binary files a/Textures/Womb/Womb_Cum.psd and /dev/null differ diff --git a/changelogs.txt b/changelogs.txt index 75f6437..7697303 100644 --- a/changelogs.txt +++ b/changelogs.txt @@ -1,3 +1,8 @@ +Version 1.0.1.12 + - added HybridExtension attribute to PawnDNAModExtension + - this will overrides RJW's hybrid definitions + - supports more detailed hybrid definition + - fixed bugs when menopause option off Version 1.0.1.11 - added a button for opening status window in health tab - added option for this diff --git a/source/RJW_Menstruation/RJW_Menstruation/Configurations.cs b/source/RJW_Menstruation/RJW_Menstruation/Configurations.cs index cb89bba..78830f2 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Configurations.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Configurations.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; using Verse; @@ -27,7 +23,7 @@ namespace RJW_Menstruation public static float ImplantationChance = ImplantationChanceDefault; public static int ImplantationChanceAdjust = ImplantationChanceAdjustDefault; - public static float FertilizeChance = FertilizeChanceDefault; + public static float FertilizeChance = FertilizeChanceDefault; public static int FertilizeChanceAdjust = FertilizeChanceAdjustDefault; public static float CumDecayRatio = CumDecayRatioDefault; public static int CumDecayRatioAdjust = CumDecayRatioAdjustDefault; @@ -51,6 +47,9 @@ namespace RJW_Menstruation public static int BleedingAmount = BleedingAmountDefault; public static bool EnableButtonInHT = false; public static PawnFlags ShowFlag = PawnFlags.Colonist | PawnFlags.Prisoner; + public static bool UseHybridExtention = true; + public static bool MotherFirst = false; + public static bool HARActivated = false; public static bool LLActivated = false; @@ -81,8 +80,14 @@ namespace RJW_Menstruation } + public static string HybridString(bool b) + { + if (b) return Translations.Option23_Label_1; + else return Translations.Option23_Label_2; + } - [Flags]public enum PawnFlags + [Flags] + public enum PawnFlags { None = 0, Colonist = 1, @@ -120,6 +125,8 @@ namespace RJW_Menstruation Scribe_Values.Look(ref BleedingAmount, "BleedingAmount", BleedingAmount, true); Scribe_Values.Look(ref EnableButtonInHT, "EnableButtonInHT", EnableButtonInHT, true); Scribe_Values.Look(ref ShowFlag, "ShowFlag", ShowFlag, true); + Scribe_Values.Look(ref UseHybridExtention, "UseHybridExtention", UseHybridExtention, true); + Scribe_Values.Look(ref MotherFirst, "MotherFirst", MotherFirst, true); base.ExposeData(); } @@ -161,7 +168,7 @@ namespace RJW_Menstruation Configurations.LLActivated = ModLister.HasActiveModWithName("RimJobWorld - Licentia Labs"); } - + public override string SettingsCategory() { @@ -178,8 +185,8 @@ namespace RJW_Menstruation listmain.Begin(mainRect); listmain.Gap(20f); Rect optionrect1 = listmain.GetRect(30f); - Widgets.CheckboxLabeled(optionrect1.LeftHalf(), Translations.Option1_Label_1, ref Configurations.EnableWombIcon); - Widgets.CheckboxLabeled(optionrect1.RightHalf(), Translations.Option1_Label_2, ref Configurations.EnableButtonInHT); + Widgets.CheckboxLabeled(optionrect1.LeftHalf(), Translations.Option1_Label_1, ref Configurations.EnableWombIcon,false,null,null,true); + Widgets.CheckboxLabeled(optionrect1.RightHalf(), Translations.Option1_Label_2, ref Configurations.EnableButtonInHT, false, null, null, true); //listmain.CheckboxLabeled(Translations.Option1_Label, ref Configurations.EnableWombIcon, Translations.Option1_Desc); if (Configurations.EnableWombIcon || Configurations.EnableButtonInHT) { @@ -210,7 +217,7 @@ namespace RJW_Menstruation wombsection.Label(Translations.Option11_Desc_4); break; } - wombsection.Label(Translations.Option21_Label + " " + Configurations.ShowFlag,-1, Translations.Option21_Desc); + wombsection.Label(Translations.Option21_Label + " " + Configurations.ShowFlag, -1, Translations.Option21_Desc); Rect flagrect = wombsection.GetRect(30f); Rect[] flagrects = new Rect[5]; for (int i = 0; i < 5; i++) @@ -242,47 +249,54 @@ namespace RJW_Menstruation listmain.EndSection(wombsection); } - + listmain.CheckboxLabeled(Translations.Option2_Label, ref Configurations.EnableAnimalCycle, Translations.Option2_Desc); listmain.CheckboxLabeled(Translations.Option12_Label, ref Configurations.EnableMenopause, Translations.Option12_Desc); - - listmain.Label(Translations.Option3_Label + " " + Configurations.ImplantationChance*100 + "%", -1, Translations.Option3_Desc); + + listmain.Label(Translations.Option3_Label + " " + Configurations.ImplantationChance * 100 + "%", -1, Translations.Option3_Desc); Configurations.ImplantationChanceAdjust = (int)listmain.Slider(Configurations.ImplantationChanceAdjust, 0, 1000); - Configurations.ImplantationChance = (float)Configurations.ImplantationChanceAdjust/100; + Configurations.ImplantationChance = (float)Configurations.ImplantationChanceAdjust / 100; - listmain.Label(Translations.Option4_Label + " " + Configurations.FertilizeChance*100 + "%", -1, Translations.Option4_Desc); + listmain.Label(Translations.Option4_Label + " " + Configurations.FertilizeChance * 100 + "%", -1, Translations.Option4_Desc); Configurations.FertilizeChanceAdjust = (int)listmain.Slider(Configurations.FertilizeChanceAdjust, 0, 1000); - Configurations.FertilizeChance = (float)Configurations.FertilizeChanceAdjust/1000; + Configurations.FertilizeChance = (float)Configurations.FertilizeChanceAdjust / 1000; - listmain.Label(Translations.Option5_Label + " " + Configurations.CumDecayRatio*100 + "%", -1, Translations.Option5_Desc); + listmain.Label(Translations.Option5_Label + " " + Configurations.CumDecayRatio * 100 + "%", -1, Translations.Option5_Desc); Configurations.CumDecayRatioAdjust = (int)listmain.Slider(Configurations.CumDecayRatioAdjust, 0, 1000); - Configurations.CumDecayRatio = (float)Configurations.CumDecayRatioAdjust/1000; - - listmain.Label(Translations.Option6_Label + " " + Configurations.CumFertilityDecayRatio*100 + "%", -1, Translations.Option6_Desc); + Configurations.CumDecayRatio = (float)Configurations.CumDecayRatioAdjust / 1000; + + listmain.Label(Translations.Option6_Label + " " + Configurations.CumFertilityDecayRatio * 100 + "%", -1, Translations.Option6_Desc); Configurations.CumFertilityDecayRatioAdjust = (int)listmain.Slider(Configurations.CumFertilityDecayRatioAdjust, 0, 1000); - Configurations.CumFertilityDecayRatio = (float)Configurations.CumFertilityDecayRatioAdjust/1000; + Configurations.CumFertilityDecayRatio = (float)Configurations.CumFertilityDecayRatioAdjust / 1000; listmain.Label(Translations.Option7_Label + " x" + Configurations.CycleAcceleration, -1, Translations.Option7_Desc); - Configurations.CycleAcceleration = (int)listmain.Slider(Configurations.CycleAcceleration,1,50); + Configurations.CycleAcceleration = (int)listmain.Slider(Configurations.CycleAcceleration, 1, 50); float var2 = EstimatedBleedingAmountPerHour; - float var1 = Math.Max(EstimatedBleedingAmount,var2); + float var1 = Math.Max(EstimatedBleedingAmount, var2); listmain.LabelDouble(Translations.Option19_Label_1, Translations.Option19_Label_2 + ": " + var1 + "ml, " + var2 + "ml/h", Translations.Option19_Desc); Configurations.BleedingAmount = (int)listmain.Slider(Configurations.BleedingAmount, 0, 200); listmain.CheckboxLabeled(Translations.Option13_Label, ref Configurations.UseMultiplePregnancy, Translations.Option13_Desc); if (Configurations.UseMultiplePregnancy) { - float sectionheight = 50f; + float sectionheight = 75f; if (Configurations.EnableEnzygoticTwins) sectionheight += 100; Listing_Standard twinsection = listmain.BeginSection_NewTemp(sectionheight); + Rect hybridrect = twinsection.GetRect(25); + Widgets.CheckboxLabeled(hybridrect.LeftHalf(), Translations.Option22_Label, ref Configurations.UseHybridExtention, false, null, null, true); + if (Widgets.ButtonText(hybridrect.RightHalf(), Translations.Option23_Label + ": " + Configurations.HybridString(Configurations.MotherFirst))) + { + Configurations.MotherFirst = !Configurations.MotherFirst; + } + twinsection.CheckboxLabeled(Translations.Option14_Label, ref Configurations.EnableHeteroOvularTwins, Translations.Option14_Desc); twinsection.CheckboxLabeled(Translations.Option15_Label, ref Configurations.EnableEnzygoticTwins, Translations.Option15_Desc); if (Configurations.EnableEnzygoticTwins) { - twinsection.Label(Translations.Option16_Label + " " + Configurations.EnzygoticTwinsChance*100 + "%", -1, Translations.Option16_Desc); + twinsection.Label(Translations.Option16_Label + " " + Configurations.EnzygoticTwinsChance * 100 + "%", -1, Translations.Option16_Desc); Configurations.EnzygoticTwinsChanceAdjust = (int)twinsection.Slider(Configurations.EnzygoticTwinsChanceAdjust, 0, 1000); Configurations.EnzygoticTwinsChance = (float)Configurations.EnzygoticTwinsChanceAdjust / 1000; diff --git a/source/RJW_Menstruation/RJW_Menstruation/Cum.cs b/source/RJW_Menstruation/RJW_Menstruation/Cum.cs index 43f6a9b..3a2bc3b 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Cum.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Cum.cs @@ -1,13 +1,7 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Verse; -using RimWorld; +using RimWorld; +using System; using UnityEngine; -using rjw; +using Verse; namespace RJW_Menstruation { @@ -36,7 +30,7 @@ namespace RJW_Menstruation } private Color customColor; - public PawnDNAModExtention DNA + public PawnDNAModExtension DNA { get { @@ -44,22 +38,22 @@ namespace RJW_Menstruation { try { - DNAcache = pawn.def.GetModExtension(); + DNAcache = pawn.def.GetModExtension(); } catch (NullReferenceException) { - DNAcache = ThingDefOf.Human.GetModExtension(); + DNAcache = ThingDefOf.Human.GetModExtension(); } if (DNAcache == null) { - DNAcache = ThingDefOf.Human.GetModExtension(); + DNAcache = ThingDefOf.Human.GetModExtension(); } return DNAcache; } else return DNAcache; } } - private PawnDNAModExtention DNAcache = null; + private PawnDNAModExtension DNAcache = null; public ThingDef FilthDef { get @@ -89,7 +83,7 @@ namespace RJW_Menstruation } - public Cum() {} + public Cum() { } public Cum(Pawn pawn) { diff --git a/source/RJW_Menstruation/RJW_Menstruation/Dialog_WombStatus.cs b/source/RJW_Menstruation/RJW_Menstruation/Dialog_WombStatus.cs index 5d60066..eb96828 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Dialog_WombStatus.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Dialog_WombStatus.cs @@ -1,316 +1,312 @@ -using System; -using System.Collections.Generic; +using RimWorld; +using rjw; using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; using Verse; using Verse.Sound; -using RimWorld; -using rjw; namespace RJW_Menstruation { public class Dialog_WombStatus : Window { public Pawn pawn; - private HediffComp_Menstruation comp; - private const float windowMargin = 20f; - private const float pawnRectWidth = 150f; - private const float pawnRectHeight = 150f; - private const float wombRectHeight = 300f; - private const float wombRectWidth = 300f; - private const float fontheight = 30; - private const float genitalRectWidth = 102; - private const float genitalRectHeight = 140; + private HediffComp_Menstruation comp; + private const float windowMargin = 20f; + private const float pawnRectWidth = 150f; + private const float pawnRectHeight = 150f; + private const float wombRectHeight = 300f; + private const float wombRectWidth = 300f; + private const float fontheight = 30; + private const float genitalRectWidth = 102; + private const float genitalRectHeight = 140; - private Texture2D womb; - private Texture2D cum; - private Texture2D vagina; - private Texture2D anal; - private Color cumcolor; + private Texture2D womb; + private Texture2D cum; + private Texture2D vagina; + private Texture2D anal; + private Color cumcolor; - private GUIStyle fontstylecenter = new GUIStyle() { alignment = TextAnchor.MiddleCenter }; - private GUIStyle fontstyleright = new GUIStyle() { alignment = TextAnchor.MiddleRight }; - private GUIStyle fontstyleleft = new GUIStyle() { alignment = TextAnchor.MiddleLeft }; - private GUIStyle boxstyle = new GUIStyle(GUI.skin.textArea); - private GUIStyle buttonstyle = new GUIStyle(GUI.skin.button); + private GUIStyle fontstylecenter = new GUIStyle() { alignment = TextAnchor.MiddleCenter }; + private GUIStyle fontstyleright = new GUIStyle() { alignment = TextAnchor.MiddleRight }; + private GUIStyle fontstyleleft = new GUIStyle() { alignment = TextAnchor.MiddleLeft }; + private GUIStyle boxstyle = new GUIStyle(GUI.skin.textArea); + private GUIStyle buttonstyle = new GUIStyle(GUI.skin.button); - public override Vector2 InitialSize + public override Vector2 InitialSize { get { - float width = 300f + 2 * windowMargin; - float height = 820f; - if (!Configurations.DrawWombStatus) height -= wombRectHeight; - if (!Configurations.DrawVaginaStatus) height -= genitalRectHeight; - return new Vector2(width,height); + float width = 300f + 2 * windowMargin; + float height = 820f; + if (!Configurations.DrawWombStatus) height -= wombRectHeight; + if (!Configurations.DrawVaginaStatus) height -= genitalRectHeight; + return new Vector2(width, height); } } public Dialog_WombStatus(Pawn pawn, HediffComp_Menstruation comp) { this.pawn = pawn; - this.comp = comp; + this.comp = comp; } - public void ChangePawn(Pawn pawn, HediffComp_Menstruation comp) + public void ChangePawn(Pawn pawn, HediffComp_Menstruation comp) { - this.pawn = pawn; - this.comp = comp; + this.pawn = pawn; + this.comp = comp; } - public static void ToggleWindow(Pawn pawn, HediffComp_Menstruation comp) + public static void ToggleWindow(Pawn pawn, HediffComp_Menstruation comp) { - Dialog_WombStatus window = (Dialog_WombStatus)Find.WindowStack.Windows.FirstOrDefault(x => x.GetType().Equals(typeof(Dialog_WombStatus))); - if (window != null) - { - if (window.pawn != pawn) - { - SoundDefOf.TabOpen.PlayOneShotOnCamera(); - window.ChangePawn(pawn, comp); - } - else Find.WindowStack.TryRemove(typeof(Dialog_WombStatus), true); - } - else - { - SoundDefOf.InfoCard_Open.PlayOneShotOnCamera(); - Find.WindowStack.Add(new Dialog_WombStatus(pawn, comp)); - } + Dialog_WombStatus window = (Dialog_WombStatus)Find.WindowStack.Windows.FirstOrDefault(x => x.GetType().Equals(typeof(Dialog_WombStatus))); + if (window != null) + { + if (window.pawn != pawn) + { + SoundDefOf.TabOpen.PlayOneShotOnCamera(); + window.ChangePawn(pawn, comp); + } + else Find.WindowStack.TryRemove(typeof(Dialog_WombStatus), true); + } + else + { + SoundDefOf.InfoCard_Open.PlayOneShotOnCamera(); + Find.WindowStack.Add(new Dialog_WombStatus(pawn, comp)); + } - } + } public override void DoWindowContents(Rect inRect) { - bool flag = false; - soundClose = SoundDefOf.InfoCard_Close; - //closeOnClickedOutside = true; - absorbInputAroundWindow = false; - forcePause = false; - preventCameraMotion = false; - draggable = true; - //resizeable = true; + bool flag = false; + soundClose = SoundDefOf.InfoCard_Close; + //closeOnClickedOutside = true; + absorbInputAroundWindow = false; + forcePause = false; + preventCameraMotion = false; + draggable = true; + //resizeable = true; - if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.Escape)) - { - flag = true; - Event.current.Use(); - } - - Rect windowRect = inRect.ContractedBy(windowMargin); - Rect mainRect = new Rect(windowRect.x, windowRect.y, windowRect.width, windowRect.height); - Rect closeRect = new Rect(windowRect.xMax, 0f, 20f, 20f); - MainContents(mainRect); - if (Widgets.CloseButtonFor(closeRect)) + if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.Escape)) { - Close(); + flag = true; + Event.current.Use(); } - } - private void MainContents(Rect mainRect) - { + Rect windowRect = inRect.ContractedBy(windowMargin); + Rect mainRect = new Rect(windowRect.x, windowRect.y, windowRect.width, windowRect.height); + Rect closeRect = new Rect(windowRect.xMax, 0f, 20f, 20f); + MainContents(mainRect); + if (Widgets.CloseButtonFor(closeRect)) + { + Close(); + } + } - boxstyle.hover = boxstyle.normal; - boxstyle.onHover = boxstyle.normal; - boxstyle.onNormal = boxstyle.normal; + private void MainContents(Rect mainRect) + { - buttonstyle.onHover = buttonstyle.onNormal; - buttonstyle.hover = buttonstyle.normal; - boxstyle.border.left = 4; boxstyle.border.right = 4; boxstyle.border.bottom = 4; boxstyle.border.top = 4; + boxstyle.hover = boxstyle.normal; + boxstyle.onHover = boxstyle.normal; + boxstyle.onNormal = boxstyle.normal; - float preginfoheight = 0f; - bool pregnant = pawn.IsPregnant(); - Hediff hediff = PregnancyHelper.GetPregnancy(pawn); - if (pregnant && Utility.ShowFetusImage((Hediff_BasePregnancy)hediff)) - { - womb = Utility.GetPregnancyIcon(comp, hediff); - if (hediff is Hediff_MultiplePregnancy) - { - Hediff_MultiplePregnancy h = (Hediff_MultiplePregnancy)hediff; - if (h.GestationProgress < 0.2f) cum = comp.GetCumIcon(); - else cum = ContentFinder.Get(("Womb/Empty"), true); - Pawn fetus = pawn.GetFetus(); - if (fetus != null && Utility.ShowFetusInfo()) - { - string feinfo = h.GetBabyInfo(); - string fainfo = h.GetFatherInfo() + " "; - if (feinfo.Length + fainfo.Length > 45) + buttonstyle.onHover = buttonstyle.onNormal; + buttonstyle.hover = buttonstyle.normal; + boxstyle.border.left = 4; boxstyle.border.right = 4; boxstyle.border.bottom = 4; boxstyle.border.top = 4; + + float preginfoheight = 0f; + bool pregnant = pawn.IsPregnant(); + Hediff hediff = PregnancyHelper.GetPregnancy(pawn); + if (pregnant && Utility.ShowFetusImage((Hediff_BasePregnancy)hediff)) + { + womb = Utility.GetPregnancyIcon(comp, hediff); + if (hediff is Hediff_MultiplePregnancy) + { + Hediff_MultiplePregnancy h = (Hediff_MultiplePregnancy)hediff; + if (h.GestationProgress < 0.2f) cum = comp.GetCumIcon(); + else cum = ContentFinder.Get(("Womb/Empty"), true); + Pawn fetus = pawn.GetFetus(); + if (fetus != null && Utility.ShowFetusInfo()) + { + string feinfo = h.GetBabyInfo(); + string fainfo = h.GetFatherInfo() + " "; + if (feinfo.Length + fainfo.Length > 45) { - preginfoheight = fontheight + 2; - buttonstyle.alignment = TextAnchor.UpperLeft; - fontstyleright.alignment = TextAnchor.LowerRight; - } - else + preginfoheight = fontheight + 2; + buttonstyle.alignment = TextAnchor.UpperLeft; + fontstyleright.alignment = TextAnchor.LowerRight; + } + else { - preginfoheight = fontheight; - buttonstyle.alignment = TextAnchor.MiddleLeft; + preginfoheight = fontheight; + buttonstyle.alignment = TextAnchor.MiddleLeft; - } - Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight); - fontstyleright.normal.textColor = Color.white; - GUI.Box(preginfo, feinfo, buttonstyle); - GUI.Label(preginfo, fainfo, fontstyleright); - } + } + Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight); + fontstyleright.normal.textColor = Color.white; + GUI.Box(preginfo, feinfo, buttonstyle); + GUI.Label(preginfo, fainfo, fontstyleright); + } - } - else if (hediff is Hediff_BasePregnancy) - { - Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff; - if (h.GestationProgress < 0.2f) cum = comp.GetCumIcon(); - else cum = ContentFinder.Get(("Womb/Empty"), true); - Pawn fetus = pawn.GetFetus(); - if (fetus != null && Utility.ShowFetusInfo()) - { + } + else if (hediff is Hediff_BasePregnancy) + { + Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff; + if (h.GestationProgress < 0.2f) cum = comp.GetCumIcon(); + else cum = ContentFinder.Get(("Womb/Empty"), true); + Pawn fetus = pawn.GetFetus(); + if (fetus != null && Utility.ShowFetusInfo()) + { - preginfoheight = fontheight; - Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight); - fontstyleright.normal.textColor = Color.white; - fontstyleright.alignment = TextAnchor.MiddleRight; - buttonstyle.alignment = TextAnchor.MiddleLeft; - - GUI.Box(preginfo, h.babies.Count + " " + fetus.def.label + " " + Translations.Dialog_WombInfo02, buttonstyle); - GUI.Label(preginfo, Translations.Dialog_WombInfo03 + ": " + h.father.LabelShort + " ", fontstyleright); - } - - } - else cum = ContentFinder.Get(("Womb/Empty"), true); - } - else - { - womb = comp.GetWombIcon(); - cum = comp.GetCumIcon(); - } + preginfoheight = fontheight; + Rect preginfo = new Rect(0f, mainRect.yMax - wombRectHeight - 2, wombRectWidth, preginfoheight); + fontstyleright.normal.textColor = Color.white; + fontstyleright.alignment = TextAnchor.MiddleRight; + buttonstyle.alignment = TextAnchor.MiddleLeft; + + GUI.Box(preginfo, h.babies.Count + " " + fetus.def.label + " " + Translations.Dialog_WombInfo02, buttonstyle); + GUI.Label(preginfo, Translations.Dialog_WombInfo03 + ": " + h.father.LabelShort + " ", fontstyleright); + } + + } + else cum = ContentFinder.Get(("Womb/Empty"), true); + } + else + { + womb = comp.GetWombIcon(); + cum = comp.GetCumIcon(); + } - Rect pawnRect = new Rect(0, 0, pawnRectWidth, pawnRectHeight); - Widgets.DrawTextureFitted(pawnRect, PortraitsCache.Get(pawn, pawnRect.size), 1.0f); - Rect pawnLabelRect = new Rect(0, pawnRectHeight, pawnRectWidth, fontheight - 10); - Rect pawnLabel2Rect = new Rect(0, pawnRectHeight + fontheight - 10, pawnRectWidth, fontheight - 10); - fontstylecenter.normal.textColor = pawn.DrawColor; - GUI.Label(pawnLabelRect, pawn.Name.ToStringFull, fontstylecenter); - if (pawn.story != null)GUI.Label(pawnLabel2Rect, pawn.story.Title, fontstylecenter); - GUI.color = Color.white; + Rect pawnRect = new Rect(0, 0, pawnRectWidth, pawnRectHeight); + Widgets.DrawTextureFitted(pawnRect, PortraitsCache.Get(pawn, pawnRect.size), 1.0f); + Rect pawnLabelRect = new Rect(0, pawnRectHeight, pawnRectWidth, fontheight - 10); + Rect pawnLabel2Rect = new Rect(0, pawnRectHeight + fontheight - 10, pawnRectWidth, fontheight - 10); + fontstylecenter.normal.textColor = pawn.DrawColor; + GUI.Label(pawnLabelRect, pawn.Name.ToStringFull, fontstylecenter); + if (pawn.story != null) GUI.Label(pawnLabel2Rect, pawn.story.Title, fontstylecenter); + GUI.color = Color.white; - float wombrecth = 0; - if (Configurations.DrawWombStatus) - { - wombrecth = wombRectHeight; - cumcolor = comp.GetCumMixtureColor; - Rect wombRect = new Rect(0f, mainRect.yMax - wombRectHeight + preginfoheight, wombRectWidth, wombRectWidth*0.9f); - DrawWomb(wombRect); + float wombrecth = 0; + if (Configurations.DrawWombStatus) + { + wombrecth = wombRectHeight; + cumcolor = comp.GetCumMixtureColor; + Rect wombRect = new Rect(0f, mainRect.yMax - wombRectHeight + preginfoheight, wombRectWidth, wombRectWidth * 0.9f); + DrawWomb(wombRect); - if (Configurations.DrawEggOverlay) - { - comp.DrawEggOverlay(wombRect); - } + if (Configurations.DrawEggOverlay) + { + comp.DrawEggOverlay(wombRect); + } - } + } - Rect wombInfoRect = new Rect(0f, mainRect.yMax - wombrecth - fontheight - 2, wombRectWidth, fontheight); + Rect wombInfoRect = new Rect(0f, mainRect.yMax - wombrecth - fontheight - 2, wombRectWidth, fontheight); - buttonstyle.normal.textColor = Color.white; - //boxstyle.normal.background = Texture2D.whiteTexture; - buttonstyle.alignment = TextAnchor.MiddleLeft; - GUI.backgroundColor = new Color(0.24f, 0.29f, 0.35f, 1); - GUI.Box(wombInfoRect, Translations.Dialog_WombInfo01 + ": " + comp.GetCurStageLabel, buttonstyle); - GUI.color = Color.white; + buttonstyle.normal.textColor = Color.white; + //boxstyle.normal.background = Texture2D.whiteTexture; + buttonstyle.alignment = TextAnchor.MiddleLeft; + GUI.backgroundColor = new Color(0.24f, 0.29f, 0.35f, 1); + GUI.Box(wombInfoRect, Translations.Dialog_WombInfo01 + ": " + comp.GetCurStageLabel, buttonstyle); + GUI.color = Color.white; - fontstyleright.normal.textColor = Color.red; - fontstyleright.alignment = TextAnchor.MiddleRight; - //if (comp.GetFertilization) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo05 + " ", fontstyleright); - //else if (comp.GetEggFertilizing) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo06 + " ", fontstyleright); - //else if (comp.GetEgg) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo07 + " ", fontstyleright); - GUI.Label(wombInfoRect, comp.GetFertilizingInfo + " ", fontstyleright); + fontstyleright.normal.textColor = Color.red; + fontstyleright.alignment = TextAnchor.MiddleRight; + //if (comp.GetFertilization) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo05 + " ", fontstyleright); + //else if (comp.GetEggFertilizing) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo06 + " ", fontstyleright); + //else if (comp.GetEgg) GUI.Label(wombInfoRect, Translations.Dialog_WombInfo07 + " ", fontstyleright); + GUI.Label(wombInfoRect, comp.GetFertilizingInfo + " ", fontstyleright); - //Widgets.Label(wombInfoRect,Translations.Dialog_WombInfo01 + ": " + comp.GetCurStageLabel); + //Widgets.Label(wombInfoRect,Translations.Dialog_WombInfo01 + ": " + comp.GetCurStageLabel); - if (Configurations.DrawVaginaStatus && !pawn.IsAnimal()) - { - Rect genitalRect = new Rect(24, pawnRectHeight + 2 * fontheight, genitalRectWidth, genitalRectHeight + fontheight * 2); - DrawVagina(genitalRect); - } - - - - Rect cumlistTitle = new Rect(pawnRectWidth, 0, wombRectWidth - pawnRectWidth, fontheight); - GUI.Label(cumlistTitle,Translations.Dialog_WombInfo04); - - - Rect cumlistRect = new Rect(pawnRectWidth, fontheight, wombRectWidth - pawnRectWidth, mainRect.yMax - wombrecth - fontheight); - DrawCumlist(cumlistRect); - - + if (Configurations.DrawVaginaStatus && !pawn.IsAnimal()) + { + Rect genitalRect = new Rect(24, pawnRectHeight + 2 * fontheight, genitalRectWidth, genitalRectHeight + fontheight * 2); + DrawVagina(genitalRect); + } - } - - + Rect cumlistTitle = new Rect(pawnRectWidth, 0, wombRectWidth - pawnRectWidth, fontheight); + GUI.Label(cumlistTitle, Translations.Dialog_WombInfo04); - private void DrawCumlist(Rect rect) + Rect cumlistRect = new Rect(pawnRectWidth, fontheight, wombRectWidth - pawnRectWidth, mainRect.yMax - wombrecth - fontheight); + DrawCumlist(cumlistRect); + + + + + + } + + + + + private void DrawCumlist(Rect rect) { - Listing_Standard cumlist = new Listing_Standard - { - maxOneColumn = true, - ColumnWidth = wombRectWidth - pawnRectWidth - }; - cumlist.Begin(rect); - Listing_Standard cumlistsection = cumlist.BeginSection_NewTemp(rect.height - fontheight - 12f); - foreach (string s in comp.GetCumsInfo) - { - cumlistsection.Label(s); - } - cumlist.EndSection(cumlistsection); - cumlist.End(); - } + Listing_Standard cumlist = new Listing_Standard + { + maxOneColumn = true, + ColumnWidth = wombRectWidth - pawnRectWidth + }; + cumlist.Begin(rect); + Listing_Standard cumlistsection = cumlist.BeginSection_NewTemp(rect.height - fontheight - 12f); + foreach (string s in comp.GetCumsInfo) + { + cumlistsection.Label(s); + } + cumlist.EndSection(cumlistsection); + cumlist.End(); + } - private void DrawWomb(Rect rect) + private void DrawWomb(Rect rect) { - GUI.color = new Color(1.00f, 0.47f, 0.47f, 1); - GUI.Box(rect, "", boxstyle); - //GUI.color = Color.white; - //Widgets.DrawTextureFitted(wombRect, womb,1.0f); - //GUI.color = cumcolor; - //Widgets.DrawTextureFitted(wombRect, cum,1.0f); - GUI.DrawTexture(rect, womb, ScaleMode.ScaleToFit, true, 0, Color.white, 0, 0); - GUI.DrawTexture(rect, cum, ScaleMode.ScaleToFit, true, 0, cumcolor, 0, 0); - GUI.color = Color.white; + GUI.color = new Color(1.00f, 0.47f, 0.47f, 1); + GUI.Box(rect, "", boxstyle); + //GUI.color = Color.white; + //Widgets.DrawTextureFitted(wombRect, womb,1.0f); + //GUI.color = cumcolor; + //Widgets.DrawTextureFitted(wombRect, cum,1.0f); + GUI.DrawTexture(rect, womb, ScaleMode.ScaleToFit, true, 0, Color.white, 0, 0); + GUI.DrawTexture(rect, cum, ScaleMode.ScaleToFit, true, 0, cumcolor, 0, 0); + GUI.color = Color.white; - - } - + } - private void DrawVagina(Rect rect) + + + private void DrawVagina(Rect rect) { - Rect genitalIconRect = new Rect(rect.x, rect.y + fontheight, genitalRectWidth, genitalRectHeight); - Rect genitalVaginaLabelRect = new Rect(rect.x, rect.y, genitalRectWidth, fontheight); - Rect genitalAnusLabelRect = new Rect(rect.x, rect.y + fontheight + genitalRectHeight, genitalRectWidth, fontheight); + Rect genitalIconRect = new Rect(rect.x, rect.y + fontheight, genitalRectWidth, genitalRectHeight); + Rect genitalVaginaLabelRect = new Rect(rect.x, rect.y, genitalRectWidth, fontheight); + Rect genitalAnusLabelRect = new Rect(rect.x, rect.y + fontheight + genitalRectHeight, genitalRectWidth, fontheight); - vagina = pawn.GetGenitalIcon(); - anal = pawn.GetAnalIcon(); - GUI.color = new Color(1.00f, 0.47f, 0.47f, 1); - GUI.Box(rect, "", boxstyle); - GUI.color = pawn.story.SkinColor; - //Widgets.DrawTextureFitted(genitalIconRect, anal, 1.0f); - //Widgets.DrawTextureFitted(genitalIconRect, vagina, 1.0f); - GUI.DrawTexture(genitalIconRect, anal, ScaleMode.ScaleToFit); - GUI.DrawTexture(genitalIconRect, vagina, ScaleMode.ScaleToFit); + vagina = pawn.GetGenitalIcon(); + anal = pawn.GetAnalIcon(); + GUI.color = new Color(1.00f, 0.47f, 0.47f, 1); + GUI.Box(rect, "", boxstyle); + GUI.color = pawn.story.SkinColor; + //Widgets.DrawTextureFitted(genitalIconRect, anal, 1.0f); + //Widgets.DrawTextureFitted(genitalIconRect, vagina, 1.0f); + GUI.DrawTexture(genitalIconRect, anal, ScaleMode.ScaleToFit); + GUI.DrawTexture(genitalIconRect, vagina, ScaleMode.ScaleToFit); - GUI.color = Color.white; - GUI.Label(genitalVaginaLabelRect, pawn.GetVaginaLabel(), fontstylecenter); - GUI.Label(genitalAnusLabelRect, pawn.GetAnusLabel(), fontstylecenter); + GUI.color = Color.white; + GUI.Label(genitalVaginaLabelRect, pawn.GetVaginaLabel(), fontstylecenter); + GUI.Label(genitalAnusLabelRect, pawn.GetAnusLabel(), fontstylecenter); - } + } } diff --git a/source/RJW_Menstruation/RJW_Menstruation/DrugOutcomDoers.cs b/source/RJW_Menstruation/RJW_Menstruation/DrugOutcomDoers.cs index 80a4f64..1d5662f 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/DrugOutcomDoers.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/DrugOutcomDoers.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using RimWorld; +using RimWorld; using Verse; namespace RJW_Menstruation @@ -13,7 +8,7 @@ namespace RJW_Menstruation protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested) { HediffComp_Menstruation comp = Utility.GetMenstruationComp(pawn); - if (comp != null && (comp.curStage.Equals(HediffComp_Menstruation.Stage.Follicular) + if (comp != null && (comp.curStage.Equals(HediffComp_Menstruation.Stage.Follicular) || comp.curStage.Equals(HediffComp_Menstruation.Stage.Luteal) || comp.curStage.Equals(HediffComp_Menstruation.Stage.ClimactericFollicular) || comp.curStage.Equals(HediffComp_Menstruation.Stage.ClimactericLuteal) @@ -50,7 +45,7 @@ namespace RJW_Menstruation HediffComp_Menstruation comp = Utility.GetMenstruationComp(pawn); if (comp != null) { - comp.eggstack += Rand.Range(1,4); + comp.eggstack += Rand.Range(1, 4); } diff --git a/source/RJW_Menstruation/RJW_Menstruation/FilthMaker_Colored.cs b/source/RJW_Menstruation/RJW_Menstruation/FilthMaker_Colored.cs index 4ea1896..a14e186 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/FilthMaker_Colored.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/FilthMaker_Colored.cs @@ -1,62 +1,59 @@ -using System; +using RimWorld; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using RimWorld; -using Verse; using UnityEngine; +using Verse; namespace RJW_Menstruation { public class FilthMaker_Colored { - public static bool TryMakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable sources, Color color , bool shouldPropagate, FilthSourceFlags additionalFlags = FilthSourceFlags.None) - { - Filth_Colored filth = (Filth_Colored)(from t in c.GetThingList(map) - where t.def == filthDef - select t).FirstOrDefault(); - if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened)) - { - if (shouldPropagate) - { - List list = GenAdj.AdjacentCells8WayRandomized(); - for (int i = 0; i < 8; i++) - { - IntVec3 c2 = c + list[i]; - if (c2.InBounds(map) && TryMakeFilth(c2, map, filthDef, sources, color,false, FilthSourceFlags.None)) - { - return true; - } - } - } - if (filth != null) - { - filth.AddSources(sources); - } - return false; - } - if (filth != null) - { - filth.ThickenFilth(); - filth.AddSources(sources); - } - else - { - if (!FilthMaker.CanMakeFilth(c, map, filthDef, additionalFlags)) - { - return false; - } - Filth_Colored filth2 = (Filth_Colored)ThingMaker.MakeThing(filthDef, null); - filth2.DrawColor = color; - filth2.AddSources(sources); - GenSpawn.Spawn(filth2, c, map, WipeMode.Vanish); - } - //FilthMonitor.Notify_FilthSpawned(); - return true; - } + public static bool TryMakeFilth(IntVec3 c, Map map, ThingDef filthDef, IEnumerable sources, Color color, bool shouldPropagate, FilthSourceFlags additionalFlags = FilthSourceFlags.None) + { + Filth_Colored filth = (Filth_Colored)(from t in c.GetThingList(map) + where t.def == filthDef + select t).FirstOrDefault(); + if (!c.Walkable(map) || (filth != null && !filth.CanBeThickened)) + { + if (shouldPropagate) + { + List list = GenAdj.AdjacentCells8WayRandomized(); + for (int i = 0; i < 8; i++) + { + IntVec3 c2 = c + list[i]; + if (c2.InBounds(map) && TryMakeFilth(c2, map, filthDef, sources, color, false, FilthSourceFlags.None)) + { + return true; + } + } + } + if (filth != null) + { + filth.AddSources(sources); + } + return false; + } + if (filth != null) + { + filth.ThickenFilth(); + filth.AddSources(sources); + } + else + { + if (!FilthMaker.CanMakeFilth(c, map, filthDef, additionalFlags)) + { + return false; + } + Filth_Colored filth2 = (Filth_Colored)ThingMaker.MakeThing(filthDef, null); + filth2.DrawColor = color; + filth2.AddSources(sources); + GenSpawn.Spawn(filth2, c, map, WipeMode.Vanish); + } + //FilthMonitor.Notify_FilthSpawned(); + return true; + } - } + } } diff --git a/source/RJW_Menstruation/RJW_Menstruation/Gizmo_Womb.cs b/source/RJW_Menstruation/RJW_Menstruation/Gizmo_Womb.cs index da77b4b..abd7d51 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Gizmo_Womb.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Gizmo_Womb.cs @@ -1,47 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using UnityEngine; using Verse; -using RimWorld; -using UnityEngine; -using Verse.Sound; namespace RJW_Menstruation { public class Gizmo_Womb : Command_Action { public Texture2D icon_overay; - public Color cumcolor; - public HediffComp_Menstruation comp; + public Color cumcolor; + public HediffComp_Menstruation comp; protected override void DrawIcon(Rect rect, Material buttonMat = null) { - Texture2D badTex = icon; - Texture2D overay = icon_overay; - Color color = cumcolor; + Texture2D badTex = icon; + Texture2D overay = icon_overay; + Color color = cumcolor; + + if (badTex == null) + { + badTex = BaseContent.BadTex; + } + if (overay == null) + { + overay = BaseContent.BadTex; + } + if (color == null) color = Color.white; + rect.position += new Vector2(iconOffset.x * rect.size.x, iconOffset.y * rect.size.y); + GUI.color = IconDrawColor; + Widgets.DrawTextureFitted(rect, badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, buttonMat); + GUI.color = color; + Widgets.DrawTextureFitted(rect, overay, iconDrawScale * 0.85f, iconProportions, iconTexCoords, iconAngle, buttonMat); + GUI.color = Color.white; + if (Configurations.DrawEggOverlay) comp.DrawEggOverlay(rect); + + } - if (badTex == null) - { - badTex = BaseContent.BadTex; - } - if (overay == null) - { - overay = BaseContent.BadTex; - } - if (color == null) color = Color.white; - rect.position += new Vector2(iconOffset.x * rect.size.x, iconOffset.y * rect.size.y); - GUI.color = IconDrawColor; - Widgets.DrawTextureFitted(rect, badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, buttonMat); - GUI.color = color; - Widgets.DrawTextureFitted(rect, overay, iconDrawScale * 0.85f, iconProportions, iconTexCoords, iconAngle, buttonMat); - GUI.color = Color.white; - if (Configurations.DrawEggOverlay) comp.DrawEggOverlay(rect); - } - - } diff --git a/source/RJW_Menstruation/RJW_Menstruation/HARCompatibility.cs b/source/RJW_Menstruation/RJW_Menstruation/HARCompatibility.cs index fb35a52..c274d8d 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/HARCompatibility.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/HARCompatibility.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Linq; using Verse; -using RimWorld; namespace RJW_Menstruation { diff --git a/source/RJW_Menstruation/RJW_Menstruation/HediffComp_Menstruation.cs b/source/RJW_Menstruation/RJW_Menstruation/HediffComp_Menstruation.cs index 7e5fc42..cccbb8f 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/HediffComp_Menstruation.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/HediffComp_Menstruation.cs @@ -1,17 +1,16 @@ -using System; +using HugsLib; +using RimWorld; +using rjw; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Verse; -using RimWorld; -using HugsLib; -using rjw; using UnityEngine; +using Verse; namespace RJW_Menstruation { - [Flags]public enum SeasonalBreed + [Flags] + public enum SeasonalBreed { Always = 0, Spring = 1, @@ -26,8 +25,8 @@ namespace RJW_Menstruation public class CompProperties_Menstruation : HediffCompProperties { public float maxCumCapacity; // ml - public float baseImplantationChanceFactor; - public float basefertilizationChanceFactor; + public float baseImplantationChanceFactor; + public float basefertilizationChanceFactor; public float deviationFactor; public int folicularIntervalDays = 14; //before ovulation including beginning of bleeding public int lutealIntervalDays = 14; //after ovulation until bleeding @@ -44,7 +43,7 @@ namespace RJW_Menstruation public CompProperties_Menstruation() { - + compClass = typeof(HediffComp_Menstruation); } } @@ -62,10 +61,10 @@ namespace RJW_Menstruation - - + + public class HediffComp_Menstruation : HediffComp { const float minmakefilthvalue = 1.0f; @@ -104,7 +103,7 @@ namespace RJW_Menstruation private int lutealIntervalhours = -1; private int bleedingIntervalhours = -1; private int recoveryIntervalhours = -1; - private float crampPain= -1; + private float crampPain = -1; private Need sexNeed = null; private string customwombtex = null; private string customvagtex = null; @@ -164,7 +163,7 @@ namespace RJW_Menstruation { res += cum.volume; } - return res/ Props.maxCumCapacity; + return res / Props.maxCumCapacity; } } public float CumCapacity @@ -181,7 +180,7 @@ namespace RJW_Menstruation get { float res = 1.0f; - if (parent.pawn.health.hediffSet.HasHediff(VariousDefOf.RJW_IUD)) res = 0.001f; + if (parent.pawn.health.hediffSet.HasHediff(VariousDefOf.RJW_IUD)) res = 0.01f; return res; } } @@ -202,8 +201,8 @@ namespace RJW_Menstruation { float factor = 1.0f; if (parent.pawn.Has(Quirk.Breeder)) factor = 10.0f; - if (xxx.is_animal(parent.pawn)) factor *= RJWPregnancySettings.animal_impregnation_chance/100f; - else factor *= RJWPregnancySettings.humanlike_impregnation_chance/100f; + if (xxx.is_animal(parent.pawn)) factor *= RJWPregnancySettings.animal_impregnation_chance / 100f; + else factor *= RJWPregnancySettings.humanlike_impregnation_chance / 100f; return parent.pawn.health.capacities.GetLevel(xxx.reproduction) * factor; } } @@ -230,7 +229,7 @@ namespace RJW_Menstruation float mixedsofar = 0; foreach (Cum cum in cums) { - mixedcolor = Colors.CMYKLerp(mixedcolor, cum.color, cum.volume/(mixedsofar + cum.volume)); + mixedcolor = Colors.CMYKLerp(mixedcolor, cum.color, cum.volume / (mixedsofar + cum.volume)); mixedsofar += cum.volume; } } @@ -309,16 +308,19 @@ namespace RJW_Menstruation string res = ""; if (!eggs.NullOrEmpty()) { - if (cums.NullOrEmpty() || TotalFertCum == 0) return eggs.Count + " " + Translations.Dialog_WombInfo07; + int fertilized = 0; + foreach (Egg egg in eggs) + { + if (egg.fertilized) fertilized++; + } + if (fertilized != 0) res += fertilized + " " + Translations.Dialog_WombInfo05; + if (fertilized != 0 && eggs.Count - fertilized != 0) res += ", "; + if (cums.NullOrEmpty() || TotalFertCum == 0) + { + if (eggs.Count - fertilized != 0) res += eggs.Count - fertilized + " " + Translations.Dialog_WombInfo07; + } else { - int fertilized = 0; - foreach (Egg egg in eggs) - { - if (egg.fertilized) fertilized++; - } - if (fertilized != 0) res += fertilized + " " + Translations.Dialog_WombInfo05; - if (fertilized != 0 && eggs.Count - fertilized != 0) res += ", "; if (eggs.Count - fertilized != 0) res += eggs.Count - fertilized + " " + Translations.Dialog_WombInfo06; } } @@ -332,7 +334,7 @@ namespace RJW_Menstruation { if (!eggs.NullOrEmpty()) { - if (!cums.NullOrEmpty()) foreach(Cum cum in cums) + if (!cums.NullOrEmpty()) foreach (Cum cum in cums) { if (cum.fertvolume > 0) return true; } @@ -350,7 +352,7 @@ namespace RJW_Menstruation { get { - if (!eggs.NullOrEmpty()) foreach(Egg egg in eggs) + if (!eggs.NullOrEmpty()) foreach (Egg egg in eggs) { if (egg.fertilized) return egg.fertstage; } @@ -425,7 +427,7 @@ namespace RJW_Menstruation } - + public override void CompPostPostAdd(DamageInfo? dinfo) { if (!loaded) Initialize(); @@ -442,7 +444,7 @@ namespace RJW_Menstruation public override void CompPostPostRemoved() { - + HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(actionref); ModLog.Message(parent.pawn.Label + "tick scheduler removed"); base.CompPostPostRemoved(); @@ -451,7 +453,7 @@ namespace RJW_Menstruation - + /// /// Get fluid in womb that not a cum /// @@ -479,7 +481,7 @@ namespace RJW_Menstruation } return null; } - + /// /// Inject pawn's cum into womb /// @@ -497,18 +499,18 @@ namespace RJW_Menstruation float cumoutrate = 1 - (CumCapacity / tmp); bool merged = false; if (!cums.NullOrEmpty()) foreach (Cum cum in cums) - { - if (cum.pawn.Equals(pawn)) { - cum.volume += volume; - cum.fertvolume += volume; - cum.FilthDef = filthdef; - merged = true; + if (cum.pawn.Equals(pawn)) + { + cum.volume += volume; + cum.fertvolume += volume * CumInFactor; + cum.FilthDef = filthdef; + merged = true; + } + cum.volume *= 1 - cumoutrate; + cum.fertvolume *= 1 - cumoutrate; } - cum.volume *= 1 - cumoutrate; - cum.fertvolume *= 1 - cumoutrate; - } - if (!merged) cums.Add(new Cum(pawn, volume * (1 - cumoutrate),fertility, filthdef)); + if (!merged) cums.Add(new Cum(pawn, volume * (1 - cumoutrate), fertility, filthdef)); } else { @@ -560,7 +562,7 @@ namespace RJW_Menstruation cum.volume *= 1 - cumoutrate; cum.fertvolume *= 1 - cumoutrate; } - if (!merged) cums.Add(new Cum(pawn, volume * (1 - cumoutrate), notcumlabel,decayresist, filthdef)); + if (!merged) cums.Add(new Cum(pawn, volume * (1 - cumoutrate), notcumlabel, decayresist, filthdef)); } else { @@ -577,7 +579,7 @@ namespace RJW_Menstruation merged = true; } } - if (!merged) cums.Add(new Cum(pawn, volume, notcumlabel,decayresist, filthdef)); + if (!merged) cums.Add(new Cum(pawn, volume, notcumlabel, decayresist, filthdef)); } cumd = TotalCumPercent - cumd; AfterNotCumIn(); @@ -661,7 +663,7 @@ namespace RJW_Menstruation ModLog.Message("cumflation in"); BodyPartRecord genital = Genital_Helper.get_genitalsBPR(parent.pawn); HediffWithComps hediff = parent.pawn.health?.hediffSet?.GetHediffs()?.FirstOrDefault(x => x.def == VariousDefOf.Cumflation && x.Part.Equals(genital)); - + if (hediff == null) // 1.0 fd = 0.002 severity { ModLog.Message("hediff null"); @@ -688,7 +690,7 @@ namespace RJW_Menstruation { ModLog.Message("decrease severity: " + hediff?.Part?.Label + TotalCumPercent * 0.002f); hediff.Severity -= fd * 0.002f; - if (hediff.Severity < TotalCumPercent * 0.002f) hediff.Severity = TotalCumPercent * 0.002f; + if (hediff.Severity < TotalCumPercent * 0.002f) hediff.Severity = TotalCumPercent * 0.002f; } } @@ -741,7 +743,7 @@ namespace RJW_Menstruation if (cums.NullOrEmpty()) return; else if (absorber != null && absorber.dirty && !absorber.LeakAfterDirty) leakfactor = 0f; List removecums = new List(); - foreach(Cum cum in cums) + foreach (Cum cum in cums) { float vd = cum.volume; cum.volume *= Math.Max(0, (1 - (Configurations.CumDecayRatio * (1 - cum.decayresist)) * leakfactor)); @@ -749,7 +751,7 @@ namespace RJW_Menstruation vd -= cum.volume; totalleak += AbsorbCum(cum, vd, absorber); string tmp = "FilthLabelWithSource".Translate(cum.FilthDef.label, cum.pawn?.LabelShort ?? "Unknown", 1.ToString()); - filthlabels.Add(tmp.Replace(" x1","")); + filthlabels.Add(tmp.Replace(" x1", "")); if (cum.fertvolume < 0.01f) cum.fertvolume = 0; if (cum.volume < 0.01f) removecums.Add(cum); } @@ -845,7 +847,7 @@ namespace RJW_Menstruation return outcum; } - + @@ -861,7 +863,8 @@ namespace RJW_Menstruation foreach (Egg egg in eggs) { if (!egg.fertilized) egg.fertilizer = Fertilize(); - if (egg.fertilizer != null) { + if (egg.fertilizer != null) + { egg.fertilized = true; egg.lifespanhrs += 240; onefertilized = true; @@ -890,14 +893,18 @@ namespace RJW_Menstruation if (crampPain < 0) crampPain = PainRandomizer(); if (cums == null) cums = new List(); if (eggs == null) eggs = new List(); - - + + if (!Configurations.EnableMenopause) { Hediff hediff = parent.pawn.health.hediffSet.GetFirstHediffOfDef(VariousDefOf.Hediff_Climacteric); if (hediff != null) parent.pawn.health.RemoveHediff(hediff); hediff = parent.pawn.health.hediffSet.GetFirstHediffOfDef(VariousDefOf.Hediff_Menopause); if (hediff != null) parent.pawn.health.RemoveHediff(hediff); + if (curStage == Stage.ClimactericBleeding) curStage = Stage.Bleeding; + else if (curStage == Stage.ClimactericFollicular) curStage = Stage.Follicular; + else if (curStage == Stage.ClimactericLuteal) curStage = Stage.Luteal; + } else if (ovarypower < -50000) { @@ -914,7 +921,8 @@ namespace RJW_Menstruation avglittersize = 1; } ovarypower = (int)(((Props.ovaryPower * Rand.Range(0.7f, 1.3f) * parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy) - - (Math.Max(0, parent.pawn.ageTracker.AgeBiologicalYears - 15)) * (60 / (Props.folicularIntervalDays + Props.lutealIntervalDays) * Configurations.CycleAcceleration)) * avglittersize); + - (Math.Max(0, parent.pawn.ageTracker.AgeBiologicalYears - RJWSettings.sex_minimum_age * parent.pawn.def.race.lifeExpectancy / ThingDefOf.Human.race.lifeExpectancy)) + * (60 / (Props.folicularIntervalDays + Props.lutealIntervalDays) * Configurations.CycleAcceleration)) * avglittersize); if (ovarypower < 1) { Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_Menopause, parent.pawn); @@ -930,8 +938,8 @@ namespace RJW_Menstruation } } } - - + + if (parent.pawn.IsPregnant()) curStage = Stage.Pregnant; if (parent.pawn.IsAnimal()) { @@ -958,7 +966,7 @@ namespace RJW_Menstruation public void AfterSimulator() { - if (ovarypower < ovarypowerthreshold) + if (Configurations.EnableMenopause && ovarypower < ovarypowerthreshold) { if (sexNeed == null) sexNeed = parent.pawn.needs.TryGetNeed(VariousDefOf.SexNeed); else @@ -973,7 +981,7 @@ namespace RJW_Menstruation HediffDef estrusdef; if (Props.consealedEstrus) estrusdef = VariousDefOf.Hediff_Estrus_Consealed; else estrusdef = VariousDefOf.Hediff_Estrus; - + HediffWithComps hediff = (HediffWithComps)parent.pawn.health.hediffSet.GetFirstHediffOfDef(estrusdef); if (hediff != null) { @@ -987,6 +995,30 @@ namespace RJW_Menstruation } } + public bool IsBreedingSeason() + { + if (Props.breedingSeason == SeasonalBreed.Always) return true; + switch (GenLocalDate.Season(parent.pawn.Map)) + { + case Season.Spring: + if ((Props.breedingSeason & SeasonalBreed.Spring) != 0) return true; + break; + case Season.Summer: + case Season.PermanentSummer: + if ((Props.breedingSeason & SeasonalBreed.Summer) != 0) return true; + break; + case Season.Fall: + if ((Props.breedingSeason & SeasonalBreed.Fall) != 0) return true; + break; + case Season.Winter: + case Season.PermanentWinter: + if ((Props.breedingSeason & SeasonalBreed.Winter) != 0) return true; + break; + default: + return false; + } + return false; + } private Pawn Fertilize() { @@ -1010,7 +1042,7 @@ namespace RJW_Menstruation { List deadeggs = new List(); bool pregnant = false; - foreach(Egg egg in eggs) + foreach (Egg egg in eggs) { if (!egg.fertilized || egg.fertstage < 168) continue; else if (Rand.Range(0.0f, 1.0f) <= Configurations.ImplantationChance * Props.baseImplantationChanceFactor * ImplantFactor * InterspeciesImplantFactor(egg.fertilizer)) @@ -1078,7 +1110,7 @@ namespace RJW_Menstruation private void BleedOut() { //FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, ThingDefOf.Filth_Blood,parent.pawn.Label); - CumIn(parent.pawn, Rand.Range(0.02f * Configurations.BleedingAmount, 0.04f * Configurations.BleedingAmount), Translations.Menstrual_Blood,-5.0f,ThingDefOf.Filth_Blood); + CumIn(parent.pawn, Rand.Range(0.02f * Configurations.BleedingAmount, 0.04f * Configurations.BleedingAmount), Translations.Menstrual_Blood, -5.0f, ThingDefOf.Filth_Blood); GetNotCum(Translations.Menstrual_Blood).color = BloodColor; } @@ -1087,7 +1119,7 @@ namespace RJW_Menstruation /// /// /// - private void MakeCumFilth(Cum cum, float amount) + private void MakeCumFilth(Cum cum, float amount) { if (amount >= minmakefilthvalue) FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, cum.FilthDef, cum.pawn?.LabelShort ?? "Unknown"); } @@ -1101,11 +1133,11 @@ namespace RJW_Menstruation /// private float AbsorbCum(Cum cum, float amount, Absorber absorber) { - + if (absorber != null) { float absorbable = absorber.GetStatValue(VariousDefOf.MaxAbsorbable); - absorber.SetColor(Colors.CMYKLerp(GetCumMixtureColor, absorber.DrawColor, 1f - amount/absorbable)); + absorber.SetColor(Colors.CMYKLerp(GetCumMixtureColor, absorber.DrawColor, 1f - amount / absorbable)); if (!absorber.dirty) { absorber.absorbedfluids += amount; @@ -1118,7 +1150,7 @@ namespace RJW_Menstruation } else { - + //if (absorber.LeakAfterDirty) FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, cum.FilthDef, cum.pawn.LabelShort); return amount; } @@ -1133,10 +1165,10 @@ namespace RJW_Menstruation private float MakeCumFilthMixture(float amount, List cumlabels) { - + if (amount >= minmakefilthvalue) { - FilthMaker_Colored.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, VariousDefOf.FilthMixture, cumlabels,GetCumMixtureColor,false); + FilthMaker_Colored.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, VariousDefOf.FilthMixture, cumlabels, GetCumMixtureColor, false); } return amount; } @@ -1164,6 +1196,14 @@ namespace RJW_Menstruation } } + private void AddCrampPain() + { + Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_MenstrualCramp, parent.pawn); + hediff.Severity = crampPain * Rand.Range(0.9f, 1.1f); + HediffCompProperties_SeverityPerDay Prop = (HediffCompProperties_SeverityPerDay)hediff.TryGetComp().props; + Prop.severityPerDay = -hediff.Severity / (bleedingIntervalhours / 24) * Configurations.CycleAcceleration; + parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn)); + } private Action PeriodSimulator(Stage targetstage) { @@ -1173,28 +1213,10 @@ namespace RJW_Menstruation case Stage.Follicular: action = delegate { - if (Props.breedingSeason != SeasonalBreed.Always) + if (!IsBreedingSeason()) { - if (!Props.breedingSeason.HasFlag(SeasonalBreed.Spring) && GenLocalDate.Season(parent.pawn.Map).Equals(Season.Spring)) - { - GoNextStage(Stage.Anestrus); - return; - } - else if (!Props.breedingSeason.HasFlag(SeasonalBreed.Summer) && (GenLocalDate.Season(parent.pawn.Map).Equals(Season.Summer) || GenLocalDate.Season(parent.pawn.Map).Equals(Season.PermanentSummer))) - { - GoNextStage(Stage.Anestrus); - return; - } - else if (!Props.breedingSeason.HasFlag(SeasonalBreed.Fall) && GenLocalDate.Season(parent.pawn.Map).Equals(Season.Fall)) - { - GoNextStage(Stage.Anestrus); - return; - } - else if (!Props.breedingSeason.HasFlag(SeasonalBreed.Winter) && (GenLocalDate.Season(parent.pawn.Map).Equals(Season.Winter) || GenLocalDate.Season(parent.pawn.Map).Equals(Season.PermanentWinter))) - { - GoNextStage(Stage.Anestrus); - return; - } + GoNextStage(Stage.Anestrus); + return; } if (curStageHrs >= FollicularIntervalHours) { @@ -1202,8 +1224,8 @@ namespace RJW_Menstruation } else { - curStageHrs+=Configurations.CycleAcceleration; - if (!estrusflag && curStageHrs > FollicularIntervalHours - Props.estrusDaysBeforeOvulation*24) + curStageHrs += Configurations.CycleAcceleration; + if (!estrusflag && curStageHrs > FollicularIntervalHours - Props.estrusDaysBeforeOvulation * 24) { estrusflag = true; SetEstrus(Props.eggLifespanDays + Props.estrusDaysBeforeOvulation); @@ -1265,8 +1287,8 @@ namespace RJW_Menstruation } else if (curStageHrs <= lutealIntervalhours) { - curStageHrs+=Configurations.CycleAcceleration; - StayCurrentStage(); + curStageHrs += Configurations.CycleAcceleration; + StayCurrentStage(); } else { @@ -1280,11 +1302,7 @@ namespace RJW_Menstruation bleedingIntervalhours = PeriodRandomizer(bleedingIntervalhours, Props.deviationFactor); if (crampPain >= 0.05f) { - Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_MenstrualCramp, parent.pawn); - hediff.Severity = crampPain * Rand.Range(0.9f, 1.1f); - HediffCompProperties_SeverityPerDay Prop = (HediffCompProperties_SeverityPerDay)hediff.TryGetComp().props; - Prop.severityPerDay = - hediff.Severity / (bleedingIntervalhours/24) * Configurations.CycleAcceleration; - parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn)); + AddCrampPain(); } GoNextStage(Stage.Bleeding); } @@ -1304,7 +1322,7 @@ namespace RJW_Menstruation else { if (curStageHrs < bleedingIntervalhours / 4) for (int i = 0; i < Configurations.CycleAcceleration; i++) BleedOut(); - curStageHrs+=Configurations.CycleAcceleration; + curStageHrs += Configurations.CycleAcceleration; StayCurrentStage(); } }; @@ -1366,7 +1384,7 @@ namespace RJW_Menstruation } else { - curStageHrs+=Configurations.CycleAcceleration; + curStageHrs += Configurations.CycleAcceleration; StayCurrentStage(); } }; @@ -1429,7 +1447,7 @@ namespace RJW_Menstruation follicularIntervalhours = PeriodRandomizer(follicularIntervalhours, Props.deviationFactor * 6); GoNextStage(Stage.ClimactericFollicular); } - else if (ovarypower < ovarypowerthreshold / 4 || (ovarypower < ovarypowerthreshold / 3 && Rand.Range(0.0f,1.0f) < 0.3f)) //skips bleeding + else if (ovarypower < ovarypowerthreshold / 4 || (ovarypower < ovarypowerthreshold / 3 && Rand.Range(0.0f, 1.0f) < 0.3f)) //skips bleeding { follicularIntervalhours = PeriodRandomizer(follicularIntervalhours, Props.deviationFactor * 6); GoNextStage(Stage.ClimactericFollicular); @@ -1439,11 +1457,7 @@ namespace RJW_Menstruation bleedingIntervalhours = PeriodRandomizer(bleedingIntervalhours, Props.deviationFactor); if (crampPain >= 0.05f) { - Hediff hediff = HediffMaker.MakeHediff(VariousDefOf.Hediff_MenstrualCramp, parent.pawn); - hediff.Severity = crampPain * Rand.Range(0.9f, 1.1f); - HediffCompProperties_SeverityPerDay Prop = (HediffCompProperties_SeverityPerDay)hediff.TryGetComp().props; - Prop.severityPerDay = -hediff.Severity / (bleedingIntervalhours / 24) * Configurations.CycleAcceleration; - parent.pawn.health.AddHediff(hediff, Genital_Helper.get_genitalsBPR(parent.pawn)); + AddCrampPain(); } GoNextStage(Stage.ClimactericBleeding); } @@ -1470,25 +1484,7 @@ namespace RJW_Menstruation case Stage.Anestrus: action = delegate { - if (Props.breedingSeason == SeasonalBreed.Always) - { - //case for XML changes - follicularIntervalhours = PeriodRandomizer(follicularIntervalhours, Props.deviationFactor); - GoNextStage(Stage.Follicular); - } - else if (Props.breedingSeason.HasFlag(SeasonalBreed.Spring) && GenLocalDate.Season(parent.pawn.Map).Equals(Season.Spring)) - { - GoFollicularOrBleeding(); - } - else if (Props.breedingSeason.HasFlag(SeasonalBreed.Summer) && (GenLocalDate.Season(parent.pawn.Map).Equals(Season.Summer) || GenLocalDate.Season(parent.pawn.Map).Equals(Season.PermanentSummer))) - { - GoFollicularOrBleeding(); - } - else if (Props.breedingSeason.HasFlag(SeasonalBreed.Fall) && GenLocalDate.Season(parent.pawn.Map).Equals(Season.Fall)) - { - GoFollicularOrBleeding(); - } - else if (Props.breedingSeason.HasFlag(SeasonalBreed.Winter) && (GenLocalDate.Season(parent.pawn.Map).Equals(Season.Winter) || GenLocalDate.Season(parent.pawn.Map).Equals(Season.PermanentWinter))) + if (IsBreedingSeason()) { GoFollicularOrBleeding(); } @@ -1501,7 +1497,7 @@ namespace RJW_Menstruation default: curStage = Stage.Follicular; curStageHrs = 0; - if (follicularIntervalhours < 0) follicularIntervalhours = PeriodRandomizer(Props.folicularIntervalDays*24, Props.deviationFactor); + if (follicularIntervalhours < 0) follicularIntervalhours = PeriodRandomizer(Props.folicularIntervalDays * 24, Props.deviationFactor); HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(Stage.Follicular), tickInterval, parent.pawn, false); break; } @@ -1522,7 +1518,7 @@ namespace RJW_Menstruation HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(nextstage), (int)(tickInterval * factor), parent.pawn, false); } - + void GoNextStageSetHour(Stage nextstage, int hour, float factor = 1.0f) { curStageHrs = hour; @@ -1541,7 +1537,7 @@ namespace RJW_Menstruation { HugsLibController.Instance.TickDelayScheduler.ScheduleCallback(PeriodSimulator(curstage), (int)(tickInterval * factor), parent.pawn, false); } - + void GoFollicularOrBleeding() { if (Props.bleedingIntervalDays == 0) @@ -1562,7 +1558,7 @@ namespace RJW_Menstruation private int PeriodRandomizer(int intervalhours, float deviation) { - return intervalhours + (int)(intervalhours*Rand.Range(-deviation,deviation)); + return intervalhours + (int)(intervalhours * Rand.Range(-deviation, deviation)); } private float InterspeciesImplantFactor(Pawn fertilizer) @@ -1574,7 +1570,7 @@ namespace RJW_Menstruation private float PainRandomizer() { float rand = Rand.Range(0.0f, 1.0f); - if (rand < 0.01f) return Rand.Range(0.0f,0.2f); + if (rand < 0.01f) return Rand.Range(0.0f, 0.2f); else if (rand < 0.2f) return Rand.Range(0.1f, 0.2f); else if (rand < 0.8f) return Rand.Range(0.2f, 0.4f); else if (rand < 0.95f) return Rand.Range(0.4f, 0.6f); @@ -1583,7 +1579,7 @@ namespace RJW_Menstruation private Stage RandomStage() { - int rand = Rand.Range(0,2); + int rand = Rand.Range(0, 2); switch (rand) { @@ -1605,7 +1601,7 @@ namespace RJW_Menstruation - + public class Egg : IExposable { public bool fertilized; diff --git a/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs b/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs index 2c44644..159f51e 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Hediff_MultiplePregnancy.cs @@ -1,13 +1,9 @@ -using System; +using RimWorld; +using rjw; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Reflection; -using rjw; -using Verse; -using RimWorld; using UnityEngine; +using Verse; namespace RJW_Menstruation { @@ -15,562 +11,596 @@ namespace RJW_Menstruation { public override void DiscoverPregnancy() { - if (!is_discovered && xxx.is_human(pawn) && !pawn.Has(Quirk.Breeder) && pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Spouse) || x.def.Equals(PawnRelationDefOf.Fiance)) == null) + if (!is_discovered && xxx.is_human(pawn) && !pawn.Has(Quirk.Breeder) && pawn.relations?.DirectRelations?.Find(x => x.def.Equals(PawnRelationDefOf.Spouse) || x.def.Equals(PawnRelationDefOf.Fiance)) == null) { - pawn.needs.mood.thoughts.memories.TryGainMemory(VariousDefOf.UnwantedPregnancy); + pawn.needs.mood.thoughts.memories.TryGainMemory(VariousDefOf.UnwantedPregnancy); } - base.DiscoverPregnancy(); + base.DiscoverPregnancy(); } public override void GiveBirth() { - - if (babies.NullOrEmpty()) - { - ModLog.Warning(" no babies (debug?) " + this.GetType().Name); - if (father == null) - { - father = Trytogetfather(ref pawn); - } - Initialize(pawn, father); - } - List siblings = new List(); - foreach (Pawn baby in babies) - { - if (xxx.is_animal(baby)) + if (babies.NullOrEmpty()) + { + ModLog.Warning(" no babies (debug?) " + this.GetType().Name); + if (father == null) { - BestialBirth(baby, siblings); + father = Trytogetfather(ref pawn); + } + Initialize(pawn, father); + } + + List siblings = new List(); + foreach (Pawn baby in babies) + { + if (xxx.is_animal(baby)) + { + BestialBirth(baby, siblings); } else { - HumanlikeBirth(baby, siblings); + HumanlikeBirth(baby, siblings); } - } + } - pawn.health.RemoveHediff(this); - } - - public string GetBabyInfo() - { - string res = ""; - if (!babies.NullOrEmpty()) - { - var babiesdistinct = babies.Distinct(new RaceComparer()); - int iteration = 0; - foreach (Pawn baby in babiesdistinct) - { - int num = babies.Where(x => x.def.Equals(baby.def)).Count(); - if (iteration > 0) res += ", "; - res += num + " " + baby.def.label; - iteration++; - } - res += " " + Translations.Dialog_WombInfo02; - return res; - } - return "Null"; + pawn.health.RemoveHediff(this); } - public string GetFatherInfo() + public string GetBabyInfo() { - string res = Translations.Dialog_WombInfo03 + ": "; - if (!babies.NullOrEmpty()) - { - var babiesdistinct = babies.Distinct(new FatherComparer(pawn)); - int iteration = 0; - foreach (Pawn baby in babiesdistinct) - { - if (iteration > 0) res += ", "; - res += Utility.GetFather(baby, pawn)?.LabelShort ?? "Unknown"; - iteration++; - } - return res; - } - return "Null"; - } + string res = ""; + if (!babies.NullOrEmpty()) + { + var babiesdistinct = babies.Distinct(new RaceComparer()); + int iteration = 0; + foreach (Pawn baby in babiesdistinct) + { + int num = babies.Where(x => x.def.Equals(baby.def)).Count(); + if (iteration > 0) res += ", "; + res += num + " " + baby.def.label; + iteration++; + } + res += " " + Translations.Dialog_WombInfo02; + return res; + } + return "Null"; + } + + public string GetFatherInfo() + { + string res = Translations.Dialog_WombInfo03 + ": "; + if (!babies.NullOrEmpty()) + { + var babiesdistinct = babies.Distinct(new FatherComparer(pawn)); + int iteration = 0; + foreach (Pawn baby in babiesdistinct) + { + if (iteration > 0) res += ", "; + res += Utility.GetFather(baby, pawn)?.LabelShort ?? "Unknown"; + iteration++; + } + return res; + } + return "Null"; + } private void HumanlikeBirth(Pawn baby, List siblings) { - Pawn mother = pawn; Pawn father = Utility.GetFather(baby,pawn); - //backup melanin, LastName for when baby reset by other mod on spawn/backstorychange - //var skin_whiteness = baby.story.melanin; - //var last_name = baby.story.birthLastName; + Pawn mother = pawn; Pawn father = Utility.GetFather(baby, pawn); + //backup melanin, LastName for when baby reset by other mod on spawn/backstorychange + //var skin_whiteness = baby.story.melanin; + //var last_name = baby.story.birthLastName; - PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother); + PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother); - var sex_need = mother.needs?.TryGetNeed(); - if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null) - { - sex_need.CurLevel = 1.0f; - } - if (mother.Faction != null) - { - if (mother.Faction != baby.Faction) - baby.SetFaction(mother.Faction); - } - if (mother.IsPrisonerOfColony) - { - baby.guest.CapturedBy(Faction.OfPlayer); - } + var sex_need = mother.needs?.TryGetNeed(); + if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null) + { + sex_need.CurLevel = 1.0f; + } + if (mother.Faction != null) + { + if (mother.Faction != baby.Faction) + baby.SetFaction(mother.Faction); + } + if (mother.IsPrisonerOfColony) + { + baby.guest.CapturedBy(Faction.OfPlayer); + } - foreach (Pawn sibling in siblings) - { - baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling); - } - siblings.Add(baby); - - PostBirth(mother, father, baby); - } + foreach (Pawn sibling in siblings) + { + baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling); + } + siblings.Add(baby); + + PostBirth(mother, father, baby); + } - private void BestialBirth(Pawn baby, List siblings) + private void BestialBirth(Pawn baby, List siblings) { - Pawn mother = pawn; Pawn father = Utility.GetFather(baby,pawn); - //backup melanin, LastName for when baby reset by other mod on spawn/backstorychange - //var skin_whiteness = baby.story.melanin; - //var last_name = baby.story.birthLastName; + Pawn mother = pawn; Pawn father = Utility.GetFather(baby, pawn); + //backup melanin, LastName for when baby reset by other mod on spawn/backstorychange + //var skin_whiteness = baby.story.melanin; + //var last_name = baby.story.birthLastName; - PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother); + PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother); - Need_Sex sex_need = mother.needs?.TryGetNeed(); - if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null) - { - sex_need.CurLevel = 1.0f; - } - if (mother.Faction != null) - { - if (mother.Faction != baby.Faction) - baby.SetFaction(mother.Faction); - } + Need_Sex sex_need = mother.needs?.TryGetNeed(); + if (mother.Faction != null && !(mother.Faction?.IsPlayer ?? false) && sex_need != null) + { + sex_need.CurLevel = 1.0f; + } + if (mother.Faction != null) + { + if (mother.Faction != baby.Faction) + baby.SetFaction(mother.Faction); + } - foreach (Pawn sibling in siblings) - { - baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling); - } - siblings.Add(baby); - train(baby, mother, father); + foreach (Pawn sibling in siblings) + { + baby.relations.AddDirectRelation(PawnRelationDefOf.Sibling, sibling); + } + siblings.Add(baby); + train(baby, mother, father); - PostBirth(mother, father, baby); + PostBirth(mother, father, baby); - //restore melanin, LastName for when baby reset by other mod on spawn/backstorychange - //baby.story.melanin = skin_whiteness; - //baby.story.birthLastName = last_name; - } + //restore melanin, LastName for when baby reset by other mod on spawn/backstorychange + //baby.story.melanin = skin_whiteness; + //baby.story.birthLastName = last_name; + } protected override void GenerateBabies() - { - AddNewBaby(pawn, father); - } + { + AddNewBaby(pawn, father); + } - protected void train(Pawn baby, Pawn mother, Pawn father) - { - bool _; - if (!xxx.is_human(baby) && baby.Faction == Faction.OfPlayer) - { - if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Obedience, out _).Accepted) - { - baby.training.Train(TrainableDefOf.Obedience, mother); - } - if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Tameness, out _).Accepted) - { - baby.training.Train(TrainableDefOf.Tameness, mother); - } - } - } - - - public bool AddNewBaby(Pawn mother, Pawn father) - { - float melanin; - string lastname; - if (xxx.is_human(mother)) + protected void train(Pawn baby, Pawn mother, Pawn father) + { + bool _; + if (!xxx.is_human(baby) && baby.Faction == Faction.OfPlayer) { - if (xxx.is_human(father)) + if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Obedience, out _).Accepted) { - melanin = (mother.story.melanin + father.story.melanin) / 2; - lastname = NameTriple.FromString(father.Name.ToStringFull).Last; - } + baby.training.Train(TrainableDefOf.Obedience, mother); + } + if (xxx.is_human(mother) && baby.Faction == Faction.OfPlayer && baby.training.CanAssignToTrain(TrainableDefOf.Tameness, out _).Accepted) + { + baby.training.Train(TrainableDefOf.Tameness, mother); + } + } + } + + + public bool AddNewBaby(Pawn mother, Pawn father) + { + float melanin; + string lastname; + if (xxx.is_human(mother)) + { + if (xxx.is_human(father)) + { + melanin = (mother.story.melanin + father.story.melanin) / 2; + lastname = NameTriple.FromString(father.Name.ToStringFull).Last; + } else { - melanin = mother.story.melanin; - lastname = NameTriple.FromString(mother.Name.ToStringFull).Last; - } + melanin = mother.story.melanin; + lastname = NameTriple.FromString(mother.Name.ToStringFull).Last; + } } else { - if (xxx.is_human(father)) + if (xxx.is_human(father)) { - melanin = father.story.melanin; - lastname = NameTriple.FromString(father.Name.ToStringFull).Last; - } + melanin = father.story.melanin; + lastname = NameTriple.FromString(father.Name.ToStringFull).Last; + } else - { - melanin = Rand.Range(0, 1.0f); - lastname = NameTriple.FromString(mother.Name.ToStringFull).Last; - } + { + melanin = Rand.Range(0, 1.0f); + lastname = NameTriple.FromString(mother.Name.ToStringFull).Last; + } } - - PawnGenerationRequest request = new PawnGenerationRequest( - newborn: true, - allowDowned: true, - canGeneratePawnRelations: false, - colonistRelationChanceFactor: 0, - allowFood: false, - allowAddictions: false, - relationWithExtraPawnChanceFactor: 0, - fixedMelanin: melanin, - fixedLastName: lastname, - kind: BabyPawnKindDecider(mother, father) - ); - int division = 1; - HairDef firsthair = null; - Color firsthaircolor = Color.white; - BodyTypeDef firstbody = null; - CrownType firstcrown = CrownType.Undefined; - string firstheadpath = null; - string firstHARcrown = null; - while (Rand.Chance(Configurations.EnzygoticTwinsChance) && division < Configurations.MaxEnzygoticTwins) division++; - for (int i = 0; i < division; i++) - { - Pawn baby = GenerateBaby(request, mother, father); - if (division > 1) - { - if (i == 0 && baby.story != null) - { - firsthair = baby.story.hairDef; - firsthaircolor = baby.story.hairColor; - request.FixedGender = baby.gender; - firstbody = baby.story.bodyType; - firstcrown = baby.story.crownType; - firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath"); - if (firstheadpath == null) - { - baby.story.SetMemberValue("headGraphicPath", GraphicDatabaseHeadRecords.GetHeadRandom(baby.gender, baby.story.SkinColor, baby.story.crownType).GraphicPath); - firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath"); - } - if (Configurations.HARActivated && baby.IsHAR()) + PawnGenerationRequest request = new PawnGenerationRequest( + newborn: true, + allowDowned: true, + canGeneratePawnRelations: false, + colonistRelationChanceFactor: 0, + allowFood: false, + allowAddictions: false, + relationWithExtraPawnChanceFactor: 0, + fixedMelanin: melanin, + fixedLastName: lastname, + kind: BabyPawnKindDecider(mother, father) + ); + + int division = 1; + HairDef firsthair = null; + Color firsthaircolor = Color.white; + BodyTypeDef firstbody = null; + CrownType firstcrown = CrownType.Undefined; + string firstheadpath = null; + string firstHARcrown = null; + while (Rand.Chance(Configurations.EnzygoticTwinsChance) && division < Configurations.MaxEnzygoticTwins) division++; + for (int i = 0; i < division; i++) + { + Pawn baby = GenerateBaby(request, mother, father); + if (division > 1) + { + if (i == 0 && baby.story != null) + { + firsthair = baby.story.hairDef; + firsthaircolor = baby.story.hairColor; + request.FixedGender = baby.gender; + firstbody = baby.story.bodyType; + firstcrown = baby.story.crownType; + firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath"); + if (firstheadpath == null) { - firstHARcrown = baby.GetHARCrown(); + baby.story.SetMemberValue("headGraphicPath", GraphicDatabaseHeadRecords.GetHeadRandom(baby.gender, baby.story.SkinColor, baby.story.crownType).GraphicPath); + firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath"); + } + if (Configurations.HARActivated && baby.IsHAR()) + { + firstHARcrown = baby.GetHARCrown(); } - } - else - { - if (baby.story != null) - { - baby.story.hairDef = firsthair; - baby.story.hairColor = firsthaircolor; - baby.story.bodyType = firstbody; - baby.story.crownType = firstcrown; - baby.story.SetMemberValue("headGraphicPath", firstheadpath); + } + else + { + if (baby.story != null) + { + baby.story.hairDef = firsthair; + baby.story.hairColor = firsthaircolor; + baby.story.bodyType = firstbody; + baby.story.crownType = firstcrown; + baby.story.SetMemberValue("headGraphicPath", firstheadpath); - if (Configurations.HARActivated && baby.IsHAR()) - { - baby.SetHARCrown(firstHARcrown); - } - } - } - } + if (Configurations.HARActivated && baby.IsHAR()) + { + baby.SetHARCrown(firstHARcrown); + } + } + } + } if (baby != null) babies.Add(baby); - } - - + } - return true; + + + return true; } - public Pawn GenerateBaby(PawnGenerationRequest request, Pawn mother, Pawn father) - { - - Pawn baby = PawnGenerator.GeneratePawn(request); - if (baby != null) - { - if (xxx.is_human(baby)) - { - List traitpool = new List(); - baby.SetMother(mother); - if (mother != father) - { - if (father.gender != Gender.Female) baby.SetFather(father); - else - { - baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father); - } - } - - if (xxx.has_traits(pawn) && pawn.RaceProps.Humanlike) - { - foreach (Trait momtrait in pawn.story.traits.allTraits) - { - if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(momtrait.def.defName)) - traitpool.Add(momtrait); - } - } - if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike) - { - foreach (Trait poptrait in father.story.traits.allTraits) - { - if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(poptrait.def.defName)) - traitpool.Add(poptrait); - } - } - updateTraits(baby, traitpool); - - } - else - { - baby.relations.AddDirectRelation(VariousDefOf.Relation_birthgiver, mother); - mother.relations.AddDirectRelation(VariousDefOf.Relation_spawn, baby); - if (mother != father) - { - baby.relations.AddDirectRelation(VariousDefOf.Relation_birthgiver, father); - father.relations.AddDirectRelation(VariousDefOf.Relation_spawn, baby); - } - } - } - return baby; - } - - /// - /// Decide pawnkind from mother and father - /// Come from RJW - /// - /// - /// - /// - public PawnKindDef BabyPawnKindDecider(Pawn mother, Pawn father) + public Pawn GenerateBaby(PawnGenerationRequest request, Pawn mother, Pawn father) { - PawnKindDef spawn_kind_def = mother.kindDef; - int flag = 0; - if (xxx.is_human(mother)) flag += 2; - if (xxx.is_human(father)) flag += 1; + + Pawn baby = PawnGenerator.GeneratePawn(request); + if (baby != null) + { + if (xxx.is_human(baby)) + { + List traitpool = new List(); + baby.SetMother(mother); + if (mother != father) + { + if (father.gender != Gender.Female) baby.SetFather(father); + else + { + baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father); + } + } + + if (xxx.has_traits(pawn) && pawn.RaceProps.Humanlike) + { + foreach (Trait momtrait in pawn.story.traits.allTraits) + { + if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(momtrait.def.defName)) + traitpool.Add(momtrait); + } + } + if (father != null && xxx.has_traits(father) && father.RaceProps.Humanlike) + { + foreach (Trait poptrait in father.story.traits.allTraits) + { + if (!RJWPregnancySettings.trait_filtering_enabled || !non_genetic_traits.Contains(poptrait.def.defName)) + traitpool.Add(poptrait); + } + } + updateTraits(baby, traitpool); + + } + else + { + baby.relations.AddDirectRelation(VariousDefOf.Relation_birthgiver, mother); + mother.relations.AddDirectRelation(VariousDefOf.Relation_spawn, baby); + if (mother != father) + { + baby.relations.AddDirectRelation(VariousDefOf.Relation_birthgiver, father); + father.relations.AddDirectRelation(VariousDefOf.Relation_spawn, baby); + } + } + } + return baby; + } + + /// + /// Decide pawnkind from mother and father + /// Come from RJW + /// + /// + /// + /// + public PawnKindDef BabyPawnKindDecider(Pawn mother, Pawn father) + { + PawnKindDef spawn_kind_def = mother.kindDef; + + int flag = 0; + if (xxx.is_human(mother)) flag += 2; + if (xxx.is_human(father)) flag += 1; //Mother - Father = Flag - //Human - Human = 3 + //Human - Human = 3 //Human - Animal = 2 //Animal - Human = 1 //Animal - Animal = 0 switch (flag) { - case 3: - if (!Rand.Chance(RJWPregnancySettings.humanlike_DNA_from_mother)) spawn_kind_def = father.kindDef; - break; - case 2: - if (RJWPregnancySettings.bestiality_DNA_inheritance == 0f) spawn_kind_def = father.kindDef; - else if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother)) spawn_kind_def = father.kindDef; - break; - case 1: - if (RJWPregnancySettings.bestiality_DNA_inheritance == 1f) spawn_kind_def = father.kindDef; - else if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother)) spawn_kind_def = father.kindDef; - break; - case 0: - if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother)) spawn_kind_def = father.kindDef; - break; + case 3: + if (!Rand.Chance(RJWPregnancySettings.humanlike_DNA_from_mother)) spawn_kind_def = father.kindDef; + break; + case 2: + if (RJWPregnancySettings.bestiality_DNA_inheritance == 0f) spawn_kind_def = father.kindDef; + else if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother)) spawn_kind_def = father.kindDef; + break; + case 1: + if (RJWPregnancySettings.bestiality_DNA_inheritance == 1f) spawn_kind_def = father.kindDef; + else if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother)) spawn_kind_def = father.kindDef; + break; + case 0: + if (!Rand.Chance(RJWPregnancySettings.bestial_DNA_from_mother)) spawn_kind_def = father.kindDef; + break; } - bool IsAndroidmother = AndroidsCompatibility.IsAndroid(mother); - bool IsAndroidfather = AndroidsCompatibility.IsAndroid(father); - if (IsAndroidmother && !IsAndroidfather) - { - spawn_kind_def = father.kindDef; - } - else if (!IsAndroidmother && IsAndroidfather) - { - spawn_kind_def = mother.kindDef; - } + bool IsAndroidmother = AndroidsCompatibility.IsAndroid(mother); + bool IsAndroidfather = AndroidsCompatibility.IsAndroid(father); + if (IsAndroidmother && !IsAndroidfather) + { + spawn_kind_def = father.kindDef; + } + else if (!IsAndroidmother && IsAndroidfather) + { + spawn_kind_def = mother.kindDef; + } + + string MotherRaceName = ""; + string FatherRaceName = ""; + MotherRaceName = mother.kindDef.race.defName; + PawnKindDef tmp = spawn_kind_def; + if (father != null) + FatherRaceName = father.kindDef.race.defName; + if (MotherRaceName != FatherRaceName && FatherRaceName != "") + { + + if (Configurations.UseHybridExtention) + { + if (Configurations.MotherFirst) + { + spawn_kind_def = GetHybrid(mother, father); + } + else + { + spawn_kind_def = GetHybrid(father, mother); + } + Log.Message("pawnkind: " + spawn_kind_def?.defName); + } + if (!Configurations.UseHybridExtention || spawn_kind_def == null) + { + spawn_kind_def = tmp; + var groups = DefDatabase.AllDefs.Where(x => !(x.hybridRaceParents.NullOrEmpty() || x.hybridChildKindDef.NullOrEmpty())); - string MotherRaceName = ""; - string FatherRaceName = ""; - MotherRaceName = mother.kindDef.race.defName; - if (father != null) - FatherRaceName = father.kindDef.race.defName; - if (MotherRaceName != FatherRaceName && FatherRaceName != "") - { - var groups = DefDatabase.AllDefs.Where(x => !(x.hybridRaceParents.NullOrEmpty() || x.hybridChildKindDef.NullOrEmpty())); - + //ModLog.Message(" found custom RaceGroupDefs " + groups.Count()); + foreach (var t in groups) + { + if ((t.hybridRaceParents.Contains(MotherRaceName) && t.hybridRaceParents.Contains(FatherRaceName)) + || (t.hybridRaceParents.Contains("Any") && (t.hybridRaceParents.Contains(MotherRaceName) || t.hybridRaceParents.Contains(FatherRaceName)))) + { + //ModLog.Message(" has hybridRaceParents"); + if (t.hybridChildKindDef.Contains("MotherKindDef")) + spawn_kind_def = mother.kindDef; + else if (t.hybridChildKindDef.Contains("FatherKindDef") && father != null) + spawn_kind_def = father.kindDef; + else + { + //ModLog.Message(" trying hybridChildKindDef " + t.defName); + var child_kind_def_list = new List(); + child_kind_def_list.AddRange(DefDatabase.AllDefs.Where(x => t.hybridChildKindDef.Contains(x.defName))); - //ModLog.Message(" found custom RaceGroupDefs " + groups.Count()); - foreach (var t in groups) - { - if ((t.hybridRaceParents.Contains(MotherRaceName) && t.hybridRaceParents.Contains(FatherRaceName)) - || (t.hybridRaceParents.Contains("Any") && (t.hybridRaceParents.Contains(MotherRaceName) || t.hybridRaceParents.Contains(FatherRaceName)))) - { - //ModLog.Message(" has hybridRaceParents"); - if (t.hybridChildKindDef.Contains("MotherKindDef")) - spawn_kind_def = mother.kindDef; - else if (t.hybridChildKindDef.Contains("FatherKindDef") && father != null) - spawn_kind_def = father.kindDef; - else - { - //ModLog.Message(" trying hybridChildKindDef " + t.defName); - var child_kind_def_list = new List(); - child_kind_def_list.AddRange(DefDatabase.AllDefs.Where(x => t.hybridChildKindDef.Contains(x.defName))); + //ModLog.Message(" found custom hybridChildKindDefs " + t.hybridChildKindDef.Count); + if (!child_kind_def_list.NullOrEmpty()) + spawn_kind_def = child_kind_def_list.RandomElement(); + } + } + } + } - //ModLog.Message(" found custom hybridChildKindDefs " + t.hybridChildKindDef.Count); - if (!child_kind_def_list.NullOrEmpty()) - spawn_kind_def = child_kind_def_list.RandomElement(); - } - } - } - - - - } + } else { - spawn_kind_def = mother.RaceProps.AnyPawnKind; + spawn_kind_def = mother.RaceProps.AnyPawnKind; + } + + if (spawn_kind_def.defName.Contains("Nymph")) + { + //child is nymph, try to find other PawnKindDef + var spawn_kind_def_list = new List(); + spawn_kind_def_list.AddRange(DefDatabase.AllDefs.Where(x => x.race == spawn_kind_def.race && !x.defName.Contains("Nymph"))); + //no other PawnKindDef found try mother + if (spawn_kind_def_list.NullOrEmpty()) + spawn_kind_def_list.AddRange(DefDatabase.AllDefs.Where(x => x.race == mother.kindDef.race && !x.defName.Contains("Nymph"))); + //no other PawnKindDef found try father + if (spawn_kind_def_list.NullOrEmpty() && father != null) + spawn_kind_def_list.AddRange(DefDatabase.AllDefs.Where(x => x.race == father.kindDef.race && !x.defName.Contains("Nymph"))); + //no other PawnKindDef found fallback to generic colonist + if (spawn_kind_def_list.NullOrEmpty()) + spawn_kind_def = PawnKindDefOf.Colonist; + + spawn_kind_def = spawn_kind_def_list.RandomElement(); } - if (spawn_kind_def.defName.Contains("Nymph")) - { - //child is nymph, try to find other PawnKindDef - var spawn_kind_def_list = new List(); - spawn_kind_def_list.AddRange(DefDatabase.AllDefs.Where(x => x.race == spawn_kind_def.race && !x.defName.Contains("Nymph"))); - //no other PawnKindDef found try mother - if (spawn_kind_def_list.NullOrEmpty()) - spawn_kind_def_list.AddRange(DefDatabase.AllDefs.Where(x => x.race == mother.kindDef.race && !x.defName.Contains("Nymph"))); - //no other PawnKindDef found try father - if (spawn_kind_def_list.NullOrEmpty() && father != null) - spawn_kind_def_list.AddRange(DefDatabase.AllDefs.Where(x => x.race == father.kindDef.race && !x.defName.Contains("Nymph"))); - //no other PawnKindDef found fallback to generic colonist - if (spawn_kind_def_list.NullOrEmpty()) - spawn_kind_def = PawnKindDefOf.Colonist; - - spawn_kind_def = spawn_kind_def_list.RandomElement(); - } - - - return spawn_kind_def; + return spawn_kind_def; } - - /// - /// Copy from RJW - /// - /// - /// - public void updateTraits(Pawn pawn, List parenttraits) + public PawnKindDef GetHybrid(Pawn first, Pawn second) { - if (pawn?.story?.traits == null) return; + PawnDNAModExtension dna; + PawnKindDef res = null; + dna = first.def.GetModExtension(); + if (dna != null) + { + res = dna.GetHybridWith(second.def.defName) ?? null; + } + else + { + dna = second.def.GetModExtension(); + if (dna != null) + { + res = dna.GetHybridWith(first.def.defName) ?? null; + } + } + return res; + } - List traitlist = new List(pawn.story.traits.allTraits); - if (!parenttraits.NullOrEmpty()) traitlist.AddRange(parenttraits); - else return; + /// + /// Copy from RJW + /// + /// + /// + public void updateTraits(Pawn pawn, List parenttraits) + { + if (pawn?.story?.traits == null) return; + + List traitlist = new List(pawn.story.traits.allTraits); + if (!parenttraits.NullOrEmpty()) traitlist.AddRange(parenttraits); + else return; - var forcedTraits = traitlist - .Where(x => x.ScenForced) - .Distinct(new TraitComparer(ignoreDegree: true)); + var forcedTraits = traitlist + .Where(x => x.ScenForced) + .Distinct(new TraitComparer(ignoreDegree: true)); - List res = new List(); - res.AddRange(forcedTraits); + List res = new List(); + res.AddRange(forcedTraits); - var comparer = new TraitComparer(); // trait comparision implementation, because without game compares traits *by reference*, makeing them all unique. + var comparer = new TraitComparer(); // trait comparision implementation, because without game compares traits *by reference*, makeing them all unique. - while (res.Count < traitlist.Count && traitlist.Count > 0) - { - int index = Rand.Range(0, traitlist.Count); // getting trait and removing from the pull - var trait = traitlist[index]; - traitlist.RemoveAt(index); + while (res.Count < traitlist.Count && traitlist.Count > 0) + { + int index = Rand.Range(0, traitlist.Count); // getting trait and removing from the pull + var trait = traitlist[index]; + traitlist.RemoveAt(index); - if (!res.Any(x => comparer.Equals(x, trait) || // skipping traits conflicting with already added - x.def.ConflictsWith(trait))) - { - res.Add(new Trait(trait.def, trait.Degree, false)); - } - } + if (!res.Any(x => comparer.Equals(x, trait) || // skipping traits conflicting with already added + x.def.ConflictsWith(trait))) + { + res.Add(new Trait(trait.def, trait.Degree, false)); + } + } - pawn.story.traits.allTraits = res; - } + pawn.story.traits.allTraits = res; + } - } + } - /// - /// Copy from RJW - /// - public class TraitComparer : IEqualityComparer - { - bool ignoreForced; - bool ignoreDegree; + /// + /// Copy from RJW + /// + public class TraitComparer : IEqualityComparer + { + bool ignoreForced; + bool ignoreDegree; - public TraitComparer(bool ignoreDegree = false, bool ignoreForced = true) - { - this.ignoreDegree = ignoreDegree; - this.ignoreForced = ignoreForced; - } + public TraitComparer(bool ignoreDegree = false, bool ignoreForced = true) + { + this.ignoreDegree = ignoreDegree; + this.ignoreForced = ignoreForced; + } - public bool Equals(Trait x, Trait y) - { - return - x.def == y.def && - (ignoreDegree || (x.Degree == y.Degree)) && - (ignoreForced || (x.ScenForced == y.ScenForced)); - } + public bool Equals(Trait x, Trait y) + { + return + x.def == y.def && + (ignoreDegree || (x.Degree == y.Degree)) && + (ignoreForced || (x.ScenForced == y.ScenForced)); + } - public int GetHashCode(Trait obj) - { - return - (obj.def.GetHashCode() << 5) + - (ignoreDegree ? 0 : obj.Degree) + - ((ignoreForced || obj.ScenForced) ? 0 : 0x10); - } - } + public int GetHashCode(Trait obj) + { + return + (obj.def.GetHashCode() << 5) + + (ignoreDegree ? 0 : obj.Degree) + + ((ignoreForced || obj.ScenForced) ? 0 : 0x10); + } + } public class RaceComparer : IEqualityComparer { public bool Equals(Pawn x, Pawn y) { - return x.def.Equals(y.def); + return x.def.Equals(y.def); } public int GetHashCode(Pawn obj) { - return obj.def.GetHashCode(); + return obj.def.GetHashCode(); } } - public class FatherComparer : IEqualityComparer - { - Pawn mother; - - public FatherComparer(Pawn mother) + public class FatherComparer : IEqualityComparer + { + Pawn mother; + + public FatherComparer(Pawn mother) { - this.mother = mother; + this.mother = mother; } - public bool Equals(Pawn x, Pawn y) - { - if (Utility.GetFather(x, mother) == null && Utility.GetFather(y, mother) == null) return true; - return Utility.GetFather(x,mother)?.Label.Equals(Utility.GetFather(y,mother)?.Label) ?? false; - } + public bool Equals(Pawn x, Pawn y) + { + if (Utility.GetFather(x, mother) == null && Utility.GetFather(y, mother) == null) return true; + return Utility.GetFather(x, mother)?.Label.Equals(Utility.GetFather(y, mother)?.Label) ?? false; + } - public int GetHashCode(Pawn obj) - { - return obj.def.GetHashCode(); - } - } + public int GetHashCode(Pawn obj) + { + return obj.def.GetHashCode(); + } + } } diff --git a/source/RJW_Menstruation/RJW_Menstruation/JobDrivers.cs b/source/RJW_Menstruation/RJW_Menstruation/JobDrivers.cs index c2781c4..4af7051 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/JobDrivers.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/JobDrivers.cs @@ -1,45 +1,39 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using RimWorld; -using Verse; +using System.Collections.Generic; using Verse.AI; namespace RJW_Menstruation { - public class JobDriver_VaginaWashing : JobDriver - { - const int excretingTime = 300;//ticks - 120 = 2 real seconds, 3 in-game minutes + public class JobDriver_VaginaWashing : JobDriver + { + const int excretingTime = 300;//ticks - 120 = 2 real seconds, 3 in-game minutes - public override bool TryMakePreToilReservations(bool errorOnFailed) - { - return pawn.Reserve(pawn, job, 1, -1, null, errorOnFailed); - } + public override bool TryMakePreToilReservations(bool errorOnFailed) + { + return pawn.Reserve(pawn, job, 1, -1, null, errorOnFailed); + } - protected override IEnumerable MakeNewToils() - { + protected override IEnumerable MakeNewToils() + { - HediffComp_Menstruation Comp = Utility.GetMenstruationComp(pawn); - this.FailOn(delegate - { - return !(Comp.TotalCumPercent > 0.01); - }); - Toil excreting = Toils_General.Wait(excretingTime, TargetIndex.None);//duration of + HediffComp_Menstruation Comp = Utility.GetMenstruationComp(pawn); + this.FailOn(delegate + { + return !(Comp.TotalCumPercent > 0.01); + }); + Toil excreting = Toils_General.Wait(excretingTime, TargetIndex.None);//duration of - excreting.WithProgressBarToilDelay(TargetIndex.A); - yield return excreting; - yield return new Toil() - { - initAction = delegate () - { - Comp.CumOutForce(null, 0.5f); - if (Comp.TotalCumPercent > 0.01) this.JumpToToil(excreting); - } - }; - //yield return excreting; + excreting.WithProgressBarToilDelay(TargetIndex.A); + yield return excreting; + yield return new Toil() + { + initAction = delegate () + { + Comp.CumOutForce(null, 0.5f); + if (Comp.TotalCumPercent > 0.01) this.JumpToToil(excreting); + } + }; + //yield return excreting; - } - } + } + } } diff --git a/source/RJW_Menstruation/RJW_Menstruation/Patch/GetGizmos.cs b/source/RJW_Menstruation/RJW_Menstruation/Patch/GetGizmos.cs index 6c93368..a519729 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Patch/GetGizmos.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Patch/GetGizmos.cs @@ -1,14 +1,9 @@ -using System; +using HarmonyLib; +using rjw; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using Verse; -using RimWorld; -using rjw; using UnityEngine; -using Verse.Sound; +using Verse; namespace RJW_Menstruation { @@ -38,7 +33,7 @@ namespace RJW_Menstruation - + __result = gizmoList; } @@ -50,9 +45,9 @@ namespace RJW_Menstruation } - private static Gizmo CreateGizmo_WombStatus(Pawn pawn , HediffComp_Menstruation comp) + private static Gizmo CreateGizmo_WombStatus(Pawn pawn, HediffComp_Menstruation comp) { - Texture2D icon,icon_overay; + Texture2D icon, icon_overay; string description = ""; if (Configurations.Debug) description += comp.curStage + ": " + comp.curStageHrs + "\n" + "fertcums: " + comp.TotalFertCum + "\n" + "ovarypower: " + comp.ovarypower + "\n" + "eggs: " + comp.GetNumofEggs + "\n"; else description += comp.GetCurStageLabel + "\n"; diff --git a/source/RJW_Menstruation/RJW_Menstruation/Patch/Harmony.cs b/source/RJW_Menstruation/RJW_Menstruation/Patch/Harmony.cs index d6e4b6d..69ad681 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Patch/Harmony.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Patch/Harmony.cs @@ -1,27 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using HarmonyLib; using System.Reflection; -using HarmonyLib; using Verse; -using RimWorld; -using rjw; namespace RJW_Menstruation { - [StaticConstructorOnStartup] - internal static class First - { - static First() - { - var har = new Harmony("RJW_Menstruation"); - har.PatchAll(Assembly.GetExecutingAssembly()); - } - } + [StaticConstructorOnStartup] + internal static class First + { + static First() + { + var har = new Harmony("RJW_Menstruation"); + har.PatchAll(Assembly.GetExecutingAssembly()); + } + } + - } diff --git a/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs b/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs index fecae83..0d9cb19 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Patch/Pawn_Patch.cs @@ -1,14 +1,10 @@ -using System; +using HarmonyLib; +using HugsLib; +using RimWorld; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; -using RimWorld; using Verse; -using HarmonyLib; -using HugsLib; -using rjw; namespace RJW_Menstruation { @@ -40,12 +36,12 @@ namespace RJW_Menstruation if (pawn.HasMenstruationComp()) opts.AddDistinct(MakeSelfMenu(pawn, t)); break; } - - + + } - + public static FloatMenuOption MakeSelfMenu(Pawn pawn, LocalTargetInfo target) { FloatMenuOption option = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(Translations.FloatMenu_CleanSelf, delegate () @@ -59,7 +55,7 @@ namespace RJW_Menstruation } - + //[HarmonyPatch(typeof(HealthCardUtility), "DrawHediffListing")] //public class DrawHediffListing_Patch //{ diff --git a/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs b/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs index 6bbdbcf..58a5bb4 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Patch/RJW_Patch.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; +using HarmonyLib; using rjw; using Verse; @@ -11,76 +6,76 @@ using Verse; namespace RJW_Menstruation { - [HarmonyPatch(typeof(PregnancyHelper), "impregnate")] - public static class impregnate_Patch - { - public static bool Prefix(Pawn pawn, Pawn partner, xxx.rjwSextype sextype = xxx.rjwSextype.None) - { - if (sextype == xxx.rjwSextype.Vaginal) - { - var pawnpartBPR = Genital_Helper.get_genitalsBPR(pawn); - var pawnparts = Genital_Helper.get_PartsHediffList(pawn, pawnpartBPR); - var partnerpartBPR = Genital_Helper.get_genitalsBPR(partner); - var partnerparts = Genital_Helper.get_PartsHediffList(partner, partnerpartBPR); - - if (Genital_Helper.has_vagina(partner, partnerparts)) - { - if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; - HediffComp_Menstruation comp = Utility.GetMenstruationComp(partner); - if (comp != null) - { - if (Genital_Helper.has_penis_fertile(pawn, pawnparts) && PregnancyHelper.CanImpregnate(pawn, partner, sextype)) - { - PregnancyHelper.Doimpregnate(pawn, partner); - return false; - } - else comp.CumIn(pawn, pawn.GetCumVolume(), 0); - } - } - else if (Genital_Helper.has_vagina(pawn, pawnparts)) - { - if (pawn.IsAnimal() && !Configurations.EnableAnimalCycle) return true; - HediffComp_Menstruation comp = Utility.GetMenstruationComp(pawn); - if (comp != null) - { - if (Genital_Helper.has_penis_fertile(partner, partnerparts) && PregnancyHelper.CanImpregnate(partner, pawn, sextype)) - { - PregnancyHelper.Doimpregnate(partner, pawn); - return false; - } - else comp.CumIn(partner, partner.GetCumVolume(), 0); - } - } - } - return true; - - - } - } - - [HarmonyPatch(typeof(PregnancyHelper), "Doimpregnate")] - public static class Doimpregnate_Patch - { - public static bool Prefix(Pawn pawn, Pawn partner) // partner has vagina - { - if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; - HediffComp_Menstruation comp = partner.GetMenstruationComp(); - if (comp != null) + [HarmonyPatch(typeof(PregnancyHelper), "impregnate")] + public static class impregnate_Patch + { + public static bool Prefix(Pawn pawn, Pawn partner, xxx.rjwSextype sextype = xxx.rjwSextype.None) + { + if (sextype == xxx.rjwSextype.Vaginal) { - if (AndroidsCompatibility.IsAndroid(pawn) && !AndroidsCompatibility.AndroidPenisFertility(pawn)) - { - comp.CumIn(pawn, pawn.GetCumVolume(), 0); - return false; - } - else comp.CumIn(pawn, pawn.GetCumVolume(), pawn.health.capacities.GetLevel(xxx.reproduction)); - return false; - } - ModLog.Message("used original rjw method: Comp missing"); - return true; - } - } + var pawnpartBPR = Genital_Helper.get_genitalsBPR(pawn); + var pawnparts = Genital_Helper.get_PartsHediffList(pawn, pawnpartBPR); + var partnerpartBPR = Genital_Helper.get_genitalsBPR(partner); + var partnerparts = Genital_Helper.get_PartsHediffList(partner, partnerpartBPR); + + if (Genital_Helper.has_vagina(partner, partnerparts)) + { + if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; + HediffComp_Menstruation comp = Utility.GetMenstruationComp(partner); + if (comp != null) + { + if (Genital_Helper.has_penis_fertile(pawn, pawnparts) && PregnancyHelper.CanImpregnate(pawn, partner, sextype)) + { + PregnancyHelper.Doimpregnate(pawn, partner); + return false; + } + else comp.CumIn(pawn, pawn.GetCumVolume(), 0); + } + } + else if (Genital_Helper.has_vagina(pawn, pawnparts)) + { + if (pawn.IsAnimal() && !Configurations.EnableAnimalCycle) return true; + HediffComp_Menstruation comp = Utility.GetMenstruationComp(pawn); + if (comp != null) + { + if (Genital_Helper.has_penis_fertile(partner, partnerparts) && PregnancyHelper.CanImpregnate(partner, pawn, sextype)) + { + PregnancyHelper.Doimpregnate(partner, pawn); + return false; + } + else comp.CumIn(partner, partner.GetCumVolume(), 0); + } + } + } + return true; + + + } + } + + [HarmonyPatch(typeof(PregnancyHelper), "Doimpregnate")] + public static class Doimpregnate_Patch + { + public static bool Prefix(Pawn pawn, Pawn partner) // partner has vagina + { + if (partner.IsAnimal() && !Configurations.EnableAnimalCycle) return true; + HediffComp_Menstruation comp = partner.GetMenstruationComp(); + if (comp != null) + { + if (AndroidsCompatibility.IsAndroid(pawn) && !AndroidsCompatibility.AndroidPenisFertility(pawn)) + { + comp.CumIn(pawn, pawn.GetCumVolume(), 0); + return false; + } + else comp.CumIn(pawn, pawn.GetCumVolume(), pawn.health.capacities.GetLevel(xxx.reproduction)); + return false; + } + ModLog.Message("used original rjw method: Comp missing"); + return true; + } + } + - diff --git a/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj b/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj index dbb1a2f..21b8c0a 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj +++ b/source/RJW_Menstruation/RJW_Menstruation/RJW_Menstruation.csproj @@ -43,7 +43,7 @@ AnyCPU pdbonly true - bin\Release\ + ..\..\..\Assemblies\ TRACE prompt 4 @@ -92,6 +92,7 @@ ..\..\..\..\RJW\1.2\Assemblies\RJW.dll False + ..\..\..\..\..\RimWorldWin64_Data\Managed\Unity.TextMeshPro.dll False diff --git a/source/RJW_Menstruation/RJW_Menstruation/Reflect.cs b/source/RJW_Menstruation/RJW_Menstruation/Reflect.cs index 1fa5898..cba2c61 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Reflect.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Reflect.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Reflection; -using RimWorld; namespace RJW_Menstruation { diff --git a/source/RJW_Menstruation/RJW_Menstruation/Things.cs b/source/RJW_Menstruation/RJW_Menstruation/Things.cs index cfe8c1d..700b5e3 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Things.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Things.cs @@ -1,26 +1,83 @@ using System; +using System.Xml; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using RimWorld; -using Verse; using rjw; using UnityEngine; +using Verse; namespace RJW_Menstruation { - public class PawnDNAModExtention : DefModExtension + public class PawnDNAModExtension : DefModExtension { public string fetusTexPath; public ColorInt cumColor; public Color CumColor => cumColor.ToColor; public float cumThickness = 0f; + public List hybridExtension; + + public HybridExtension GetHybridExtention(string race) + { + if (hybridExtension.NullOrEmpty()) return null; + else + { + return hybridExtension.Find(x => x.thingDef.defName.Equals(race)); + } + } + + public PawnKindDef GetHybridWith(string race) + { + return GetHybridExtention(race)?.ChooseOne() ?? null; + } + } + + public class HybridExtension + { + + public Dictionary hybridInfo; + public ThingDef thingDef; + + public HybridExtension() { } + + public PawnKindDef ChooseOne() + { + if (hybridInfo.EnumerableNullOrEmpty()) return null; + PawnKindDef res = null; + do + { + res = DefDatabase.GetNamedSilentFail(hybridInfo.RandomElementByWeight(x => x.Value).Key); + if (res == null) res = DefDatabase.GetNamedSilentFail(hybridInfo.RandomElementByWeight(x => x.Value).Key).race.AnyPawnKind; + + if (res == null) hybridInfo.Remove(res.defName); + } while (res == null && !hybridInfo.EnumerableNullOrEmpty()); + + return res; + } + + + public void LoadDataFromXmlCustom(XmlNode xmlRoot) + { + hybridInfo = new Dictionary(); + DirectXmlCrossRefLoader.RegisterObjectWantsCrossRef(this, "thingDef", xmlRoot.Name); + XmlNodeList childNodes = xmlRoot.ChildNodes; + + if (childNodes.Count >= 1) foreach (XmlNode node in childNodes) + { + //Log.Message(xmlRoot.Name + "HybridInfo: " + node.Name + " " + node.InnerText); + hybridInfo.Add(node.Name, ParseHelper.FromString(node.InnerText)); + } + + + + } } - public class AbsorberModExtention : DefModExtension + + + + public class AbsorberModExtension : DefModExtension { public bool leakAfterDirty = false; public bool effectsAfterDirty = false; @@ -34,20 +91,20 @@ namespace RJW_Menstruation public float absorbedfluids = 0; public bool dirty = false; public int wearhours = 0; - public virtual bool LeakAfterDirty => def.GetModExtension().leakAfterDirty; - public virtual bool EffectAfterDirty => def.GetModExtension().effectsAfterDirty; - public virtual ThingDef DirtyDef => def.GetModExtension().dirtyDef; - public virtual int MinHrstoDirtyEffect => def.GetModExtension().minHourstoDirtyEffect; + public virtual bool LeakAfterDirty => def.GetModExtension().leakAfterDirty; + public virtual bool EffectAfterDirty => def.GetModExtension().effectsAfterDirty; + public virtual ThingDef DirtyDef => def.GetModExtension().dirtyDef; + public virtual int MinHrstoDirtyEffect => def.GetModExtension().minHourstoDirtyEffect; public Color fluidColor = Color.white; - - public virtual void DirtyEffect() {} - public virtual void WearEffect() + public virtual void DirtyEffect() { } + + public virtual void WearEffect() { - absorbedfluids+=0.1f; + absorbedfluids += 0.1f; wearhours++; } diff --git a/source/RJW_Menstruation/RJW_Menstruation/Translations.cs b/source/RJW_Menstruation/RJW_Menstruation/Translations.cs index eb8fdce..47d1249 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Translations.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Translations.cs @@ -32,47 +32,47 @@ namespace RJW_Menstruation public static readonly string Option1_Label_1 = "Option1_Label_1".Translate(); - public static readonly string Option1_Label_2 = "Option1_Label_2".Translate(); + public static readonly string Option1_Label_2 = "Option1_Label_2".Translate(); public static readonly string Option2_Label = "Option2_Label".Translate(); - public static readonly string Option2_Desc = "Option2_Desc".Translate(); + public static readonly string Option2_Desc = "Option2_Desc".Translate(); public static readonly string Option3_Label = "Option3_Label".Translate(); - public static readonly string Option3_Desc = "Option3_Desc".Translate(); + public static readonly string Option3_Desc = "Option3_Desc".Translate(); public static readonly string Option4_Label = "Option4_Label".Translate(); - public static readonly string Option4_Desc = "Option4_Desc".Translate(); + public static readonly string Option4_Desc = "Option4_Desc".Translate(); public static readonly string Option5_Label = "Option5_Label".Translate(); - public static readonly string Option5_Desc = "Option5_Desc".Translate(); + public static readonly string Option5_Desc = "Option5_Desc".Translate(); public static readonly string Option6_Label = "Option6_Label".Translate(); - public static readonly string Option6_Desc = "Option6_Desc".Translate(); + public static readonly string Option6_Desc = "Option6_Desc".Translate(); public static readonly string Option7_Label = "Option7_Label".Translate(); - public static readonly string Option7_Desc = "Option7_Desc".Translate(); + public static readonly string Option7_Desc = "Option7_Desc".Translate(); public static readonly string Option8_Label = "Option8_Label".Translate(); - public static readonly string Option8_Desc = "Option8_Desc".Translate(); + public static readonly string Option8_Desc = "Option8_Desc".Translate(); public static readonly string Option9_Label = "Option9_Label".Translate(); - public static readonly string Option9_Desc = "Option9_Desc".Translate(); + public static readonly string Option9_Desc = "Option9_Desc".Translate(); public static readonly string Option10_Label = "Option10_Label".Translate(); - public static readonly string Option10_Desc = "Option10_Desc".Translate(); + public static readonly string Option10_Desc = "Option10_Desc".Translate(); public static readonly string Option11_Label = "Option11_Label".Translate(); - public static readonly string Option11_Desc_1 = "Option11_Desc_1".Translate(); - public static readonly string Option11_Desc_2 = "Option11_Desc_2".Translate(); - public static readonly string Option11_Desc_3 = "Option11_Desc_3".Translate(); - public static readonly string Option11_Desc_4 = "Option11_Desc_4".Translate(); + public static readonly string Option11_Desc_1 = "Option11_Desc_1".Translate(); + public static readonly string Option11_Desc_2 = "Option11_Desc_2".Translate(); + public static readonly string Option11_Desc_3 = "Option11_Desc_3".Translate(); + public static readonly string Option11_Desc_4 = "Option11_Desc_4".Translate(); public static readonly string Option12_Label = "Option12_Label".Translate(); - public static readonly string Option12_Desc = "Option12_Desc".Translate(); + public static readonly string Option12_Desc = "Option12_Desc".Translate(); public static readonly string Option13_Label = "Option13_Label".Translate(); - public static readonly string Option13_Desc = "Option13_Desc".Translate(); + public static readonly string Option13_Desc = "Option13_Desc".Translate(); public static readonly string Option14_Label = "Option14_Label".Translate(); - public static readonly string Option14_Desc = "Option14_Desc".Translate(); + public static readonly string Option14_Desc = "Option14_Desc".Translate(); public static readonly string Option15_Label = "Option15_Label".Translate(); - public static readonly string Option15_Desc = "Option15_Desc".Translate(); + public static readonly string Option15_Desc = "Option15_Desc".Translate(); public static readonly string Option16_Label = "Option16_Label".Translate(); - public static readonly string Option16_Desc = "Option16_Desc".Translate(); + public static readonly string Option16_Desc = "Option16_Desc".Translate(); public static readonly string Option17_Label = "Option17_Label".Translate(); - public static readonly string Option17_Desc = "Option17_Desc".Translate(); + public static readonly string Option17_Desc = "Option17_Desc".Translate(); public static readonly string Option18_Label = "Option18_Label".Translate(); - public static readonly string Option18_Desc = "Option18_Desc".Translate(); + public static readonly string Option18_Desc = "Option18_Desc".Translate(); public static readonly string Option19_Label_1 = "Option19_Label_1".Translate(); public static readonly string Option19_Label_2 = "Option19_Label_2".Translate(); - public static readonly string Option19_Desc = "Option19_Desc".Translate(); + public static readonly string Option19_Desc = "Option19_Desc".Translate(); public static readonly string Option20_Label_1 = "Option20_Label_1".Translate(); public static readonly string Option20_Label_2 = "Option20_Label_2".Translate(); public static readonly string Option20_Label_3 = "Option20_Label_3".Translate(); @@ -80,6 +80,11 @@ namespace RJW_Menstruation public static readonly string Option20_Label_5 = "Option20_Label_5".Translate(); public static readonly string Option21_Label = "Option21_Label".Translate(); public static readonly string Option21_Desc = "Option21_Desc".Translate(); + public static readonly string Option22_Label = "Option22_Label".Translate(); + public static readonly string Option22_Desc = "Option22_Desc".Translate(); + public static readonly string Option23_Label = "Option23_Label".Translate(); + public static readonly string Option23_Label_1 = "Option23_Label_1".Translate(); + public static readonly string Option23_Label_2 = "Option23_Label_2".Translate(); public static readonly string FloatMenu_CleanSelf = "FloatMenu_CleanSelf".Translate(); diff --git a/source/RJW_Menstruation/RJW_Menstruation/Utility.cs b/source/RJW_Menstruation/RJW_Menstruation/Utility.cs index b1c31d4..034d124 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/Utility.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/Utility.cs @@ -1,21 +1,16 @@ -using System; -using System.Runtime.Serialization.Formatters.Binary; -using System.IO; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Verse; +using RimWorld; using rjw; -using RimWorld; +using System; +using System.Linq; using UnityEngine; +using Verse; namespace RJW_Menstruation { public static class Colors { public static Color blood = new Color(0.78f, 0, 0); - + public static Color CMYKLerp(Color a, Color b, float t) { @@ -27,14 +22,14 @@ namespace RJW_Menstruation public static void RGBtoCMYK(Color rgb, out float c, out float m, out float y, out float k) { - k = 1 - Math.Max(rgb.r,Math.Max(rgb.g,rgb.b)); + k = 1 - Math.Max(rgb.r, Math.Max(rgb.g, rgb.b)); c = (1 - rgb.r - k) / (1 - k); m = (1 - rgb.g - k) / (1 - k); y = (1 - rgb.b - k) / (1 - k); } - public static Color CMYKtoRGB(float c,float m, float y, float k) + public static Color CMYKtoRGB(float c, float m, float y, float k) { return new Color((1 - c) * (1 - k), (1 - m) * (1 - k), (1 - y) * (1 - k)); } @@ -46,7 +41,7 @@ namespace RJW_Menstruation public static class Utility { - + public static float GetCumVolume(this Pawn pawn) @@ -65,7 +60,7 @@ namespace RJW_Menstruation { res = 0.0f; } - if (pawn.Has(Quirk.Messy)) res *= Rand.Range(4.0f,8.0f); + if (pawn.Has(Quirk.Messy)) res *= Rand.Range(4.0f, 8.0f); return res; } @@ -178,7 +173,7 @@ namespace RJW_Menstruation else if (hediff is Hediff_BasePregnancy) { Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff; - string fetustex = h.babies?.FirstOrDefault()?.def.GetModExtension()?.fetusTexPath ?? "Fetus/Fetus_Default"; + string fetustex = h.babies?.FirstOrDefault()?.def.GetModExtension()?.fetusTexPath ?? "Fetus/Fetus_Default"; if (h.GestationProgress < 0.2f) icon = comp.wombTex + "_Implanted"; else if (h.GestationProgress < 0.3f) icon += "Fetus/Fetus_Early00"; else if (h.GestationProgress < 0.4f) icon += fetustex + "00"; @@ -310,24 +305,24 @@ namespace RJW_Menstruation { if (pawn.Faction.IsPlayer) { - if (Configurations.ShowFlag.HasFlag(Configurations.PawnFlags.Colonist)) return true; + if ((Configurations.ShowFlag & Configurations.PawnFlags.Colonist) != 0) return true; } else if (pawn.IsPrisonerOfColony) { - if (Configurations.ShowFlag.HasFlag(Configurations.PawnFlags.Prisoner)) return true; + if ((Configurations.ShowFlag & Configurations.PawnFlags.Prisoner) != 0) return true; } else if (pawn.Faction.PlayerRelationKind == FactionRelationKind.Ally) { - if (Configurations.ShowFlag.HasFlag(Configurations.PawnFlags.Ally)) return true; + if ((Configurations.ShowFlag & Configurations.PawnFlags.Ally) != 0) return true; } else if (pawn.Faction.PlayerRelationKind == FactionRelationKind.Hostile) { - if (Configurations.ShowFlag.HasFlag(Configurations.PawnFlags.Hostile)) return true; + if ((Configurations.ShowFlag & Configurations.PawnFlags.Hostile) != 0) return true; } - else if (Configurations.ShowFlag.HasFlag(Configurations.PawnFlags.Neutral)) return true; + else if ((Configurations.ShowFlag & Configurations.PawnFlags.Neutral) != 0) return true; else return false; } - else if (Configurations.ShowFlag.HasFlag(Configurations.PawnFlags.Neutral)) return true; + else if ((Configurations.ShowFlag & Configurations.PawnFlags.Neutral) != 0) return true; return false; } @@ -345,7 +340,7 @@ namespace RJW_Menstruation public static void DrawEggOverlay(this HediffComp_Menstruation comp, Rect wombRect) { - Rect rect = new Rect(wombRect.xMax - wombRect.width/3, wombRect.y, wombRect.width / 3, wombRect.width / 3); + Rect rect = new Rect(wombRect.xMax - wombRect.width / 3, wombRect.y, wombRect.width / 3, wombRect.width / 3); GUI.color = Color.white; GUI.DrawTexture(rect, comp.GetEggIcon(), ScaleMode.ScaleToFit); } diff --git a/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs b/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs index 30ece9b..b13ea37 100644 --- a/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs +++ b/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Verse; -using RimWorld; +using RimWorld; using rjw; +using System.Linq; +using Verse; namespace RJW_Menstruation {