Fix HAR compatibility, copy all HAR properties for enzygotic siblings.

This commit is contained in:
lutepickle 2022-08-11 18:43:12 -07:00
parent 624ae1ce75
commit d1ceebb4e7
7 changed files with 39 additions and 20 deletions

Binary file not shown.

View File

@ -249,8 +249,8 @@ namespace RJW_Menstruation
public RJW_Menstruation(ModContentPack content) : base(content)
{
GetSettings<Configurations>();
Configurations.HARActivated = ModLister.HasActiveModWithName("Humanoid Alien Races 2.0");
Configurations.LLActivated = ModLister.HasActiveModWithName("RimJobWorld - Licentia Labs");
Configurations.HARActivated = ModLister.GetActiveModWithIdentifier("erdelf.HumanoidAlienRaces") != null;
Configurations.LLActivated = ModLister.GetActiveModWithIdentifier("LustLicentia.RJWLabs") != null;
}

View File

@ -1,4 +1,6 @@
using System.Linq;
using AlienRace;
using System.Collections.Generic;
using UnityEngine;
using Verse;
namespace RJW_Menstruation
@ -8,24 +10,38 @@ namespace RJW_Menstruation
public static bool IsHAR(this Pawn pawn)
{
return pawn.def.GetType().ToString().StartsWith("AlienRace");
if (!Configurations.HARActivated) return false;
return pawn?.def is ThingDef_AlienRace;
}
public static ThingComp GetHARComp(this Pawn pawn)
public static AlienPartGenerator.AlienComp GetHARComp(this Pawn pawn)
{
return pawn?.GetComps<ThingComp>()?.First(x => x.GetType().Namespace.EqualsIgnoreCase("AlienRace") && x.GetType().Name.EndsWith("AlienComp"));
return pawn?.TryGetComp<AlienPartGenerator.AlienComp>();
}
public static string GetHARCrown(this Pawn pawn)
public static void CopyHARProperties(Pawn baby, Pawn original)
{
return (string)pawn.GetHARComp().GetMemberValue("crownType");
AlienPartGenerator.AlienComp babyHARComp = baby.GetHARComp();
AlienPartGenerator.AlienComp originalHARComp = original.GetHARComp();
if (babyHARComp == null || originalHARComp == null) return;
babyHARComp.crownType = originalHARComp.crownType;
foreach(KeyValuePair<string, AlienPartGenerator.ExposableValueTuple<Color, Color>> channel in originalHARComp.ColorChannels)
{
babyHARComp.OverwriteColorChannel(channel.Key, channel.Value.first, channel.Value.second);
}
babyHARComp.headMaskVariant = originalHARComp.headMaskVariant;
babyHARComp.bodyMaskVariant = originalHARComp.bodyMaskVariant;
}
public static void SetHARCrown(this Pawn pawn, string crown)
// HAR doesn't populate variants until the graphics are called for, so this has to happen late
public static void CopyHARPropertiesPostBirth(Pawn baby, Pawn original)
{
pawn.GetHARComp().SetMemberValue("crownType", crown);
AlienPartGenerator.AlienComp babyHARComp = baby.GetHARComp();
AlienPartGenerator.AlienComp originalHARComp = original.GetHARComp();
if (babyHARComp == null || originalHARComp == null) return;
if (originalHARComp.addonVariants != null) // Testing has shown that the addons are valid by this point, but it's better to be safe
babyHARComp.addonVariants = new List<int>(originalHARComp.addonVariants);
}
}
}

View File

@ -238,6 +238,8 @@ namespace RJW_Menstruation
CopyBodyPartRecord(baby, original, Genital_Helper.get_genitalsBPR(baby), Genital_Helper.get_genitalsBPR(original));
CopyBodyPartRecord(baby, original, Genital_Helper.get_breastsBPR(baby), Genital_Helper.get_breastsBPR(original));
CopyBodyPartRecord(baby, original, Genital_Helper.get_anusBPR(baby), Genital_Helper.get_anusBPR(original));
if (baby.IsHAR())
HARCompatibility.CopyHARPropertiesPostBirth(baby, original);
}
public override void PostBirth(Pawn mother, Pawn father, Pawn baby)
@ -417,7 +419,6 @@ namespace RJW_Menstruation
int division = 1;
Pawn firstbaby = null;
string firstheadpath = null;
string firstHARcrown = null;
int traitSeed = Rand.Int;
List<Trait> parentTraits = GetInheritableTraits(mother, father);
while (Rand.Chance(Configurations.EnzygoticTwinsChance) && division < Configurations.MaxEnzygoticTwins) division++;
@ -442,10 +443,6 @@ namespace RJW_Menstruation
if (head != null) baby.story.SetMemberValue("headGraphicPath", head.GraphicPath);
firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
}
if (Configurations.HARActivated && baby.IsHAR())
{
firstHARcrown = baby.GetHARCrown();
}
}
else
@ -456,9 +453,9 @@ namespace RJW_Menstruation
baby.story.crownType = firstbaby.story.crownType;
baby.story.SetMemberValue("headGraphicPath", firstheadpath);
if (Configurations.HARActivated && baby.IsHAR())
if (baby.IsHAR())
{
baby.SetHARCrown(firstHARcrown);
HARCompatibility.CopyHARProperties(baby, firstbaby);
}
}
}

View File

@ -89,6 +89,10 @@
<Compile Include="VariousDefOf.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="AlienRace">
<HintPath>..\..\..\..\..\..\..\..\workshop\content\294100\839005762\1.3\Assemblies\AlienRace.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>

View File

@ -21,6 +21,7 @@
</modDependencies>
<loadAfter>
<li>brrainz.harmony</li>
<li>erdelf.HumanoidAlienRaces</li>
<li>rim.job.world</li>
<li>Abraxas.RJW.RaceSupport</li>
<li>rjw.milk.humanoid</li>

View File

@ -1,9 +1,10 @@
Version 1.0.7.1
- Null reference error fix for multiple wombs when one is pregnant.
- Nipple size/transition system rewritten to be simpler under the hood. Should work with existing saves, but you might find sizes to be different, especially for very large or very small breasts.
- Identical twins conceived after this update will have identical sex part sizes, properties, etc. upon being born.
- Replaced HugsLib-based scheduler with normal ticking. This should reduce some 'phantom cycle' bugs.
- Redone calculation to determine low eggs remaining. This should cause climacteric to be applied at a more appropriate time in the pawn's life, especially for those with very long cycles.
- Identical twins conceived after this update will have identical sex part sizes, properties, etc. upon being born.
- Identical twins of HAR races will have identical coloration, part variations, and masking.
- For modders:
- The function Hediff_MultiplePregnancy.ProcessIdenticalSibling is called on every identical sibling when born except the first. Any race-specfic genetic properties can be patched in there.
- Any mods that add comps to RJW parts should copy what they need to on a postfix to Hediff_MultiplePregnancy.CopyBodyPartProperties, e.g. how menstruation itself does in that function.