offset changer + fix for pawns off map

This commit is contained in:
Platinum 2020-05-29 23:10:31 -07:00
parent c13b3d793b
commit c915b10e54
11 changed files with 163 additions and 21 deletions

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Defs>
<MainButtonDef>
<defName>OffsetManager</defName>
<label>offset manager</label>
<description>Control pawn offsets</description>
<tabWindowClass>Rimworld_Animations.MainTabWindow_OffsetConfigure</tabWindowClass>
<order>54</order>
<buttonVisible>false</buttonVisible>
</MainButtonDef>
</Defs>

View File

@ -88,7 +88,8 @@
<Compile Include="Source\Defs\AnimationDef.cs" />
<Compile Include="Source\JobDrivers\JobDriver_SexBaseRecieverLovedForAnimation.cs" />
<Compile Include="Source\JobDrivers\JobDriver_SexCasualForAnimation.cs" />
<Compile Include="Source\MainTabWindows\MainTabWindow_SexAnimator.cs" />
<Compile Include="Source\MainTabWindows\MainTabWindow_OffsetConfigure.cs" />
<Compile Include="Source\MainTabWindows\OffsetMainButtonDefOf.cs" />
<Compile Include="Source\Patches\HarmonyPatch_AlienRace.cs" />
<Compile Include="Source\Patches\HarmonyPatch_CSL.cs" />
<Compile Include="Source\Patches\HarmonyPatch_DontShaveYourHead.cs" />
@ -106,6 +107,15 @@
<Compile Include="Source\Patches\rjwPatches\HarmonyPatch_WorkGiverSex.cs" />
<Compile Include="Source\Settings\AnimationSettings.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Defs\AnimationDefs\Animations_Beast.xml" />
<Content Include="Defs\AnimationDefs\Animations_Lesbian.xml" />
<Content Include="Defs\AnimationDefs\Animations_Masturbate.xml" />
<Content Include="Defs\AnimationDefs\Animations_Multi.xml" />
<Content Include="Defs\AnimationDefs\Animations_vanilla.xml" />
<Content Include="Defs\JobDefs\Jobs_SexForAnim.xml" />
<Content Include="Defs\MainTabDefs\MainButtonDef.xml" />
<Content Include="Defs\SoundDefs\Sounds_Sex.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -4,9 +4,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;
namespace Rimworld_Animations {
public class Actor {
public class Actor : IExposable {
public List<string> defNames;
public List<string> requiredGenitals;
public List<AlienRaceOffset> raceOffsets;
@ -18,5 +19,11 @@ namespace Rimworld_Animations {
public bool controlGenitalAngle = false;
public BodyTypeOffset bodyTypeOffset = new BodyTypeOffset();
public Vector3 offset = new Vector2(0, 0);
public Dictionary<string, Vector2> offsetsByDefName = new Dictionary<string, Vector2>();
public void ExposeData() {
Scribe_Collections.Look(ref offsetsByDefName, "OffsetsSetInOptions", LookMode.Value, LookMode.Value);
}
}
}

View File

@ -146,7 +146,7 @@ namespace Rimworld_Animations {
public static void RenderPawnHeadMeshInAnimation(Mesh mesh, Vector3 loc, Quaternion quaternion, Material material, bool portrait, Pawn pawn) {
if(pawn == null) {
if(pawn == null || pawn.Map != Find.CurrentMap) {
GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, material, portrait);
return;
}

View File

@ -284,8 +284,28 @@ namespace Rimworld_Animations {
public Vector3 getPawnHeadPosition() {
return anchor + deltaPos + Quaternion.AngleAxis(bodyAngle, Vector3.up) * (pawn.Drawer.renderer.BaseHeadOffsetAt(headFacing) + headBob);
Vector3 headPos = anchor + deltaPos + Quaternion.AngleAxis(bodyAngle, Vector3.up) * (pawn.Drawer.renderer.BaseHeadOffsetAt(headFacing) + headBob);
if (CurrentAnimation?.actors[ActorIndex]?.offsetsByDefName != null && CurrentAnimation.actors[ActorIndex].offsetsByDefName.ContainsKey(pawn.def.defName)) {
headPos.x += CurrentAnimation.actors[ActorIndex].offsetsByDefName[pawn.def.defName].x;
headPos.z += CurrentAnimation.actors[ActorIndex].offsetsByDefName[pawn.def.defName].y;
}
return headPos;
}
public AnimationDef CurrentAnimation {
get {
return anim;
}
}
public int ActorIndex {
get {
return actor;
}
}
public override void PostExposeData() {

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using UnityEngine;
namespace Rimworld_Animations {
class MainTabWindow_OffsetConfigure : MainTabWindow
{
public override Vector2 RequestedTabSize => new Vector2(505, 300);
public override void DoWindowContents(Rect inRect) {
Rect position = new Rect(inRect.x, inRect.y, inRect.width, inRect.height);
Listing_Standard listingStandard = new Listing_Standard();
listingStandard.Begin(position);
listingStandard.Label("Offset Controller");
if (Find.Selector.SingleSelectedThing is Pawn) {
Pawn curPawn = Find.Selector.SingleSelectedThing as Pawn;
if (curPawn.TryGetComp<CompBodyAnimator>().isAnimating) {
Actor curActor = curPawn.TryGetComp<CompBodyAnimator>().CurrentAnimation.actors[curPawn.TryGetComp<CompBodyAnimator>().ActorIndex];
float offsetX = 0, offsetZ = 0;
if (curActor.offsetsByDefName.ContainsKey(curPawn.def.defName)) {
offsetX = curActor.offsetsByDefName[curPawn.def.defName].x;
offsetZ = curActor.offsetsByDefName[curPawn.def.defName].y;
} else {
curActor.offsetsByDefName.Add(curPawn.def.defName, new Vector2(0, 0));
}
listingStandard.GapLine();
listingStandard.Label("Offset for race " + curPawn.def.defName + " in actor position " + curPawn.TryGetComp<CompBodyAnimator>().ActorIndex);
if(curPawn.def.defName == "Human") {
listingStandard.Label("Warning--You generally don't want to change human offsets, only alien offsets");
}
listingStandard.Label("X Offset: " + offsetX);
offsetX = listingStandard.Slider(offsetX, -10, 10);
listingStandard.Label("Z Offset: " + offsetZ);
offsetZ = listingStandard.Slider(offsetZ, -10, 10);
if (offsetX != curActor.offsetsByDefName[curPawn.def.defName].x || offsetZ != curActor.offsetsByDefName[curPawn.def.defName].y) {
curActor.offsetsByDefName[curPawn.def.defName] = new Vector2(offsetX, offsetZ);
}
}
}
listingStandard.End();
base.DoWindowContents(inRect);
}
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
namespace Rimworld_Animations {
class MainTabWindow_SexAnimator : MainTabWindow
{
//todo: add animation maker window
}
}

View File

@ -0,0 +1,23 @@
using RimWorld;
using Verse;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rimworld_Animations {
[DefOf]
public static class OffsetMainButtonDefOf {
public static MainButtonDef OffsetManager;
static OffsetMainButtonDefOf() {
DefOfHelper.EnsureInitializedInCtor(typeof(OffsetMainButtonDefOf));
//OffsetManager.buttonVisible = false;
}
}
}

View File

@ -40,9 +40,14 @@ namespace Rimworld_Animations {
}
if (bodyAnim != null && bodyAnim.isAnimating && !portrait) {
if (bodyAnim != null && bodyAnim.isAnimating && !portrait && pawn.Map == Find.CurrentMap) {
bodyAnim.tickGraphics(graphics);
pawn.TryGetComp<CompBodyAnimator>().animatePawn(ref rootLoc, ref angle, ref bodyFacing, ref headFacing);
bodyAnim.animatePawn(ref rootLoc, ref angle, ref bodyFacing, ref headFacing);
if(bodyAnim.CurrentAnimation?.actors[bodyAnim.ActorIndex]?.offsetsByDefName != null && bodyAnim.CurrentAnimation.actors[bodyAnim.ActorIndex].offsetsByDefName.ContainsKey(pawn.def.defName)) {
rootLoc.x += bodyAnim.CurrentAnimation.actors[bodyAnim.ActorIndex].offsetsByDefName[pawn.def.defName].x;
rootLoc.z += bodyAnim.CurrentAnimation.actors[bodyAnim.ActorIndex].offsetsByDefName[pawn.def.defName].y;
}
}
}

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using Verse;
using UnityEngine;
using RimWorld;
namespace Rimworld_Animations {
public class AnimationSettings : ModSettings {
@ -12,6 +13,8 @@ namespace Rimworld_Animations {
public static bool orgasmQuiver, rapeShiver, soundOverride = true, hearts = true, controlGenitalRotation = false, applySemenOnAnimationOrgasm = false, fastAnimForQuickie = false;
public static float shiverIntensity = 2f;
public static Dictionary<string, Vector2> offsetsByDefName;
public override void ExposeData() {
base.ExposeData();
@ -25,6 +28,7 @@ namespace Rimworld_Animations {
Scribe_Values.Look(ref soundOverride, "rjwAnimSoundOverride", true);
Scribe_Values.Look(ref shiverIntensity, "shiverIntensity", 2f);
//todo: save offsetsByDefName
}
@ -54,9 +58,12 @@ namespace Rimworld_Animations {
listingStandard.CheckboxLabeled("Enable Rape Shiver", ref AnimationSettings.rapeShiver);
listingStandard.CheckboxLabeled("Enable hearts during lovin'", ref AnimationSettings.hearts);
listingStandard.CheckboxLabeled("Enable Offset Tab", ref OffsetMainButtonDefOf.OffsetManager.buttonVisible);
listingStandard.Label("Shiver/Quiver Intensity (default 2): " + AnimationSettings.shiverIntensity);
AnimationSettings.shiverIntensity = listingStandard.Slider(AnimationSettings.shiverIntensity, 0.0f, 12f);
listingStandard.End();
base.DoSettingsWindowContents(inRect);
}