This commit is contained in:
AbstractConcept 2023-02-04 01:13:57 -06:00
parent fcf187c7dd
commit 38ec4f86c1
68 changed files with 846 additions and 1934 deletions

View file

@ -0,0 +1,70 @@
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;
}
}
}

View file

@ -0,0 +1,15 @@
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;
}
}

View file

@ -16,14 +16,16 @@ namespace Rimworld_Animations_Patch
public int currentStage = 0;
public int stageTicks = 0;
public Rot4 actorFacing = Rot4.South;
public bool isMirrored;
public ActorAnimationData(AnimationDef animationDef, int actorID, int currentStage, int stageTicks, Rot4 actorFacing)
public ActorAnimationData(AnimationDef animationDef, int actorID, int currentStage, int stageTicks, Rot4 actorFacing, bool isMirrored)
{
this.animationDef = animationDef;
this.actorID = actorID;
this.currentStage = currentStage;
this.stageTicks = stageTicks;
this.actorFacing = actorFacing;
this.isMirrored = isMirrored;
}
}
}

View file

@ -0,0 +1,56 @@
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;
}
}
}

View file

@ -16,7 +16,7 @@ namespace Rimworld_Animations_Patch
public BodyPartRecord bodyPartRecord;
public List<Vector3> bodyAddonOffsets = new List<Vector3>();
public bool alignsWithHead = false;
private Pawn pawn;
private string bodyType;
private PawnRenderFlags renderFlags;
@ -31,7 +31,7 @@ namespace Rimworld_Animations_Patch
if (isPortrait)
{ renderFlags |= PawnRenderFlags.Portrait; }
bodyPartRecord = pawn.def?.race?.body?.AllParts?.FirstOrDefault(x => x.def.defName == bodyAddon?.bodyPart || x.customLabel == bodyAddon?.bodyPart);
bodyPartRecord = pawn.def?.race?.body?.AllParts?.FirstOrDefault(x => x.def == bodyAddon?.bodyPart);
alignsWithHead = bodyAddon.alignWithHead || (bodyPartRecord != null && bodyPartRecord.IsInGroup(BodyPartGroupDefOf.FullHead));
GenerateOffsets();
@ -43,7 +43,7 @@ namespace Rimworld_Animations_Patch
bodyType = pawn.story.bodyType.defName;
bodyAddonOffsets.Clear();
int bodyAddonIndex = (pawn.def as ThingDef_AlienRace).alienRace.generalSettings.alienPartGenerator.bodyAddons.ToList().IndexOf(bodyAddon);
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];
@ -53,20 +53,20 @@ 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, alienComp.crownType) : Vector3.zero;
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);
Vector3 bodyAddonOffset = bodyTypeOffset + ((rotationOffsets != null) ? rotationOffsets.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, alienComp.crownType) : Vector3.zero);
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)
if (bodyAddon.bodyPart == "Genitals" || bodyAddon.bodyPart == "Chest" || bodyAddon.bodyPart == "Anus" || addonGraphic.path.ToLower().Contains("belly"))
if (bodyAddon.bodyPart == PatchBodyPartDefOf.Genitals || bodyAddon.bodyPart == PatchBodyPartDefOf.Chest || bodyAddon.bodyPart == PatchBodyPartDefOf.Anus || addonGraphic.path.Contains("belly") || addonGraphic.path.Contains("Belly"))
{
bodyAddonOffset.y = (bodyAddonOffset.y + 0.40f) / 1000f + 0.012f;
// Erected penises should be drawn over apparel
if (pawn.RaceProps.Humanlike &&
addonGraphic.path.ToLower().Contains("penis") &&
addonGraphic.path.ToLower().Contains("flaccid") == false &&
(addonGraphic.path.Contains("penis") || addonGraphic.path.Contains("Penis")) &&
(addonGraphic.path.Contains("flaccid") == false && addonGraphic.path.Contains("Flaccid") == false) &&
apparentRotation == Rot4.South)
{ bodyAddonOffset.y += 0.010f; }
}
@ -121,7 +121,7 @@ namespace Rimworld_Animations_Patch
if (renderFlags.FlagSet(PawnRenderFlags.Portrait) == false && (pawn.GetPosture() == PawnPosture.LayingOnGroundNormal || pawn.GetPosture() == PawnPosture.LayingOnGroundFaceUp) && bodyAddon.drawnOnGround == false)
{ return false; }
if (bodyAddon.backstoryRequirement.NullOrEmpty() == false && pawn.story?.AllBackstories?.Any((Backstory x) => x.identifier == bodyAddon.backstoryRequirement) == false)
if (bodyAddon.backstoryRequirement != null && pawn.story?.AllBackstories?.Any((BackstoryDef x) => x == bodyAddon.backstoryRequirement) == false)
{ return false; }
if (bodyAddon.drawnDesiccated == false && pawn.Corpse?.GetRotStage() == RotStage.Dessicated)
@ -130,7 +130,7 @@ namespace Rimworld_Animations_Patch
if (pawn.gender == Gender.Female && bodyAddon.drawForFemale == false || pawn.gender == Gender.Male && bodyAddon.drawForMale == false)
{ return false; }
if (bodyAddon.bodyTypeRequirement.NullOrEmpty() == false && pawn.story?.bodyType.ToString() != bodyAddon.bodyTypeRequirement)
if (bodyAddon.bodyTypeRequirement != null && pawn.story?.bodyType != bodyAddon.bodyTypeRequirement)
{ return false; }
return true;
@ -139,7 +139,6 @@ namespace Rimworld_Animations_Patch
public void UpdateVisibility()
{
if (pawn == null || bodyAddon == null || bodyPartRecord == null) return;
canDraw = true;
if (pawn.health?.hediffSet?.GetNotMissingParts()?.Contains(bodyPartRecord) == false)
@ -156,15 +155,18 @@ namespace Rimworld_Animations_Patch
if (comp.isBeingWorn == false) continue;
if (bodyAddon.bodyPart == "Genitals" || bodyAddon.bodyPart == "Anus" || bodyAddon.bodyPart == "Chest" || bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && x.path.ToLower().Contains("belly")) == true)
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 == "Genitals" || bodyAddon.bodyPart == "Anus") && comp.coversGroin)
if ((bodyAddon.bodyPart == PatchBodyPartDefOf.Genitals || bodyAddon.bodyPart == PatchBodyPartDefOf.Anus) && comp.coversGroin)
{ canDraw = false; return; };
if (bodyAddon.bodyPart == "Chest" && comp.coversChest)
if (bodyAddon.bodyPart == PatchBodyPartDefOf.Chest && comp.coversChest)
{ canDraw = false; return; };
if (bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && x.path.ToLower().Contains("belly")) == true && comp.coversBelly)
if (bodyAddon.hediffGraphics?.Any(x => x.path.NullOrEmpty() == false && (x.path.Contains("belly") || x.path.Contains("Belly"))) == true && comp.coversBelly)
{ canDraw = false; return; }
}

View file

@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using Verse;
using Rimworld_Animations;
@ -8,8 +12,7 @@ namespace Rimworld_Animations_Patch
{
public class HandAnimationDef : Def
{
public string animationDefName;
public AnimationDef animationDef;
public List<HandAnimationData> handAnimationData = new List<HandAnimationData>();
}
@ -24,5 +27,23 @@ namespace Rimworld_Animations_Patch
public string motion;
public int cycleTime = 0;
public bool mirror = false;
private HandMotion _motion;
public HandMotion Motion
{
get
{
if (_motion == null)
{
if (Type.GetType(motion) == null)
{ DebugMode.Message("ERROR: Hand motion " + motion + " does not exist!"); return null; }
_motion = (HandMotion)Activator.CreateInstance(Type.GetType(motion));
}
return _motion;
}
}
}
}