diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index 634cfa9..a394dd9 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 index f106da7..6ca49b0 100644 --- a/1.5/Defs/AnimationDefs/TestAnimation1.xml +++ b/1.5/Defs/AnimationDefs/TestAnimation1.xml @@ -4,13 +4,8 @@ TestAnimation1 400 False - -
  • - Pawn -
  • -
    - +
  • Root @@ -19,58 +14,52 @@
  • 30 0 - North true
  • 100 0 - East true
  • 200 0 - South true
  • 300 0 - West true
  • -
  • Head diff --git a/1.5/Defs/AnimationDefs/TestAnimation2.xml b/1.5/Defs/AnimationDefs/TestAnimation2.xml index 712cb2c..81923af 100644 --- a/1.5/Defs/AnimationDefs/TestAnimation2.xml +++ b/1.5/Defs/AnimationDefs/TestAnimation2.xml @@ -10,23 +10,31 @@
  • Root - AnimationWorker_Keyframes + Rimworld_Animations.AnimationWorker_KeyframesExtended -
  • +
  • + (0, -1, 0) 0 23 + North
  • -
  • +
  • + (0, -1, 0) 6 -5 + North
  • -
  • +
  • + (0, -1, 0) 12 4 + North
  • -
  • +
  • + (0, -1, 0) 188 -1 + North
  • @@ -34,23 +42,27 @@
  • Head - AnimationWorker_Keyframes + Rimworld_Animations.AnimationWorker_KeyframesExtended -
  • +
  • 0 - 5 + 0 + North
  • -
  • +
  • 6 -5 + North
  • -
  • +
  • 12 4 + North
  • -
  • +
  • 128 - -1 + 0 + North
  • diff --git a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml index 0bf9f68..701c56d 100644 --- a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml +++ b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml @@ -1,41 +1,41 @@  - + TestGroupAnimation1 2 - +
  • 200 -
  • Pawn1_Stage1_TestAnimation1
  • -
  • Pawn2_Stage1_TestAnimation2
  • +
  • TestAnimation1
  • +
  • TestAnimation2
  • 10 - +
  • 3 -
  • Pawn1_Stage2_Variant1
  • -
  • Pawn2_Stage2_Variant1
  • +
  • TestAnimation1
  • +
  • TestAnimation2
  • 1 -
  • Pawn1_Stage2_Variant2
  • -
  • Pawn2_Stage2_Variant2
  • +
  • TestAnimation1
  • +
  • TestAnimation2
  • - + - + +
    -
  • - -
  • Sex
  • - - 0 +
  • + +
  • Sex_Anal
  • +
  • Sex_Vaginal
  • + -
  • - -
  • Sex_Reverse
  • - - 1 - -
  • - -
  • Sex
  • - - -
  • Human
  • -
  • Dog
  • -
    - 0 - -
  • - -
  • Sex_Reverse
  • - - -
  • Dog
  • -
  • Human
  • -
    +
  • 1 + +
  • Sex_Reverse_Anal
  • +
  • Sex_Reverse_Vaginal
  • + +
    -
    +
    diff --git a/1.5/Patches/AnimationPatchHSK.xml b/1.5/Patches/AnimationPatchHSK.xml new file mode 100644 index 0000000..e061299 --- /dev/null +++ b/1.5/Patches/AnimationPatchHSK.xml @@ -0,0 +1,31 @@ + + + + +
  • Core SK
  • +
    + + + +
  • + Defs/ThingDef/comps + Always + + Defs/ThingDef + + + + +
  • + +
  • + Defs/ThingDef[@Name="BaseAnimalPawn" or @Name="SK_BasePawn" or @Name="BasePawnSkynet"]/comps + +
  • + +
  • + +
    +
    +
    +
    diff --git a/1.5/Patches/AnimationPatch_CompExtendedAnimator.xml b/1.5/Patches/AnimationPatch_CompExtendedAnimator.xml new file mode 100644 index 0000000..87f9f7d --- /dev/null +++ b/1.5/Patches/AnimationPatch_CompExtendedAnimator.xml @@ -0,0 +1,35 @@ + + + + Always + +
  • + Always + Defs/ThingDef[race][not(comps)] + + + +
  • +
  • + Always + Defs/AlienRace.ThingDef_AlienRace[not(comps)] + + + +
  • + +
  • + Defs/ThingDef[@Name="BasePawn"]/comps + +
  • + +
  • +
  • + Defs/AlienRace.ThingDef_AlienRace/comps + +
  • + +
  • +
    +
    +
    diff --git a/1.5/Patches/CompPatches/AutoCleaner.xml b/1.5/Patches/CompPatches/AutoCleaner.xml new file mode 100644 index 0000000..c6ba2bb --- /dev/null +++ b/1.5/Patches/CompPatches/AutoCleaner.xml @@ -0,0 +1,19 @@ + + + + Always + +
  • + /Defs/ThingDef[@Name="BaseBaseAutocleaner"]/comps + Always + + /Defs/ThingDef[@Name="BaseBaseAutocleaner"]/comps + +
  • + + +
  • +
    +
    +
    + diff --git a/1.5/Patches/CompPatches/CombatExtended.xml b/1.5/Patches/CompPatches/CombatExtended.xml new file mode 100644 index 0000000..aed123b --- /dev/null +++ b/1.5/Patches/CompPatches/CombatExtended.xml @@ -0,0 +1,18 @@ + + + + Always + +
  • + /Defs/ThingDef[@Name="BasePawnSimple"]/comps + Always + + /Defs/ThingDef[@Name="BasePawnSimple"]/comps + +
  • + + +
  • +
    +
    +
    diff --git a/1.5/Patches/CompPatches/ZombieLand.xml b/1.5/Patches/CompPatches/ZombieLand.xml new file mode 100644 index 0000000..87f618c --- /dev/null +++ b/1.5/Patches/CompPatches/ZombieLand.xml @@ -0,0 +1,18 @@ + + + + Always + +
  • + /Defs/ThingDef[@Name="BaseZombie"]/comps + Always + + /Defs/ThingDef[@Name="BaseZombie"]/comps + +
  • + + +
  • +
    +
    +
    diff --git a/1.5/Patches/CompatibilityPatch_HCSK.xml b/1.5/Patches/CompatibilityPatch_HCSK.xml new file mode 100644 index 0000000..576a07f --- /dev/null +++ b/1.5/Patches/CompatibilityPatch_HCSK.xml @@ -0,0 +1,39 @@ + + + + + +
  • Core SK
  • +
    + + Always + +
  • + /Defs/ThingDef/comps + Always + + /Defs/ThingDef + + + + +
  • + +
  • + /Defs/ThingDef[@Name="SK_BasePawn"]/comps + +
  • + +
  • + +
  • + /Defs/ThingDef[@Name="BaseAnimalPawn"]/comps + +
  • + +
  • +
    +
    +
    + +
    \ No newline at end of file diff --git a/1.5/Source/Comps/CompExtendedAnimator.cs b/1.5/Source/Comps/CompExtendedAnimator.cs new file mode 100644 index 0000000..17231e2 --- /dev/null +++ b/1.5/Source/Comps/CompExtendedAnimator.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using RimWorld; +using rjw; +using UnityEngine; +using Verse; +using Verse.AI; +using Verse.Sound; + +namespace Rimworld_Animations { + public class CompExtendedAnimator : ThingComp + { + List> animationQueue; + + } + +} diff --git a/1.5/Source/Comps/CompProperties_ExtendedAnimator.cs b/1.5/Source/Comps/CompProperties_ExtendedAnimator.cs new file mode 100644 index 0000000..c74848a --- /dev/null +++ b/1.5/Source/Comps/CompProperties_ExtendedAnimator.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using RimWorld; + +namespace Rimworld_Animations { + public class CompProperties_ExtendedAnimator : CompProperties + { + public CompProperties_ExtendedAnimator() + { + base.compClass = typeof(CompExtendedAnimator); + } + } +} diff --git a/1.5/Source/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs b/1.5/Source/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs new file mode 100644 index 0000000..f5ee3dc --- /dev/null +++ b/1.5/Source/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace Rimworld_Animations +{ + public abstract class BaseGroupAnimationContext + { + public int actorShift = 0; + public abstract bool CanAnimationBeUsed(List actors, out int reorder); + + //cool class for designating contexts for animations + // configure CanAnimationBeUsed to test whether it can be used + } +} diff --git a/1.5/Source/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs b/1.5/Source/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs new file mode 100644 index 0000000..7c2033e --- /dev/null +++ b/1.5/Source/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs @@ -0,0 +1,29 @@ +using RimWorld; +using rjw; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using static rjw.xxx; + +namespace Rimworld_Animations +{ + public class GroupAnimationContext_RJWSex : BaseGroupAnimationContext + { + + public List interactionDefs; + + public override bool CanAnimationBeUsed(List actors, out int reorder) + { + Log.Message("Testing this animation"); + + JobDriver_SexBaseInitiator latestSexBaseInitiator = (actors.FindLast(x => x.jobs?.curDriver is JobDriver_SexBaseInitiator).jobs.curDriver as JobDriver_SexBaseInitiator); + reorder = base.actorShift; + + + return interactionDefs.Contains(latestSexBaseInitiator.Sexprops.dictionaryKey); + } + } +} diff --git a/1.5/Source/GroupAnimations/GroupAnimationDef.cs b/1.5/Source/GroupAnimations/GroupAnimationDef.cs new file mode 100644 index 0000000..36eb64a --- /dev/null +++ b/1.5/Source/GroupAnimations/GroupAnimationDef.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace Rimworld_Animations +{ + public class GroupAnimationDef : Def + { + public int numActors; + public List animationStages; + public List contexts; + + + public bool canAnimationBeUsed(List actors, out int reorder) + { + + foreach (BaseGroupAnimationContext context in contexts) + { + if (context.CanAnimationBeUsed(actors, out reorder)) + { + return true; + } + } + + reorder = 0; + return false; + } + } +} diff --git a/1.5/Source/GroupAnimationStages/AnimationStage.cs b/1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage.cs similarity index 100% rename from 1.5/Source/GroupAnimationStages/AnimationStage.cs rename to 1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage.cs diff --git a/1.5/Source/GroupAnimationStages/AnimationStage_Branch.cs b/1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage_Branch.cs similarity index 90% rename from 1.5/Source/GroupAnimationStages/AnimationStage_Branch.cs rename to 1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage_Branch.cs index deb7751..889b06e 100644 --- a/1.5/Source/GroupAnimationStages/AnimationStage_Branch.cs +++ b/1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage_Branch.cs @@ -9,7 +9,7 @@ namespace Rimworld_Animations { public class AnimationStage_Branch : AnimationStage { - List paths; + public List paths; public override List> GetAnimations(int actor, int seed) { return paths[(seed * 59) % paths.Count].GetAnimations(actor, seed); diff --git a/1.5/Source/GroupAnimationStages/AnimationStage_LoopRandomSelectChance.cs b/1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage_LoopRandomSelectChance.cs similarity index 79% rename from 1.5/Source/GroupAnimationStages/AnimationStage_LoopRandomSelectChance.cs rename to 1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage_LoopRandomSelectChance.cs index 6ef1ad4..a6fa374 100644 --- a/1.5/Source/GroupAnimationStages/AnimationStage_LoopRandomSelectChance.cs +++ b/1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage_LoopRandomSelectChance.cs @@ -10,11 +10,11 @@ namespace Rimworld_Animations public class AnimationStage_LoopRandomSelectChance : AnimationStage { public int loops; - public List animationOptions; + public List loopOptions; public override List> GetAnimations(int actor, int seed) { - int numberOfActors = animationOptions[0].animationDefs.Count; + int numberOfActors = loopOptions[0].animationDefs.Count; List> animations = new List>(); for (int i = 0; i < loops; i++) @@ -37,11 +37,11 @@ namespace Rimworld_Animations //select random element from loop options by weight; also calculate the longest anim length public AnimationLoopOption getAnimationLoopOptionByWeight(int seed, out int longestAnimLength) { - int totalWeight = animationOptions.Sum(x => x.probability); + int totalWeight = loopOptions.Sum(x => x.probability); int randomNumber = (seed * 56) % totalWeight; int cumulativeWeight = 0; - foreach(AnimationLoopOption option in animationOptions) { + foreach(AnimationLoopOption option in loopOptions) { cumulativeWeight += option.probability; if (randomNumber <= cumulativeWeight) { @@ -50,8 +50,8 @@ namespace Rimworld_Animations } } - longestAnimLength = animationOptions[0].animationDefs.Max(x => x.durationTicks); - return animationOptions[0]; + longestAnimLength = loopOptions[0].animationDefs.Max(x => x.durationTicks); + return loopOptions[0]; } diff --git a/1.5/Source/GroupAnimationStages/AnimationStage_TicksDuration.cs b/1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage_TicksDuration.cs similarity index 100% rename from 1.5/Source/GroupAnimationStages/AnimationStage_TicksDuration.cs rename to 1.5/Source/GroupAnimations/GroupAnimationStages/AnimationStage_TicksDuration.cs diff --git a/1.5/Source/Keyframes/ExtendedKeyframe.cs b/1.5/Source/Keyframes/ExtendedKeyframe.cs index e5e6701..893c879 100644 --- a/1.5/Source/Keyframes/ExtendedKeyframe.cs +++ b/1.5/Source/Keyframes/ExtendedKeyframe.cs @@ -13,7 +13,7 @@ namespace Rimworld_Animations public Rot4 rotation; public SoundDef sound = null; - public bool visible; + public bool visible = true; } } 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 9f11a1c..830ac41 100644 --- a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs +++ b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs @@ -40,8 +40,14 @@ namespace Rimworld_Animations { int AnimationTimeTicks = 0; List participants = partnerSexBaseReceiver.parteners.Append(partner).ToList(); - RerollAnimations(participants); + GroupAnimationDef groupAnimation = AnimationUtility.FindGroupAnimation(participants, out int reorder); + + if (groupAnimation != null) + { + AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder); + } + //Modify Orgasm ticks to only orgasm as many times as RJW stock orgasm allows if (AnimationTimeTicks != 0) @@ -53,14 +59,6 @@ namespace Rimworld_Animations { } } - public static void RerollAnimations(List participants) { - - participants[0].Drawer.renderer.SetAnimation(AnimationDefOf.TestAnimation1); - participants[1].Drawer.renderer.SetAnimation(AnimationDefOf.TestAnimation2); - - } - - static IEnumerable NonSexActRulePackDefNames = new String[] { "MutualHandholdingRP", @@ -77,12 +75,14 @@ namespace Rimworld_Animations { } } + [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "End")] static class HarmonyPatch_JobDriver_SexBaseInitiator_End { - public static void Postfix(ref JobDriver_SexBaseInitiator __instance) + public static void Prefix(ref JobDriver_SexBaseInitiator __instance) { - //stop animation + + AnimationUtility.StopGroupAnimation(__instance.pawn); } } } diff --git a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseReceiverLoved.cs b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseReceiverLoved.cs deleted file mode 100644 index dfa116e..0000000 --- a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseReceiverLoved.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using RimWorld; -using Verse; -using rjw; -using System.Reflection.Emit; -using Verse.AI; - -namespace Rimworld_Animations -{ - - [HarmonyPatch(typeof(JobDriver_SexBaseRecieverLoved), "MakeSexToil")] - public static class HarmonyPatch_JobDriver_SexBaseReceiverLoved - { - public static IEnumerable Transpiler(IEnumerable codeInstructions) - { - - var ins = codeInstructions.ToList(); - for(int i = 0; i < ins.Count; i++) - { - if(i < ins.Count && ins[i].opcode == OpCodes.Call && ins[i].OperandIs(AccessTools.DeclaredMethod(typeof(Toils_LayDown), "LayDown"))) { - - ins[i].operand = AccessTools.DeclaredMethod(typeof(HarmonyPatch_JobDriver_SexBaseReceiverLoved), "DoNotLayDown"); - yield return ins[i]; - - } - - else - { - yield return ins[i]; - } - } - - } - - public static Toil DoNotLayDown(TargetIndex bedOrRestSpotIndex, bool hasBed, bool lookForOtherJobs, bool canSleep = true, bool gainRestAndHealth = true, PawnPosture noBedLayingPosture = PawnPosture.LayingMask, bool deathrest = false) - { - return new Toil(); - } - - } -} diff --git a/1.5/Source/Patches/RJWPatches/JobDrivers/SexBaseReceivers/HarmonyPatch_JobDriver_SexBaseReceiverLoved.cs b/1.5/Source/Patches/RJWPatches/JobDrivers/SexBaseReceivers/HarmonyPatch_JobDriver_SexBaseReceiverLoved.cs new file mode 100644 index 0000000..6c4faa8 --- /dev/null +++ b/1.5/Source/Patches/RJWPatches/JobDrivers/SexBaseReceivers/HarmonyPatch_JobDriver_SexBaseReceiverLoved.cs @@ -0,0 +1,23 @@ +using HarmonyLib; +using rjw; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse.AI; + +namespace Rimworld_Animations +{ + [HarmonyPatch(typeof(JobDriver_SexBaseRecieverLoved), "MakeSexToil")] + public class HarmonyPatch_JobDriver_SexBaseReceiverLoved + { + public static void Postfix(JobDriver_SexBaseRecieverLoved __instance, ref Toil __result) + { + //added for sudden end of jobdriver + __result.AddFinishAction(delegate { + AnimationUtility.StopGroupAnimation(__instance.pawn); + }); + } + } +} diff --git a/1.5/Source/Patches/RJWPatches/JobDrivers/SexBaseReceivers/HarmonyPatch_JobDriver_SexBaseReceiverRaped.cs b/1.5/Source/Patches/RJWPatches/JobDrivers/SexBaseReceivers/HarmonyPatch_JobDriver_SexBaseReceiverRaped.cs new file mode 100644 index 0000000..e0b115d --- /dev/null +++ b/1.5/Source/Patches/RJWPatches/JobDrivers/SexBaseReceivers/HarmonyPatch_JobDriver_SexBaseReceiverRaped.cs @@ -0,0 +1,23 @@ +using HarmonyLib; +using rjw; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse.AI; + +namespace Rimworld_Animations +{ + [HarmonyPatch(typeof(JobDriver_SexBaseRecieverRaped), "MakeNewToils")] + public class HarmonyPatch_JobDriver_SexBaseReceiverRaped + { + public static void Postfix(JobDriver_SexBaseRecieverRaped __instance, ref IEnumerable __result) + { + //added for sudden end of jobdriver + __result.Last().AddFinishAction(delegate { + AnimationUtility.StopGroupAnimation(__instance.pawn); + }); + } + } +} diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs index 8855f47..c7cff4f 100644 --- a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs @@ -27,7 +27,7 @@ namespace Rimworld_Animations } - // HEAD ROTATION ADJUST FACING + // HEAD ROTATION ADJUST FACING get rotated textures Rot4 animFacing = extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick); diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs new file mode 100644 index 0000000..edc16af --- /dev/null +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs @@ -0,0 +1,35 @@ +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 +{ + [HarmonyPatch(typeof(PawnRenderTree), "TryGetMatrix")] + public class HarmonyPatch_PawnRenderTree + { + public static void Prefix(PawnRenderTree __instance, PawnRenderNode node, ref PawnDrawParms parms) + { + //Note: Maybe need to change this to check all ancestors if it's the head node + //in case of deeper nodes in the PawnRenderTree + //This code only checks for node and parent, if either are head + + + // Change facing for all head and apparelhead nodes + // So that the offset is based on body rotation, not head rotation + + //fixes misaligned hairs and headaddons + if ((node.Props.tagDef == PawnRenderNodeTagDefOf.Head || node.Props.tagDef == PawnRenderNodeTagDefOf.ApparelHead + || node?.parent?.Props?.tagDef == PawnRenderNodeTagDefOf.Head || node?.parent?.Props?.tagDef == PawnRenderNodeTagDefOf.ApparelHead) + && node.tree.rootNode.AnimationWorker is AnimationWorker_KeyframesExtended rootNodeAnimationWorker) + { + + parms.facing = rootNodeAnimationWorker.facingAtTick(node.tree.AnimationTick); + } + } + } +} diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs index b02b20a..65b34e9 100644 --- a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs @@ -9,19 +9,23 @@ namespace Rimworld_Animations { public static class HarmonyPatch_Pawn_DrawTracker { public static bool Prefix(ref Pawn ___pawn, ref Vector3 __result) { + // If animating and is sexbaseinitiator jobdriver, 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 < ) + //align pos on top of partner + if (sexdriver?.Partner?.Drawer?.DrawPos != null) + __result = sexdriver.Partner.Drawer.DrawPos; + + return false; + } return true; + + } } } diff --git a/1.5/Source/Utilities/AnimationUtility.cs b/1.5/Source/Utilities/AnimationUtility.cs index 7df7d42..d06d203 100644 --- a/1.5/Source/Utilities/AnimationUtility.cs +++ b/1.5/Source/Utilities/AnimationUtility.cs @@ -15,120 +15,57 @@ namespace Rimworld_Animations { public static class AnimationUtility { - public static bool GenitalCheckForPawn(List requiredGenitals, Pawn pawn, out string failReason) + public static void StartAnimation(List participants) { + participants[0].Drawer.renderer.SetAnimation(AnimationDefOf.TestAnimation1); + participants[1].Drawer.renderer.SetAnimation(AnimationDefOf.TestAnimation2); + } - failReason = null; - if (requiredGenitals != null) + + public static void StartGroupAnimation(List participants, GroupAnimationDef groupAnimationDef, int reorder) + { + for(int i = 0; i < participants.Count; i++) { - if (requiredGenitals.Contains("Vagina")) - { - - if (!rjw.Genital_Helper.has_vagina(pawn)) - { - failReason = "missing vagina"; - return false; - } - - } - - if (requiredGenitals.Contains("Penis")) - { - - if (!(rjw.Genital_Helper.has_multipenis(pawn) || rjw.Genital_Helper.has_penis_infertile(pawn) || rjw.Genital_Helper.has_penis_fertile(pawn) || rjw.Genital_Helper.has_ovipositorM(pawn) || rjw.Genital_Helper.has_ovipositorF(pawn))) - { - failReason = "missing penis"; - return false; - } - - } - - if (requiredGenitals.Contains("Mouth")) - { - - if (!rjw.Genital_Helper.has_mouth(pawn)) - { - failReason = "missing mouth"; - return false; - } - - } - - if (requiredGenitals.Contains("Anus")) - { - - if (!rjw.Genital_Helper.has_anus(pawn)) - { - failReason = "missing anus"; - return false; - } - - } - - if (requiredGenitals.Contains("Breasts")) - { - if (!rjw.Genital_Helper.can_do_breastjob(pawn)) - { - failReason = "missing breasts"; - return false; - } - } - - if (requiredGenitals.Contains("NoVagina")) - { - - if (rjw.Genital_Helper.has_vagina(pawn)) - { - failReason = "has vagina"; - return false; - } - - } - - if (requiredGenitals.Contains("NoPenis")) - { - - if ((rjw.Genital_Helper.has_multipenis(pawn) || rjw.Genital_Helper.has_penis_infertile(pawn) || rjw.Genital_Helper.has_penis_fertile(pawn))) - { - failReason = "has penis"; - return false; - } - - } - - if (requiredGenitals.Contains("NoMouth")) - { - - if (rjw.Genital_Helper.has_mouth(pawn)) - { - failReason = "has mouth"; - return false; - } - - } - - if (requiredGenitals.Contains("NoAnus")) - { - - if (rjw.Genital_Helper.has_anus(pawn)) - { - failReason = "has anus"; - return false; - } - - } - - if (requiredGenitals.Contains("NoBreasts")) - { - if (rjw.Genital_Helper.can_do_breastjob(pawn)) - { - failReason = "has breasts"; - return false; - } - } + //todo: pass all animationstages to ExtendedAnimator, and queue animations + participants[i].Drawer.renderer.SetAnimation( + groupAnimationDef.animationStages[0] + .GetAnimations((i + reorder) % participants.Count, GenTicks.TicksGame)[0].Item2); } + } - return true; + + public static void StopGroupAnimation(List participants) + { + foreach(Pawn pawn in participants) + { + pawn.Drawer.renderer.SetAnimation(null); + } + } + + public static void StopGroupAnimation(Pawn participant) + { + participant?.Drawer?.renderer?.SetAnimation(null); + } + + public static GroupAnimationDef FindGroupAnimation(List participants, out int reorder) + { + // go through each context in each GroupAnimationDef + // if you find one where it returns canAnimationBeUsed (and reorders), + // return that animation + + int reorder2 = 0; + + Log.Message(DefDatabase.AllDefsListForReading[0].defName); + + DefDatabase.AllDefsListForReading.TryRandomElement((GroupAnimationDef x) => + x.canAnimationBeUsed(participants, out reorder2), out GroupAnimationDef result); + + reorder = reorder2; + if (result != null) return result; + + return null; + + } } diff --git a/Rimworld-Animations.csproj b/Rimworld-Animations.csproj index 4aff51e..cd6b26a 100644 --- a/Rimworld-Animations.csproj +++ b/Rimworld-Animations.csproj @@ -73,19 +73,25 @@ + + - - - - + + + + + + + + @@ -94,7 +100,8 @@ - + + @@ -108,7 +115,13 @@ + + + + + +