added simple for dildo

This commit is contained in:
c0ffee 2022-01-24 18:17:49 -08:00
parent 52c8afbe1b
commit 015a64928a
22 changed files with 712 additions and 11 deletions

View file

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<Patch_SexToysMasturbation.SexToyAnimationDef>
<defName>Masturbation_DildoVaginal</defName>
<label>dildo masturbation</label>
<requiredBodyPart>vagina</requiredBodyPart>
<sounds>true</sounds>
<sexTypes>
<li>Masturbation</li>
</sexTypes>
<actors>
<li>
<defNames>
<li>Human</li>
</defNames>
<isFucked>true</isFucked>
</li>
</actors>
<animationStages>
<li>
<stageName>Masturbating</stageName>
<isLooping>true</isLooping>
<playTimeTicks>800</playTimeTicks>
<stageIndex>0</stageIndex>
<animationClips>
<li Class="Rimworld_Animations.PawnAnimationClip">
<layer>LayingPawn</layer>
<keyframes>
<li>
<!--out-->
<tickDuration>40</tickDuration>
<bodyAngle>73.01611</bodyAngle>
<headAngle>40.0739746</headAngle>
<genitalAngle>0</genitalAngle>
<bodyOffsetZ>0.054543376</bodyOffsetZ>
<bodyOffsetX>0.112624526</bodyOffsetX>
<headBob>0</headBob>
<bodyFacing>3</bodyFacing>
<headFacing>3</headFacing>
</li>
<li>
<!--almost out-->
<soundEffect>Slimy</soundEffect>
<tickDuration>30</tickDuration>
<bodyAngle>76.4867554</bodyAngle>
<headAngle>50.3887634</headAngle>
<genitalAngle>0</genitalAngle>
<bodyOffsetZ>0.0506898165</bodyOffsetZ>
<bodyOffsetX>0.08564949</bodyOffsetX>
<headBob>0</headBob>
<bodyFacing>3</bodyFacing>
<headFacing>3</headFacing>
</li>
<li>
<!-- in -->
<tickDuration>30</tickDuration>
<bodyAngle>78.22131</bodyAngle>
<headAngle>58.0072327</headAngle>
<genitalAngle>0</genitalAngle>
<bodyOffsetZ>0.039129138</bodyOffsetZ>
<bodyOffsetX>0.07794231</bodyOffsetX>
<headBob>0</headBob>
<bodyFacing>3</bodyFacing>
<headFacing>3</headFacing>
</li>
<li>
<!--almost out-->
<tickDuration>30</tickDuration>
<bodyAngle>76.4867554</bodyAngle>
<headAngle>50.3887634</headAngle>
<genitalAngle>0</genitalAngle>
<bodyOffsetZ>0.0506898165</bodyOffsetZ>
<bodyOffsetX>0.08564949</bodyOffsetX>
<headBob>0</headBob>
<bodyFacing>3</bodyFacing>
<headFacing>3</headFacing>
</li>
<li>
<!--out-->
<tickDuration>1</tickDuration>
<bodyAngle>73.01611</bodyAngle>
<headAngle>40.0739746</headAngle>
<genitalAngle>0</genitalAngle>
<bodyOffsetZ>0.054543376</bodyOffsetZ>
<bodyOffsetX>0.112624526</bodyOffsetX>
<headBob>0</headBob>
<bodyFacing>3</bodyFacing>
<headFacing>3</headFacing>
</li>
</keyframes>
</li>
<li Class="Rimworld_Animations.ThingAnimationClip">
<keyframes>
<li>
<!--out-->
<tickDuration>40</tickDuration>
<positionX>-0.359264076</positionX>
<positionZ>-0.00901746</positionZ>
<rotation>114.011215</rotation>
</li>
<li>
<!--almost out-->
<tickDuration>30</tickDuration>
<positionX>-0.2783391</positionX>
<positionZ>-0.0514066666</positionZ>
<rotation>81.16443</rotation>
</li>
<li>
<!--in-->
<tickDuration>30</tickDuration>
<positionX>-0.1704393</positionX>
<positionZ>-0.0668209046</positionZ>
<rotation>72.8611145</rotation>
</li>
<li>
<!--almost out-->
<tickDuration>30</tickDuration>
<positionX>-0.2783391</positionX>
<positionZ>-0.0514066666</positionZ>
<rotation>81.16443</rotation>
</li>
<li>
<!--out-->
<tickDuration>1</tickDuration>
<positionX>-0.359264076</positionX>
<positionZ>-0.00901746</positionZ>
<rotation>114.011215</rotation>
</li>
</keyframes>
</li>
</animationClips>
</li>
</animationStages>
</Patch_SexToysMasturbation.SexToyAnimationDef>
</Defs>

View file

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{87763712-0536-4D5F-9EAA-520F15D4F84E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Patch_SexToysMasturbation</RootNamespace>
<AssemblyName>Patch_SexToysMasturbation</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>1.3\Assemblies\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\..\..\..\workshop\content\294100\1127530465\1.3\Assemblies\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Rimworld-Animations, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\1.3\Assemblies\Rimworld-Animations.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RJW">
<HintPath>..\..\rjw\1.3\Assemblies\RJW.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RJW-ToysAndMasturbation">
<HintPath>..\..\rjw-toys-and-masturbation\Assemblies\RJW-ToysAndMasturbation.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\RimWorldWin64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Source\Defs\SexToyAnimationDef.cs" />
<Compile Include="Source\Patches\HarmonyPatch_JobDriver_SexBaseInitiator.cs" />
<Compile Include="Source\Harmony\Harmony_PatchAll.cs" />
<Compile Include="Source\Utilities\AnimSexToyUtility.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="1.3\Assemblies\" />
</ItemGroup>
<ItemGroup>
<Content Include="1.3\Defs\AnimationDefs\Animations_Dildo.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Patch_SexToysMasturbation")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Patch_SexToysMasturbation")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("87763712-0536-4d5f-9eaa-520f15d4f84e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,16 @@
using Rimworld_Animations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Patch_SexToysMasturbation
{
public class SexToyAnimationDef : AnimationDef
{
public String requiredBodyPart = null;
}
}

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using HarmonyLib;
using System.Reflection;
namespace Patch_SexToysMasturbation
{
[StaticConstructorOnStartup]
public static class Harmony_PatchAll {
static Harmony_PatchAll() {
Harmony val = new Harmony("animtoyspatch");
val.PatchAll(Assembly.GetExecutingAssembly());
}
}
}

View file

@ -0,0 +1,66 @@
using HarmonyLib;
using Rimworld_Animations;
using rjw;
using RJW_ToysAndMasturbation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace Patch_SexToysMasturbation
{
[HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "Start")]
public class HarmonyPatch_JobDriver_SexBaseInitiator
{
public static void Postfix(ref JobDriver_SexBaseInitiator __instance)
{
if(__instance is JobDriver_MasturbateWithToy masturbateJobDriver)
{
Log.Message("Rerolling animations...");
Pawn pawn = masturbateJobDriver.pawn;
Thing sexToy = masturbateJobDriver.dildo;
RerollAnimationsForSexToy(pawn, sexToy);
}
}
public static void RerollAnimationsForSexToy(Pawn pawn, Thing thing)
{
CompSexToy sextoy = thing.TryGetComp<CompSexToy>();
SexToyAnimationDef anim = AnimSexToyUtility.tryFindAnimation(sextoy, pawn);
if (anim != null)
{
Log.Message("Playing anim " + anim.defName);
pawn.TryGetComp<CompBodyAnimator>().setAnchor(pawn.Position);
thing.TryGetComp<CompThingAnimator>().setAnchor(pawn.Position);
pawn.TryGetComp<CompBodyAnimator>().StartAnimation(anim, new List<Pawn> { pawn }, 0);
thing.TryGetComp<CompThingAnimator>().StartAnimation(anim, pawn);
(pawn.jobs.curDriver as JobDriver_Sex).ticks_left = anim.animationTimeTicks;
(pawn.jobs.curDriver as JobDriver_Sex).sex_ticks = anim.animationTimeTicks;
(pawn.jobs.curDriver as JobDriver_Sex).duration = anim.animationTimeTicks;
}
else
{
Log.Message("No animation found");
}
}
}
}

View file

@ -0,0 +1,47 @@
using rjw;
using RJW_ToysAndMasturbation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace Patch_SexToysMasturbation
{
public class AnimSexToyUtility
{
public static SexToyAnimationDef tryFindAnimation(CompSexToy sexToy, Pawn pawn)
{
IEnumerable<SexToyAnimationDef> options = DefDatabase<SexToyAnimationDef>.AllDefs.Where((SexToyAnimationDef x) =>
{
if(!sexToy.Props.requiredBodyParts.Contains(x.requiredBodyPart))
{
return false;
}
if(x.requiredBodyPart == "vagina" && !Genital_Helper.has_vagina(pawn))
{
return false;
}
return true;
});
if(options != null && options.Any())
{
return options.RandomElement();
}
else
{
return null;
}
}
}
}