Code refactor

This commit is contained in:
AbstractConcept 2022-10-28 00:28:51 -05:00
parent 757badf4f6
commit a55ba7b95b
232 changed files with 1282 additions and 936 deletions

View file

@ -24,10 +24,10 @@ namespace RimWorldAnimationStudio
switch (rotation)
{
case 0: return new Vector3(0f, 0f, headOffset.y);
case 1: return new Vector3(headOffset.x, 0f, headOffset.y);
case 2: return new Vector3(0f, 0f, headOffset.y);
case 3: return new Vector3(-headOffset.x, 0f, headOffset.y);
case 0: return new Vector3(0f, headOffset.y, 0);
case 1: return new Vector3(headOffset.x, headOffset.y, 0);
case 2: return new Vector3(0f, headOffset.y, 0f);
case 3: return new Vector3(-headOffset.x, headOffset.y, 0f);
default: return Vector3.zero;
}
}
@ -161,5 +161,23 @@ namespace RimWorldAnimationStudio
}
}
}
public static Vector3 GetBodyPartAnchor(ActorBody anchoringActorBody, string anchorName)
{
Actor anchoringActor = Workspace.GetActor(anchoringActorBody.actorID);
Vector3 anchoringActorBodyPos = anchoringActorBody.transform.position;
Quaternion anchoringActorBodyQuad = Quaternion.AngleAxis(anchoringActorBody.transform.rotation.eulerAngles.z, Vector3.forward);
int anchoringActorFacing = anchoringActor.GetCurrentPosition().bodyFacing;
switch (anchorName)
{
case "torso": return anchoringActorBodyPos;
case "head": return anchoringActorBody.GetComponentsInChildren<ActorBodyPart>().FirstOrDefault(x => x.bodyPart.ToLower() == "head").transform.position;
case "groin": return anchoringActorBodyPos + anchoringActorBodyQuad * PawnUtility.GroinOffsetAt(anchoringActor.bodyType, anchoringActorFacing).FlipAxes();
case "left breast": return anchoringActorBodyPos + anchoringActorBodyQuad * PawnUtility.BreastLeftOffsetAt(anchoringActor.bodyType, anchoringActorFacing).FlipAxes();
case "right breast": return anchoringActorBodyPos + anchoringActorBodyQuad * PawnUtility.BreastRightOffsetAt(anchoringActor.bodyType, anchoringActorFacing).FlipAxes();
default: return new Vector3();
}
}
}
}