mirror of
				https://gitgud.io/AbstractConcept/rimworld-animations-patch.git
				synced 2024-08-15 00:43:27 +00:00 
			
		
		
		
	v 2.0.0
This commit is contained in:
		
							parent
							
								
									fcf187c7dd
								
							
						
					
					
						commit
						38ec4f86c1
					
				
					 68 changed files with 846 additions and 1934 deletions
				
			
		
							
								
								
									
										54
									
								
								Source/Scripts/Extensions/PawnAnimationClipExt.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								Source/Scripts/Extensions/PawnAnimationClipExt.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,54 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Rimworld_Animations;
 | 
			
		||||
 | 
			
		||||
namespace Rimworld_Animations_Patch
 | 
			
		||||
{
 | 
			
		||||
    public class PawnAnimationClipExt : PawnAnimationClip
 | 
			
		||||
    {
 | 
			
		||||
        public List<ActorAddon> addons = new List<ActorAddon>();
 | 
			
		||||
 | 
			
		||||
        public override void buildSimpleCurves()
 | 
			
		||||
        {
 | 
			
		||||
            base.buildSimpleCurves();
 | 
			
		||||
            int keyframePosition = 0;
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < keyframes.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                PawnKeyframeExt keyframe = keyframes[i] as PawnKeyframeExt;
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                if (keyframe.atTick.HasValue)
 | 
			
		||||
                {
 | 
			
		||||
                    foreach (ActorAddon addon in addons)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (keyframe.addonKeyframes.Any(x => x.AddonName == addon.AddonName) == false)
 | 
			
		||||
                        { keyframe.addonKeyframes.Add(new AddonKeyframe(addon.AddonName)); }
 | 
			
		||||
 | 
			
		||||
                        addon.PosX.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).PosX, true);
 | 
			
		||||
                        addon.PosZ.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).PosZ, true);
 | 
			
		||||
                        addon.Rotation.Add((float)keyframe.atTick / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).Rotation, true);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                else
 | 
			
		||||
                {                  
 | 
			
		||||
                    foreach (ActorAddon addon in addons)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (keyframe.addonKeyframes.Any(x => x.AddonName == addon.AddonName) == false)
 | 
			
		||||
                        { keyframe.addonKeyframes.Add(new AddonKeyframe(addon.AddonName)); }
 | 
			
		||||
 | 
			
		||||
                        addon.PosX.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).PosX, true);
 | 
			
		||||
                        addon.PosZ.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).PosZ, true);
 | 
			
		||||
                        addon.Rotation.Add((float)keyframePosition / (float)duration, keyframe.GetAddonKeyframe(addon.AddonName).Rotation, true);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    keyframePosition += keyframe.tickDuration;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -85,14 +85,14 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
		
 | 
			
		||||
			if (pawn.GetSexReceiver() != null)
 | 
			
		||||
			{ 
 | 
			
		||||
				List<Pawn> partners = (pawn.GetSexReceiver().jobs.curDriver as JobDriver_SexBaseReciever).parteners.ToList();
 | 
			
		||||
				List<Pawn> partners = (pawn.GetSexReceiver().jobs.curDriver as JobDriver_SexBaseReciever).parteners;
 | 
			
		||||
 | 
			
		||||
				if (partners != null)
 | 
			
		||||
				{
 | 
			
		||||
					foreach (Pawn partner in partners)
 | 
			
		||||
					{
 | 
			
		||||
						if (partner != null)
 | 
			
		||||
						{ participants = partners; }
 | 
			
		||||
						{ participants = partners; break; }
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			@ -111,77 +111,6 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
			return participants;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static bool IsLoverOfOther(this Pawn pawn, Pawn other)
 | 
			
		||||
		{
 | 
			
		||||
			if (pawn == null || other == null)
 | 
			
		||||
			{ return false; }
 | 
			
		||||
 | 
			
		||||
			List<DirectPawnRelation> lovers = SpouseRelationUtility.GetLoveRelations(pawn, false);
 | 
			
		||||
			return lovers.Any(x => x.otherPawn == other);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static bool HasPrivacy(this Pawn pawn, float radius)
 | 
			
		||||
		{
 | 
			
		||||
			if (pawn.AnimalOrWildMan() || pawn.RaceProps.Humanlike == false)
 | 
			
		||||
			{ return true; }
 | 
			
		||||
 | 
			
		||||
			if (pawn.IsHavingSex() == false && pawn.IsMasturbating() == false)
 | 
			
		||||
			{ return true; }
 | 
			
		||||
 | 
			
		||||
			if (pawn.GetLord() != null && pawn.GetLord().LordJob is LordJob_Ritual)
 | 
			
		||||
			{ return true; }
 | 
			
		||||
 | 
			
		||||
			if (pawn.GetLord() != null && pawn.GetLord().LordJob is LordJob_Joinable_Party)
 | 
			
		||||
			{ return true; }
 | 
			
		||||
 | 
			
		||||
			bool hasPrivacy = true;
 | 
			
		||||
			bool isExhibitionist = xxx.has_quirk(pawn, "Exhibitionist");
 | 
			
		||||
 | 
			
		||||
			pawn.IsInBed(out Building bed);
 | 
			
		||||
 | 
			
		||||
			foreach (Thing thing in GenRadial.RadialDistinctThingsAround(pawn.Position, pawn.Map, radius, true))
 | 
			
		||||
			{
 | 
			
		||||
				Pawn witness = thing as Pawn;
 | 
			
		||||
 | 
			
		||||
				// Caught having sex
 | 
			
		||||
				if (SexInteractionUtility.PawnCaughtLovinByWitness(pawn, witness))
 | 
			
		||||
				{
 | 
			
		||||
					SexInteractionUtility.ResolveThoughtsForWhenSexIsWitnessed(pawn, witness, out bool witnessJoiningSex);
 | 
			
		||||
 | 
			
		||||
					// Try to invite intruder to join in
 | 
			
		||||
					if (witnessJoiningSex)
 | 
			
		||||
					{
 | 
			
		||||
						if (pawn.IsMasturbating())
 | 
			
		||||
						{
 | 
			
		||||
							if (bed == null)
 | 
			
		||||
							{ 
 | 
			
		||||
								Job job = new Job(xxx.quick_sex, pawn);
 | 
			
		||||
								witness.jobs.TryTakeOrderedJob(job);
 | 
			
		||||
							}
 | 
			
		||||
 | 
			
		||||
							else
 | 
			
		||||
							{
 | 
			
		||||
								Job job = new Job(xxx.casual_sex, pawn, bed);
 | 
			
		||||
								witness.jobs.TryTakeOrderedJob(job);
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						else if (pawn.GetSexReceiver() != null)
 | 
			
		||||
						{
 | 
			
		||||
							Job job = new Job(DefDatabase<JobDef>.GetNamed("JoinInSex", false), pawn.GetSexReceiver(), bed);
 | 
			
		||||
							witness.jobs.TryTakeOrderedJob(job);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					// The invitation failed
 | 
			
		||||
					else
 | 
			
		||||
					{ hasPrivacy = false; }
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return hasPrivacy || isExhibitionist || BasicSettings.needPrivacy == false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static ActorAnimationData GetAnimationData(this Pawn pawn)
 | 
			
		||||
		{
 | 
			
		||||
			if (pawn.TryGetComp<CompBodyAnimator>() == null) return null;
 | 
			
		||||
| 
						 | 
				
			
			@ -192,82 +121,9 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
			int currentStage = (int)AccessTools.Field(typeof(CompBodyAnimator), "curStage").GetValue(pawn.TryGetComp<CompBodyAnimator>());
 | 
			
		||||
			int stageTicks = (int)AccessTools.Field(typeof(CompBodyAnimator), "stageTicks").GetValue(pawn.TryGetComp<CompBodyAnimator>());
 | 
			
		||||
			Rot4 actorFacing = (Rot4)AccessTools.Field(typeof(CompBodyAnimator), "bodyFacing").GetValue(pawn.TryGetComp<CompBodyAnimator>());
 | 
			
		||||
			bool isMirrored = pawn.TryGetComp<CompBodyAnimator>().Mirror;
 | 
			
		||||
 | 
			
		||||
			return new ActorAnimationData(animationDef, actorID, currentStage, stageTicks, actorFacing);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static List<BodyPartRecord> GetHands(this Pawn pawn)
 | 
			
		||||
		{
 | 
			
		||||
			return pawn.health.hediffSet.GetNotMissingParts().Where(x => x.def == PatchBodyPartDefOf.Hand)?.ToList();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static bool HasPreceptForIssue(this Pawn pawn, string issueDefName, out Precept precept)
 | 
			
		||||
		{
 | 
			
		||||
			precept = null;
 | 
			
		||||
 | 
			
		||||
			if (pawn?.Ideo == null)
 | 
			
		||||
			{ return false; }
 | 
			
		||||
 | 
			
		||||
			foreach (Precept _precept in pawn.Ideo.PreceptsListForReading)
 | 
			
		||||
			{
 | 
			
		||||
				if (_precept.def.issue.defName == issueDefName)
 | 
			
		||||
				{
 | 
			
		||||
					precept = _precept;
 | 
			
		||||
					return true; 
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static bool EnjoysViolence(this Pawn pawn)
 | 
			
		||||
		{
 | 
			
		||||
			if (pawn.IsAnimal() || pawn.RaceProps.IsMechanoid)
 | 
			
		||||
			{ return true; }
 | 
			
		||||
 | 
			
		||||
			if (pawn?.story?.traits?.allTraits == null || pawn?.story?.traits?.allTraits.NullOrEmpty() == true)
 | 
			
		||||
			{ return false; }
 | 
			
		||||
 | 
			
		||||
			List<string> traits = new List<string>() { "Brawler", "Psychopath", "Bloodlust" };
 | 
			
		||||
 | 
			
		||||
			return pawn.story.traits.allTraits.Any(x => traits.Contains(x.def.defName));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static bool DislikesViolence(this Pawn pawn)
 | 
			
		||||
		{
 | 
			
		||||
			if (pawn.IsAnimal() || pawn.RaceProps.IsMechanoid)
 | 
			
		||||
			{ return false; }
 | 
			
		||||
 | 
			
		||||
			if (pawn?.story?.traits?.allTraits == null || pawn?.story?.traits?.allTraits.NullOrEmpty() == true)
 | 
			
		||||
			{ return false; }
 | 
			
		||||
 | 
			
		||||
			List<string> traits = new List<string>() { "Kind", "Wimp" };
 | 
			
		||||
 | 
			
		||||
			return pawn.WorkTagIsDisabled(WorkTags.Violent) || pawn.story.traits.allTraits.Any(x => traits.Contains(x.def.defName));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static bool HasTrait(this Pawn pawn, string trait)
 | 
			
		||||
		{
 | 
			
		||||
			if (pawn?.story?.traits?.allTraits == null || pawn.story.traits.allTraits.NullOrEmpty())
 | 
			
		||||
			{ return false; }
 | 
			
		||||
 | 
			
		||||
			TraitDef traitDef = DefDatabase<TraitDef>.GetNamedSilentFail(trait);
 | 
			
		||||
 | 
			
		||||
			if (traitDef == null)
 | 
			
		||||
			{ traitDef = DefDatabase<TraitDef>.GetNamedSilentFail(trait.ToLower()); }
 | 
			
		||||
 | 
			
		||||
			return HasTrait(pawn, traitDef);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public static bool HasTrait(this Pawn pawn, TraitDef traitDef)
 | 
			
		||||
		{
 | 
			
		||||
			if (pawn?.story?.traits?.allTraits == null || pawn.story.traits.allTraits.NullOrEmpty())
 | 
			
		||||
			{ return false; }
 | 
			
		||||
 | 
			
		||||
			if (traitDef == null)
 | 
			
		||||
			{ return false; }
 | 
			
		||||
 | 
			
		||||
			return pawn.story.traits.HasTrait(traitDef);
 | 
			
		||||
			return new ActorAnimationData(animationDef, actorID, currentStage, stageTicks, actorFacing, isMirrored);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								Source/Scripts/Extensions/PawnKeyframeExt.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								Source/Scripts/Extensions/PawnKeyframeExt.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Rimworld_Animations;
 | 
			
		||||
 | 
			
		||||
namespace Rimworld_Animations_Patch
 | 
			
		||||
{
 | 
			
		||||
    public class PawnKeyframeExt : PawnKeyframe
 | 
			
		||||
    {
 | 
			
		||||
        public List<AddonKeyframe> addonKeyframes;
 | 
			
		||||
 | 
			
		||||
        public AddonKeyframe GetAddonKeyframe(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            return addonKeyframes.FirstOrDefault(x => x.AddonName == addonName);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								Source/Scripts/Extensions/StringExtension.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								Source/Scripts/Extensions/StringExtension.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Rimworld_Animations_Patch
 | 
			
		||||
{
 | 
			
		||||
    public static class StringExtension
 | 
			
		||||
    {
 | 
			
		||||
        public static bool Contains(this string fullString, string subString, StringComparison comparer)
 | 
			
		||||
        {
 | 
			
		||||
            return fullString?.IndexOf(subString, comparer) >= 0;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue