saving offset data fix

This commit is contained in:
Platinum 2020-05-31 12:03:30 -07:00
parent f22f5ac33e
commit 9786a82542
8 changed files with 63 additions and 33 deletions

View File

@ -7,7 +7,7 @@ using UnityEngine;
using Verse;
namespace Rimworld_Animations {
public class Actor : IExposable {
public class Actor {
public List<string> defNames;
public List<string> requiredGenitals;
public List<AlienRaceOffset> raceOffsets;
@ -20,12 +20,5 @@ namespace Rimworld_Animations {
public BodyTypeOffset bodyTypeOffset = new BodyTypeOffset();
public Vector3 offset = new Vector2(0, 0);
public Dictionary<string, Vector2> offsetsByDefName = new Dictionary<string, Vector2>();
public Dictionary<string, float> rotationByDefName = new Dictionary<string, float>();
public void ExposeData() {
Scribe_Collections.Look(ref offsetsByDefName, "OffsetsSetInOptions", LookMode.Value, LookMode.Value);
Scribe_Collections.Look(ref rotationByDefName, "RotationOffsetsFromOptions", LookMode.Value, LookMode.Value);
}
}
}

View File

@ -80,8 +80,8 @@ namespace Rimworld_Animations {
/*
if (x.defName != "Doggystyle")
return false;
*/
if (x.actors[i].isFucking && !rjw.xxx.can_fuck(localParticipants[i])) {
Log.Message(x.defName.ToStringSafe() + " not selected -- " + localParticipants[i].def.defName.ToStringSafe() + " " + localParticipants[i].Name.ToStringSafe() + " can't fuck");

View File

@ -261,9 +261,9 @@ namespace Rimworld_Animations {
deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent) * (mirror ? -1 : 1), clip.layer.AltitudeFor(), clip.BodyOffsetZ.Evaluate(clipPercent));
if (CurrentAnimation?.actors[ActorIndex]?.offsetsByDefName != null && CurrentAnimation.actors[ActorIndex].offsetsByDefName.ContainsKey(pawn.def.defName)) {
deltaPos.x += CurrentAnimation.actors[ActorIndex].offsetsByDefName[pawn.def.defName].x * (mirror ? -1 : 1);
deltaPos.z += CurrentAnimation.actors[ActorIndex].offsetsByDefName[pawn.def.defName].y;
if (AnimationSettings.offsets != null && AnimationSettings.offsets.ContainsKey(CurrentAnimation.defName + pawn.def.defName + ActorIndex)) {
deltaPos.x += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + ActorIndex].x * (mirror ? -1 : 1);
deltaPos.z += AnimationSettings.offsets[CurrentAnimation.defName + pawn.def.defName + ActorIndex].y;
}
@ -274,8 +274,8 @@ namespace Rimworld_Animations {
genitalAngle = clip.GenitalAngle.Evaluate(clipPercent) * (mirror ? -1 : 1);
}
if (CurrentAnimation?.actors[ActorIndex]?.rotationByDefName != null && CurrentAnimation.actors[ActorIndex].rotationByDefName.ContainsKey(pawn.def.defName)) {
float offsetRotation = CurrentAnimation.actors[ActorIndex].rotationByDefName[pawn.def.defName] * (Mirror ? -1 : 1);
if (AnimationSettings.rotation != null && AnimationSettings.rotation.ContainsKey(CurrentAnimation.defName + pawn.def.defName + ActorIndex)) {
float offsetRotation = AnimationSettings.rotation[CurrentAnimation.defName + pawn.def.defName + ActorIndex] * (Mirror ? -1 : 1);
genitalAngle += offsetRotation;
bodyAngle += offsetRotation;
headAngle += offsetRotation;

View File

@ -11,10 +11,15 @@ namespace Rimworld_Animations {
public readonly TargetIndex ipartner = TargetIndex.A;
public readonly TargetIndex ibed = TargetIndex.B;
public override bool TryMakePreToilReservations(bool errorOnFailed) {
return base.TryMakePreToilReservations(errorOnFailed);
}
protected override IEnumerable<Toil> MakeNewToils() {
setup_ticks();
parteners.Add(Partner);// add job starter, so this wont fail, before Initiator starts his job
//--Log.Message("[RJW]JobDriver_GettinLoved::MakeNewToils is called");
float partner_ability = xxx.get_sex_ability(Partner);
@ -30,6 +35,10 @@ namespace Rimworld_Animations {
else if (pawn.relations.OpinionOf(Partner) > 60)
ticks_between_hearts -= 25;
parteners.Add(Partner);// add job starter, so this wont fail, before Initiator starts his job
//--Log.Message("[RJW]JobDriver_GettinLoved::MakeNewToils is called");
this.FailOnDespawnedOrNull(ipartner);
this.FailOn(() => !Partner.health.capacities.CanBeAwake);
this.FailOn(() => pawn.Drafted);

View File

@ -31,22 +31,22 @@ namespace Rimworld_Animations {
if (curPawn.TryGetComp<CompBodyAnimator>().isAnimating) {
Actor curActor = curPawn.TryGetComp<CompBodyAnimator>().CurrentAnimation.actors[curPawn.TryGetComp<CompBodyAnimator>().ActorIndex];
AnimationDef def = curPawn.TryGetComp<CompBodyAnimator>().CurrentAnimation;
int ActorIndex = curPawn.TryGetComp<CompBodyAnimator>().ActorIndex;
float offsetX = 0, offsetZ = 0, rotation = 0;
if (curActor.offsetsByDefName.ContainsKey(curPawn.def.defName)) {
offsetX = curActor.offsetsByDefName[curPawn.def.defName].x;
offsetZ = curActor.offsetsByDefName[curPawn.def.defName].y;
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;
} else {
curActor.offsetsByDefName.Add(curPawn.def.defName, new Vector2(0, 0));
AnimationSettings.offsets.Add(def.defName + curPawn.def.defName + ActorIndex, new Vector2(0, 0));
}
if (curActor.rotationByDefName.ContainsKey(curPawn.def.defName)) {
rotation = curActor.rotationByDefName[curPawn.def.defName];
if (AnimationSettings.rotation.ContainsKey(def.defName + curPawn.def.defName + ActorIndex)) {
rotation = AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex];
}
else {
curActor.rotationByDefName.Add(curPawn.def.defName, 180);
AnimationSettings.rotation.Add(def.defName + curPawn.def.defName + ActorIndex, 0);
}
@ -72,12 +72,13 @@ namespace Rimworld_Animations {
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 (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);
}
if(rotation != curActor.rotationByDefName[curPawn.def.defName]) {
curActor.rotationByDefName[curPawn.def.defName] = rotation;
if(rotation != AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex]) {
AnimationSettings.rotation[def.defName + curPawn.def.defName + ActorIndex] = rotation;
}
}
@ -93,5 +94,24 @@ namespace Rimworld_Animations {
base.DoWindowContents(inRect);
}
public override void PreOpen() {
base.PreOpen();
if(AnimationSettings.offsets == null) {
Log.Message("New offsets");
AnimationSettings.offsets = new Dictionary<string, Vector2>();
}
if(AnimationSettings.rotation == null) {
Log.Message("New rotation");
AnimationSettings.rotation = new Dictionary<string, float>();
}
}
public override void PostClose() {
base.PostClose();
LoadedModManager.GetMod<RJW_Animations>().WriteSettings();
}
}
}

View File

@ -16,7 +16,6 @@ namespace Rimworld_Animations {
static OffsetMainButtonDefOf() {
DefOfHelper.EnsureInitializedInCtor(typeof(OffsetMainButtonDefOf));
//OffsetManager.buttonVisible = false;
}
}

View File

@ -13,7 +13,8 @@ namespace Rimworld_Animations {
public static bool orgasmQuiver, rapeShiver, soundOverride = true, hearts = true, controlGenitalRotation = false, applySemenOnAnimationOrgasm = false, fastAnimForQuickie = false;
public static float shiverIntensity = 2f;
public static Dictionary<string, Vector2> offsetsByDefName;
public static Dictionary<string, Vector2> offsets = new Dictionary<string, Vector2>();
public static Dictionary<string, float> rotation = new Dictionary<string, float>();
public override void ExposeData() {
@ -27,9 +28,16 @@ namespace Rimworld_Animations {
Scribe_Values.Look(ref applySemenOnAnimationOrgasm, "applySemenOnOrgasm", false);
Scribe_Values.Look(ref soundOverride, "rjwAnimSoundOverride", true);
Scribe_Values.Look(ref shiverIntensity, "shiverIntensity", 2f);
//todo: save offsetsByDefName
Scribe_Collections.Look(ref offsets, "animationOffsets");
Scribe_Collections.Look(ref rotation, "rotationOffsets");
//needs to be rewritten
//probably somewhere in options?
}
}
@ -38,6 +46,7 @@ namespace Rimworld_Animations {
public RJW_Animations(ModContentPack content) : base(content) {
GetSettings<AnimationSettings>();
}
public override void DoSettingsWindowContents(Rect inRect) {