Basic cleanup of errors related to new rimworld API

This commit is contained in:
lutepickle 2022-10-23 19:23:00 -07:00
parent 908eb01a50
commit 6b3044488d
15 changed files with 61 additions and 41 deletions

Binary file not shown.

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>

Binary file not shown.

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MilkModule</RootNamespace>
<AssemblyName>MilkModule</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -94,8 +95,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lib.Harmony">
<Version>2.1.1</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<Version>2.2.2</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>

View File

@ -19,7 +19,6 @@ namespace RJW_Menstruation
AlienPartGenerator.AlienComp babyHARComp = baby?.TryGetComp<AlienPartGenerator.AlienComp>();
AlienPartGenerator.AlienComp originalHARComp = original?.TryGetComp<AlienPartGenerator.AlienComp>();
if (babyHARComp == null || originalHARComp == null) return;
babyHARComp.crownType = originalHARComp.crownType;
foreach(KeyValuePair<string, AlienPartGenerator.ExposableValueTuple<Color, Color>> channel in originalHARComp.ColorChannels)
{

View File

@ -213,8 +213,11 @@ namespace RJW_Menstruation
if ((Pawn.relations == null)) return youngestAge;
List<Hediff_BasePregnancy> pregnancies = new List<Hediff_BasePregnancy>();
Pawn.health.hediffSet.GetHediffs(ref pregnancies);
bool hasChild = Pawn.relations.Children.
Where(child => !Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().Any(preg => preg.babies.Contains(child))). // no fetuses
Where(child => !pregnancies.Any(preg => preg.babies.Contains(child))). // no fetuses
Where(child => child.GetMother() == Pawn). // not Dad
TryMinBy(child => child.ageTracker.AgeBiologicalTicks, out Pawn youngest);

View File

@ -1223,7 +1223,7 @@ namespace RJW_Menstruation
deadeggs.Add(egg);
continue;
}
else if (Pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>().Any() || pregnancy is Hediff_MechanoidPregnancy)
else if (Pawn.health.hediffSet.GetFirstHediff<Hediff_InsectEgg>() != null || pregnancy is Hediff_MechanoidPregnancy)
{
if (Configurations.Debug) Log.Message($"Could not implant {Pawn}'s egg due to insect or mechanoid pregnancy");
deadeggs.Add(egg);
@ -1257,7 +1257,9 @@ namespace RJW_Menstruation
if (Configurations.Debug) Log.Message($"Creating new base RJW pregnancy");
PregnancyHelper.PregnancyDecider(Pawn, egg.fertilizer);
// I hate having to do this, but it gets the newest pregnancy
pregnancy = Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxBy(hediff => hediff.loadID);
List<Hediff_BasePregnancy> pregnancies = new List<Hediff_BasePregnancy>();
Pawn.health.hediffSet.GetHediffs(ref pregnancies);
pregnancy = pregnancies.MaxBy(hediff => hediff.loadID);
pregnant = true;
break;
}
@ -1754,8 +1756,11 @@ namespace RJW_Menstruation
{
if (pregnancy != null) return;
List<Hediff_BasePregnancy> pregnancies = new List<Hediff_BasePregnancy>();
Pawn.health.hediffSet.GetHediffs(ref pregnancies);
pregnancy =
Pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().Except(
pregnancies.Except(
Pawn.GetMenstruationComps().Select(comp => comp.pregnancy).Where(preg => preg != null)
).FirstOrDefault();
if (pregnancy != null)

View File

@ -158,7 +158,9 @@ namespace RJW_Menstruation
}
public static Texture2D GetInsectEggedIcon(this HediffComp_Menstruation comp)
{
List<Hediff_InsectEgg> hediffs = comp.Pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>().ToList();
List<Hediff_InsectEgg> hediffs = new List<Hediff_InsectEgg>();
comp.Pawn.health.hediffSet.GetHediffs(ref hediffs);
if (hediffs.NullOrEmpty()) return null;
string path = "Womb/Insect_Egged/";
if (hediffs.Max(hediff => hediff.eggssize) > 0.3) // The threshold for "large egg" in the debug

View File

@ -375,34 +375,34 @@ namespace RJW_Menstruation
public bool AddNewBaby(Pawn mother, Pawn father)
{
float melanin;
//float melanin;
string lastname;
if (xxx.is_human(mother))
{
if (xxx.is_human(father))
{
melanin = ChildRelationUtility.GetRandomChildSkinColor(father.story?.melanin ?? 0f, mother.story?.melanin ?? 0f);
//melanin = ChildRelationUtility.GetRandomChildSkinColor(father.story?.melanin ?? 0f, mother.story?.melanin ?? 0f);
//melanin = (mother.story?.melanin ?? 0f + father.story?.melanin ?? 0f) / 2;
}
else
{
melanin = mother.story?.melanin ?? 0f;
//melanin = mother.story?.melanin ?? 0f;
}
lastname = NameTriple.FromString(mother.Name.ToStringFull).Last;
}
else if (xxx.is_human(father))
{
melanin = father.story?.melanin ?? 0f;
//melanin = father.story?.melanin ?? 0f;
lastname = NameTriple.FromString(father.Name.ToStringFull).Last;
}
else
{
melanin = Rand.Range(0, 1.0f);
//melanin = Rand.Range(0, 1.0f);
lastname = "";
}
PawnGenerationRequest request = new PawnGenerationRequest(
newborn: true,
developmentalStages: DevelopmentalStage.Newborn,
allowDowned: true,
faction: mother.Faction,
canGeneratePawnRelations: false,
@ -411,7 +411,7 @@ namespace RJW_Menstruation
allowFood: false,
allowAddictions: false,
relationWithExtraPawnChanceFactor: 0,
fixedMelanin: melanin,
//fixedMelanin: melanin,
fixedLastName: lastname,
kind: BabyPawnKindDecider(mother, father),
//fixedIdeo: mother.Ideo,
@ -421,7 +421,7 @@ namespace RJW_Menstruation
int division = 1;
Pawn firstbaby = null;
string firstheadpath = null;
//string firstheadpath = null;
int traitSeed = Rand.Int;
List<Trait> parentTraits = GetInheritableTraits(mother, father);
while (Rand.Chance(Configurations.EnzygoticTwinsChance) && division < Configurations.MaxEnzygoticTwins) division++;
@ -438,13 +438,13 @@ namespace RJW_Menstruation
if (baby.story != null)
{
firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
if (firstheadpath == null)
{
Graphic_Multi head = GraphicDatabaseHeadRecords.GetHeadRandom(baby.gender, baby.story.SkinColor, baby.story.crownType, true);
if (head != null) baby.story.SetMemberValue("headGraphicPath", head.GraphicPath);
firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
}
// firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
// if (firstheadpath == null)
// {
// Graphic_Multi head = GraphicDatabaseHeadRecords.GetHeadRandom(baby.gender, baby.story.SkinColor, baby.story.crownType, true);
// if (head != null) baby.story.SetMemberValue("headGraphicPath", head.GraphicPath);
// firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath");
// }
}
}
else
@ -454,16 +454,16 @@ namespace RJW_Menstruation
if (baby.story != null)
{
baby.story.hairDef = firstbaby.story.hairDef;
baby.story.hairColor = firstbaby.story.hairColor;
//baby.story.hairColor = firstbaby.story.hairColor;
baby.story.bodyType = firstbaby.story.bodyType;
baby.story.crownType = firstbaby.story.crownType;
baby.story.SetMemberValue("headGraphicPath", firstheadpath);
//baby.story.crownType = firstbaby.story.crownType;
//baby.story.SetMemberValue("headGraphicPath", firstheadpath);
}
if (baby.IsHAR())
HARCompatibility.CopyHARProperties(baby, firstbaby);
if (Configurations.AnimalGeneticsActivated)
AnimalGeneticsCompatibility.CopyGenes(baby, firstbaby);
//if (Configurations.AnimalGeneticsActivated)
//AnimalGeneticsCompatibility.CopyGenes(baby, firstbaby);
}
}
babies.Add(baby);
@ -475,9 +475,9 @@ namespace RJW_Menstruation
public Pawn GenerateBaby(PawnGenerationRequest request, Pawn mother, Pawn father, List<Trait> parentTraits, int traitSeed)
{
if (Configurations.AnimalGeneticsActivated) AnimalGeneticsCompatibility.PreConception(mother, father);
//if (Configurations.AnimalGeneticsActivated) AnimalGeneticsCompatibility.PreConception(mother, father);
Pawn baby = PawnGenerator.GeneratePawn(request);
if (Configurations.AnimalGeneticsActivated) AnimalGeneticsCompatibility.PostConception();
//if (Configurations.AnimalGeneticsActivated) AnimalGeneticsCompatibility.PostConception();
if (baby == null)
{
Log.Error("Baby not generated. Request: " + request.ToString());

View File

@ -78,7 +78,7 @@ namespace RJW_Menstruation
}
else
{
Hediff hediff = pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>().FirstOrDefault();
Hediff hediff = pawn.health.hediffSet.GetFirstHediff<Hediff_InsectEgg>();
if (hediff != null)
{
icon = MenstruationUtility.GetInsectEggedIcon(comp);
@ -103,7 +103,7 @@ namespace RJW_Menstruation
shrinkable = Configurations.AllowShrinkIcon,
cumcolor = c,
comp = comp,
order = 100,
//order = 100,
hotKey = comp == pawn.GetFirstMenstruationComp() ? VariousDefOf.OpenStatusWindowKey : null,
groupKey = 0,
action = delegate

View File

@ -53,7 +53,7 @@ namespace RJW_Menstruation
{
Pawn pawn = props.partner;
if (props.sexType != xxx.rjwSextype.MechImplant && !pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>().Any()) return;
if (props.sexType != xxx.rjwSextype.MechImplant && pawn.health.hediffSet.GetFirstHediff<Hediff_InsectEgg>() == null) return;
// The existing pregnancies might have been destroyed, so go through see if any new mech pregnancies need to be picked up
foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps())

View File

@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<RootNamespace>RJW_Menstruation</RootNamespace>
<AssemblyName>RJW_Menstruation</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
@ -27,6 +27,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>

View File

@ -13,7 +13,7 @@ namespace RJW_Menstruation
public override void DrawIcon(Rect rect, Material buttonMat, GizmoRenderParms parms)
{
Texture2D badTex = icon;
Texture badTex = icon;
Texture2D overay = icon_overay;
Color color = cumcolor;

View File

@ -138,12 +138,14 @@ namespace RJW_Menstruation
public static bool IsRJWPregnant(this Pawn pawn)
{
return pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().Any();
return pawn.health.hediffSet.GetFirstHediff<Hediff_BasePregnancy>() != null;
}
public static float GetFarthestPregnancyProgress(this Pawn pawn)
{
return pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxByWithFallback(hediff => hediff.GestationProgress)?.GestationProgress ?? 0;
List<Hediff_BasePregnancy> pregnancies = new List<Hediff_BasePregnancy>();
pawn.health.hediffSet.GetHediffs(ref pregnancies);
return pregnancies.MaxByWithFallback(hediff => hediff.GestationProgress)?.GestationProgress ?? 0;
}
public static float GetPregnancyProgress(this HediffComp_Menstruation comp)