mirror of
https://gitgud.io/AbstractConcept/rimworld-animations-patch.git
synced 2024-08-15 00:43:27 +00:00
v2.0.5
- Fixed an issue with the orgasm not filling in some circumstances - Fixed a bug with sex overdrive not applying correctly - Fixed an issue with 'on orgasm' events not triggering correctly
This commit is contained in:
parent
cce0053fd6
commit
003b67fb97
14 changed files with 92 additions and 102 deletions
|
@ -108,16 +108,13 @@ namespace Rimworld_Animations_Patch
|
|||
public static void Postfix(ref JobDriver_SexBaseInitiator __instance)
|
||||
{
|
||||
// Allow solo animations to be played
|
||||
if (__instance is JobDriver_Masturbate && __instance.pawn.GetAnimationData() == null)
|
||||
{ PickMasturbationAnimation(__instance.pawn, __instance.Sexprops); }
|
||||
if (__instance is JobDriver_Masturbate && __instance.pawn.GetAnimationData() == null) PickMasturbationAnimation(__instance.pawn, __instance.Sexprops);
|
||||
|
||||
// Allow make out animations to be played
|
||||
if (__instance.pawn.GetAnimationData() == null)
|
||||
{ PickMakeOutAnimation(__instance.pawn, __instance.Sexprops); }
|
||||
if (__instance.pawn.GetAnimationData() == null) PickMakeOutAnimation(__instance.pawn, __instance.Sexprops);
|
||||
|
||||
// If there is no animation to play, exit
|
||||
if (__instance.pawn.GetAnimationData() == null)
|
||||
{ return; }
|
||||
if (__instance.pawn.GetAnimationData() == null) return;
|
||||
|
||||
// Get animation data
|
||||
List<Pawn> pawnsToAnimate = __instance.pawn.GetAllSexParticipants();
|
||||
|
@ -126,9 +123,7 @@ namespace Rimworld_Animations_Patch
|
|||
foreach (Pawn participant in pawnsToAnimate)
|
||||
{
|
||||
JobDriver_Sex jobdriver = participant.jobs.curDriver as JobDriver_Sex;
|
||||
|
||||
if (jobdriver == null)
|
||||
{ continue; }
|
||||
if (jobdriver == null) continue;
|
||||
|
||||
// Animation timing reset
|
||||
jobdriver.orgasms = 0;
|
||||
|
@ -136,7 +131,7 @@ namespace Rimworld_Animations_Patch
|
|||
jobdriver.ticksLeftThisToil = jobdriver.ticks_left;
|
||||
jobdriver.sex_ticks = orgasmTick;
|
||||
jobdriver.duration = jobdriver.sex_ticks;
|
||||
jobdriver.orgasmstick = 0;
|
||||
jobdriver.orgasmstick = 1;
|
||||
|
||||
// Reset anchor and animation for sex toys
|
||||
CompThingAnimator sexToyCompThingAnimator = ((Thing)jobdriver.job.GetTarget(TargetIndex.A)).TryGetComp<CompThingAnimator>();
|
||||
|
@ -169,7 +164,7 @@ namespace Rimworld_Animations_Patch
|
|||
public static void PickMasturbationAnimation(Pawn pawn, SexProps sexProps = null)
|
||||
{
|
||||
if (pawn.TryGetComp<CompBodyAnimator>() == null)
|
||||
{ Log.Error("Error: " + pawn.Name + " of race " + pawn.def.defName + " does not have CompBodyAnimator attached!"); return; }
|
||||
{ Log.Error("ERROR: " + pawn.Name + " of race " + pawn.def.defName + " does not have CompBodyAnimator attached!"); return; }
|
||||
|
||||
pawn.TryGetComp<CompBodyAnimator>().isAnimating = false;
|
||||
|
||||
|
@ -227,7 +222,7 @@ namespace Rimworld_Animations_Patch
|
|||
public static void PickMakeOutAnimation(Pawn pawn, SexProps sexProps = null)
|
||||
{
|
||||
if (pawn.TryGetComp<CompBodyAnimator>() == null)
|
||||
{ Log.Error("Error: " + pawn.Name + " of race " + pawn.def.defName + " does not have CompBodyAnimator attached!"); return; }
|
||||
{ Log.Error("ERROR: " + pawn.Name + " of race " + pawn.def.defName + " does not have CompBodyAnimator attached!"); return; }
|
||||
|
||||
List<Pawn> pawnsToAnimate = pawn.GetAllSexParticipants();
|
||||
|
||||
|
@ -260,58 +255,41 @@ namespace Rimworld_Animations_Patch
|
|||
[HarmonyPatch(typeof(JobDriver_Sex), "Orgasm")]
|
||||
public static class HarmonyPatch_JobDriver_Sex_Orgasm
|
||||
{
|
||||
// Stops orgasm triggering more than once per animation
|
||||
public static bool Prefix(ref JobDriver_Sex __instance)
|
||||
|
||||
public static void Prefix(ref JobDriver_Sex __instance, out bool __state)
|
||||
{
|
||||
if (__instance.orgasms > 0)
|
||||
{ return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Causes too much trouble...
|
||||
/*public static bool ParticipantsDesireMoreSex(JobDriver_Sex jobdriver)
|
||||
{
|
||||
List<Pawn> participants = jobdriver.pawn.GetAllSexParticipants();
|
||||
|
||||
float satisfaction = 0f;
|
||||
|
||||
foreach (Pawn pawn in participants)
|
||||
{
|
||||
Need_Sex sexNeed = pawn?.needs?.TryGetNeed<Need_Sex>();
|
||||
|
||||
if (sexNeed == null)
|
||||
{ satisfaction += 1; continue; }
|
||||
|
||||
satisfaction += sexNeed.CurLevelPercentage;
|
||||
}
|
||||
|
||||
return Rand.Chance(1 - satisfaction / participants.Count);
|
||||
__state = __instance.sex_ticks > __instance.orgasmstick;
|
||||
}
|
||||
|
||||
// Alows the starting of a new animation cycle at the end of the current one
|
||||
public static void Postfix(ref JobDriver_Sex __instance)
|
||||
public static void Postfix(ref JobDriver_Sex __instance, bool __state)
|
||||
{
|
||||
if (__instance.orgasms > 0)
|
||||
{ __instance.sex_ticks = 0; }
|
||||
if (__state || __instance.pawn.TryGetComp<CompBodyAnimator>()?.isAnimating != true) return;
|
||||
|
||||
if (__instance is JobDriver_SexBaseInitiator == false || __instance is JobDriver_JoinInSex)
|
||||
{ return; }
|
||||
DebugMode.Message(__instance.pawn.NameShortColored + " reached orgasm");
|
||||
|
||||
if (__instance.Sexprops != null && (__instance.Sexprops.isRape || __instance.Sexprops.isWhoring))
|
||||
{ return; }
|
||||
int duration = AnimationPatchUtility.FindTrueAnimationLength(__instance.pawn, out int orgasmTick, true);
|
||||
__instance.sex_ticks = duration;
|
||||
__instance.duration = duration;
|
||||
|
||||
if (__instance.ticksLeftThisToil <= 1 && (__instance.neverendingsex || ParticipantsDesireMoreSex(__instance)))
|
||||
if (__instance.neverendingsex)
|
||||
{
|
||||
List<Pawn> participants = __instance.pawn.GetAllSexParticipants();
|
||||
__instance.ticks_left = duration + (duration - orgasmTick) + 1;
|
||||
__instance.ticksLeftThisToil = __instance.ticks_left + 1;
|
||||
|
||||
if (participants.Count == 2)
|
||||
List<Pawn> participants = __instance.pawn.GetAllSexParticipants();
|
||||
foreach (Pawn participant in participants)
|
||||
{
|
||||
Job job = JobMaker.MakeJob(participants[0].CurJobDef, participants[0], participants[0].jobs.curJob.targetC);
|
||||
participants[1].jobs.StartJob(job, JobCondition.Succeeded);
|
||||
JobDriver_Sex jobDriver = participant.jobs.curDriver as JobDriver_Sex;
|
||||
|
||||
if (participant != __instance.pawn && jobDriver != null)
|
||||
{
|
||||
jobDriver.ticks_left = duration + (duration - orgasmTick) + 1;
|
||||
jobDriver.ticksLeftThisToil = jobDriver.ticks_left;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "End")]
|
||||
|
@ -322,9 +300,11 @@ namespace Rimworld_Animations_Patch
|
|||
{
|
||||
if (__instance.Partner != null &&__instance.Partner.Dead == false && __instance.Partner?.jobs?.curDriver != null && __instance.Partner?.jobs?.curDriver is JobDriver_SexBaseReciever)
|
||||
{
|
||||
foreach (Pawn participant in (__instance.Partner?.jobs.curDriver as JobDriver_SexBaseReciever).parteners)
|
||||
List<Pawn> participants = (__instance.Partner?.jobs.curDriver as JobDriver_SexBaseReciever).parteners.ToList();
|
||||
|
||||
foreach (Pawn participant in participants)
|
||||
{
|
||||
if (__instance.pawn != participant)
|
||||
if (__instance.pawn != participant && __instance.Partner?.jobs?.curDriver is JobDriver_Sex)
|
||||
{ participant.jobs.EndCurrentJob(JobCondition.Succeeded, false, true); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ namespace Rimworld_Animations_Patch
|
|||
postfix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "PostFix_AnimationUtility_GenitalCheckForPawn")));
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("Rimworld_Animations.CompBodyAnimator"), "setAnchor", new Type[] { typeof(Thing) }),
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "Prefix_HarmonyPatch_CompBodyAnimator_setAnchor")));
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("Rimworld_Animations.HarmonyPatch_JobDriver_SexBaseInitiator_Start"), "RerollAnimations"),
|
||||
postfix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "Postfix_RerollAnimations")));
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("Rimworld_Animations.HarmonyPatch_AlienRace"), "Prefix_AnimateHeadAddons"),
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Rimworld_Animations), "Prefix_DrawAddons")));
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("Rimworld_Animations.CompBodyAnimator"), "StartAnimation"),
|
||||
|
@ -61,8 +59,7 @@ namespace Rimworld_Animations_Patch
|
|||
|
||||
bool pawnInBed = pawn.IsInBed(out Building bed);
|
||||
|
||||
if (requiredGenitals.NullOrEmpty())
|
||||
{ return; }
|
||||
if (requiredGenitals.NullOrEmpty()) return;
|
||||
|
||||
if (requiredGenitals.Contains("OneHand") && handCount < 1)
|
||||
{ failReason = "missing hand"; __result = false; }
|
||||
|
@ -85,25 +82,6 @@ namespace Rimworld_Animations_Patch
|
|||
return false;
|
||||
}
|
||||
|
||||
// Adds functionality to determine which apparel each actor should discard based on the animation they are running
|
||||
public static void Postfix_RerollAnimations(Pawn pawn)
|
||||
{
|
||||
AnimationDef anim = pawn.GetAnimationData()?.animationDef;
|
||||
|
||||
if (anim != null)
|
||||
{
|
||||
DebugMode.Message("Running animation: " + anim.defName);
|
||||
|
||||
List<Pawn> pawnsToAnimate = pawn.GetAllSexParticipants();
|
||||
|
||||
foreach (Pawn participant in pawnsToAnimate)
|
||||
{
|
||||
int actorID = (int)AccessTools.Field(typeof(CompBodyAnimator), "actor").GetValue(participant.TryGetComp<CompBodyAnimator>());
|
||||
DebugMode.Message("Participant " + actorID + ": " + participant.NameShortColored);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replacement patch for AlienRace to draw the body addons
|
||||
public static bool Prefix_DrawAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation)
|
||||
{
|
||||
|
@ -250,5 +228,5 @@ namespace Rimworld_Animations_Patch
|
|||
Hair = rootLoc + YOffset_OnHead; (~ 0.029)
|
||||
Hat (over hair) = rootLoc + YOffset_PostHead; (~ 0.031)
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue