mirror of
				https://gitgud.io/AbstractConcept/rimworld-animations-patch.git
				synced 2024-08-15 00:43:27 +00:00 
			
		
		
		
	v2.0.0
This commit is contained in:
		
							parent
							
								
									38ec4f86c1
								
							
						
					
					
						commit
						ae95e34137
					
				
					 35 changed files with 242 additions and 612 deletions
				
			
		| 
						 | 
				
			
			@ -1,70 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace Rimworld_Animations_Patch
 | 
			
		||||
{
 | 
			
		||||
    public class ActorAddon
 | 
			
		||||
    {
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        public string addonName;
 | 
			
		||||
        public int? anchoringActor;
 | 
			
		||||
        public string anchorName;
 | 
			
		||||
        public string layer = "Pawn";
 | 
			
		||||
        public GraphicData graphicData;
 | 
			
		||||
        public bool? render;
 | 
			
		||||
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        public string AddonName
 | 
			
		||||
        {
 | 
			
		||||
            get { return addonName; }
 | 
			
		||||
            set { addonName = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int AnchoringActor
 | 
			
		||||
        {
 | 
			
		||||
            get { return anchoringActor.HasValue ? anchoringActor.Value : 0; }
 | 
			
		||||
            set { anchoringActor = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string AnchorName
 | 
			
		||||
        {
 | 
			
		||||
            get { return anchorName; }
 | 
			
		||||
            set { anchorName = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string Layer
 | 
			
		||||
        {
 | 
			
		||||
            get { return layer; }
 | 
			
		||||
            set { layer = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public GraphicData GraphicData
 | 
			
		||||
        {
 | 
			
		||||
            get { return graphicData; }
 | 
			
		||||
            set { graphicData = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool Render
 | 
			
		||||
        {
 | 
			
		||||
            get { return render == true; }
 | 
			
		||||
            set { render = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Simple curves
 | 
			
		||||
        public SimpleCurve PosX = new SimpleCurve();
 | 
			
		||||
        public SimpleCurve PosZ = new SimpleCurve();
 | 
			
		||||
        public SimpleCurve Rotation = new SimpleCurve();
 | 
			
		||||
 | 
			
		||||
        // Constructors
 | 
			
		||||
        public ActorAddon() { }
 | 
			
		||||
 | 
			
		||||
        public ActorAddon(ActorAddonDef actorAddonDef)
 | 
			
		||||
        {
 | 
			
		||||
            this.GraphicData = actorAddonDef.graphicData;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,15 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace Rimworld_Animations_Patch
 | 
			
		||||
{
 | 
			
		||||
    public class ActorAddonDef : Def
 | 
			
		||||
    {
 | 
			
		||||
        public float scale = 1f;
 | 
			
		||||
        public GraphicData graphicData;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,56 +0,0 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Rimworld_Animations_Patch
 | 
			
		||||
{
 | 
			
		||||
    public class AddonKeyframe
 | 
			
		||||
    {
 | 
			
		||||
        // Data to/from animationDef
 | 
			
		||||
        public string addonName;
 | 
			
		||||
        public float? posX;
 | 
			
		||||
        public float? posZ;
 | 
			
		||||
        public float? rotation;
 | 
			
		||||
 | 
			
		||||
        // Data serialization control
 | 
			
		||||
        public bool ShouldSerializeposX() { return posX.HasValue; }
 | 
			
		||||
        public bool ShouldSerializeposZ() { return posZ.HasValue; }
 | 
			
		||||
        public bool ShouldSerializerotation() { return rotation.HasValue; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // Data helper functions
 | 
			
		||||
        public string AddonName
 | 
			
		||||
        {
 | 
			
		||||
            get { return addonName; }
 | 
			
		||||
            set { addonName = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public float PosX
 | 
			
		||||
        {
 | 
			
		||||
            get { return posX.HasValue ? posX.Value : 0f; }
 | 
			
		||||
            set { posX = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public float PosZ
 | 
			
		||||
        {
 | 
			
		||||
            get { return posZ.HasValue ? posZ.Value : 0f; }
 | 
			
		||||
            set { posZ = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public float Rotation
 | 
			
		||||
        {
 | 
			
		||||
            get { return rotation.HasValue ? rotation.Value : 0f; }
 | 
			
		||||
            set { rotation = value; }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Constructors
 | 
			
		||||
        public AddonKeyframe() { }
 | 
			
		||||
 | 
			
		||||
        public AddonKeyframe(string addonName)
 | 
			
		||||
        {
 | 
			
		||||
            this.AddonName = addonName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -22,12 +22,12 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
        private PawnRenderFlags renderFlags;
 | 
			
		||||
        private bool canDraw = false;
 | 
			
		||||
        private bool bodyPartMissing = false;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
        public BodyAddonData(Pawn pawn, AlienPartGenerator.BodyAddon bodyAddon, bool isPortrait = false)
 | 
			
		||||
        {
 | 
			
		||||
            this.pawn = pawn;
 | 
			
		||||
            this.bodyAddon = bodyAddon;
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            if (isPortrait)
 | 
			
		||||
            { renderFlags |= PawnRenderFlags.Portrait; }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -42,11 +42,11 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
        {
 | 
			
		||||
            bodyType = pawn.story.bodyType.defName;
 | 
			
		||||
            bodyAddonOffsets.Clear();
 | 
			
		||||
         
 | 
			
		||||
 | 
			
		||||
            int bodyAddonIndex = (pawn.def as ThingDef_AlienRace).alienRace.generalSettings.alienPartGenerator.bodyAddons.IndexOf(bodyAddon);
 | 
			
		||||
            AlienPartGenerator.AlienComp alienComp = pawn.GetComp<AlienPartGenerator.AlienComp>();
 | 
			
		||||
            Graphic addonGraphic = alienComp.addonGraphics[bodyAddonIndex];
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
            for (int i = 0; i < 4; i++)
 | 
			
		||||
            {
 | 
			
		||||
                Rot4 apparentRotation = new Rot4(i);
 | 
			
		||||
| 
						 | 
				
			
			@ -54,8 +54,8 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
                // Get basic offset for body addon
 | 
			
		||||
                AlienPartGenerator.RotationOffset defaultOffsets = bodyAddon.defaultOffsets.GetOffset(apparentRotation);
 | 
			
		||||
                Vector3 bodyTypeOffset = (defaultOffsets != null) ? defaultOffsets.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, pawn.story.headType) : Vector3.zero;
 | 
			
		||||
                
 | 
			
		||||
                AlienPartGenerator.RotationOffset rotationOffsets = bodyAddon.offsets.GetOffset(apparentRotation);        
 | 
			
		||||
 | 
			
		||||
                AlienPartGenerator.RotationOffset rotationOffsets = bodyAddon.offsets.GetOffset(apparentRotation);
 | 
			
		||||
                Vector3 bodyAddonOffset = bodyTypeOffset + ((rotationOffsets != null) ? rotationOffsets.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, pawn.story.headType) : Vector3.zero);
 | 
			
		||||
 | 
			
		||||
                // Offset private parts so that they render over tattoos but under apparel (rendering under tatoos looks weird)
 | 
			
		||||
| 
						 | 
				
			
			@ -65,8 +65,8 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
 | 
			
		||||
                    // Erected penises should be drawn over apparel
 | 
			
		||||
                    if (pawn.RaceProps.Humanlike &&
 | 
			
		||||
                        (addonGraphic.path.Contains("penis") || addonGraphic.path.Contains("Penis")) &&
 | 
			
		||||
                        (addonGraphic.path.Contains("flaccid") == false && addonGraphic.path.Contains("Flaccid") == false) &&
 | 
			
		||||
                        addonGraphic.path.Contains("penis", StringComparison.OrdinalIgnoreCase) &&
 | 
			
		||||
                        (addonGraphic.path.Contains("flaccid", StringComparison.OrdinalIgnoreCase) == false) &&
 | 
			
		||||
                        apparentRotation == Rot4.South)
 | 
			
		||||
                    { bodyAddonOffset.y += 0.010f; }
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			@ -74,21 +74,21 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
                // Otherwise use the standard offsets
 | 
			
		||||
                else
 | 
			
		||||
                { bodyAddonOffset.y = 0.3f + bodyAddonOffset.y; }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
                // Draw addons infront of body
 | 
			
		||||
                if (!bodyAddon.inFrontOfBody)
 | 
			
		||||
                { bodyAddonOffset.y *= -1f; }
 | 
			
		||||
          
 | 
			
		||||
 | 
			
		||||
                // Adjust for facing
 | 
			
		||||
                if (apparentRotation == Rot4.North)
 | 
			
		||||
                {
 | 
			
		||||
                    if (bodyAddon.layerInvert)
 | 
			
		||||
                    { bodyAddonOffset.y = -bodyAddonOffset.y; }
 | 
			
		||||
                }
 | 
			
		||||
             
 | 
			
		||||
 | 
			
		||||
                if (apparentRotation == Rot4.East)
 | 
			
		||||
                { bodyAddonOffset.x = -bodyAddonOffset.x; }
 | 
			
		||||
          
 | 
			
		||||
 | 
			
		||||
                // Adjustment for body addons attached to the head that are not marked as such
 | 
			
		||||
                if (alignsWithHead && bodyAddon.alignWithHead == false)
 | 
			
		||||
                { bodyAddonOffset -= pawn.Drawer.renderer.BaseHeadOffsetAt(apparentRotation); }
 | 
			
		||||
| 
						 | 
				
			
			@ -102,9 +102,9 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
        {
 | 
			
		||||
            if (pawn.story.bodyType.defName != bodyType)
 | 
			
		||||
            { GenerateOffsets(); }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            return bodyAddonOffsets[facing.AsInt];
 | 
			
		||||
        }   
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool CanDraw()
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			@ -146,7 +146,7 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
 | 
			
		||||
            if (pawn?.apparel?.WornApparel == null || pawn.apparel.WornApparel.NullOrEmpty())
 | 
			
		||||
            { return; }
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
            foreach (Apparel apparel in pawn.apparel.WornApparel)
 | 
			
		||||
            {
 | 
			
		||||
                CompApparelVisibility comp = apparel?.TryGetComp<CompApparelVisibility>();
 | 
			
		||||
| 
						 | 
				
			
			@ -155,9 +155,9 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
 | 
			
		||||
                if (comp.isBeingWorn == false) continue;
 | 
			
		||||
 | 
			
		||||
                if (bodyAddon.bodyPart == PatchBodyPartDefOf.Genitals || 
 | 
			
		||||
                    bodyAddon.bodyPart == PatchBodyPartDefOf.Anus || 
 | 
			
		||||
                    bodyAddon.bodyPart == PatchBodyPartDefOf.Chest || 
 | 
			
		||||
                if (bodyAddon.bodyPart == PatchBodyPartDefOf.Genitals ||
 | 
			
		||||
                    bodyAddon.bodyPart == PatchBodyPartDefOf.Anus ||
 | 
			
		||||
                    bodyAddon.bodyPart == PatchBodyPartDefOf.Chest ||
 | 
			
		||||
                    bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && (x.path.Contains("belly") || x.path.Contains("Belly"))) == true)
 | 
			
		||||
                {
 | 
			
		||||
                    if ((bodyAddon.bodyPart == PatchBodyPartDefOf.Genitals || bodyAddon.bodyPart == PatchBodyPartDefOf.Anus) && comp.coversGroin)
 | 
			
		||||
| 
						 | 
				
			
			@ -204,4 +204,4 @@ namespace Rimworld_Animations_Patch
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue