2020-05-30 06:10:31 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Verse;
|
|
|
|
|
using RimWorld;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Rimworld_Animations {
|
|
|
|
|
class MainTabWindow_OffsetConfigure : MainTabWindow
|
|
|
|
|
{
|
|
|
|
|
|
2020-10-29 03:21:19 +00:00
|
|
|
|
public override Vector2 RequestedTabSize => new Vector2(505, 380);
|
2020-05-30 06:10:31 +00:00
|
|
|
|
public override void DoWindowContents(Rect inRect) {
|
|
|
|
|
|
|
|
|
|
Rect position = new Rect(inRect.x, inRect.y, inRect.width, inRect.height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Listing_Standard listingStandard = new Listing_Standard();
|
|
|
|
|
listingStandard.Begin(position);
|
|
|
|
|
|
2020-10-29 03:21:19 +00:00
|
|
|
|
listingStandard.Label("Animation Manager");
|
2020-05-30 21:10:22 +00:00
|
|
|
|
|
|
|
|
|
listingStandard.GapLine();
|
|
|
|
|
|
2020-05-30 06:10:31 +00:00
|
|
|
|
|
|
|
|
|
if (Find.Selector.SingleSelectedThing is Pawn) {
|
|
|
|
|
|
|
|
|
|
Pawn curPawn = Find.Selector.SingleSelectedThing as Pawn;
|
|
|
|
|
|
|
|
|
|
if (curPawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
|
|
|
|
|
2020-05-31 19:03:30 +00:00
|
|
|
|
AnimationDef def = curPawn.TryGetComp<CompBodyAnimator>().CurrentAnimation;
|
|
|
|
|
int ActorIndex = curPawn.TryGetComp<CompBodyAnimator>().ActorIndex;
|
2020-05-30 21:10:22 +00:00
|
|
|
|
float offsetX = 0, offsetZ = 0, rotation = 0;
|
2020-05-30 06:10:31 +00:00
|
|
|
|
|
2020-05-31 19:03:30 +00:00
|
|
|
|
if (AnimationSettings.offsets.ContainsKey(def.defName + curPawn.def.defName + ActorIndex)) {
|
|
|
|
|
offsetX = AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].x;
|
|
|
|
|
offsetZ = AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].y;
|
2020-05-30 06:10:31 +00:00
|
|
|
|
} else {
|
2020-05-31 19:03:30 +00:00
|
|
|
|
AnimationSettings.offsets.Add(def.defName + curPawn.def.defName + ActorIndex, new Vector2(0, 0));
|
2020-05-30 06:10:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 19:03:30 +00:00
|
|
|
|
if (AnimationSettings.rotation.ContainsKey(def.defName + curPawn.def.defName + ActorIndex)) {
|
|
|
|
|
rotation = AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex];
|
2020-05-30 21:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2020-05-31 19:03:30 +00:00
|
|
|
|
AnimationSettings.rotation.Add(def.defName + curPawn.def.defName + ActorIndex, 0);
|
2020-05-30 21:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-29 03:47:16 +00:00
|
|
|
|
listingStandard.Label("Name: " + curPawn.Name + " Race: " + curPawn.def.defName + " Actor Index: " + curPawn.TryGetComp<CompBodyAnimator>().ActorIndex + " Animation: " + def.label + (curPawn.TryGetComp<CompBodyAnimator>().Mirror ? " mirrored" : ""));
|
2020-05-30 06:10:31 +00:00
|
|
|
|
|
|
|
|
|
if(curPawn.def.defName == "Human") {
|
|
|
|
|
listingStandard.Label("Warning--You generally don't want to change human offsets, only alien offsets");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listingStandard.Label("X Offset: " + offsetX);
|
|
|
|
|
offsetX = listingStandard.Slider(offsetX, -10, 10);
|
|
|
|
|
|
|
|
|
|
listingStandard.Label("Z Offset: " + offsetZ);
|
|
|
|
|
offsetZ = listingStandard.Slider(offsetZ, -10, 10);
|
|
|
|
|
|
2020-05-30 21:10:22 +00:00
|
|
|
|
listingStandard.Label("Rotation: " + rotation);
|
|
|
|
|
rotation = listingStandard.Slider(rotation, -180, 180);
|
|
|
|
|
|
|
|
|
|
if(listingStandard.ButtonText("Reset All")) {
|
|
|
|
|
offsetX = 0;
|
|
|
|
|
offsetZ = 0;
|
|
|
|
|
rotation = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-29 03:21:19 +00:00
|
|
|
|
listingStandard.GapLine();
|
|
|
|
|
|
|
|
|
|
if(listingStandard.ButtonText("Shift Actors")) {
|
|
|
|
|
|
|
|
|
|
if(AnimationSettings.debugMode) {
|
|
|
|
|
Log.Message("Shifting actors in animation...");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < curPawn.TryGetComp<CompBodyAnimator>().actorsInCurrentAnimation.Count; i++) {
|
2020-10-29 03:53:38 +00:00
|
|
|
|
|
|
|
|
|
Pawn actor = curPawn.TryGetComp<CompBodyAnimator>().actorsInCurrentAnimation[i];
|
|
|
|
|
|
|
|
|
|
actor.TryGetComp<CompBodyAnimator>()?.shiftActorPositionAndRestartAnimation();
|
2020-10-29 03:47:16 +00:00
|
|
|
|
|
|
|
|
|
//reset the clock time of every pawn in animation
|
2020-10-29 03:53:38 +00:00
|
|
|
|
if(actor.jobs.curDriver is rjw.JobDriver_Sex) {
|
|
|
|
|
(actor.jobs.curDriver as rjw.JobDriver_Sex).ticks_left = def.animationTimeTicks;
|
|
|
|
|
(actor.jobs.curDriver as rjw.JobDriver_Sex).ticksLeftThisToil = def.animationTimeTicks;
|
|
|
|
|
(actor.jobs.curDriver as rjw.JobDriver_Sex).duration = def.animationTimeTicks;
|
2020-10-29 03:47:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-29 03:21:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 19:03:30 +00:00
|
|
|
|
if (offsetX != AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].x || offsetZ != AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex].y) {
|
|
|
|
|
AnimationSettings.offsets[def.defName + curPawn.def.defName + ActorIndex] = new Vector2(offsetX, offsetZ);
|
|
|
|
|
|
2020-05-30 06:10:31 +00:00
|
|
|
|
}
|
2020-05-30 21:10:22 +00:00
|
|
|
|
|
2020-05-31 19:03:30 +00:00
|
|
|
|
if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex]) {
|
|
|
|
|
AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex] = rotation;
|
2020-05-30 21:10:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-30 06:10:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2020-05-30 21:10:22 +00:00
|
|
|
|
else {
|
|
|
|
|
listingStandard.Label("Select a pawn currently in an animation to change their offsets");
|
|
|
|
|
}
|
2020-05-30 06:10:31 +00:00
|
|
|
|
|
|
|
|
|
listingStandard.End();
|
|
|
|
|
|
|
|
|
|
base.DoWindowContents(inRect);
|
|
|
|
|
|
|
|
|
|
}
|
2020-05-31 19:03:30 +00:00
|
|
|
|
|
|
|
|
|
public override void PreOpen() {
|
|
|
|
|
base.PreOpen();
|
|
|
|
|
if(AnimationSettings.offsets == null) {
|
2020-08-28 07:24:55 +00:00
|
|
|
|
if (AnimationSettings.debugMode)
|
|
|
|
|
Log.Message("New offsets");
|
2020-05-31 19:03:30 +00:00
|
|
|
|
AnimationSettings.offsets = new Dictionary<string, Vector2>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(AnimationSettings.rotation == null) {
|
2020-08-28 07:24:55 +00:00
|
|
|
|
if (AnimationSettings.debugMode)
|
|
|
|
|
Log.Message("New rotation");
|
2020-05-31 19:03:30 +00:00
|
|
|
|
AnimationSettings.rotation = new Dictionary<string, float>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PostClose() {
|
|
|
|
|
base.PostClose();
|
|
|
|
|
|
|
|
|
|
LoadedModManager.GetMod<RJW_Animations>().WriteSettings();
|
|
|
|
|
}
|
2020-05-30 06:10:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|