quirk system framework and parent fix

This commit is contained in:
Jaaldabaoth 2024-05-30 19:12:22 +02:00
parent ed7473ddfd
commit 6be8eea53e
14 changed files with 230 additions and 23 deletions

Binary file not shown.

View file

@ -82,11 +82,12 @@
<defName>rjw_genes_sexual_mytosis</defName> <defName>rjw_genes_sexual_mytosis</defName>
<label>Orgasmic Mytosis</label> <label>Orgasmic Mytosis</label>
<!-- <geneClass>RJW_Genes.Gene_Aphrodisiac_Pheromones</geneClass> --> <!-- <geneClass>RJW_Genes.Gene_Aphrodisiac_Pheromones</geneClass> -->
<description>Carriers of this gene grow more unstable with ongoing multiple orgasms - climaxing in a process of mytosis. This will result in an (biologically) identical pawn and both twins are set in a regenerative state. Also, the pawn can have multiple orgasms: In a state of higher unstableness, they come quicker.</description> <description>Carriers have malfunctioning regenerative archites that grow more unstable with ongoing multiple orgasms - climaxing in a process of mytosis. This will result in an (biologically) identical pawn and both twins are set in a regenerative state. Also, the pawn can have multiple orgasms: In a state of higher unstableness, they come quicker.</description>
<iconPath>UI/Icons/Genes/Gene_PsychicBonding</iconPath> <iconPath>UI/Icons/Genes/Gene_PsychicBonding</iconPath>
<displayOrderInCategory>5</displayOrderInCategory> <displayOrderInCategory>5</displayOrderInCategory>
<biostatCpx>5</biostatCpx> <biostatCpx>5</biostatCpx>
<biostatMet>-5</biostatMet> <biostatMet>-5</biostatMet>
<biostatArc>1</biostatArc>
</GeneDef> </GeneDef>
<GeneDef ParentName="SpecialBase"> <GeneDef ParentName="SpecialBase">

View file

@ -5,5 +5,7 @@
<li>Common</li> <li>Common</li>
<!-- Mods --> <!-- Mods -->
<li IfModNotActive="asmr.rjw.racesupport">Mods/NotRaceSupport</li> <li IfModNotActive="asmr.rjw.racesupport">Mods/NotRaceSupport</li>
<li IfModActive="vanillaracesexpanded.waster">Mods/VREwaster</li>
</v1.5> </v1.5>
</loadFolders> </loadFolders>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<GeneDef ParentName="VREW_MutationBase">
<defName>rjw_genes_mytosis_mutation</defName>
<label>Polluted orgasmic Mytosis</label>
<!-- <geneClass>RJW_Genes.Gene_Aphrodisiac_Pheromones</geneClass> -->
<description>Carriers of this gene grow more unstable with ongoing multiple orgasms in a polluted environnement - climaxing in a process of mytosis. This will result in an (biologically) identical pawn and both twins are set in a regenerative state. Also, the pawn can have multiple orgasms: In a state of higher unstableness, they come quicker.</description>
<iconPath>UI/Icons/Genes/Gene_PsychicBonding</iconPath>
<displayOrderInCategory>-1</displayOrderInCategory>
<biostatCpx>1</biostatCpx>
<biostatMet>-1</biostatMet>
<modExtensions>
<li Class="VanillaGenesExpanded.GeneExtension">
<backgroundPathEndogenes>UI/Icons/Genes/GeneBackground_PollutionMutation</backgroundPathEndogenes>
</li>
</modExtensions>
</GeneDef>
</Defs>

View file

@ -125,5 +125,43 @@ namespace RJW_Genes
} }
} }
} }
[HarmonyPrefix]
[HarmonyPatch("SetFather")]
private static bool SetFatherPrefix(Pawn pawn, Pawn newFather)
{
Pawn father = pawn.GetFather();
if (father != newFather)
{
if (father != null)
{
pawn.relations.RemoveDirectRelation(PawnRelationDefOf.Parent, father);
}
if (newFather != null)
{
pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, newFather);
}
}
return false;
}
[HarmonyPrefix]
[HarmonyPatch("SetMother")]
private static bool SetMotherPrefix(Pawn pawn, Pawn newMother)
{
Pawn mother = pawn.GetMother();
if (mother != newMother)
{
if (mother != null)
{
pawn.relations.RemoveDirectRelation(PawnRelationDefOf.Parent, mother);
}
if (newMother != null)
{
pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, newMother);
}
}
return false;
}
} }
} }

View file

@ -114,6 +114,9 @@ namespace RJW_Genes
public static readonly GeneDef rjw_genes_cockeater; public static readonly GeneDef rjw_genes_cockeater;
public static readonly GeneDef rjw_genes_lifeforce_empath; public static readonly GeneDef rjw_genes_lifeforce_empath;
//waster
[MayRequire("vanillaracesexpanded.waster")] public static readonly GeneDef rjw_genes_mytosis_mutation;
//Other Defs //Other Defs
public static readonly XenotypeDef rjw_genes_succubus; public static readonly XenotypeDef rjw_genes_succubus;
public static readonly DutyDef rjw_genes_flirt; public static readonly DutyDef rjw_genes_flirt;

View file

@ -0,0 +1,12 @@
using Verse;
using RimWorld;
using rjw;
namespace RJW_Genes
{
public class QirkExtension : DefModExtension
{
public Quirk Satisfiedquirk;
}
}

View file

@ -0,0 +1,36 @@
using Verse;
using RimWorld;
using rjw;
using System.Collections.Generic;
using rjw.Modules.Quirks;
namespace RJW_Genes
{
public class QuirkPatcher
{
public static void CountSatisfiedPostfix(ref int __result, SexProps props)
{
Pawn pawn = props.pawn;
Pawn partner = props.partner;
int count= 0;
List<Quirk> listquirk= new List<Quirk>();
foreach(Gene g in partner.genes.GenesListForReading) {
if (partner.genes.HasActiveGene(g.def))
{
listquirk.Add(g.def?.GetModExtension<QirkExtension>().Satisfiedquirk);
}
}
foreach (Quirk q in listquirk)
{
if (pawn.Has(q)){
count++;
}
}
__result = __result + count;
return;
}
}
}

View file

@ -1,5 +1,6 @@
using HarmonyLib; using HarmonyLib;
using RimWorld; using RimWorld;
using RimWorld.BaseGen;
using RimWorld.QuestGen; using RimWorld.QuestGen;
using rjw; using rjw;
using rjw.Modules.Shared.Extensions; using rjw.Modules.Shared.Extensions;
@ -9,6 +10,8 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Verse; using Verse;
using VanillaRacesExpandedWaster;
namespace RJW_Genes namespace RJW_Genes
{ {
@ -23,14 +26,26 @@ namespace RJW_Genes
{ {
private const float SEVERITY_INCREASE_PER_ORGASM = 0.075f; private const float SEVERITY_INCREASE_PER_ORGASM = 0.075f;
public static Def mytosis_mutation = DefDatabase<GeneDef>.GetNamed("rjw_genes_mytosis_mutation",false);
public static void Postfix(JobDriver_Sex __instance) public static void Postfix(JobDriver_Sex __instance)
{ {
Pawn orgasmingPawn = __instance.pawn; Pawn orgasmingPawn = __instance.pawn;
if (orgasmingPawn != null && GeneUtility.HasGeneNullCheck(orgasmingPawn, GeneDefOf.rjw_genes_sexual_mytosis) && ! orgasmingPawn.health.hediffSet.HasHediff(HediffDefOf.rjw_genes_mytosis_shock_hediff)) bool hasPollutedMytosis = false;
if (mytosis_mutation != null)
{
if (GeneUtility.HasGeneNullCheck(orgasmingPawn, GeneDefOf.rjw_genes_mytosis_mutation))
{
hasPollutedMytosis = true;
}
}
if (orgasmingPawn != null && (GeneUtility.HasGeneNullCheck(orgasmingPawn, GeneDefOf.rjw_genes_sexual_mytosis) || hasPollutedMytosis) && ! orgasmingPawn.health.hediffSet.HasHediff(HediffDefOf.rjw_genes_mytosis_shock_hediff))
{ {
var mytosisHediff = GetOrgasmMytosisHediff(orgasmingPawn); var mytosisHediff = GetOrgasmMytosisHediff(orgasmingPawn);
mytosisHediff.Severity += SEVERITY_INCREASE_PER_ORGASM; mytosisHediff.Severity += SEVERITY_INCREASE_PER_ORGASM;
if(hasPollutedMytosis && orgasmingPawn.Spawned && GridsUtility.IsPolluted(orgasmingPawn.Position, orgasmingPawn.Map))
{
mytosisHediff.Severity -= SEVERITY_INCREASE_PER_ORGASM;
}
if (mytosisHediff.Severity >= 1.0) if (mytosisHediff.Severity >= 1.0)
{ {
@ -295,6 +310,8 @@ namespace RJW_Genes
} }
} }
/* /*

View file

@ -0,0 +1,62 @@
using HarmonyLib;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;
using VanillaRacesExpandedWaster;
namespace RJW_Genes
{
public static class Patch_Waster
{
public static void Gene_Randomizer_Prefix(Gene_Randomizer __instance)
{
if (Patch_OrgasmMytosis.mytosis_mutation != null)
{
if (!__instance.mutationGenes.Contains(GeneDefOf.rjw_genes_mytosis_mutation))
{
__instance.mutationGenes.Add(GeneDefOf.rjw_genes_mytosis_mutation);
}
if (!__instance.mutationGenes.Contains(GeneDefOf.rjw_genes_Necro_genitalia))
{
__instance.mutationGenes.Add(GeneDefOf.rjw_genes_Necro_genitalia);
}
if (!__instance.mutationGenes.Contains(GeneDefOf.rjw_genes_Tentacle_genitalia))
{
__instance.mutationGenes.Add(GeneDefOf.rjw_genes_Tentacle_genitalia);
}
}
}
public static GeneDef VRE_GauntBody = DefDatabase<GeneDef>.GetNamed("VRE_GauntBody", false);
public static void SatisfiesTeratophile_Postfix(ref bool __result, Pawn partner)
{
if (!__result)
{
ModLog.Message("check 1");
if (VRE_GauntBody != null)
{
ModLog.Message("check 2");
if (partner.genes.HasActiveGene(VRE_GauntBody))
{
ModLog.Message("check 3");
__result = true;
return;
}
}
}
}
}
}

View file

@ -4,6 +4,7 @@ using System;
using rjw; using rjw;
using RJWLoveFeeding; using RJWLoveFeeding;
using RimWorld; using RimWorld;
using System.Linq;
namespace RJW_Genes namespace RJW_Genes
{ {
@ -22,32 +23,41 @@ namespace RJW_Genes
{ {
harmony.Patch(typeof(SexUtility).GetMethod("ProcessSex"), new HarmonyMethod(typeof(LustFeeding), "Postfix", null)); harmony.Patch(typeof(SexUtility).GetMethod("ProcessSex"), new HarmonyMethod(typeof(LustFeeding), "Postfix", null));
} }
// Non-rapist would_rape bypass for limbic stimulator
harmony.Patch(AccessTools.Method(typeof(SexAppraiser), nameof(SexAppraiser.would_rape)), harmony.Patch(AccessTools.Method(typeof(SexAppraiser), nameof(SexAppraiser.would_rape)),
postfix: new HarmonyMethod(typeof(PatchImplants), nameof(PatchImplants.would_rape_PostFix))); postfix: new HarmonyMethod(typeof(PatchImplants), nameof(PatchImplants.would_rape_PostFix)));
// Non-rapist is_rapist bypass for limbic stimulator
harmony.Patch(AccessTools.Method(typeof(xxx), nameof(xxx.is_rapist)), harmony.Patch(AccessTools.Method(typeof(xxx), nameof(xxx.is_rapist)),
postfix: new HarmonyMethod(typeof(PatchImplants), nameof(PatchImplants.is_rapist_PostFix))); postfix: new HarmonyMethod(typeof(PatchImplants), nameof(PatchImplants.is_rapist_PostFix)));
// Non-Rapist trait rape thoughts
harmony.Patch(AccessTools.Method(typeof(AfterSexUtility), nameof(AfterSexUtility.think_about_sex_Rapist)), harmony.Patch(AccessTools.Method(typeof(AfterSexUtility), nameof(AfterSexUtility.think_about_sex_Rapist)),
postfix: new HarmonyMethod(typeof(PatchImplants), nameof(PatchImplants.think_about_sex_Rapist_PostFix))); postfix: new HarmonyMethod(typeof(PatchImplants), nameof(PatchImplants.think_about_sex_Rapist_PostFix)));
// Bioscaffold double gestation speed tick
harmony.Patch(AccessTools.Method(typeof(PawnUtility), nameof(PawnUtility.BodyResourceGrowthSpeed)), harmony.Patch(AccessTools.Method(typeof(PawnUtility), nameof(PawnUtility.BodyResourceGrowthSpeed)),
postfix: new HarmonyMethod(typeof(PatchImplants), nameof(PatchImplants.MultiplyPregnancy))); postfix: new HarmonyMethod(typeof(PatchImplants), nameof(PatchImplants.MultiplyPregnancy)));
// Hediff_Labor state capture
harmony.Patch(AccessTools.Method(typeof(Hediff_Labor), nameof(Hediff_Labor.PostRemoved)), harmony.Patch(AccessTools.Method(typeof(Hediff_Labor), nameof(Hediff_Labor.PostRemoved)),
postfix: new HarmonyMethod(typeof(PatchLitteredBirth), nameof(PatchLitteredBirth.Hediff_Labor_PostRemovedPostFix))); postfix: new HarmonyMethod(typeof(PatchLitteredBirth), nameof(PatchLitteredBirth.Hediff_Labor_PostRemovedPostFix)));
// OvaryAgitator/Gene_LitteredBirths multibirth logic
harmony.Patch(AccessTools.Method(typeof(Hediff_LaborPushing), nameof(Hediff_LaborPushing.PostRemoved)), harmony.Patch(AccessTools.Method(typeof(Hediff_LaborPushing), nameof(Hediff_LaborPushing.PostRemoved)),
postfix: new HarmonyMethod(typeof(PatchLitteredBirth), nameof(PatchLitteredBirth.Hediff_LaborPushing_PostRemovedPostFix))); postfix: new HarmonyMethod(typeof(PatchLitteredBirth), nameof(PatchLitteredBirth.Hediff_LaborPushing_PostRemovedPostFix)));
// Patch Licentia, if Licentia exists
// Logic & Explanation taken from https://rimworldwiki.com/wiki/Modding_Tutorials/Compatibility_with_DLLs harmony.Patch(AccessTools.Method(typeof(Quirk), nameof(Quirk.CountSatisfiedQuirks)),
// Adjusted to use ModsConfig (which makes it work, the example above does not run out of the box) postfix: new HarmonyMethod(typeof(QuirkPatcher), nameof(QuirkPatcher.CountSatisfiedPostfix)));
Type Gene_Randomizer_Instance = null;
try
{
Gene_Randomizer_Instance = (from asm in AppDomain.CurrentDomain.GetAssemblies()
from type in asm.GetTypes()
where type.IsClass && type.Name == "Gene_Randomizer"
select type).Single();
}
catch (Exception ex) { }
Def mytosis_mutation = DefDatabase<GeneDef>.GetNamed("rjw_genes_mytosis_mutation", false);
if (mytosis_mutation != null)
{
harmony.Patch(AccessTools.Method(Gene_Randomizer_Instance, "PostAdd"),
prefix: new HarmonyMethod(typeof(Patch_Waster), nameof(Patch_Waster.Gene_Randomizer_Prefix)));
harmony.Patch(AccessTools.Method(typeof(Quirk), nameof(Quirk.SatisfiesTeratophile)),
postfix: new HarmonyMethod(typeof(Patch_Waster), nameof(Patch_Waster.SatisfiesTeratophile_Postfix)));
}
} }
} }

Binary file not shown.

Binary file not shown.

View file

@ -161,6 +161,8 @@
<Compile Include="Genes\Patches\LustFeeding.cs" /> <Compile Include="Genes\Patches\LustFeeding.cs" />
<Compile Include="Genes\Patches\MultiplePregnancies.cs" /> <Compile Include="Genes\Patches\MultiplePregnancies.cs" />
<Compile Include="Genes\Patch_AddNotifyOnGeneration.cs" /> <Compile Include="Genes\Patch_AddNotifyOnGeneration.cs" />
<Compile Include="Genes\QuirkPatching\Defs\QirkExtension.cs" />
<Compile Include="Genes\QuirkPatching\QuirkPatcher.cs" />
<Compile Include="Genes\Special\Abilities\CompAbilityEffect_CocoonWeaver.cs" /> <Compile Include="Genes\Special\Abilities\CompAbilityEffect_CocoonWeaver.cs" />
<Compile Include="Genes\Special\Abilities\CompProperties_AbilityCocoonWeaver.cs" /> <Compile Include="Genes\Special\Abilities\CompProperties_AbilityCocoonWeaver.cs" />
<Compile Include="Genes\Special\Defs\AgeTransferExtension.cs" /> <Compile Include="Genes\Special\Defs\AgeTransferExtension.cs" />
@ -168,6 +170,7 @@
<Compile Include="Genes\Special\Patches\Patch_AgeDrain.cs" /> <Compile Include="Genes\Special\Patches\Patch_AgeDrain.cs" />
<Compile Include="Genes\Special\Patches\Patch_HormonalSaliva.cs" /> <Compile Include="Genes\Special\Patches\Patch_HormonalSaliva.cs" />
<Compile Include="Genes\Special\Patches\Patch_OrgasmMytosis.cs" /> <Compile Include="Genes\Special\Patches\Patch_OrgasmMytosis.cs" />
<Compile Include="Genes\Special\Patches\Patch_Waster.cs" />
<Compile Include="Genes\Special\Thoughts\ThoughtWorker_Aphrodisiac_Pheromones_Social.cs" /> <Compile Include="Genes\Special\Thoughts\ThoughtWorker_Aphrodisiac_Pheromones_Social.cs" />
<Compile Include="LetterDefOf.cs" /> <Compile Include="LetterDefOf.cs" />
<Compile Include="Interactions\SuccubusTailjob\CompAbility_SexInteractionRequirements.cs" /> <Compile Include="Interactions\SuccubusTailjob\CompAbility_SexInteractionRequirements.cs" />
@ -203,14 +206,11 @@
<HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath> <HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="RJW, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="RJW">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\rjw\1.5\Assemblies\RJW.dll</HintPath> <HintPath>..\..\rjw\1.5\Assemblies\RJW.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="RJWSexperience"> <Reference Include="RJWSexperience">
<HintPath>..\..\rjw-sexperience\1.5\Assemblies\RJWSexperience.dll</HintPath> <HintPath>..\..\rjw-sexperience-master\1.5\Assemblies\RJWSexperience.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
@ -227,9 +227,15 @@
<HintPath>..\..\..\RimWorldWin64_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath> <HintPath>..\..\..\RimWorldWin64_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="VanillaRacesExpanded-Waster">
<HintPath>..\..\..\..\..\workshop\content\294100\2983471725\1.5\Assemblies\VanillaRacesExpanded-Waster.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Genes\Gender\Patches\" /> <Folder Include="Genes\Gender\Patches\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>