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

@ -103,6 +103,7 @@
<Compile Include="Assets\Scripts\Math\CurvePoint.cs" /> <Compile Include="Assets\Scripts\Math\CurvePoint.cs" />
<Compile Include="Assets\Scripts\Math\GenMath.cs" /> <Compile Include="Assets\Scripts\Math\GenMath.cs" />
<Compile Include="Assets\Scripts\Math\SimpleCurve.cs" /> <Compile Include="Assets\Scripts\Math\SimpleCurve.cs" />
<Compile Include="Assets\Scripts\RequiresAnimationDef.cs" />
<Compile Include="Assets\Scripts\Singleton.cs" /> <Compile Include="Assets\Scripts\Singleton.cs" />
<Compile Include="Assets\Scripts\StandaloneFileBrowser\IStandaloneFileBrowser.cs" /> <Compile Include="Assets\Scripts\StandaloneFileBrowser\IStandaloneFileBrowser.cs" />
<Compile Include="Assets\Scripts\StandaloneFileBrowser\Sample\BasicSample.cs" /> <Compile Include="Assets\Scripts\StandaloneFileBrowser\Sample\BasicSample.cs" />
@ -120,6 +121,7 @@
<Compile Include="Assets\Scripts\Utilities\XmlUtility.cs" /> <Compile Include="Assets\Scripts\Utilities\XmlUtility.cs" />
<Compile Include="Assets\Scripts\Workspace\Workspace.cs" /> <Compile Include="Assets\Scripts\Workspace\Workspace.cs" />
<Compile Include="Assets\Scripts\Workspace\WorkspaceSnapShot.cs" /> <Compile Include="Assets\Scripts\Workspace\WorkspaceSnapShot.cs" />
<None Include="Assets\StreamingAssets\AnimationDefs\newAnimationDef.xml" />
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
<HintPath>C:/Program Files/Unity/Hub/Editor/2019.4.20f1/Editor/Data/Managed/UnityEngine/UnityEngine.dll</HintPath> <HintPath>C:/Program Files/Unity/Hub/Editor/2019.4.20f1/Editor/Data/Managed/UnityEngine/UnityEngine.dll</HintPath>
</Reference> </Reference>

View File

@ -133,8 +133,8 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 7929422520673851209} - component: {fileID: 7929422520673851209}
- component: {fileID: 7929422520673851208} - component: {fileID: 7929422520673851208}
- component: {fileID: -4411442180840688308}
- component: {fileID: -7575978412006062152} - component: {fileID: -7575978412006062152}
- component: {fileID: -4411442180840688308}
m_Layer: 0 m_Layer: 0
m_Name: ActorBody m_Name: ActorBody
m_TagString: Untagged m_TagString: Untagged
@ -207,22 +207,6 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!114 &-4411442180840688308
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7929422520673851210}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 511a9ed9093e7fc458dec8d3c657f9a5, type: 3}
m_Name:
m_EditorClassIdentifier:
actorID: 0
bodyType: Male
bodyRenderer: {fileID: 7929422520673851208}
headRenderer: {fileID: 7929422519883802244}
--- !u!61 &-7575978412006062152 --- !u!61 &-7575978412006062152
BoxCollider2D: BoxCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -249,3 +233,19 @@ BoxCollider2D:
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 0.75, y: 1} m_Size: {x: 0.75, y: 1}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!114 &-4411442180840688308
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7929422520673851210}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 511a9ed9093e7fc458dec8d3c657f9a5, type: 3}
m_Name:
m_EditorClassIdentifier:
actorID: 0
bodyType: Male
bodyRenderer: {fileID: 7929422520673851208}
headRenderer: {fileID: 7929422519883802244}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -65,7 +65,7 @@ namespace RimWorldAnimationStudio
{ {
Workspace.actorID = parent.actorID; 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.bodyRenderer.color = Constants.ColorWhite;
actorBody.headRenderer.color = Constants.ColorWhite; actorBody.headRenderer.color = Constants.ColorWhite;

View File

@ -37,7 +37,7 @@ namespace RimWorldAnimationStudio
string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text; string bodyType = bodyTypeDropdown.options[bodyTypeDropdown.value].text;
bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType; 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(); bodyOffsetXField.text = actor.bodyTypeOffset.GetOffset(bodyType).x.ToString();
bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString(); bodyOffsetZField.text = actor.bodyTypeOffset.GetOffset(bodyType).z.ToString();
@ -57,6 +57,15 @@ namespace RimWorldAnimationStudio
actor.bodyTypeOffset.SetOffset(bodyType, new Vector2(x, z)); actor.bodyTypeOffset.SetOffset(bodyType, new Vector2(x, z));
actor.initiator = initiatorToggle.isOn; 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() public void OpenSelectBodyPartsDialog()
@ -100,11 +109,11 @@ namespace RimWorldAnimationStudio
{ {
isDirty = true; 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; } { Debug.Log("Waiting for actors to initialize..."); return; }
Actor actor = Workspace.animationDef.actors[Workspace.actorID]; 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; string bodyType = actorBody.bodyType;
bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType; bodyType = bodyType == null || bodyType == "" ? "Male" : bodyType;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@ namespace RimWorldAnimationStudio
public void OnMoveStage(int delta) 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 siblingCount = transform.parent.childCount;
int index = Mathf.Clamp(transform.GetSiblingIndex() + delta, 0, siblingCount - 1); int index = Mathf.Clamp(transform.GetSiblingIndex() + delta, 0, siblingCount - 1);

View File

@ -24,7 +24,8 @@ namespace RimWorldAnimationStudio
public InputField animationClipTimeField; public InputField animationClipTimeField;
public InputField animationClipLengthField; public InputField animationClipLengthField;
public ActorCard actorCard; public ActorCard actorCard;
public Transform animationTimelines; public Transform animationTimelines;
public Transform actorBodies;
[Header("Prefabs")] [Header("Prefabs")]
public ActorBody actorBodyPrefab; public ActorBody actorBodyPrefab;
@ -110,9 +111,9 @@ namespace RimWorldAnimationStudio
InitializeAnimationTimeline(); 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) if (Workspace.stageID >= Workspace.animationDef?.animationStages.Count)
{ Debug.Log("Waiting for animation stage data to initialize..."); return; } { Debug.Log("Waiting for animation stage data to initialize..."); return; }
@ -127,7 +128,7 @@ namespace RimWorldAnimationStudio
float clipPercent = (float)(stageTick % clip.duration) / clip.duration; float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
ActorBody actorBody = actorBodies[actorID]; ActorBody actorBody = _actorBodies[actorID];
string bodyType = actorBody.bodyType; string bodyType = actorBody.bodyType;
Vector3 deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent), 0, clip.BodyOffsetZ.Evaluate(clipPercent)); 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.bodyRenderer.sortingLayerName = clip.layer;
actorBody.headRenderer.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() public void Initialize()
{ {
Debug.Log("Initializing animation preview"); Debug.Log("Initializing animation preview");
foreach (Transform child in transform)
{ child.gameObject.SetActive(true); }
Reset(); Reset();
InitializeAnimationTimeline(); InitializeAnimationTimeline();
@ -183,7 +188,7 @@ namespace RimWorldAnimationStudio
for (int actorID = 0; actorID < Workspace.animationDef.actors.Count; actorID++) for (int actorID = 0; actorID < Workspace.animationDef.actors.Count; actorID++)
{ {
ActorBody actorBody = Instantiate(actorBodyPrefab, transform); ActorBody actorBody = Instantiate(actorBodyPrefab, actorBodies.transform);
actorBody.Initialize(actorID); actorBody.Initialize(actorID);
AnimationTimeline animationTimeline = Instantiate(animationTimelinePrefab, animationTimelines); AnimationTimeline animationTimeline = Instantiate(animationTimelinePrefab, animationTimelines);
@ -212,65 +217,13 @@ namespace RimWorldAnimationStudio
timeSinceLastUpdate = 0; timeSinceLastUpdate = 0;
cycleIndex = 0; cycleIndex = 0;
foreach (ActorBody actorBody in GetComponentsInChildren<ActorBody>()) foreach (ActorBody actorBody in actorBodies.GetComponentsInChildren<ActorBody>())
{ Destroy(actorBody.gameObject); } { Destroy(actorBody.gameObject); }
foreach (AnimationTimeline animationTimeline in animationTimelines.GetComponentsInChildren<AnimationTimeline>()) foreach (AnimationTimeline animationTimeline in animationTimelines.GetComponentsInChildren<AnimationTimeline>())
{ Destroy(animationTimeline.gameObject); } { 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() public void AddActor()
{ {
Actor actor = new Actor(); Actor actor = new Actor();

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using System.IO;
using UnityEngine.UI; using UnityEngine.UI;
using SFB; using SFB;
@ -54,6 +55,7 @@ namespace RimWorldAnimationStudio
Workspace.Instance.ClearHistory(); Workspace.Instance.ClearHistory();
Workspace.Instance.MakeDirty(); Workspace.Instance.MakeDirty();
AnimationController.Instance.MakeDirty(); AnimationController.Instance.MakeDirty();
var animationDefCards = Resources.FindObjectsOfTypeAll(typeof(AnimationDefCard)) as AnimationDefCard[]; var animationDefCards = Resources.FindObjectsOfTypeAll(typeof(AnimationDefCard)) as AnimationDefCard[];
@ -93,19 +95,14 @@ namespace RimWorldAnimationStudio
public void NewAnimation() 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(); LoadAnimation(defs.animationDefs[0]);
Workspace.Instance.MakeDirty();
var animationDefCards = Resources.FindObjectsOfTypeAll(typeof(AnimationDefCard)) as GameObject[];
if (animationDefCards != null)
{ animationDefCards[0].SetActive(true); }
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System.Collections; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -33,23 +34,75 @@ namespace RimWorldAnimationStudio
public void OnNewStage() public void OnNewStage()
{ {
if (AnimationController.Instance.AddAnimationStage()) if (AddAnimationStage())
{ MakeStageCard("NewStage"); } { MakeStageCard("NewStage"); }
} }
public bool AddAnimationStage()
{
AnimationStage stage = new AnimationStage();
Workspace.Instance.MakeDirty();
return stage.MakeNew();
}
public void OnCloneStage() public void OnCloneStage()
{ {
if (AnimationController.Instance.CloneAnimationStage()) if (CloneAnimationStage())
{ {
StageCard stageCard = MakeStageCard(Workspace.animationDef.animationStages[Workspace.stageID + 1].stageName); StageCard stageCard = MakeStageCard(Workspace.animationDef.animationStages[Workspace.stageID + 1].stageName);
stageCard.transform.SetSiblingIndex(Workspace.stageID + 1); 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); } { 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> 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> 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> 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>(); public static List<string> interactionDefTypes = new List<string>();
@ -76,10 +76,6 @@ namespace RimWorldAnimationStudio
public void TrackChanges() public void TrackChanges()
{ {
Debug.Log("Test");
Debug.Log(historyIndex + 1);
Debug.Log(workspaceHistory.Count - historyIndex);
if (historyIndex < workspaceHistory.Count - 1) if (historyIndex < workspaceHistory.Count - 1)
{ workspaceHistory.RemoveRange(historyIndex + 1, workspaceHistory.Count - historyIndex - 1); } { workspaceHistory.RemoveRange(historyIndex + 1, workspaceHistory.Count - historyIndex - 1); }

View File

@ -1,6 +1,7 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 55d980591973c924eb2a68aedd2a8b10 guid: 7a47251a120f3e14697b10a380be1f99
PrefabImporter: folderAsset: yes
DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2abecb9ffac6b4f43a931f7a6d59c3ac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<Defs>
<Rimworld_Animations.AnimationDef>
<defName>newAnimation</defName>
<label>New Animation</label>
<sounds>true</sounds>
<sexTypes>
<li>None</li>
</sexTypes>
<actors>
<li>
<defNames>
<li>Human</li>
</defNames>
</li>
</actors>
<animationStages>
<li>
<stageName>NewStage</stageName>
<stageIndex>0</stageIndex>
<playTimeTicks>600</playTimeTicks>
<playTimeTicksQuick>-1</playTimeTicksQuick>
<isLooping>false</isLooping>
<animationClips>
<li Class="Rimworld_Animations.PawnAnimationClip">
<layer>Pawn</layer>
<keyframes>
<li>
<tickDuration>599</tickDuration>
<headFacing>2</headFacing>
<bodyFacing>2</bodyFacing>
</li>
<li>
<tickDuration>1</tickDuration>
<headFacing>2</headFacing>
<bodyFacing>2</bodyFacing>
</li>
</keyframes>
</li>
</animationClips>
</li>
</animationStages>
</Rimworld_Animations.AnimationDef>
</Defs>

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 73a40f7e8cdb25c4390e3ea857ff50ea guid: 8686649f08f948342a04388fd9e155b1
PrefabImporter: TextScriptImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More