mirror of
				https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
				synced 2024-08-15 00:43:45 +00:00 
			
		
		
		
	HAR Patch
Sound override options
This commit is contained in:
		
							parent
							
								
									72b1201559
								
							
						
					
					
						commit
						f3cd391c6f
					
				
					 10 changed files with 114 additions and 11 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -2526,7 +2526,6 @@
 | 
			
		|||
    </animationStages>
 | 
			
		||||
 | 
			
		||||
  </Rimworld_Animations.AnimationDef>
 | 
			
		||||
  
 | 
			
		||||
</Defs>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,6 +36,10 @@
 | 
			
		|||
      <HintPath>..\..\..\..\workshop\content\294100\2009463077\v1.1\Assemblies\0Harmony.dll</HintPath>
 | 
			
		||||
      <Private>False</Private>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="AlienRace">
 | 
			
		||||
      <HintPath>..\..\..\..\workshop\content\294100\839005762\1.1\Assemblies\AlienRace.dll</HintPath>
 | 
			
		||||
      <Private>False</Private>
 | 
			
		||||
    </Reference>
 | 
			
		||||
    <Reference Include="Assembly-CSharp, Version=1.1.7397.36407, Culture=neutral, processorArchitecture=MSIL">
 | 
			
		||||
      <SpecificVersion>False</SpecificVersion>
 | 
			
		||||
      <HintPath>..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -68,9 +68,9 @@ namespace Rimworld_Animations {
 | 
			
		|||
 | 
			
		||||
                    //TESTING ANIMATIONS ONLY REMEMBER TO COMMENT OUT BEFORE PUSH
 | 
			
		||||
                    /*
 | 
			
		||||
                    if (x.defName != "Doggystyle")
 | 
			
		||||
                    if (x.defName != "Test")
 | 
			
		||||
                        return false;
 | 
			
		||||
                        */
 | 
			
		||||
                    */
 | 
			
		||||
                    
 | 
			
		||||
 | 
			
		||||
                    if (x.actors[i].isFucking && !rjw.xxx.can_fuck(localParticipants[i])) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -184,7 +184,7 @@ namespace Rimworld_Animations {
 | 
			
		|||
            clipTicks++;
 | 
			
		||||
 | 
			
		||||
            //play sound effect
 | 
			
		||||
            if(rjw.RJWSettings.sounds_enabled && clip.SoundEffects.ContainsKey(clipTicks)) {
 | 
			
		||||
            if(rjw.RJWSettings.sounds_enabled && clip.SoundEffects.ContainsKey(clipTicks) && AnimationSettings.soundOverride) {
 | 
			
		||||
                SoundDef.Named(clip.SoundEffects[clipTicks]).PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
 | 
			
		||||
            }
 | 
			
		||||
            if(AnimationSettings.orgasmQuiver && clip.quiver.ContainsKey(clipTicks)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -204,7 +204,16 @@ namespace Rimworld_Animations {
 | 
			
		|||
 | 
			
		||||
            deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent) * (mirror ? -1 : 1), clip.layer.AltitudeFor(), clip.BodyOffsetZ.Evaluate(clipPercent));
 | 
			
		||||
            bodyAngle = (clip.BodyAngle.Evaluate(clipPercent) + (quiver || shiver ? ((Rand.Value * AnimationSettings.shiverIntensity) - (AnimationSettings.shiverIntensity / 2f)) : 0f)) * (mirror ? -1 : 1);
 | 
			
		||||
 | 
			
		||||
            //don't go past 360 or less than 0
 | 
			
		||||
            if (bodyAngle < 0) bodyAngle = 360 - ((-1f*bodyAngle) % 360);
 | 
			
		||||
            if (bodyAngle > 360) bodyAngle %= 360;
 | 
			
		||||
 | 
			
		||||
            headAngle = clip.HeadAngle.Evaluate(clipPercent) * (mirror ? -1 : 1);
 | 
			
		||||
            if (headAngle < 0) headAngle = 360 - ((-1f * headAngle) % 360);
 | 
			
		||||
            if (headAngle > 360) headAngle %= 360;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            bodyFacing = mirror ? new Rot4((int)clip.BodyFacing.Evaluate(clipPercent)).Opposite : new Rot4((int)clip.BodyFacing.Evaluate(clipPercent));
 | 
			
		||||
 | 
			
		||||
            bodyFacing = new Rot4((int)clip.BodyFacing.Evaluate(clipPercent));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,6 @@ namespace Rimworld_Animations {
 | 
			
		|||
		public readonly TargetIndex ipartner = TargetIndex.A;
 | 
			
		||||
		public readonly TargetIndex ibed = TargetIndex.B;
 | 
			
		||||
 | 
			
		||||
		public Pawn Partner => (Pawn)(job.GetTarget(ipartner));
 | 
			
		||||
		public new Building_Bed Bed => (Building_Bed)(job.GetTarget(ibed));
 | 
			
		||||
 | 
			
		||||
		protected override IEnumerable<Toil> MakeNewToils() {
 | 
			
		||||
			setup_ticks();
 | 
			
		||||
			parteners.Add(Partner);// add job starter, so this wont fail, before Initiator starts his job
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,9 +2,13 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.Reflection.Emit;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using Verse;
 | 
			
		||||
using AlienRace;
 | 
			
		||||
 | 
			
		||||
namespace Rimworld_Animations {
 | 
			
		||||
    [StaticConstructorOnStartup]
 | 
			
		||||
| 
						 | 
				
			
			@ -13,8 +17,12 @@ namespace Rimworld_Animations {
 | 
			
		|||
			try {
 | 
			
		||||
				((Action)(() => {
 | 
			
		||||
					if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "Humanoid Alien Races 2.0")) {
 | 
			
		||||
 | 
			
		||||
						(new Harmony("rjw")).Patch(AccessTools.Method(typeof(PawnGraphicSet), "ResolveApparelGraphics"),
 | 
			
		||||
							prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_AlienRace), "Prefix_StopResolveAllGraphicsWhileSex")));
 | 
			
		||||
 | 
			
		||||
						(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("AlienRace.HarmonyPatches"), "DrawAddons"),
 | 
			
		||||
							prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_AlienRace), "Prefix_AnimateHeadAddons")));
 | 
			
		||||
					}
 | 
			
		||||
				}))();
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -31,5 +39,88 @@ namespace Rimworld_Animations {
 | 
			
		|||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
		public static bool Prefix_AnimateHeadAddons(bool portrait, Vector3 vector, Pawn pawn, Quaternion quat, Rot4 rotation, bool invisible) {
 | 
			
		||||
 | 
			
		||||
			if (portrait) return true;
 | 
			
		||||
			if (!(pawn.def is ThingDef_AlienRace alienProps) || invisible) return false;
 | 
			
		||||
 | 
			
		||||
			List<AlienPartGenerator.BodyAddon> addons = alienProps.alienRace.generalSettings.alienPartGenerator.bodyAddons;
 | 
			
		||||
			AlienPartGenerator.AlienComp alienComp = pawn.GetComp<AlienPartGenerator.AlienComp>();
 | 
			
		||||
 | 
			
		||||
			for (int i = 0; i < addons.Count; i++) {
 | 
			
		||||
				AlienPartGenerator.BodyAddon ba = addons[index: i];
 | 
			
		||||
				if (!ba.CanDrawAddon(pawn: pawn)) continue;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
				AlienPartGenerator.RotationOffset offset = rotation == Rot4.South ?
 | 
			
		||||
															   ba.offsets.south :
 | 
			
		||||
															   rotation == Rot4.North ?
 | 
			
		||||
																   ba.offsets.north :
 | 
			
		||||
																   rotation == Rot4.East ?
 | 
			
		||||
																	ba.offsets.east :
 | 
			
		||||
																	ba.offsets.west;
 | 
			
		||||
 | 
			
		||||
				Vector2 bodyOffset = (portrait ? offset?.portraitBodyTypes ?? offset?.bodyTypes : offset?.bodyTypes)?.FirstOrDefault(predicate: to => to.bodyType == pawn.story.bodyType)
 | 
			
		||||
								   ?.offset ?? Vector2.zero;
 | 
			
		||||
				Vector2 crownOffset = (portrait ? offset?.portraitCrownTypes ?? offset?.crownTypes : offset?.crownTypes)?.FirstOrDefault(predicate: to => to.crownType == alienComp.crownType)
 | 
			
		||||
									?.offset ?? Vector2.zero;
 | 
			
		||||
 | 
			
		||||
				//Defaults for tails 
 | 
			
		||||
				//south 0.42f, -0.3f, -0.22f
 | 
			
		||||
				//north     0f,  0.3f, -0.55f
 | 
			
		||||
				//east -0.42f, -0.3f, -0.22f   
 | 
			
		||||
 | 
			
		||||
				float moffsetX = 0.42f;
 | 
			
		||||
				float moffsetZ = -0.22f;
 | 
			
		||||
				float moffsetY = ba.inFrontOfBody ? 0.002f + ba.layerOffset : -0.002f - ba.layerOffset;
 | 
			
		||||
				float num = ba.angle;
 | 
			
		||||
 | 
			
		||||
				if (rotation == Rot4.North) {
 | 
			
		||||
					moffsetX = 0f;
 | 
			
		||||
					if (ba.layerInvert)
 | 
			
		||||
						moffsetY = -moffsetY;
 | 
			
		||||
 | 
			
		||||
					moffsetZ = -0.55f;
 | 
			
		||||
					num = 0;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				moffsetX += bodyOffset.x + crownOffset.x;
 | 
			
		||||
				moffsetZ += bodyOffset.y + crownOffset.y;
 | 
			
		||||
 | 
			
		||||
				if (rotation == Rot4.East) {
 | 
			
		||||
					moffsetX = -moffsetX;
 | 
			
		||||
					num = -num; //Angle
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				Vector3 offsetVector = new Vector3(x: moffsetX, y: moffsetY, z: moffsetZ);
 | 
			
		||||
 | 
			
		||||
				//Angle calculation to not pick the shortest, taken from Quaternion.Angle and modified
 | 
			
		||||
 | 
			
		||||
				//assume drawnInBed means headAddon
 | 
			
		||||
				if (ba.drawnInBed && pawn.TryGetComp<CompBodyAnimator>() != null && pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
 | 
			
		||||
 | 
			
		||||
					CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
 | 
			
		||||
					Quaternion headQuatInAnimation = Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up);
 | 
			
		||||
					Rot4 headRotInAnimation = pawnAnimator.headFacing;
 | 
			
		||||
					Vector3 headPositionInAnimation = pawnAnimator.getPawnHeadPosition() - pawn.Drawer.renderer.BaseHeadOffsetAt(pawnAnimator.headFacing).RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: headQuatInAnimation)) * 2f * 57.29578f);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
					GenDraw.DrawMeshNowOrLater(mesh: alienComp.addonGraphics[index: i].MeshAt(rot: headRotInAnimation), loc: headPositionInAnimation + offsetVector.RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: headQuatInAnimation)) * 2f * 57.29578f),
 | 
			
		||||
						quat: Quaternion.AngleAxis(angle: num, axis: Vector3.up) * headQuatInAnimation, mat: alienComp.addonGraphics[index: i].MatAt(rot: pawnAnimator.headFacing), drawNow: portrait);
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
				else {
 | 
			
		||||
 | 
			
		||||
					GenDraw.DrawMeshNowOrLater(mesh: alienComp.addonGraphics[index: i].MeshAt(rot: rotation), loc: vector + offsetVector.RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: quat)) * 2f * 57.29578f),
 | 
			
		||||
					quat: Quaternion.AngleAxis(angle: num, axis: Vector3.up) * quat, mat: alienComp.addonGraphics[index: i].MatAt(rot: rotation), drawNow: portrait);
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,7 +51,7 @@ namespace Rimworld_Animations {
 | 
			
		|||
		[HarmonyReversePatch(HarmonyReversePatchType.Snapshot)]
 | 
			
		||||
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
 | 
			
		||||
 | 
			
		||||
			MethodInfo drawMeshNowOrLater = AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater");//typeof(GenDraw).GetMethod("DrawMeshNowOrLater", BindingFlags.Static | BindingFlags.Public);
 | 
			
		||||
			MethodInfo drawMeshNowOrLater = AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater");
 | 
			
		||||
			FieldInfo headGraphic = AccessTools.Field(typeof(PawnGraphicSet), "headGraphic");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ namespace Rimworld_Animations {
 | 
			
		|||
				pawn.rotationTracker.Face(((Thing)partner).DrawPos);
 | 
			
		||||
				partner.rotationTracker.Face(((Thing)pawn).DrawPos);
 | 
			
		||||
			}
 | 
			
		||||
			if (RJWSettings.sounds_enabled && !pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
 | 
			
		||||
			if (RJWSettings.sounds_enabled && (!pawn.TryGetComp<CompBodyAnimator>().isAnimating || !AnimationSettings.soundOverride)) {
 | 
			
		||||
				SoundDef.Named("Sex").PlayOneShot(new TargetInfo(pawn.Position, pawn.Map));
 | 
			
		||||
			}
 | 
			
		||||
			pawn.Drawer.Notify_MeleeAttackOn((Thing)(object)partner);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,13 +9,15 @@ using UnityEngine;
 | 
			
		|||
namespace Rimworld_Animations {
 | 
			
		||||
    public class AnimationSettings : ModSettings {
 | 
			
		||||
 | 
			
		||||
        public static bool orgasmQuiver, rapeShiver;
 | 
			
		||||
        public static bool orgasmQuiver, rapeShiver, soundOverride = true;
 | 
			
		||||
        public static float shiverIntensity = 2f;
 | 
			
		||||
 | 
			
		||||
        public override void ExposeData() {
 | 
			
		||||
            Scribe_Values.Look(ref orgasmQuiver, "orgasmQuiver");
 | 
			
		||||
            Scribe_Values.Look(ref rapeShiver, "rapeShiver");
 | 
			
		||||
            Scribe_Values.Look(ref soundOverride, "rjwAnimSoundOverride", true);
 | 
			
		||||
            Scribe_Values.Look(ref shiverIntensity, "shiverIntensity", 2f);
 | 
			
		||||
 | 
			
		||||
            base.ExposeData();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +33,7 @@ namespace Rimworld_Animations {
 | 
			
		|||
            Listing_Standard listingStandard = new Listing_Standard();
 | 
			
		||||
            listingStandard.Begin(inRect);
 | 
			
		||||
 | 
			
		||||
            listingStandard.CheckboxLabeled("Enable Sound Override", ref AnimationSettings.soundOverride);
 | 
			
		||||
            listingStandard.CheckboxLabeled("Enable Orgasm Quiver", ref AnimationSettings.orgasmQuiver);
 | 
			
		||||
            listingStandard.CheckboxLabeled("Enable Rape Shiver", ref AnimationSettings.rapeShiver);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue