mirror of
				https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
				synced 2024-08-15 00:43:45 +00:00 
			
		
		
		
	Merge branch '1.5_solo_anims' into '1.5'
Patch to allow solo anims See merge request c0ffeeeeeeee/rimworld-animations!22
This commit is contained in:
		
						commit
						1a66bae865
					
				
					 2 changed files with 122 additions and 81 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -6,22 +6,22 @@ using RimWorld;
 | 
				
			||||||
using Verse;
 | 
					using Verse;
 | 
				
			||||||
using rjw;
 | 
					using rjw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Rimworld_Animations {
 | 
					namespace Rimworld_Animations
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "Start")]
 | 
					    [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "Start")]
 | 
				
			||||||
    static class HarmonyPatch_JobDriver_SexBaseInitiator_Start {
 | 
					    static class HarmonyPatch_JobDriver_SexBaseInitiator_Start
 | 
				
			||||||
        public static void Postfix(ref JobDriver_SexBaseInitiator __instance) {
 | 
					    {
 | 
				
			||||||
 | 
					        public static void Postfix(ref JobDriver_SexBaseInitiator __instance)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Pawn pawn = __instance.pawn;
 | 
					            Pawn pawn = __instance.pawn;
 | 
				
			||||||
            Pawn partner = __instance.Target as Pawn;
 | 
					            Pawn partner = __instance.Target as Pawn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (partner == null)
 | 
				
			||||||
 | 
					                partner = pawn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (partner?.jobs?.curDriver is JobDriver_SexBaseReciever partnerSexBaseReceiver) {
 | 
					            List<Pawn> participants = GetAllSexParticipants(pawn);
 | 
				
			||||||
 | 
					 | 
				
			||||||
				Pawn Target = __instance.Target as Pawn;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				List<Pawn> participants = partnerSexBaseReceiver.parteners.Append(partner).ToList();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            GroupAnimationDef groupAnimation = AnimationUtility.FindGroupAnimation(participants, out int reorder);
 | 
					            GroupAnimationDef groupAnimation = AnimationUtility.FindGroupAnimation(participants, out int reorder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (groupAnimation != null)
 | 
					            if (groupAnimation != null)
 | 
				
			||||||
| 
						 | 
					@ -31,13 +31,12 @@ namespace Rimworld_Animations {
 | 
				
			||||||
                AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder, anchor);
 | 
					                AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder, anchor);
 | 
				
			||||||
                int animTicks = AnimationUtility.GetAnimationLength(pawn);
 | 
					                int animTicks = AnimationUtility.GetAnimationLength(pawn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					foreach(Pawn participant in participants)
 | 
					                foreach (Pawn participant in participants)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (RJWAnimationSettings.debugMode)
 | 
					                    if (RJWAnimationSettings.debugMode)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        Log.Message("Participant: " + participant.Name);
 | 
					                        Log.Message("Participant: " + participant.Name);
 | 
				
			||||||
                        Log.Message("JobDriver: " + participant.CurJobDef.defName);
 | 
					                        Log.Message("JobDriver: " + participant.CurJobDef.defName);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    //null ref check for pawns that might have lost their jobs or become null for some reason
 | 
					                    //null ref check for pawns that might have lost their jobs or become null for some reason
 | 
				
			||||||
| 
						 | 
					@ -51,6 +50,47 @@ namespace Rimworld_Animations {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static List<Pawn> GetAllSexParticipants(this Pawn pawn)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            List<Pawn> participants = new List<Pawn>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (pawn?.jobs?.curDriver == null ||
 | 
				
			||||||
 | 
					                (pawn.jobs.curDriver is JobDriver_Sex) == false)
 | 
				
			||||||
 | 
					                return participants;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var receiver = pawn.GetSexReceiver();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (receiver != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                participants = (receiver.jobs.curDriver as JobDriver_SexBaseReciever).parteners;
 | 
				
			||||||
 | 
					                participants.AddDistinct(receiver);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return participants;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            participants.AddDistinct(pawn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return participants;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static Pawn GetSexReceiver(this Pawn pawn)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (pawn?.jobs?.curDriver == null)
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (pawn.jobs.curDriver is JobDriver_SexBaseReciever)
 | 
				
			||||||
 | 
					                return pawn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            JobDriver_SexBaseInitiator jobDriver = pawn.jobs.curDriver as JobDriver_SexBaseInitiator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (jobDriver?.Partner?.jobs?.curDriver == null)
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (jobDriver.Partner.jobs.curDriver is JobDriver_SexBaseReciever)
 | 
				
			||||||
 | 
					                return jobDriver.Partner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static IEnumerable<String> NonSexActRulePackDefNames = new String[]
 | 
					        static IEnumerable<String> NonSexActRulePackDefNames = new String[]
 | 
				
			||||||
| 
						 | 
					@ -61,7 +101,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static bool NonSexualAct(JobDriver_SexBaseInitiator sexBaseInitiator)
 | 
					        public static bool NonSexualAct(JobDriver_SexBaseInitiator sexBaseInitiator)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
			if(NonSexActRulePackDefNames.Contains(sexBaseInitiator.Sexprops.rulePack))
 | 
					            if (NonSexActRulePackDefNames.Contains(sexBaseInitiator.Sexprops.rulePack))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -71,7 +111,8 @@ namespace Rimworld_Animations {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "End")]
 | 
					    [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "End")]
 | 
				
			||||||
	static class HarmonyPatch_JobDriver_SexBaseInitiator_End {
 | 
					    static class HarmonyPatch_JobDriver_SexBaseInitiator_End
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void Prefix(ref JobDriver_SexBaseInitiator __instance)
 | 
					        public static void Prefix(ref JobDriver_SexBaseInitiator __instance)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -88,7 +129,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
            //added null ref checks for instances when pawns get nulled or lose their jobs
 | 
					            //added null ref checks for instances when pawns get nulled or lose their jobs
 | 
				
			||||||
            if (__instance.Partner?.jobs?.curDriver is JobDriver_SexBaseReciever partnerReceiverJob)
 | 
					            if (__instance.Partner?.jobs?.curDriver is JobDriver_SexBaseReciever partnerReceiverJob)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
				foreach(Pawn pawn in partnerReceiverJob.parteners)
 | 
					                foreach (Pawn pawn in partnerReceiverJob.parteners)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if (pawn != null) AnimationUtility.StopGroupAnimation(pawn);
 | 
					                    if (pawn != null) AnimationUtility.StopGroupAnimation(pawn);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue