mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
81 lines
2.9 KiB
C#
81 lines
2.9 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Xml;
|
|
using System.Xml.Serialization;
|
|
using UnityEngine;
|
|
|
|
namespace RimWorldAnimationStudio
|
|
{
|
|
public class AnimationDef
|
|
{
|
|
public string defName = "Undefined";
|
|
public string label = "Undefined";
|
|
public bool sounds = false;
|
|
|
|
[XmlArray("sexTypes"), XmlArrayItem("li")] public List<string> sexTypes = new List<string>();
|
|
[XmlArray("interactionDefTypes"), XmlArrayItem("li")] public List<string> interactionDefTypes = new List<string>();
|
|
[XmlArray("actors"), XmlArrayItem("li")] public List<Actor> actors = new List<Actor>();
|
|
[XmlArray("animationStages"), XmlArrayItem("li")] public List<AnimationStage> animationStages = new List<AnimationStage>();
|
|
|
|
[XmlIgnore] public int animationTimeTicks = 0;
|
|
|
|
public void Initialize()
|
|
{
|
|
animationTimeTicks = 0;
|
|
|
|
foreach (AnimationStage stage in animationStages)
|
|
{
|
|
stage.Initialize();
|
|
animationTimeTicks += stage.playTimeTicks;
|
|
}
|
|
}
|
|
|
|
public void RunPreSaveOperations()
|
|
{
|
|
// Stage edits
|
|
for (int i = 0; i < animationStages.Count; i++)
|
|
{
|
|
AnimationStage stage = animationStages[i];
|
|
|
|
// Sort keyframes by atTick
|
|
foreach (PawnAnimationClip clip in stage.animationClips)
|
|
{ clip.keyframes = clip.keyframes.OrderBy(x => x.atTick).ToList(); }
|
|
|
|
// Check if looping
|
|
int stageWindowSize = animationStages[i].stageWindowSize > 0 ? animationStages[i].stageWindowSize : animationStages[i].animationClips.Select(x => x.duration).Max();
|
|
int cycles = Mathf.CeilToInt(animationStages[i].playTimeTicks / stageWindowSize);
|
|
|
|
Debug.Log(animationStages[i].playTimeTicks);
|
|
Debug.Log(animationStages[i].stageWindowSize);
|
|
Debug.Log(cycles);
|
|
stage.isLooping = cycles > 1;
|
|
}
|
|
|
|
// Body part list edit
|
|
foreach (Actor actor in actors)
|
|
{
|
|
actor.isFucking = actor.requiredGenitals.Contains("Any appendage");
|
|
|
|
if (actor.isFucking == true)
|
|
{ actor.requiredGenitals.Remove("Any appendage"); }
|
|
|
|
actor.isFucked= actor.requiredGenitals.Contains("Any orifice");
|
|
|
|
if (actor.isFucked == true)
|
|
{ actor.requiredGenitals.Remove("Any orifice"); }
|
|
}
|
|
}
|
|
|
|
public void RunPostLoadOperations()
|
|
{
|
|
foreach (Actor actor in actors)
|
|
{
|
|
if (actor.isFucking == true)
|
|
{ actor.requiredGenitals.Add("Any appendage"); }
|
|
|
|
if (actor.isFucked == true)
|
|
{ actor.requiredGenitals.Add("Any orifice"); }
|
|
}
|
|
}
|
|
}
|
|
}
|