Bug fixes plus better layout

This commit is contained in:
AbstractConcept 2022-09-19 00:35:34 -05:00
parent b0a965e0b2
commit 18c0473f39
192 changed files with 4773 additions and 5746 deletions

View file

@ -13,8 +13,8 @@ namespace RimWorldAnimationStudio
public float headBob;
public float bodyOffsetX;
public float bodyOffsetZ;
public float headFacing;
public float bodyFacing;
public float headFacing = 2;
public float bodyFacing = 2;
public float? genitalAngle;
public bool? quiver;

View file

@ -67,7 +67,7 @@ namespace RimWorldAnimationStudio
{
Workspace.actorID = actorID;
foreach (ActorBody actorBody in AnimationController.Instance.GetComponentsInChildren<ActorBody>())
foreach (ActorBody actorBody in AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>())
{
if (actorBody == this)
{ continue; }

View file

@ -65,7 +65,7 @@ namespace RimWorldAnimationStudio
{
Workspace.actorID = parent.actorID;
foreach (ActorBody actorBody in AnimationController.Instance.GetComponentsInChildren<ActorBody>())
foreach (ActorBody actorBody in AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>())
{
actorBody.bodyRenderer.color = Constants.ColorWhite;
actorBody.headRenderer.color = Constants.ColorWhite;

View file

@ -37,7 +37,7 @@ namespace RimWorldAnimationStudio
string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;
AnimationController.Instance.GetComponentsInChildren<ActorBody>()[Workspace.actorID].bodyType = bodyType;
AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()[Workspace.actorID].bodyType = bodyType;
bodyOffsetXField.text = actor.bodyTypeOffset.GetOffset(bodyType).x.ToString();
bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString();
@ -57,6 +57,15 @@ namespace RimWorldAnimationStudio
actor.bodyTypeOffset.SetOffset(bodyType, new Vector2(x, z));
actor.initiator = initiatorToggle.isOn;
switch (genderDropdown.value)
{
case 0: actor.requiredGender = new List<string>() { "Female" }; break;
case 2: actor.requiredGender = new List<string>() { "Male" }; break;
default: actor.requiredGender = null; break;
}
Workspace.Instance.MakeDirty();
}
public void OpenSelectBodyPartsDialog()
@ -100,11 +109,11 @@ namespace RimWorldAnimationStudio
{
isDirty = true;
if (Workspace.actorID >= AnimationController.Instance.GetComponentsInChildren<ActorBody>().Count())
if (Workspace.actorID >= AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>().Count())
{ Debug.Log("Waiting for actors to initialize..."); return; }
Actor actor = Workspace.animationDef.actors[Workspace.actorID];
ActorBody actorBody = AnimationController.Instance.GetComponentsInChildren<ActorBody>()[Workspace.actorID];
ActorBody actorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()[Workspace.actorID];
string bodyType = actorBody.bodyType;
bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;

View file

@ -23,7 +23,7 @@ namespace RimWorldAnimationStudio
if (Workspace.actorID >= AnimationController.Instance.transform.childCount)
{ return; }
ActorBody actorBody = AnimationController.Instance.transform.GetChild(Workspace.actorID).GetComponent<ActorBody>();
ActorBody actorBody = AnimationController.Instance.actorBodies.GetComponentsInChildren<ActorBody>()[Workspace.actorID];
string bodyType = actorBody.bodyType;
PawnAnimationClip clip = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[Workspace.actorID];

View file

@ -19,21 +19,18 @@ namespace RimWorldAnimationStudio
public void AddBodyDefType(InputField field)
{
Debug.Log("Attempting to add new body def type");
if (field?.text == null || field.text == "")
{ Debug.LogWarning("Input field is null"); return; }
{ return; }
if (Workspace.bodyDefTypes.Contains(field.text))
{ Debug.LogWarning("Body def type is null"); field.text = ""; return; }
{ field.text = ""; return; }
Debug.Log("Added new body type def: " + field.text);
Workspace.bodyDefTypes.Add(field.text);
Initialize();
Initialize(null, true);
}
public void Initialize(Actor actor = null)
public void Initialize(Actor actor = null, bool addedNewTag = false)
{
if (actor != null)
{ this.actor = actor; }
@ -68,7 +65,12 @@ namespace RimWorldAnimationStudio
else if (toggleComp.isOn == false && actor.bodyDefTypes.Contains(bodyDefType))
{ actor.bodyDefTypes.Remove(bodyDefType); }
Workspace.Instance.MakeDirty();
});
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
{ toggleComp.isOn = true; }
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;

View file

@ -30,10 +30,10 @@ namespace RimWorldAnimationStudio
Debug.Log("Add new body part: " + field.text);
Workspace.bodyParts.Add(field.text);
Initialize();
Initialize(null, true);
}
public void Initialize(Actor actor = null)
public void Initialize(Actor actor = null, bool addedNewTag = false)
{
if (actor != null)
{ this.actor = actor; }
@ -68,7 +68,12 @@ namespace RimWorldAnimationStudio
else if (toggleComp.isOn == false && actor.requiredGenitals.Contains(bodyPart))
{ actor.requiredGenitals.Remove(bodyPart); }
Workspace.Instance.MakeDirty();
});
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
{ toggleComp.isOn = true; }
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;

View file

@ -19,21 +19,18 @@ namespace RimWorldAnimationStudio
public void AddDefName(InputField field)
{
Debug.Log("Attempting to add new def name");
if (field?.text == null || field.text == "")
{ Debug.LogWarning("Input field is null"); return; }
{ return; }
if (Workspace.defNames.Contains(field.text))
{ Debug.LogWarning("Def name is null"); field.text = ""; return; }
{ field.text = ""; return; }
Debug.Log("Added new def name: " + field.text);
Workspace.defNames.Add(field.text);
Initialize();
Initialize(null, true);
}
public void Initialize(Actor actor = null)
public void Initialize(Actor actor = null, bool addedNewTag = false)
{
if (actor != null)
{ this.actor = actor; }
@ -68,7 +65,12 @@ namespace RimWorldAnimationStudio
else if (toggleComp.isOn == false && actor.defNames.Contains(defName))
{ actor.defNames.Remove(defName); }
Workspace.Instance.MakeDirty();
});
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
{ toggleComp.isOn = true; }
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;

View file

@ -15,20 +15,20 @@ namespace RimWorldAnimationStudio
Initialize();
}
public void AddBodyPart(InputField field)
public void AddInteractionDef(InputField field)
{
if (field?.text == null || field.text == "")
{ return; }
if (Workspace.bodyParts.Contains(field.text))
if (Workspace.interactionDefTypes.Contains(field.text))
{ field.text = ""; return; }
Workspace.interactionDefTypes.Add(field.text);
Initialize();
Initialize(true);
}
public void Initialize()
public void Initialize(bool addedNewTag = false)
{
if (Workspace.animationDef == null) return;
@ -57,14 +57,19 @@ namespace RimWorldAnimationStudio
else if (toggleComp.isOn == false && Workspace.animationDef.interactionDefTypes.Contains(interactionDefType))
{ Workspace.animationDef.interactionDefTypes.Remove(interactionDefType); }
Workspace.Instance.MakeDirty();
});
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
{ toggleComp.isOn = true; }
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;
_optionField.Find("Placeholder").GetComponent<Text>().text = "Enter new interaction def type...";
InputField fieldComp = _optionField.GetComponent<InputField>();
fieldComp.onEndEdit.AddListener(delegate { AddBodyPart(fieldComp); });
fieldComp.onEndEdit.AddListener(delegate { AddInteractionDef(fieldComp); });
}
public void Reset()

View file

@ -20,15 +20,15 @@ namespace RimWorldAnimationStudio
if (field?.text == null || field.text == "")
{ return; }
if (Workspace.bodyParts.Contains(field.text))
if (Workspace.sexTypes.Contains(field.text))
{ field.text = ""; return; }
Workspace.sexTypes.Add(field.text);
Initialize();
Initialize(true);
}
public void Initialize()
public void Initialize(bool addedNewTag = false)
{
if (Workspace.animationDef == null) return;
@ -41,7 +41,7 @@ namespace RimWorldAnimationStudio
Transform contentWindow = transform.FindDeepChild("Content");
Reset();
for (int i = 0; i < Workspace.bodyParts.Count; i++)
for (int i = 0; i < Workspace.sexTypes.Count; i++)
{
string sexType = Workspace.sexTypes[i];
@ -57,7 +57,12 @@ namespace RimWorldAnimationStudio
else if (toggleComp.isOn == false && Workspace.animationDef.sexTypes.Contains(sexType))
{ Workspace.animationDef.sexTypes.Remove(sexType); }
Workspace.Instance.MakeDirty();
});
if (addedNewTag && i == Workspace.sexTypes.Count - 1)
{ toggleComp.isOn = true; }
}
Transform _optionField = AddCloneObjectToParent(contentWindow, 1).transform;

View file

@ -24,7 +24,7 @@ namespace RimWorldAnimationStudio
public void OnMoveStage(int delta)
{
if (AnimationController.Instance.MoveAnimationStage(transform.GetSiblingIndex(), delta))
if (StageCardManager.Instance.MoveAnimationStage(transform.GetSiblingIndex(), delta))
{
int siblingCount = transform.parent.childCount;
int index = Mathf.Clamp(transform.GetSiblingIndex() + delta, 0, siblingCount - 1);

View file

@ -24,7 +24,8 @@ namespace RimWorldAnimationStudio
public InputField animationClipTimeField;
public InputField animationClipLengthField;
public ActorCard actorCard;
public Transform animationTimelines;
public Transform animationTimelines;
public Transform actorBodies;
[Header("Prefabs")]
public ActorBody actorBodyPrefab;
@ -110,9 +111,9 @@ namespace RimWorldAnimationStudio
InitializeAnimationTimeline();
}
List<ActorBody> actorBodies = GetComponentsInChildren<ActorBody>().ToList();
List<ActorBody> _actorBodies = actorBodies.GetComponentsInChildren<ActorBody>().ToList();
for (int actorID = 0; actorID < actorBodies.Count; actorID++)
for (int actorID = 0; actorID < _actorBodies.Count; actorID++)
{
if (Workspace.stageID >= Workspace.animationDef?.animationStages.Count)
{ Debug.Log("Waiting for animation stage data to initialize..."); return; }
@ -127,7 +128,7 @@ namespace RimWorldAnimationStudio
float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
ActorBody actorBody = actorBodies[actorID];
ActorBody actorBody = _actorBodies[actorID];
string bodyType = actorBody.bodyType;
Vector3 deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent), 0, clip.BodyOffsetZ.Evaluate(clipPercent));
@ -161,13 +162,17 @@ namespace RimWorldAnimationStudio
actorBody.bodyRenderer.sortingLayerName = clip.layer;
actorBody.headRenderer.sortingLayerName = clip.layer;
actorBody.headRenderer.sortingOrder = headFacing == 0 ? -1 : 1;
actorBody.headRenderer.sortingOrder = bodyFacing == 0 ? -1 : 1;
}
}
public void Initialize()
{
Debug.Log("Initializing animation preview");
foreach (Transform child in transform)
{ child.gameObject.SetActive(true); }
Reset();
InitializeAnimationTimeline();
@ -183,7 +188,7 @@ namespace RimWorldAnimationStudio
for (int actorID = 0; actorID < Workspace.animationDef.actors.Count; actorID++)
{
ActorBody actorBody = Instantiate(actorBodyPrefab, transform);
ActorBody actorBody = Instantiate(actorBodyPrefab, actorBodies.transform);
actorBody.Initialize(actorID);
AnimationTimeline animationTimeline = Instantiate(animationTimelinePrefab, animationTimelines);
@ -212,65 +217,13 @@ namespace RimWorldAnimationStudio
timeSinceLastUpdate = 0;
cycleIndex = 0;
foreach (ActorBody actorBody in GetComponentsInChildren<ActorBody>())
foreach (ActorBody actorBody in actorBodies.GetComponentsInChildren<ActorBody>())
{ Destroy(actorBody.gameObject); }
foreach (AnimationTimeline animationTimeline in animationTimelines.GetComponentsInChildren<AnimationTimeline>())
{ Destroy(animationTimeline.gameObject); }
}
public bool AddAnimationStage()
{
AnimationStage stage = new AnimationStage();
Workspace.Instance.MakeDirty();
return stage.MakeNew();
}
public bool CloneAnimationStage()
{
AnimationStage stage = Workspace.animationDef.animationStages[Workspace.stageID].Copy();
stage.Initialize();
stage.stageName += " (Clone)";
Workspace.animationDef.animationStages.Insert(Workspace.stageID + 1, stage);
Workspace.Instance.MakeDirty();
return true;
}
public bool MoveAnimationStage(int startIndex, int delta)
{
if (startIndex + delta < 0 || startIndex + delta >= Workspace.animationDef.animationStages.Count)
{ return false; }
AnimationStage stage = Workspace.animationDef.animationStages[startIndex];
Workspace.animationDef.animationStages[startIndex] = Workspace.animationDef.animationStages[startIndex + delta];
Workspace.animationDef.animationStages[startIndex + delta] = stage;
Workspace.Instance.MakeDirty();
return true;
}
public bool RemoveAnimationStage()
{
if (Workspace.animationDef.animationStages.Count == 1)
{
Debug.LogWarning("Cannot delete animation stage - the animation must contain at least one animation stage.");
return false;
}
Workspace.animationDef.animationStages.RemoveAt(Workspace.stageID);
Workspace.stageID = Workspace.stageID >= Workspace.animationDef.animationStages.Count ? Workspace.stageID = Workspace.animationDef.animationStages.Count - 1 : Workspace.stageID;
Workspace.Instance.MakeDirty();
return true;
}
public void AddActor()
{
Actor actor = new Actor();

View file

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
using SFB;
@ -54,6 +55,7 @@ namespace RimWorldAnimationStudio
Workspace.Instance.ClearHistory();
Workspace.Instance.MakeDirty();
AnimationController.Instance.MakeDirty();
var animationDefCards = Resources.FindObjectsOfTypeAll(typeof(AnimationDefCard)) as AnimationDefCard[];
@ -93,19 +95,14 @@ namespace RimWorldAnimationStudio
public void NewAnimation()
{
return;
var path = Path.Combine(Application.streamingAssetsPath, "AnimationDefs/newAnimationDef.xml");
AnimationDef animationDef = new AnimationDef();
Defs defs = XmlUtility.ReadXML<Defs>(path);
// Add one stage, add one actor, add one clip, add one frame
if (defs?.animationDefs == null)
{ Debug.LogError("Default animation def file contains no animation data"); return; }
Workspace.animationDef = new AnimationDef();
Workspace.Instance.MakeDirty();
var animationDefCards = Resources.FindObjectsOfTypeAll(typeof(AnimationDefCard)) as GameObject[];
if (animationDefCards != null)
{ animationDefCards[0].SetActive(true); }
LoadAnimation(defs.animationDefs[0]);
}
}
}

View file

@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@ -33,23 +34,75 @@ namespace RimWorldAnimationStudio
public void OnNewStage()
{
if (AnimationController.Instance.AddAnimationStage())
if (AddAnimationStage())
{ MakeStageCard("NewStage"); }
}
public bool AddAnimationStage()
{
AnimationStage stage = new AnimationStage();
Workspace.Instance.MakeDirty();
return stage.MakeNew();
}
public void OnCloneStage()
{
if (AnimationController.Instance.CloneAnimationStage())
if (CloneAnimationStage())
{
StageCard stageCard = MakeStageCard(Workspace.animationDef.animationStages[Workspace.stageID + 1].stageName);
stageCard.transform.SetSiblingIndex(Workspace.stageID + 1);
}
}
public void OnDeleteStage()
public bool CloneAnimationStage()
{
if (AnimationController.Instance.RemoveAnimationStage())
AnimationStage stage = Workspace.animationDef.animationStages[Workspace.stageID].Copy();
stage.Initialize();
stage.stageName += " (Clone)";
Workspace.animationDef.animationStages.Insert(Workspace.stageID + 1, stage);
Workspace.Instance.MakeDirty();
return true;
}
public bool MoveAnimationStage(int startIndex, int delta)
{
if (startIndex + delta < 0 || startIndex + delta >= Workspace.animationDef.animationStages.Count)
{ return false; }
AnimationStage stage = Workspace.animationDef.animationStages[startIndex];
Workspace.animationDef.animationStages[startIndex] = Workspace.animationDef.animationStages[startIndex + delta];
Workspace.animationDef.animationStages[startIndex + delta] = stage;
Workspace.Instance.MakeDirty();
return true;
}
public void OnRemoveStage()
{
if (RemoveAnimationStage())
{ Destroy(transform.GetChild(Workspace.stageID).gameObject); }
}
public bool RemoveAnimationStage()
{
if (Workspace.animationDef.animationStages.Count == 1)
{
Debug.LogWarning("Cannot delete animation stage - the animation must contain at least one animation stage.");
return false;
}
Workspace.animationDef.animationStages.RemoveAt(Workspace.stageID);
Workspace.stageID = Workspace.stageID >= Workspace.animationDef.animationStages.Count ? Workspace.stageID = Workspace.animationDef.animationStages.Count - 1 : Workspace.stageID;
Workspace.Instance.MakeDirty();
return true;
}
}
}

View file

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class RequiresAnimationDef : MonoBehaviour
{
private Button button;
public void Start()
{
button = GetComponent<Button>();
}
public void Update()
{
button.interactable = Workspace.animationDef != null;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7903694afa5d7ba429917c147e222781
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -16,7 +16,7 @@ namespace RimWorldAnimationStudio
public static List<string> defNames = new List<string>() { "Human" };
public static List<string> bodyParts = new List<string>() { "Any appendage", "Any orifice", "Penis", "Vagina", "Anus", "Breasts", "Mouth" };
public static List<string> bodyDefTypes = new List<string>() { "Human" };
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" };
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>();
@ -76,10 +76,6 @@ namespace RimWorldAnimationStudio
public void TrackChanges()
{
Debug.Log("Test");
Debug.Log(historyIndex + 1);
Debug.Log(workspaceHistory.Count - historyIndex);
if (historyIndex < workspaceHistory.Count - 1)
{ workspaceHistory.RemoveRange(historyIndex + 1, workspaceHistory.Count - historyIndex - 1); }