rotation, quick reset, better handling of offset values

This commit is contained in:
Platinum 2020-05-30 14:10:22 -07:00
parent 2e18be1953
commit f22f5ac33e
6 changed files with 66 additions and 26 deletions

View file

@ -11,7 +11,7 @@ namespace Rimworld_Animations {
class MainTabWindow_OffsetConfigure : MainTabWindow
{
public override Vector2 RequestedTabSize => new Vector2(505, 300);
public override Vector2 RequestedTabSize => new Vector2(505, 340);
public override void DoWindowContents(Rect inRect) {
Rect position = new Rect(inRect.x, inRect.y, inRect.width, inRect.height);
@ -20,7 +20,10 @@ namespace Rimworld_Animations {
Listing_Standard listingStandard = new Listing_Standard();
listingStandard.Begin(position);
listingStandard.Label("Offset Controller");
listingStandard.Label("Offset Manager");
listingStandard.GapLine();
if (Find.Selector.SingleSelectedThing is Pawn) {
@ -30,7 +33,7 @@ namespace Rimworld_Animations {
Actor curActor = curPawn.TryGetComp<CompBodyAnimator>().CurrentAnimation.actors[curPawn.TryGetComp<CompBodyAnimator>().ActorIndex];
float offsetX = 0, offsetZ = 0;
float offsetX = 0, offsetZ = 0, rotation = 0;
if (curActor.offsetsByDefName.ContainsKey(curPawn.def.defName)) {
offsetX = curActor.offsetsByDefName[curPawn.def.defName].x;
@ -39,9 +42,15 @@ namespace Rimworld_Animations {
curActor.offsetsByDefName.Add(curPawn.def.defName, new Vector2(0, 0));
}
listingStandard.GapLine();
if (curActor.rotationByDefName.ContainsKey(curPawn.def.defName)) {
rotation = curActor.rotationByDefName[curPawn.def.defName];
}
else {
curActor.rotationByDefName.Add(curPawn.def.defName, 180);
}
listingStandard.Label("Offset for race " + curPawn.def.defName + " in actor position " + curPawn.TryGetComp<CompBodyAnimator>().ActorIndex);
listingStandard.Label("Offset for race " + curPawn.def.defName + " in actor position " + curPawn.TryGetComp<CompBodyAnimator>().ActorIndex + (curPawn.TryGetComp<CompBodyAnimator>().Mirror ? " mirrored" : ""));
if(curPawn.def.defName == "Human") {
listingStandard.Label("Warning--You generally don't want to change human offsets, only alien offsets");
@ -54,13 +63,30 @@ namespace Rimworld_Animations {
listingStandard.Label("Z Offset: " + offsetZ);
offsetZ = listingStandard.Slider(offsetZ, -10, 10);
listingStandard.Label("Rotation: " + rotation);
rotation = listingStandard.Slider(rotation, -180, 180);
if(listingStandard.ButtonText("Reset All")) {
offsetX = 0;
offsetZ = 0;
rotation = 0;
}
if (offsetX != curActor.offsetsByDefName[curPawn.def.defName].x || offsetZ != curActor.offsetsByDefName[curPawn.def.defName].y) {
curActor.offsetsByDefName[curPawn.def.defName] = new Vector2(offsetX, offsetZ);
}
if(rotation != curActor.rotationByDefName[curPawn.def.defName]) {
curActor.rotationByDefName[curPawn.def.defName] = rotation;
}
}
}
else {
listingStandard.Label("Select a pawn currently in an animation to change their offsets");
}
listingStandard.End();