mirror of
				https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
				synced 2024-08-15 00:43:45 +00:00 
			
		
		
		
	save shift value and reuse for every anim
This commit is contained in:
		
							parent
							
								
									2886b647a7
								
							
						
					
					
						commit
						59d062f4c9
					
				
					 5 changed files with 68 additions and 11 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -49,6 +49,8 @@ namespace Rimworld_Animations {
 | 
				
			||||||
        public float bodyAngle = 0, headAngle = 0, genitalAngle = 0;
 | 
					        public float bodyAngle = 0, headAngle = 0, genitalAngle = 0;
 | 
				
			||||||
        public Rot4 headFacing = Rot4.North, bodyFacing = Rot4.North;
 | 
					        public Rot4 headFacing = Rot4.North, bodyFacing = Rot4.North;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public xxx.rjwSextype curSexType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public List<Pawn> actorsInCurrentAnimation;
 | 
					        public List<Pawn> actorsInCurrentAnimation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool controlGenitalAngle = false;
 | 
					        public bool controlGenitalAngle = false;
 | 
				
			||||||
| 
						 | 
					@ -111,9 +113,10 @@ namespace Rimworld_Animations {
 | 
				
			||||||
                anchor = thing.Position.ToVector3Shifted();
 | 
					                anchor = thing.Position.ToVector3Shifted();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public void StartAnimation(AnimationDef anim, List<Pawn> actors, int actor, bool mirror = false, bool shiver = false, bool fastAnimForQuickie = false) {
 | 
					        public void StartAnimation(AnimationDef anim, List<Pawn> actors, int actor, bool mirror = false, bool shiver = false, bool fastAnimForQuickie = false, xxx.rjwSextype sexType = xxx.rjwSextype.Masturbation) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            actorsInCurrentAnimation = actors;
 | 
					            actorsInCurrentAnimation = actors;
 | 
				
			||||||
 | 
					            curSexType = sexType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (anim.actors.Count <= actor)
 | 
					            if (anim.actors.Count <= actor)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -497,6 +500,15 @@ namespace Rimworld_Animations {
 | 
				
			||||||
            controlGenitalAngle = anim.actors[actor].controlGenitalAngle;
 | 
					            controlGenitalAngle = anim.actors[actor].controlGenitalAngle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            tickAnim();
 | 
					            tickAnim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //reset the clock time of every pawn in animation
 | 
				
			||||||
 | 
					            if (pawn.jobs.curDriver is rjw.JobDriver_Sex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                (pawn.jobs.curDriver as rjw.JobDriver_Sex).ticks_left = anim.animationTimeTicks;
 | 
				
			||||||
 | 
					                (pawn.jobs.curDriver as rjw.JobDriver_Sex).ticksLeftThisToil = anim.animationTimeTicks;
 | 
				
			||||||
 | 
					                (pawn.jobs.curDriver as rjw.JobDriver_Sex).duration = anim.animationTimeTicks;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool LoopNeverending()
 | 
					        public bool LoopNeverending()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,6 +51,26 @@ namespace Rimworld_Animations {
 | 
				
			||||||
                        AnimationSettings.rotation.Add(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex, 0);
 | 
					                        AnimationSettings.rotation.Add(def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex, 0);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    List<Pawn> pawnsToAnimateOrdered = curPawn.TryGetComp<CompBodyAnimator>().actorsInCurrentAnimation.OrderBy(x => Int32.Parse(x.Name.ToStringSafe())).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    string pawnNamesAndSexType = "";
 | 
				
			||||||
 | 
					                    foreach (Pawn p in pawnsToAnimateOrdered)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        pawnNamesAndSexType += p.Name.ToStringSafe();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    pawnNamesAndSexType += curPawn.TryGetComp<CompBodyAnimator>().curSexType.ToStringSafe();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    int shiftCount = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (AnimationSettings.shiftCount.TryGetValue(pawnNamesAndSexType, out int value))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        shiftCount = value;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        AnimationSettings.shiftCount.Add(pawnNamesAndSexType, 0);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    listingStandard.Label("Name: " + curPawn.Name + " Race: " + curPawn.def.defName + " Actor Index: " + curPawn.TryGetComp<CompBodyAnimator>().ActorIndex + " Body Type (if any): " + bodyTypeDef + " Animation: " + def.label + (curPawn.TryGetComp<CompBodyAnimator>().Mirror ? " mirrored" : ""));
 | 
					                    listingStandard.Label("Name: " + curPawn.Name + " Race: " + curPawn.def.defName + " Actor Index: " + curPawn.TryGetComp<CompBodyAnimator>().ActorIndex + " Body Type (if any): " + bodyTypeDef + " Animation: " + def.label + (curPawn.TryGetComp<CompBodyAnimator>().Mirror ? " mirrored" : ""));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if(curPawn.def.defName == "Human") {
 | 
					                    if(curPawn.def.defName == "Human") {
 | 
				
			||||||
| 
						 | 
					@ -76,32 +96,31 @@ namespace Rimworld_Animations {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    listingStandard.GapLine();
 | 
					                    listingStandard.GapLine();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if(listingStandard.ButtonText("Shift Actors")) {
 | 
					                    if (listingStandard.ButtonText("Shift Actors")) {
 | 
				
			||||||
                        
 | 
					                        
 | 
				
			||||||
                        if(AnimationSettings.debugMode) {
 | 
					                        if(AnimationSettings.debugMode) {
 | 
				
			||||||
                            Log.Message("Shifting actors in animation...");
 | 
					                            Log.Message("Shifting actors in animation...");
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        for(int i = 0; i < curPawn.TryGetComp<CompBodyAnimator>().actorsInCurrentAnimation.Count; i++) {
 | 
					                        AnimationSettings.shiftCount[pawnNamesAndSexType] = shiftCount + 1 % curPawn.TryGetComp<CompBodyAnimator>().actorsInCurrentAnimation.Count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        for (int i = 0; i < curPawn.TryGetComp<CompBodyAnimator>().actorsInCurrentAnimation.Count; i++) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            Pawn actor = curPawn.TryGetComp<CompBodyAnimator>().actorsInCurrentAnimation[i];
 | 
					                            Pawn actor = curPawn.TryGetComp<CompBodyAnimator>().actorsInCurrentAnimation[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            actor.TryGetComp<CompBodyAnimator>()?.shiftActorPositionAndRestartAnimation();
 | 
					                            actor.TryGetComp<CompBodyAnimator>()?.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) {
 | 
					                    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);
 | 
					                        AnimationSettings.offsets[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex] = new Vector2(offsetX, offsetZ);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex]) {
 | 
					                    if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + bodyTypeDef + ActorIndex]) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,6 +94,30 @@ namespace Rimworld_Animations {
 | 
				
			||||||
					pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().isAnimating = false;
 | 
										pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().isAnimating = false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									List<Pawn> pawnsToAnimateOrdered = pawnsToAnimate.OrderBy(x => Int32.Parse(x.Name.ToStringSafe())).ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									string pawnNamesAndSexType = "";
 | 
				
			||||||
 | 
									foreach (Pawn p in pawnsToAnimateOrdered)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
										pawnNamesAndSexType += p.Name.ToStringSafe();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
									pawnNamesAndSexType += sexType.ToStringSafe();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (AnimationSettings.shiftCount.TryGetValue(pawnNamesAndSexType, out int value))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										Log.Message("Shifting " + pawnNamesAndSexType + " " + value + "times");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										for(int i = 0; i < value; i++)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
											for(int j = 0; j < pawnsToAnimate.Count; j++)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
												pawnsToAnimate[j].TryGetComp<CompBodyAnimator>().shiftActorPositionAndRestartAnimation();
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				for (int i = 0; i < pawnsToAnimate.Count; i++) {
 | 
									for (int i = 0; i < pawnsToAnimate.Count; i++) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					if (bed != null)
 | 
										if (bed != null)
 | 
				
			||||||
| 
						 | 
					@ -104,7 +128,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					bool shiver = pawnsToAnimate[i].jobs.curDriver is JobDriver_SexBaseRecieverRaped;
 | 
										bool shiver = pawnsToAnimate[i].jobs.curDriver is JobDriver_SexBaseRecieverRaped;
 | 
				
			||||||
					pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().StartAnimation(anim, pawnsToAnimate, i, mirror, shiver, fastAnimForQuickie);
 | 
										pawnsToAnimate[i].TryGetComp<CompBodyAnimator>().StartAnimation(anim, pawnsToAnimate, i, mirror, shiver, fastAnimForQuickie, sexType);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					int animTicks = anim.animationTimeTicks - (fastAnimForQuickie ? anim.animationStages[0].playTimeTicks : 0);
 | 
										int animTicks = anim.animationTimeTicks - (fastAnimForQuickie ? anim.animationStages[0].playTimeTicks : 0);
 | 
				
			||||||
					(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = animTicks;
 | 
										(pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = animTicks;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static Dictionary<string, Vector2> offsets = new Dictionary<string, Vector2>();
 | 
					        public static Dictionary<string, Vector2> offsets = new Dictionary<string, Vector2>();
 | 
				
			||||||
        public static Dictionary<string, float> rotation = new Dictionary<string, float>();
 | 
					        public static Dictionary<string, float> rotation = new Dictionary<string, float>();
 | 
				
			||||||
 | 
					        public static Dictionary<string, int> shiftCount = new Dictionary<string, int>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public override void ExposeData() {
 | 
					        public override void ExposeData() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +39,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Scribe_Collections.Look(ref offsets, "RJWAnimations-animationOffsets");
 | 
					            Scribe_Collections.Look(ref offsets, "RJWAnimations-animationOffsets");
 | 
				
			||||||
            Scribe_Collections.Look(ref rotation, "RJWAnimations-rotationOffsets");
 | 
					            Scribe_Collections.Look(ref rotation, "RJWAnimations-rotationOffsets");
 | 
				
			||||||
 | 
					            Scribe_Collections.Look(ref shiftCount, "RJWAnimations-shiftCount");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue