mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Bug fixes plus better layout
This commit is contained in:
parent
b0a965e0b2
commit
18c0473f39
192 changed files with 4773 additions and 5746 deletions
|
@ -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();
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue