diff --git a/1.5/Assemblies/RJW.dll b/1.5/Assemblies/RJW.dll new file mode 100644 index 0000000..c1b1980 Binary files /dev/null and b/1.5/Assemblies/RJW.dll differ diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index 292a905..9f4b569 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/TestAnimation2.xml b/1.5/Defs/AnimationDefs/TestAnimation2.xml index 8125f0c..04fb662 100644 --- a/1.5/Defs/AnimationDefs/TestAnimation2.xml +++ b/1.5/Defs/AnimationDefs/TestAnimation2.xml @@ -13,25 +13,25 @@ Rimworld_Animations.AnimationWorker_KeyframesExtended
  • - (1, 0, 0) + (1, -1, 0) 0 0 North
  • - (0, 0, 0) + (0, -1, 0) 30 15 North
  • - (-1, 0, 0) + (-1, -1, 0) 60 0 North
  • - (0, 0, 0) + (0, -1, 0) 90 -15 North diff --git a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml index 6be826f..1f68f3d 100644 --- a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml +++ b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml @@ -3,6 +3,7 @@ TestGroupAnimation1 2 + True
  • 10 diff --git a/1.5/Defs/OffsetDefs/OffsetDef_GroinToAppropriateHeight.xml b/1.5/Defs/OffsetDefs/OffsetDef_GroinToAppropriateHeight.xml index 544eb4d..6566375 100644 --- a/1.5/Defs/OffsetDefs/OffsetDef_GroinToAppropriateHeight.xml +++ b/1.5/Defs/OffsetDefs/OffsetDef_GroinToAppropriateHeight.xml @@ -3,12 +3,11 @@ GroinToAppropriateHeight -
  • +
  • Alien_Orassan
  • (0, 0, 5) - 90
  • @@ -16,7 +15,7 @@
  • Human
  • -
  • Hulk(0, 0, 0.5)90
  • +
  • Hulk(0, 0, 0.5)
  • Thin(0, 0, 0.3)
  • Female(0, 0, 0.4)
  • diff --git a/1.5/Source/Animations/AnimationOffsets/AnimationOffsetDef.cs b/1.5/Source/Animations/AnimationOffsets/AnimationOffsetDef.cs index 03cdc8d..a939d66 100644 --- a/1.5/Source/Animations/AnimationOffsets/AnimationOffsetDef.cs +++ b/1.5/Source/Animations/AnimationOffsets/AnimationOffsetDef.cs @@ -13,20 +13,21 @@ namespace Rimworld_Animations public List offsets; - public bool FindOffset(Pawn pawn, out BaseAnimationOffset offset) + public Vector3 FindOffset(Pawn pawn) { foreach (BaseAnimationOffset animOffset in offsets) { if (animOffset.appliesToPawn(pawn)) { - offset = animOffset; - return true; + Vector3? offset = animOffset.getOffset(pawn); + return (offset == null ? Vector3.zero : (Vector3)offset); } } - offset = null; - return false; + return Vector3.zero; } + + } } diff --git a/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_BodyType.cs b/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_BodyType.cs index 3777af7..3ea9f74 100644 --- a/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_BodyType.cs +++ b/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_BodyType.cs @@ -18,11 +18,6 @@ namespace Rimworld_Animations { return offsets.Find(x => x.bodyType == pawn.story.bodyType)?.offset; } - - public override int? getRotation(Pawn pawn) - { - return offsets.Find(x => x.bodyType == pawn.story.bodyType)?.rotation; - } } } diff --git a/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_BodyTypeGendered.cs b/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_BodyTypeGendered.cs index f6d44a3..3809af2 100644 --- a/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_BodyTypeGendered.cs +++ b/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_BodyTypeGendered.cs @@ -26,19 +26,5 @@ namespace Rimworld_Animations } } - - public override int? getRotation(Pawn pawn) - { - - if (pawn.gender == Gender.Female) - { - return offsetsFemale.Find(x => x.bodyType == pawn.story.bodyType)?.rotation; - } - else - { - return offsetsMale.Find(x => x.bodyType == pawn.story.bodyType)?.rotation; - } - - } } } diff --git a/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_Single.cs b/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_Single.cs index 2744039..7ea3135 100644 --- a/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_Single.cs +++ b/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_Single.cs @@ -12,16 +12,10 @@ namespace Rimworld_Animations { public Vector3 offset; - public int? rotation; public override Vector3? getOffset(Pawn pawn) { return offset; } - - public override int? getRotation(Pawn pawn) - { - return rotation; - } } } diff --git a/1.5/Source/Animations/AnimationOffsets/Offsets/BaseAnimationOffset.cs b/1.5/Source/Animations/AnimationOffsets/Offsets/BaseAnimationOffset.cs index 57bab15..d0ccd19 100644 --- a/1.5/Source/Animations/AnimationOffsets/Offsets/BaseAnimationOffset.cs +++ b/1.5/Source/Animations/AnimationOffsets/Offsets/BaseAnimationOffset.cs @@ -15,8 +15,6 @@ namespace Rimworld_Animations public abstract Vector3? getOffset(Pawn pawn); - public abstract int? getRotation(Pawn pawn); - public bool appliesToPawn(Pawn pawn) { return races.Contains(pawn.def); diff --git a/1.5/Source/Animations/AnimationOffsets/Offsets/BodyTypeOffset.cs b/1.5/Source/Animations/AnimationOffsets/Offsets/BodyTypeOffset.cs index df35501..92e7b71 100644 --- a/1.5/Source/Animations/AnimationOffsets/Offsets/BodyTypeOffset.cs +++ b/1.5/Source/Animations/AnimationOffsets/Offsets/BodyTypeOffset.cs @@ -12,7 +12,6 @@ namespace Rimworld_Animations public class BodyTypeOffset { public BodyTypeDef bodyType; - public int rotation = 0; public Vector3 offset; } } diff --git a/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs b/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs index da77e49..c9cc5e0 100644 --- a/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs +++ b/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs @@ -18,7 +18,7 @@ namespace Rimworld_Animations public bool canAnimationBeUsed(List actors, out int reorder) { - if (RJWAnimationSettings.debugMode) + if (AnimationSettings.debugMode) { Log.Message("[anims] Checking if " + defName + " is valid animation"); } @@ -51,23 +51,12 @@ namespace Rimworld_Animations return animations; } - public bool GetOffset(int actor, Pawn pawn, out Vector3? position, out int? rotation, int reorder = 0) + public Vector3? GetOffset(int actor, Pawn pawn, int reorder = 0) { - - position = null; - rotation = null; - //element at or default to stop errors - if (offsetDefs == null) return false; - if ((actor + reorder) % numActors >= offsetDefs.Count) return false; - if (offsetDefs[(actor + reorder) % numActors].FindOffset(pawn, out BaseAnimationOffset animationOffset)) - { - position = animationOffset.getOffset(pawn); - rotation = animationOffset.getRotation(pawn); - return true; - } - - return false; + if (offsetDefs == null) return null; + if ((actor + reorder) % numActors >= offsetDefs.Count) return null; + return offsetDefs[(actor + reorder) % numActors].FindOffset(pawn); } } } diff --git a/1.5/Source/Comps/CompExtendedAnimator.cs b/1.5/Source/Comps/CompExtendedAnimator.cs index a7c6973..442a0fb 100644 --- a/1.5/Source/Comps/CompExtendedAnimator.cs +++ b/1.5/Source/Comps/CompExtendedAnimator.cs @@ -19,7 +19,6 @@ namespace Rimworld_Animations { private List animationQueue; private BaseExtendedAnimatorAnchor anchor; - private int? rotation; private Vector3? offset; private bool isAnimating = false; @@ -52,18 +51,6 @@ namespace Rimworld_Animations { } } - public int? Rotation - { - get - { - return rotation; - } - set - { - this.rotation = value; - } - } - public int AnimationLength { get @@ -81,15 +68,6 @@ namespace Rimworld_Animations { } } - public AnimationDef CurrentAnimation { - - get - { - return IsAnimating ? animationQueue[0] : null; - } - - } - public Vector3 getAnchor() { return anchor.getDrawPos(); @@ -157,18 +135,17 @@ namespace Rimworld_Animations { pawn.Drawer.renderer.SetAnimation(null); } - public void PlayGroupAnimation(List groupAnimation, Vector3? positionOffset, int? rotationOffset) + public void PlayGroupAnimation(List groupAnimation, Vector3? offset) { - this.Offset = positionOffset; - this.Rotation = rotationOffset; + this.Offset = offset; animationQueue = groupAnimation; PlayNextAnimation(); } - public void PlayGroupAnimation(List groupAnimation, Vector3? positionOffset, int? rotationOffset, BaseExtendedAnimatorAnchor anchor) + public void PlayGroupAnimation(List groupAnimation, Vector3? offset, BaseExtendedAnimatorAnchor anchor) { this.anchor = anchor; - PlayGroupAnimation(groupAnimation, positionOffset, rotationOffset); + PlayGroupAnimation(groupAnimation, offset); } public override void PostExposeData() diff --git a/1.5/Source/Comps/ExtendedAnimatorAnchor/ExtendedAnimatorAnchor_Thing.cs b/1.5/Source/Comps/ExtendedAnimatorAnchor/ExtendedAnimatorAnchor_Thing.cs index 4331046..8b61405 100644 --- a/1.5/Source/Comps/ExtendedAnimatorAnchor/ExtendedAnimatorAnchor_Thing.cs +++ b/1.5/Source/Comps/ExtendedAnimatorAnchor/ExtendedAnimatorAnchor_Thing.cs @@ -22,7 +22,6 @@ namespace Rimworld_Animations public override Vector3 getDrawPos() { - //vector3.up means stand above the thing return thing.DrawPos; } diff --git a/1.5/Source/MainTabWindows/MainTabWindow_OffsetConfigure.cs b/1.5/Source/MainTabWindows/MainTabWindow_OffsetConfigure.cs index 18ba6d6..45784d0 100644 --- a/1.5/Source/MainTabWindows/MainTabWindow_OffsetConfigure.cs +++ b/1.5/Source/MainTabWindows/MainTabWindow_OffsetConfigure.cs @@ -2,13 +2,12 @@ using Verse; using RimWorld; using UnityEngine; -using System.Windows; namespace Rimworld_Animations { class MainTabWindow_OffsetConfigure : MainTabWindow { - public override Vector2 RequestedTabSize => new Vector2(505, 500); + public override Vector2 RequestedTabSize => new Vector2(505, 380); public override void DoWindowContents(Rect inRect) { Rect position = new Rect(inRect.x, inRect.y, inRect.width, inRect.height); @@ -17,167 +16,121 @@ namespace Rimworld_Animations { Listing_Standard listingStandard = new Listing_Standard(); listingStandard.Begin(position); - listingStandard.Label("RimAnims_AnimManager".Translate()); + listingStandard.Label("Animation Manager"); listingStandard.GapLine(); + /* + if (Find.Selector.SingleSelectedThing is Pawn curPawn) { - if (Find.Selector.SingleSelectedThing is Pawn curPawn - && curPawn.TryGetComp(out CompExtendedAnimator extendedAnimator) - && extendedAnimator.IsAnimating) - { - //Pawn info about their body, race - Vector3 offsetPosition = extendedAnimator.Offset != null ? (Vector3)extendedAnimator.Offset : Vector3.zero; - int offsetRotation = extendedAnimator.Rotation != null ? (int)extendedAnimator.Rotation : 0; + if (CompBodyAnimator.IsAnimating(curPawn)) { - string pawnDef = curPawn.def.defName; - string bodyTypeDef = (curPawn.story?.bodyType != null) ? curPawn.story.bodyType.ToString() : "None"; - string genderDef = curPawn.gender.ToString(); - string currentAnimation = extendedAnimator.CurrentAnimation != null ? extendedAnimator.CurrentAnimation.defName : "None"; + CompBodyAnimator compBodyAnimator = curPawn.TryGetComp(); + AnimationDef def = compBodyAnimator.CurrentAnimation; + int ActorIndex = compBodyAnimator.ActorIndex; + float offsetX = 0, offsetZ = 0, rotation = 0; - listingStandard.Label(curPawn.Name + ": " + curPawn.def.defName + ", " + bodyTypeDef + ", " + genderDef + ", Animation: " + currentAnimation); + string bodyTypeDef = (curPawn.story?.bodyType != null) ? curPawn.story.bodyType.ToString() : ""; - if (curPawn.def.defName == "Human") - { - listingStandard.Label("RimAnims_Warning".Translate()); - } + if (AnimationSettings.offsets.ContainsKey(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex)) { + offsetX = AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].x; + offsetZ = AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].y; + } else { + AnimationSettings.offsets.Add(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex, new Vector2(0, 0)); + } - float posX = offsetPosition.x, posY = offsetPosition.y, posZ = offsetPosition.z; - int rot = offsetRotation; + if (AnimationSettings.rotation.ContainsKey(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex)) { + rotation = AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex]; + } + else { + AnimationSettings.rotation.Add(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex, 0); + } - float.TryParse(listingStandard.TextEntryLabeled("X: ", posX.ToString()), out posX); - posX = listingStandard.Slider(posX, -2, 2); + listingStandard.Label("Name: " + curPawn.Name + " Race: " + curPawn.def.defName + " Actor Index: " + curPawn.TryGetComp().ActorIndex + " Body Type (if any): " + bodyTypeDef + " Animation: " + def.label + (curPawn.TryGetComp().Mirror ? " mirrored" : "")); - float.TryParse(listingStandard.TextEntryLabeled("Y: ", offsetPosition.y.ToString()), out posY); - posY = listingStandard.Slider(posY, -2, 2); + if(curPawn.def.defName == "Human") { + listingStandard.Label("Warning--You generally don't want to change human offsets, only alien offsets"); + } - float.TryParse(listingStandard.TextEntryLabeled("Z: ", posZ.ToString()), out posZ); - posZ = listingStandard.Slider(posZ, -2, 2); + float.TryParse(listingStandard.TextEntryLabeled("X Offset: ", offsetX.ToString()), out offsetX); + offsetX = listingStandard.Slider(offsetX, -2, 2); - int.TryParse(listingStandard.TextEntryLabeled("Rotation: ", rot.ToString()), out rot); - rot = (int)listingStandard.Slider(rot, -180, 180); + float.TryParse(listingStandard.TextEntryLabeled("Z Offset: ", offsetZ.ToString()), out offsetZ); + offsetZ = listingStandard.Slider(offsetZ, -2, 2); - listingStandard.GapLine(); - Vector3 newOffsetVector = new Vector3(posX, posY, posZ); + float.TryParse(listingStandard.TextEntryLabeled("Rotation: ", rotation.ToString()), out rotation); + rotation = listingStandard.Slider(rotation, -180, 180); - string offset = "
  • "; - offset += bodyTypeDef != "None" ? "" + bodyTypeDef + "" : ""; - offset += newOffsetVector != Vector3.zero ? "(" + posX + ", " + posY + ", " + posZ + ")" : ""; - offset += rot != 0 ? "" + rot + "" : ""; - offset += "
  • "; + if(listingStandard.ButtonText("Reset All")) { + offsetX = 0; + offsetZ = 0; + rotation = 0; + } - listingStandard.Label("Appropriate Offset value for " + currentAnimation + ", " + pawnDef + ", " + bodyTypeDef + ", " + genderDef + ": "); - listingStandard.Label(offset); + listingStandard.GapLine(); - if (listingStandard.ButtonText("RimAnims_CopyToClipboard".Translate())) - { + if(listingStandard.ButtonText("Shift Actors")) { + + if(AnimationSettings.debugMode) { + Log.Message("Shifting actors in animation..."); + } - GUIUtility.systemCopyBuffer = offset; + for(int i = 0; i < curPawn.TryGetComp().actorsInCurrentAnimation.Count; i++) { + + Pawn actor = curPawn.TryGetComp().actorsInCurrentAnimation[i]; + + actor.TryGetComp()?.shiftActorPositionAndRestartAnimation(); + + //reset the clock time of every pawn in animation + if(actor.jobs.curDriver is rjw.JobDriver_Sex) { + (actor.jobs.curDriver as rjw.JobDriver_Sex).ticks_left = def.animationTimeTicks; + (actor.jobs.curDriver as rjw.JobDriver_Sex).ticksLeftThisToil = def.animationTimeTicks; + (actor.jobs.curDriver as rjw.JobDriver_Sex).duration = def.animationTimeTicks; + } + + } + + } + + if (offsetX != AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].x || offsetZ != AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].y) { + AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex] = new Vector2(offsetX, offsetZ); + + } + + if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex]) { + AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex] = rotation; + } } - listingStandard.Label("RimAnims_ShareSettings".Translate()); - - extendedAnimator.Offset = newOffsetVector; - extendedAnimator.Rotation = rot; - } - - else - { + else { listingStandard.Label("Select a pawn currently in an animation to change their offsets"); } - + */ listingStandard.End(); } - } -} -/** - if (curPawn.TryGetComp animator) { - - - - /* - CompBodyAnimator compBodyAnimator = curPawn.TryGetComp(); - AnimationDef def = compBodyAnimator.CurrentAnimation; - int ActorIndex = compBodyAnimator.ActorIndex; - float offsetX = 0, offsetZ = 0, rotation = 0; - - string bodyTypeDef = (curPawn.story?.bodyType != null) ? curPawn.story.bodyType.ToString() : ""; - - if (AnimationSettings.offsets.ContainsKey(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex)) { - offsetX = AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].x; - offsetZ = AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].y; - } else { - AnimationSettings.offsets.Add(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex, new Vector2(0, 0)); - } - - if (AnimationSettings.rotation.ContainsKey(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex)) { - rotation = AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex]; - } - else { - AnimationSettings.rotation.Add(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex, 0); - } - - listingStandard.Label("Name: " + curPawn.Name + " Race: " + curPawn.def.defName + " Actor Index: " + curPawn.TryGetComp().ActorIndex + " Body Type (if any): " + bodyTypeDef + " Animation: " + def.label + (curPawn.TryGetComp().Mirror ? " mirrored" : "")); - - if(curPawn.def.defName == "Human") { - listingStandard.Label("Warning--You generally don't want to change human offsets, only alien offsets"); - } - - float.TryParse(listingStandard.TextEntryLabeled("X Offset: ", offsetX.ToString()), out offsetX); - offsetX = listingStandard.Slider(offsetX, -2, 2); - - float.TryParse(listingStandard.TextEntryLabeled("Z Offset: ", offsetZ.ToString()), out offsetZ); - offsetZ = listingStandard.Slider(offsetZ, -2, 2); - - float.TryParse(listingStandard.TextEntryLabeled("Rotation: ", rotation.ToString()), out rotation); - rotation = listingStandard.Slider(rotation, -180, 180); - - if(listingStandard.ButtonText("Reset All")) { - offsetX = 0; - offsetZ = 0; - rotation = 0; - } - - listingStandard.GapLine(); - - if(listingStandard.ButtonText("Shift Actors")) { - - if(AnimationSettings.debugMode) { - Log.Message("Shifting actors in animation..."); + public override void PreOpen() { + base.PreOpen(); + if(AnimationSettings.offsets == null) { + if (AnimationSettings.debugMode) + Log.Message("New offsets"); + AnimationSettings.offsets = new Dictionary(); } - for(int i = 0; i < curPawn.TryGetComp().actorsInCurrentAnimation.Count; i++) { - - Pawn actor = curPawn.TryGetComp().actorsInCurrentAnimation[i]; - - actor.TryGetComp()?.shiftActorPositionAndRestartAnimation(); - - //reset the clock time of every pawn in animation - if(actor.jobs.curDriver is rjw.JobDriver_Sex) { - (actor.jobs.curDriver as rjw.JobDriver_Sex).ticks_left = def.animationTimeTicks; - (actor.jobs.curDriver as rjw.JobDriver_Sex).ticksLeftThisToil = def.animationTimeTicks; - (actor.jobs.curDriver as rjw.JobDriver_Sex).duration = def.animationTimeTicks; - } - + if(AnimationSettings.rotation == null) { + if (AnimationSettings.debugMode) + Log.Message("New rotation"); + AnimationSettings.rotation = new Dictionary(); } - } - if (offsetX != AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].x || offsetZ != AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex].y) { - AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex] = new Vector2(offsetX, offsetZ); + public override void PostClose() { + base.PostClose(); + LoadedModManager.GetMod().WriteSettings(); } - - if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex]) { - AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex] = rotation; - } - } - } - */ - diff --git a/1.5/Source/MainTabWindows/WorldComponent_UpdateMainTab.cs b/1.5/Source/MainTabWindows/WorldComponent_UpdateMainTab.cs index ff89d7e..2694419 100644 --- a/1.5/Source/MainTabWindows/WorldComponent_UpdateMainTab.cs +++ b/1.5/Source/MainTabWindows/WorldComponent_UpdateMainTab.cs @@ -16,7 +16,7 @@ namespace Rimworld_Animations { public override void FinalizeInit() { base.FinalizeInit(); - OffsetMainButtonDefOf.OffsetManager.buttonVisible = RJWAnimationSettings.offsetTab; + OffsetMainButtonDefOf.OffsetManager.buttonVisible = AnimationSettings.offsetTab; } diff --git a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_Sex.cs b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_Sex.cs index c025bec..f18dbcf 100644 --- a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_Sex.cs +++ b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_Sex.cs @@ -5,23 +5,20 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using UnityEngine; using Verse; namespace Rimworld_Animations { - - [HarmonyPatch(typeof(JobDriver_Sex), "setup_ticks")] + /* + [HarmonyPatch(typeof(JobDriver_Sex), "SexTick")] public class HarmonyPatch_JobDriver_Sex { - public static void Postfix(JobDriver_Sex __instance) + public static void Prefix(JobDriver_Sex __instance) { - if (!RJWAnimationSettings.hearts) - { - __instance.ticks_between_hearts = int.MaxValue; - } + 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 e464028..07f286f 100644 --- a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs +++ b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs @@ -21,7 +21,7 @@ namespace Rimworld_Animations { } - if(!RJWAnimationSettings.PlayAnimForNonsexualActs && NonSexualAct(__instance)) + if(!AnimationSettings.PlayAnimForNonsexualActs && NonSexualAct(__instance)) { return; } @@ -34,6 +34,8 @@ namespace Rimworld_Animations { Pawn Target = __instance.Target as Pawn; + bool quickie = (__instance is JobDriver_SexQuick) && AnimationSettings.fastAnimForQuickie; + int preAnimDuration = __instance.duration; @@ -42,11 +44,7 @@ namespace Rimworld_Animations { GroupAnimationDef groupAnimation = AnimationUtility.FindGroupAnimation(participants, out int reorder); if (groupAnimation != null) { - Thing anchor; - if (bed != null) anchor = bed; - else anchor = partner; - - AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder, anchor); + AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder, partner); int animTicks = AnimationUtility.GetAnimationLength(pawn); foreach(Pawn participant in participants) diff --git a/1.5/Source/Patches/RJWPatches/RJWAnimationSettings.cs b/1.5/Source/Patches/RJWPatches/RJWAnimationSettings.cs deleted file mode 100644 index 6cb30d2..0000000 --- a/1.5/Source/Patches/RJWPatches/RJWAnimationSettings.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Verse; -using UnityEngine; -using RimWorld; - -namespace Rimworld_Animations { - - public class RJWAnimationSettings : ModSettings { - - public static bool orgasmQuiver, rapeShiver, soundOverride = true, hearts = true, controlGenitalRotation = false, - PlayAnimForNonsexualActs = true; - - public static bool offsetTab = false, debugMode = false; - public static float shiverIntensity = 2f; - - public override void ExposeData() { - - base.ExposeData(); - - Scribe_Values.Look(ref debugMode, "RJWAnimations-AnimsDebugMode", false); - Scribe_Values.Look(ref offsetTab, "RJWAnimations-EnableOffsetTab", false); - Scribe_Values.Look(ref controlGenitalRotation, "RJWAnimations-controlGenitalRotation", false); - Scribe_Values.Look(ref orgasmQuiver, "RJWAnimations-orgasmQuiver"); - Scribe_Values.Look(ref rapeShiver, "RJWAnimations-rapeShiver"); - Scribe_Values.Look(ref hearts, "RJWAnimation-heartsOnLovin"); - Scribe_Values.Look(ref PlayAnimForNonsexualActs, "RJWAnims-PlayAnimForNonsexualActs"); - Scribe_Values.Look(ref soundOverride, "RJWAnimations-rjwAnimSoundOverride", true); - Scribe_Values.Look(ref shiverIntensity, "RJWAnimations-shiverIntensity", 2f); - //todo: save offsetsByDefName - - } - - } - - public class RJW_Animations : Mod { - - public RJW_Animations(ModContentPack content) : base(content) { - GetSettings(); - - } - - public override void DoSettingsWindowContents(Rect inRect) { - - Listing_Standard listingStandard = new Listing_Standard(); - listingStandard.Begin(inRect); - - listingStandard.CheckboxLabeled("RimAnim_SoundOverride".Translate(), ref RJWAnimationSettings.soundOverride); - listingStandard.CheckboxLabeled("RimAnim_GenitalRotation".Translate(), ref RJWAnimationSettings.controlGenitalRotation); - listingStandard.CheckboxLabeled("RimAnim_OrgasmQuiver".Translate(), ref RJWAnimationSettings.orgasmQuiver); - listingStandard.CheckboxLabeled("RimAnim_RapeShiver".Translate(), ref RJWAnimationSettings.rapeShiver); - listingStandard.CheckboxLabeled("RimAnim_HeartsDuringLovin".Translate(), ref RJWAnimationSettings.hearts); - listingStandard.CheckboxLabeled("RimAnim_PlayNonsexual".Translate(), ref RJWAnimationSettings.PlayAnimForNonsexualActs); - listingStandard.CheckboxLabeled("RimAnim_AnimManagerTab".Translate(), ref RJWAnimationSettings.offsetTab); - listingStandard.Label("RimAnim_ShiverIntensity".Translate() + RJWAnimationSettings.shiverIntensity); - RJWAnimationSettings.shiverIntensity = listingStandard.Slider(RJWAnimationSettings.shiverIntensity, 0.0f, 12f); - - listingStandard.CheckboxLabeled("RimAnim_DebugMode".Translate(), ref RJWAnimationSettings.debugMode); - - - listingStandard.End(); - base.DoSettingsWindowContents(inRect); - } - - public override void WriteSettings() { - base.WriteSettings(); - OffsetMainButtonDefOf.OffsetManager.buttonVisible = RJWAnimationSettings.offsetTab; - - } - - public override string SettingsCategory() { - return "RimAnim_ModSettings".Translate(); - } - } -} diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs index 31c4692..8b467e1 100644 --- a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTracker.cs @@ -7,20 +7,20 @@ 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) { - //switch to postfix to get pawn original height first - public static void Postfix(ref Pawn ___pawn, ref Vector3 __result) { + + CompExtendedAnimator animator = ___pawn.TryGetComp(); //align pos on top of partner, position, etc., based on animatoranchor - if (___pawn.TryGetComp() is CompExtendedAnimator animator - && animator.IsAnchored) + if (animator != null && animator.IsAnchored) { - Vector3 anchor = animator.getAnchor(); - //ignore y so that pawns don't clip through stuff - __result.x = anchor.x; - __result.z = anchor.z; + __result = animator.getAnchor(); + return false; } + return true; + } } } diff --git a/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs b/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs index 117e459..2ce182e 100644 --- a/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs +++ b/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs @@ -26,25 +26,5 @@ namespace Rimworld_Animations } } - - public override void TransformRotation(PawnRenderNode node, PawnDrawParms parms, ref Quaternion rotation) - { - - if (node.AnimationWorker is AnimationWorker_KeyframesExtended - && node.tree.pawn.TryGetComp(out CompExtendedAnimator extendedAnimator) - && extendedAnimator.IsAnimating) - { - int? pawnRotation = extendedAnimator.Rotation; - if (pawnRotation != null) - { - Quaternion additionalRotation = Quaternion.AngleAxis((int)pawnRotation, Vector3.up); - rotation *= additionalRotation; - } - - } - - base.TransformRotation(node, parms, ref rotation); - } - } } diff --git a/1.5/Source/Settings/AnimationSettings.cs b/1.5/Source/Settings/AnimationSettings.cs new file mode 100644 index 0000000..f320fa2 --- /dev/null +++ b/1.5/Source/Settings/AnimationSettings.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using UnityEngine; +using RimWorld; + +namespace Rimworld_Animations { + + public class AnimationSettings : ModSettings { + + public static bool orgasmQuiver, rapeShiver, soundOverride = true, hearts = true, controlGenitalRotation = false, applySemenOnAnimationOrgasm = false, fastAnimForQuickie = false, + PlayAnimForNonsexualActs = true; + public static bool offsetTab = false, debugMode = false; + public static float shiverIntensity = 2f; + + public static Dictionary offsets = new Dictionary(); + public static Dictionary rotation = new Dictionary(); + + public override void ExposeData() { + + base.ExposeData(); + + Scribe_Values.Look(ref debugMode, "RJWAnimations-AnimsDebugMode", false); + Scribe_Values.Look(ref offsetTab, "RJWAnimations-EnableOffsetTab", false); + Scribe_Values.Look(ref controlGenitalRotation, "RJWAnimations-controlGenitalRotation", false); + Scribe_Values.Look(ref orgasmQuiver, "RJWAnimations-orgasmQuiver"); + Scribe_Values.Look(ref fastAnimForQuickie, "RJWAnimations-fastAnimForQuickie"); + Scribe_Values.Look(ref rapeShiver, "RJWAnimations-rapeShiver"); + Scribe_Values.Look(ref hearts, "RJWAnimation-heartsOnLovin"); + Scribe_Values.Look(ref PlayAnimForNonsexualActs, "RJWAnims-PlayAnimForNonsexualActs"); + Scribe_Values.Look(ref applySemenOnAnimationOrgasm, "RJWAnimations-applySemenOnOrgasm", false); + Scribe_Values.Look(ref soundOverride, "RJWAnimations-rjwAnimSoundOverride", true); + Scribe_Values.Look(ref shiverIntensity, "RJWAnimations-shiverIntensity", 2f); + //todo: save offsetsByDefName + + Scribe_Collections.Look(ref offsets, "RJWAnimations-animationOffsets"); + Scribe_Collections.Look(ref rotation, "RJWAnimations-rotationOffsets"); + + + + //needs to be rewritten + //probably somewhere in options? + + } + + } + + public class RJW_Animations : Mod { + + public RJW_Animations(ModContentPack content) : base(content) { + GetSettings(); + + } + + public override void DoSettingsWindowContents(Rect inRect) { + + Listing_Standard listingStandard = new Listing_Standard(); + listingStandard.Begin(inRect); + + listingStandard.CheckboxLabeled("Enable Sound Override", ref AnimationSettings.soundOverride); + listingStandard.CheckboxLabeled("Control Genital Rotation", ref AnimationSettings.controlGenitalRotation); + listingStandard.CheckboxLabeled("Play Fast Animation for Quickie", ref AnimationSettings.fastAnimForQuickie); + listingStandard.CheckboxLabeled("Apply Semen on Animation Orgasm", ref AnimationSettings.applySemenOnAnimationOrgasm); + + if(AnimationSettings.applySemenOnAnimationOrgasm) { + listingStandard.Label("Recommended--turn down \"Cum on body percent\" in RJW settings to about 33%"); + } + + listingStandard.CheckboxLabeled("Enable Orgasm Quiver", ref AnimationSettings.orgasmQuiver); + listingStandard.CheckboxLabeled("Enable Rape Shiver", ref AnimationSettings.rapeShiver); + listingStandard.CheckboxLabeled("Enable hearts during lovin'", ref AnimationSettings.hearts); + listingStandard.CheckboxLabeled("Play animation for nonsexual acts (handholding, makeout)", ref AnimationSettings.PlayAnimForNonsexualActs); + listingStandard.CheckboxLabeled("Enable Animation Manager Tab", ref AnimationSettings.offsetTab); + + listingStandard.Label("Shiver/Quiver Intensity (default 2): " + AnimationSettings.shiverIntensity); + AnimationSettings.shiverIntensity = listingStandard.Slider(AnimationSettings.shiverIntensity, 0.0f, 12f); + + listingStandard.CheckboxLabeled("Debug Mode", ref AnimationSettings.debugMode); + + + listingStandard.End(); + base.DoSettingsWindowContents(inRect); + } + + public override void WriteSettings() { + base.WriteSettings(); + OffsetMainButtonDefOf.OffsetManager.buttonVisible = AnimationSettings.offsetTab; + + } + + public override string SettingsCategory() { + return "RJW Animation Settings"; + } + } +} diff --git a/1.5/Source/Utilities/AnimationUtility.cs b/1.5/Source/Utilities/AnimationUtility.cs index 04950f4..e57a096 100644 --- a/1.5/Source/Utilities/AnimationUtility.cs +++ b/1.5/Source/Utilities/AnimationUtility.cs @@ -30,21 +30,21 @@ namespace Rimworld_Animations { for (int i = 0; i < participants.Count; i++) { - - groupAnimationDef.GetOffset(i, participants[i], out Vector3? position, out int? rotation, reorder); + + Vector3? offset = groupAnimationDef.GetOffset(i, participants[i], reorder); if (anchor is Pawn pawn && pawn == participants[i]) { List allAnimationsForPawn = groupAnimationDef.GetAllAnimationsForActor(i, seed, reorder); - participants[i].TryGetComp().PlayGroupAnimation(allAnimationsForPawn, position, rotation); + participants[i].TryGetComp().PlayGroupAnimation(allAnimationsForPawn, offset); } else { //each participant gets their own unique extendedanimatoranchor, important for scribe_deep saving List allAnimationsForPawn = groupAnimationDef.GetAllAnimationsForActor(i, seed, reorder); BaseExtendedAnimatorAnchor animatorAnchor = new ExtendedAnimatorAnchor_Thing(anchor); - participants[i].TryGetComp().PlayGroupAnimation(allAnimationsForPawn, position, rotation, animatorAnchor); + participants[i].TryGetComp().PlayGroupAnimation(allAnimationsForPawn, offset, animatorAnchor); } } } @@ -57,8 +57,8 @@ namespace Rimworld_Animations { for (int i = 0; i < participants.Count; i++) { List allAnimationsForPawn = groupAnimationDef.GetAllAnimationsForActor(i, seed, reorder); - groupAnimationDef.GetOffset(i, participants[i], out Vector3? position, out int? rotation, reorder); - participants[i].TryGetComp().PlayGroupAnimation(allAnimationsForPawn, position, rotation); + Vector3? offset = groupAnimationDef.GetOffset(i, participants[i], reorder); + participants[i].TryGetComp().PlayGroupAnimation(allAnimationsForPawn, offset); } } diff --git a/Languages/English/Keyed/RJWAnimations-LanguageData.xml b/Languages/English/Keyed/RJWAnimations-LanguageData.xml deleted file mode 100644 index 95ecca6..0000000 --- a/Languages/English/Keyed/RJWAnimations-LanguageData.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - RJW Animation Settings - Enable Sound Override - Control Genital Rotation - Enable Orgasm Quiver - Enable Rape Shiver - Enable hearts during lovin' - Play animation for nonsexual acts (handholding, makeout) - Enable Animation Manager Tab - Shiver/Quiver Intensity (default 2): - Debug Mode - - - Animation Manager - Warning--You generally don't want to change human offsets, only alien offsets or animals - Copy Offset to Clipboard - Paste offset values in OffsetDef, or share in Discord - - \ No newline at end of file diff --git a/Rimworld-Animations.csproj b/Rimworld-Animations.csproj index a57ed97..bdf8615 100644 --- a/Rimworld-Animations.csproj +++ b/Rimworld-Animations.csproj @@ -68,10 +68,6 @@ ..\..\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll False - - ..\..\RimWorldWin64_Data\Managed\UnityEngine.IMGUIModule.dll - False - @@ -126,7 +122,7 @@ - + @@ -191,7 +187,6 @@ - @@ -202,7 +197,6 @@ - \ No newline at end of file