mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
Account for offsets
This commit is contained in:
parent
67cb546336
commit
369d8fa011
2 changed files with 26 additions and 11 deletions
Binary file not shown.
|
@ -46,14 +46,26 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
List<AlienPartGenerator.BodyAddon> addons = alienProps.alienRace.generalSettings.alienPartGenerator.bodyAddons;
|
List<AlienPartGenerator.BodyAddon> addons = alienProps.alienRace.generalSettings.alienPartGenerator.bodyAddons;
|
||||||
AlienPartGenerator.AlienComp alienComp = pawn.GetComp<AlienPartGenerator.AlienComp>();
|
AlienPartGenerator.AlienComp alienComp = pawn.GetComp<AlienPartGenerator.AlienComp>();
|
||||||
|
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
||||||
|
|
||||||
for (int i = 0; i < addons.Count; i++) {
|
for (int i = 0; i < addons.Count; i++) {
|
||||||
AlienPartGenerator.BodyAddon ba = addons[index: i];
|
AlienPartGenerator.BodyAddon ba = addons[index: i];
|
||||||
if (!ba.CanDrawAddon(pawn: pawn)) continue;
|
if (!ba.CanDrawAddon(pawn: pawn)) continue;
|
||||||
|
|
||||||
|
AlienPartGenerator.RotationOffset offset;
|
||||||
|
if (ba.drawnInBed) {
|
||||||
|
|
||||||
|
offset = pawnAnimator.headFacing == Rot4.South ?
|
||||||
|
ba.offsets.south :
|
||||||
|
pawnAnimator.headFacing == Rot4.North ?
|
||||||
|
ba.offsets.north :
|
||||||
|
pawnAnimator.headFacing == Rot4.East ?
|
||||||
|
ba.offsets.east :
|
||||||
|
ba.offsets.west;
|
||||||
|
|
||||||
AlienPartGenerator.RotationOffset offset = rotation == Rot4.South ?
|
} else {
|
||||||
|
|
||||||
|
offset = rotation == Rot4.South ?
|
||||||
ba.offsets.south :
|
ba.offsets.south :
|
||||||
rotation == Rot4.North ?
|
rotation == Rot4.North ?
|
||||||
ba.offsets.north :
|
ba.offsets.north :
|
||||||
|
@ -61,6 +73,10 @@ namespace Rimworld_Animations {
|
||||||
ba.offsets.east :
|
ba.offsets.east :
|
||||||
ba.offsets.west;
|
ba.offsets.west;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector2 bodyOffset = (portrait ? offset?.portraitBodyTypes ?? offset?.bodyTypes : offset?.bodyTypes)?.FirstOrDefault(predicate: to => to.bodyType == pawn.story.bodyType)
|
Vector2 bodyOffset = (portrait ? offset?.portraitBodyTypes ?? offset?.bodyTypes : offset?.bodyTypes)?.FirstOrDefault(predicate: to => to.bodyType == pawn.story.bodyType)
|
||||||
?.offset ?? Vector2.zero;
|
?.offset ?? Vector2.zero;
|
||||||
Vector2 crownOffset = (portrait ? offset?.portraitCrownTypes ?? offset?.crownTypes : offset?.crownTypes)?.FirstOrDefault(predicate: to => to.crownType == alienComp.crownType)
|
Vector2 crownOffset = (portrait ? offset?.portraitCrownTypes ?? offset?.crownTypes : offset?.crownTypes)?.FirstOrDefault(predicate: to => to.crownType == alienComp.crownType)
|
||||||
|
@ -73,10 +89,10 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
float moffsetX = 0.42f;
|
float moffsetX = 0.42f;
|
||||||
float moffsetZ = -0.22f;
|
float moffsetZ = -0.22f;
|
||||||
float moffsetY = ba.inFrontOfBody ? 0.002f + ba.layerOffset : -0.002f - ba.layerOffset;
|
float moffsetY = ba.inFrontOfBody ? 0.3f + ba.layerOffset : -0.3f - ba.layerOffset;
|
||||||
float num = ba.angle;
|
float num = ba.angle;
|
||||||
|
|
||||||
if (rotation == Rot4.North) {
|
if ((ba.drawnInBed ? pawnAnimator.headFacing : rotation) == Rot4.North) {
|
||||||
moffsetX = 0f;
|
moffsetX = 0f;
|
||||||
if (ba.layerInvert)
|
if (ba.layerInvert)
|
||||||
moffsetY = -moffsetY;
|
moffsetY = -moffsetY;
|
||||||
|
@ -88,7 +104,7 @@ namespace Rimworld_Animations {
|
||||||
moffsetX += bodyOffset.x + crownOffset.x;
|
moffsetX += bodyOffset.x + crownOffset.x;
|
||||||
moffsetZ += bodyOffset.y + crownOffset.y;
|
moffsetZ += bodyOffset.y + crownOffset.y;
|
||||||
|
|
||||||
if (rotation == Rot4.East) {
|
if ((ba.drawnInBed ? pawnAnimator.headFacing : rotation) == Rot4.East) {
|
||||||
moffsetX = -moffsetX;
|
moffsetX = -moffsetX;
|
||||||
num = -num; //Angle
|
num = -num; //Angle
|
||||||
}
|
}
|
||||||
|
@ -100,7 +116,6 @@ namespace Rimworld_Animations {
|
||||||
//assume drawnInBed means headAddon
|
//assume drawnInBed means headAddon
|
||||||
if (ba.drawnInBed && pawn.TryGetComp<CompBodyAnimator>() != null && pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
if (ba.drawnInBed && pawn.TryGetComp<CompBodyAnimator>() != null && pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
||||||
|
|
||||||
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
|
||||||
Quaternion headQuatInAnimation = Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up);
|
Quaternion headQuatInAnimation = Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up);
|
||||||
Rot4 headRotInAnimation = pawnAnimator.headFacing;
|
Rot4 headRotInAnimation = pawnAnimator.headFacing;
|
||||||
Vector3 headPositionInAnimation = pawnAnimator.getPawnHeadPosition() - pawn.Drawer.renderer.BaseHeadOffsetAt(pawnAnimator.headFacing).RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: headQuatInAnimation)) * 2f * 57.29578f);
|
Vector3 headPositionInAnimation = pawnAnimator.getPawnHeadPosition() - pawn.Drawer.renderer.BaseHeadOffsetAt(pawnAnimator.headFacing).RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: headQuatInAnimation)) * 2f * 57.29578f);
|
||||||
|
|
Loading…
Reference in a new issue