diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index 93d7989..634cfa9 100644 Binary files a/1.5/Assemblies/Rimworld-Animations.dll and b/1.5/Assemblies/Rimworld-Animations.dll differ diff --git a/1.5/Defs/AnimationDefs/TestAnimation1.xml b/1.5/Defs/AnimationDefs/TestAnimation1.xml new file mode 100644 index 0000000..f106da7 --- /dev/null +++ b/1.5/Defs/AnimationDefs/TestAnimation1.xml @@ -0,0 +1,114 @@ + + + + TestAnimation1 + 400 + False + +
  • + Pawn +
  • +
    + + +
  • + Root + + Rimworld_Animations.AnimationWorker_KeyframesExtended + +
  • + 30 + 0 + North + true +
  • +
  • + 100 + 0 + East + true +
  • +
  • + 200 + 0 + South + true +
  • +
  • + 300 + 0 + West + true +
  • + + + + +
  • + Head + + Rimworld_Animations.AnimationWorker_KeyframesExtended + +
  • + 0 + 0 + North + true +
  • +
  • + 2 + 0 + East + true +
  • +
  • + 4 + 0 + South + true +
  • +
  • + 6 + 0 + West + false +
  • +
  • + 8 + 0 + North + false +
  • + + + +
    +
    +
    diff --git a/1.5/Defs/AnimationDefs/TestAnimation2.xml b/1.5/Defs/AnimationDefs/TestAnimation2.xml new file mode 100644 index 0000000..712cb2c --- /dev/null +++ b/1.5/Defs/AnimationDefs/TestAnimation2.xml @@ -0,0 +1,60 @@ + + + + TestAnimation2 + 200 + False + False + + +
  • + Root + + AnimationWorker_Keyframes + +
  • + 0 + 23 +
  • +
  • + 6 + -5 +
  • +
  • + 12 + 4 +
  • +
  • + 188 + -1 +
  • + + + +
  • + Head + + AnimationWorker_Keyframes + +
  • + 0 + 5 +
  • +
  • + 6 + -5 +
  • +
  • + 12 + 4 +
  • +
  • + 128 + -1 +
  • + + + +
    +
    +
    diff --git a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml new file mode 100644 index 0000000..297e28e --- /dev/null +++ b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml @@ -0,0 +1,88 @@ + + + + TestGroupAnimation1 + 2 + + +
  • + 200 + +
  • Pawn1_Stage1_TestAnimation1
  • +
  • Pawn2_Stage1_TestAnimation2
  • + + +
  • + 10 + +
  • + 3 +
  • Pawn1_Stage2_Variant1
  • +
  • Pawn2_Stage2_Variant1
  • + + +
  • + 1 +
  • Pawn1_Stage2_Variant2
  • +
  • Pawn2_Stage2_Variant2
  • + + + + +
  • + +
  • + 10 + +
  • + 3 +
  • Pawn1_Stage2_Variant1
  • +
  • Pawn2_Stage2_Variant1
  • + + +
  • + 1 +
  • Pawn1_Stage2_Variant2
  • +
  • Pawn2_Stage2_Variant2
  • + + + + +
  • + 10 + +
  • + 3 +
  • Pawn1_Stage2_Variant1
  • +
  • Pawn2_Stage2_Variant1
  • + + +
  • + 1 +
  • Pawn1_Stage2_Variant2
  • +
  • Pawn2_Stage2_Variant2
  • + + + + + + +
    + + +
  • + +
  • Sex
  • + + 0 + +
  • + +
  • Sex_Reverse
  • + + 1 + +
    + +
    +
    diff --git a/1.5/Patches/Patch_GenitaliaRenderNode.xml b/1.5/Patches/Patch_GenitaliaRenderNode.xml new file mode 100644 index 0000000..553374a --- /dev/null +++ b/1.5/Patches/Patch_GenitaliaRenderNode.xml @@ -0,0 +1,16 @@ + + + + diff --git a/1.5/Source/AnimationWorkers/AnimationWorker_KeyframesExtended.cs b/1.5/Source/AnimationWorkers/AnimationWorker_KeyframesExtended.cs new file mode 100644 index 0000000..50af003 --- /dev/null +++ b/1.5/Source/AnimationWorkers/AnimationWorker_KeyframesExtended.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Verse; + +namespace Rimworld_Animations +{ + class AnimationWorker_KeyframesExtended : AnimationWorker_Keyframes + { + + public AnimationWorker_KeyframesExtended(AnimationDef def, Pawn pawn, AnimationPart part, PawnRenderNode node) : base(def, pawn, part, node) + { + } + + + + //use extendedkeyframes to determine addon facing + public Rot4 facingAtTick(int tick) + { + //if ticks are < first keyframe tick, just be stuck to first keyframe rot + if (tick <= this.part.keyframes[0].tick) { + + return (this.part.keyframes[0] as ExtendedKeyframe).rotation; + + } + + //if ticks are > last keyframe tick, just be stuck to last keyframe rot + if (tick >= this.part.keyframes[this.part.keyframes.Count - 1].tick) + { + + return (this.part.keyframes[this.part.keyframes.Count - 1] as ExtendedKeyframe).rotation; + + } + Verse.Keyframe keyframe = this.part.keyframes[0]; + Verse.Keyframe keyframe2 = this.part.keyframes[this.part.keyframes.Count - 1]; + int i = 0; + while (i < this.part.keyframes.Count) + { + if (tick <= this.part.keyframes[i].tick) + { + keyframe2 = this.part.keyframes[i]; + if (i > 0) + { + keyframe = this.part.keyframes[i - 1]; + break; + } + break; + } + else + { + i++; + } + } + + return (keyframe as ExtendedKeyframe).rotation; + + } + + + public bool visibleAtTick(int tick) + { + //if ticks are < first keyframe tick, just be stuck to first keyframe rot + if (tick <= this.part.keyframes[0].tick) + { + + return (this.part.keyframes[0] as ExtendedKeyframe).visible; + + } + + //if ticks are > last keyframe tick, just be stuck to last keyframe rot + if (tick >= this.part.keyframes[this.part.keyframes.Count - 1].tick) + { + + return (this.part.keyframes[this.part.keyframes.Count - 1] as ExtendedKeyframe).visible; + + } + + Verse.Keyframe keyframe = this.part.keyframes[0]; + Verse.Keyframe keyframe2 = this.part.keyframes[this.part.keyframes.Count - 1]; + + int i = 0; + while (i < this.part.keyframes.Count) + { + if (tick <= this.part.keyframes[i].tick) + { + keyframe2 = this.part.keyframes[i]; + if (i > 0) + { + keyframe = this.part.keyframes[i - 1]; + break; + } + break; + } + else + { + i++; + } + } + + return (keyframe as ExtendedKeyframe).visible; + + + } + } +} diff --git a/1.5/Source/Defs/AnimationDefOf.cs b/1.5/Source/Defs/AnimationDefOf.cs new file mode 100644 index 0000000..9c62e50 --- /dev/null +++ b/1.5/Source/Defs/AnimationDefOf.cs @@ -0,0 +1,22 @@ +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace Rimworld_Animations +{ + [DefOf] + public static class AnimationDefOf + { + static AnimationDefOf() + { + DefOfHelper.EnsureInitializedInCtor(typeof(SoundDefOf)); + } + + public static AnimationDef TestAnimation1; + public static AnimationDef TestAnimation2; + } +} diff --git a/1.5/Source/GroupAnimationStages/AnimationStage.cs b/1.5/Source/GroupAnimationStages/AnimationStage.cs new file mode 100644 index 0000000..f8a22e0 --- /dev/null +++ b/1.5/Source/GroupAnimationStages/AnimationStage.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Rimworld_Animations +{ + public abstract class AnimationStage + { + //single stage containing group of animations + } +} diff --git a/1.5/Source/Keyframes/ExtendedKeyframe.cs b/1.5/Source/Keyframes/ExtendedKeyframe.cs new file mode 100644 index 0000000..ff23cab --- /dev/null +++ b/1.5/Source/Keyframes/ExtendedKeyframe.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Verse; + +namespace Rimworld_Animations +{ + public class ExtendedKeyframe : Verse.Keyframe + { + + public Rot4 rotation; + public bool visible; + + } +} diff --git a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_Sex.cs b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_Sex.cs new file mode 100644 index 0000000..f18dbcf --- /dev/null +++ b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_Sex.cs @@ -0,0 +1,24 @@ +using HarmonyLib; +using rjw; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace Rimworld_Animations +{ + /* + [HarmonyPatch(typeof(JobDriver_Sex), "SexTick")] + public class HarmonyPatch_JobDriver_Sex + { + public static void Prefix(JobDriver_Sex __instance) + { + Pawn partner = __instance.Partner; + + } + } + + */ +} diff --git a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs index 56d756c..9f11a1c 100644 --- a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs +++ b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs @@ -16,7 +16,9 @@ namespace Rimworld_Animations { don't play anim for now */ if(__instance is JobDriver_Masturbate || __instance is JobDriver_ViolateCorpse) { + return; + } if(!AnimationSettings.PlayAnimForNonsexualActs && NonSexualAct(__instance)) @@ -25,10 +27,10 @@ namespace Rimworld_Animations { } Pawn pawn = __instance.pawn; - + Pawn partner = __instance.Target as Pawn; Building_Bed bed = __instance.Bed; - if ((__instance.Target as Pawn)?.jobs?.curDriver is JobDriver_SexBaseReciever) { + if (partner?.jobs?.curDriver is JobDriver_SexBaseReciever partnerSexBaseReceiver) { Pawn Target = __instance.Target as Pawn; @@ -37,17 +39,12 @@ namespace Rimworld_Animations { int preAnimDuration = __instance.duration; int AnimationTimeTicks = 0; - - if (bed != null) { - RerollAnimations(bed as Thing); - } - else { - RerollAnimations(); - } + List participants = partnerSexBaseReceiver.parteners.Append(partner).ToList(); + RerollAnimations(participants); //Modify Orgasm ticks to only orgasm as many times as RJW stock orgasm allows - if(AnimationTimeTicks != 0) + if (AnimationTimeTicks != 0) { __instance.orgasmstick = preAnimDuration * __instance.orgasmstick / AnimationTimeTicks; } @@ -56,9 +53,11 @@ namespace Rimworld_Animations { } } - public static void RerollAnimations(Thing bed = null) { + public static void RerollAnimations(List participants) { + + participants[0].Drawer.renderer.SetAnimation(AnimationDefOf.TestAnimation1); + participants[1].Drawer.renderer.SetAnimation(AnimationDefOf.TestAnimation2); - } diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs new file mode 100644 index 0000000..fe6c81a --- /dev/null +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs @@ -0,0 +1,45 @@ +using HarmonyLib; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace Rimworld_Animations +{ + //Head Rotation Code + [HarmonyPatch(typeof(PawnRenderNode), "AppendRequests")] + public static class HarmonyPatch_PawnRenderNode + { + //if rendernodetag is head, update PawnDrawParms so that head, and all children, are rotated for anim + public static bool Prefix(ref PawnRenderNode __instance, ref PawnDrawParms parms) + { + if (__instance.AnimationWorker is AnimationWorker_KeyframesExtended extendedAnimWorker) + { + //INVIS IF ANIM CALLS FOR IT + if (!extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick)) + { + __instance.requestRecache = true; + return false; + } + + + // HEAD ROTATION ADJUST FACING + Rot4 animFacing = extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick); + + if (parms.facing != animFacing) + { + //requestRecache or else it won't update properly + __instance.requestRecache = true; + parms.facing = animFacing; + } + + } + + return true; + + } + } +} diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs new file mode 100644 index 0000000..b02b20a --- /dev/null +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs @@ -0,0 +1,27 @@ +using HarmonyLib; +using rjw; +using UnityEngine; +using Verse; + +namespace Rimworld_Animations { + + [HarmonyPatch(typeof(Pawn_DrawTracker), "DrawPos", MethodType.Getter)] + public static class HarmonyPatch_Pawn_DrawTracker { + public static bool Prefix(ref Pawn ___pawn, ref Vector3 __result) { + + if (___pawn?.Drawer?.renderer?.renderTree?.rootNode?.AnimationWorker is AnimationWorker_KeyframesExtended + && ___pawn.jobs?.curDriver is JobDriver_SexBaseInitiator sexdriver) + { + //align pos on top of partner + __result = sexdriver.Partner.Drawer.DrawPos; + + //change height so that they're all layered properly + if (sexdriver.Partner.jobs.curDriver is JobDriver_SexBaseReciever) + for (int i = 0; i < ) + return false; + } + + return true; + } + } +} diff --git a/Patch_SexToysMasturbation/1.5/Assemblies/Patch_SexToysMasturbation.dll b/Patch_SexToysMasturbation/1.5/Assemblies/Patch_SexToysMasturbation.dll index 858a7e1..e213401 100644 Binary files a/Patch_SexToysMasturbation/1.5/Assemblies/Patch_SexToysMasturbation.dll and b/Patch_SexToysMasturbation/1.5/Assemblies/Patch_SexToysMasturbation.dll differ diff --git a/Rimworld-Animations.csproj b/Rimworld-Animations.csproj index 1f5a8fb..398d8a9 100644 --- a/Rimworld-Animations.csproj +++ b/Rimworld-Animations.csproj @@ -72,17 +72,24 @@ + + + + + + + @@ -90,10 +97,16 @@ - + + + + + + + @@ -133,10 +146,7 @@ - - - - +