2022-09-14 05:25:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace RimWorldAnimationStudio
|
|
|
|
|
{
|
2022-09-15 05:17:44 +00:00
|
|
|
|
public class Workspace : Singleton<Workspace>
|
2022-09-14 05:25:58 +00:00
|
|
|
|
{
|
2022-09-15 05:17:44 +00:00
|
|
|
|
public static AnimationDef animationDef;
|
|
|
|
|
public static int stageID = 0;
|
2022-09-16 22:50:15 +00:00
|
|
|
|
public static int actorID = 0;
|
2022-09-19 00:07:44 +00:00
|
|
|
|
public static int keyframeID = 0;
|
2022-09-14 05:25:58 +00:00
|
|
|
|
|
2022-09-15 05:17:44 +00:00
|
|
|
|
public static List<string> defNames = new List<string>() { "Human" };
|
2022-09-19 00:07:44 +00:00
|
|
|
|
public static List<string> bodyParts = new List<string>() { "Any appendage", "Any orifice", "Penis", "Vagina", "Anus", "Breasts", "Mouth" };
|
2022-09-19 05:35:34 +00:00
|
|
|
|
public static List<string> bodyDefTypes = new List<string>() { "Human", "Bird", "BeetleLike", "BeetleLikeWithClaw", "MechanicalCentipede", "MechanicalTermite", "Lancer", "Pikeman", "Monkey", "QuadrupedAnimalWithClawsTailAndJowl", "QuadrupedAnimalWithHooves", "QuadrupedAnimalWithHoovesAndHorn", "QuadrupedAnimalWithHoovesAndHump", "QuadrupedAnimalWithHoovesAndTusks", "QuadrupedAnimalWithHoovesTusksAndTrunk", "QuadrupedAnimalWithPaws", "QuadrupedAnimalWithPawsAndTail", "Scyther", "Snake", "TurtleLike" };
|
2022-09-15 05:17:44 +00:00
|
|
|
|
public static List<string> sexTypes = new List<string>() { "None", "Vaginal", "Anal", "Oral", "Masturbation", "DoublePenetration", "Boobjob", "Handjob", "Footjob", "Fingering", "Scissoring", "MutualMasturbation", "Fisting", "MechImplant", "Rimming", "Fellatio", "Cunnilingus", "Sixtynine" };
|
|
|
|
|
public static List<string> interactionDefTypes = new List<string>();
|
2022-09-20 06:03:55 +00:00
|
|
|
|
public static List<string> soundDefs = new List<string>() { "None", "Sex", "Fuck", "Slimy", "Suck", "Cum" };
|
2022-09-14 05:25:58 +00:00
|
|
|
|
|
2022-09-19 00:07:44 +00:00
|
|
|
|
[SerializeField] private List<WorkspaceSnapShot> workspaceHistory = new List<WorkspaceSnapShot>();
|
|
|
|
|
[SerializeField] private int historyIndex = 0;
|
|
|
|
|
[SerializeField] private int maxHistoryDepth = 100;
|
|
|
|
|
private bool isDirty = false;
|
2022-09-14 05:25:58 +00:00
|
|
|
|
|
2022-09-16 22:50:15 +00:00
|
|
|
|
public static ActorManipulationMode actorManipulationMode = ActorManipulationMode.Pan;
|
2022-09-20 06:03:55 +00:00
|
|
|
|
public static ActorBodyPart selectedBodyPart;
|
|
|
|
|
|
2022-09-18 05:01:12 +00:00
|
|
|
|
public static int StageWindowSize
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (animationDef == null)
|
|
|
|
|
{ return -1; }
|
|
|
|
|
|
|
|
|
|
if (animationDef.animationStages[stageID].stageWindowSize < 0)
|
|
|
|
|
{ return animationDef.animationStages[stageID].animationClips.Select(x => x.duration).Max(); }
|
|
|
|
|
|
|
|
|
|
return animationDef.animationStages[stageID].stageWindowSize;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-16 14:18:06 +00:00
|
|
|
|
|
2022-09-19 00:07:44 +00:00
|
|
|
|
public void Update()
|
|
|
|
|
{
|
|
|
|
|
if (isDirty)
|
|
|
|
|
{ TrackChanges(); }
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 06:03:55 +00:00
|
|
|
|
public PawnKeyframe GetCurrentPawnKeyframe(bool makeKeyframe = false)
|
2022-09-18 00:06:33 +00:00
|
|
|
|
{
|
|
|
|
|
int stageTick = AnimationController.Instance.stageTick;
|
|
|
|
|
PawnKeyframe keyframe = animationDef?.animationStages[stageID]?.animationClips[actorID]?.keyframes.FirstOrDefault(x => x.atTick == stageTick);
|
|
|
|
|
|
2022-09-20 06:03:55 +00:00
|
|
|
|
if (keyframe != null || makeKeyframe == false)
|
2022-09-18 00:06:33 +00:00
|
|
|
|
{ return keyframe; }
|
|
|
|
|
|
|
|
|
|
AnimationController.Instance.AddPawnKeyframe();
|
|
|
|
|
return animationDef?.animationStages[stageID]?.animationClips[actorID]?.keyframes.FirstOrDefault(x => x.atTick == stageTick);
|
|
|
|
|
}
|
2022-09-16 22:50:15 +00:00
|
|
|
|
|
2022-09-18 00:06:33 +00:00
|
|
|
|
public PawnAnimationClip GetCurrentPawnAnimationClip()
|
|
|
|
|
{
|
|
|
|
|
return animationDef.animationStages[stageID].animationClips[actorID];
|
|
|
|
|
}
|
2022-09-16 14:18:06 +00:00
|
|
|
|
|
|
|
|
|
public PawnAnimationClip GetPawnAnimationClip(int actorID)
|
|
|
|
|
{
|
|
|
|
|
return animationDef.animationStages[stageID].animationClips[actorID];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PawnKeyframe GetPawnKeyframe(int actorID, int keyframeID)
|
|
|
|
|
{
|
|
|
|
|
return animationDef.animationStages[stageID].animationClips[actorID].keyframes.FirstOrDefault(x => x.keyframeID == keyframeID);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 05:25:58 +00:00
|
|
|
|
public void TrackChanges()
|
|
|
|
|
{
|
|
|
|
|
if (historyIndex < workspaceHistory.Count - 1)
|
2022-09-19 00:07:44 +00:00
|
|
|
|
{ workspaceHistory.RemoveRange(historyIndex + 1, workspaceHistory.Count - historyIndex - 1); }
|
2022-09-14 05:25:58 +00:00
|
|
|
|
|
|
|
|
|
if (workspaceHistory.Any() && workspaceHistory.Count >= maxHistoryDepth)
|
|
|
|
|
{ workspaceHistory.RemoveAt(0); }
|
|
|
|
|
|
|
|
|
|
WorkspaceSnapShot workspaceSnapShot = new WorkspaceSnapShot();
|
2022-09-19 00:07:44 +00:00
|
|
|
|
workspaceSnapShot.animationDef = animationDef.Copy();
|
2022-09-14 05:25:58 +00:00
|
|
|
|
workspaceSnapShot.stageID = stageID;
|
2022-09-19 00:07:44 +00:00
|
|
|
|
workspaceSnapShot.actorID = actorID;
|
|
|
|
|
workspaceSnapShot.keyframeID = keyframeID;
|
2022-09-14 05:25:58 +00:00
|
|
|
|
|
|
|
|
|
workspaceHistory.Add(workspaceSnapShot);
|
2022-09-19 00:07:44 +00:00
|
|
|
|
historyIndex = workspaceHistory.Count - 1;
|
2022-09-14 05:25:58 +00:00
|
|
|
|
|
2022-09-19 00:07:44 +00:00
|
|
|
|
isDirty = false;
|
2022-09-14 05:25:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Undo()
|
|
|
|
|
{
|
|
|
|
|
historyIndex = Mathf.Clamp(historyIndex - 1, 0, workspaceHistory.Count - 1);
|
|
|
|
|
LoadHistoricState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Redo()
|
|
|
|
|
{
|
2022-09-19 00:07:44 +00:00
|
|
|
|
historyIndex = Mathf.Clamp(historyIndex + 1, 0, workspaceHistory.Count - 1);
|
2022-09-14 05:25:58 +00:00
|
|
|
|
LoadHistoricState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadHistoricState()
|
|
|
|
|
{
|
2022-09-19 00:07:44 +00:00
|
|
|
|
if (workspaceHistory.NullOrEmpty())
|
|
|
|
|
{ Debug.LogWarning("Cannot load historic state - workspace history is empty"); return; }
|
2022-09-14 05:25:58 +00:00
|
|
|
|
|
2022-09-19 00:07:44 +00:00
|
|
|
|
animationDef = workspaceHistory[historyIndex].animationDef.Copy();
|
|
|
|
|
stageID = workspaceHistory[historyIndex].stageID;
|
|
|
|
|
actorID = workspaceHistory[historyIndex].actorID;
|
|
|
|
|
keyframeID = workspaceHistory[historyIndex].keyframeID;
|
2022-09-18 06:52:54 +00:00
|
|
|
|
|
2022-09-19 00:07:44 +00:00
|
|
|
|
AnimationController.Instance.MakeTimelineDirty();
|
|
|
|
|
}
|
2022-09-18 06:52:54 +00:00
|
|
|
|
|
2022-09-19 00:07:44 +00:00
|
|
|
|
public void ClearHistory()
|
2022-09-18 06:52:54 +00:00
|
|
|
|
{
|
2022-09-19 00:07:44 +00:00
|
|
|
|
workspaceHistory.Clear();
|
|
|
|
|
historyIndex = 0;
|
2022-09-18 06:52:54 +00:00
|
|
|
|
}
|
2022-09-19 00:07:44 +00:00
|
|
|
|
|
|
|
|
|
public void MakeDirty()
|
|
|
|
|
{ isDirty = true; }
|
2022-09-14 05:25:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|