rimworld-animation-studio/Assets/Scripts/AnimationComponents/AnimationDef.cs

41 lines
1.8 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 = true;
[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 { get { return animationStages.Sum(x => x.playTimeTicks); } }
[XmlIgnore] public int animationTimeTicksQuick { get { return animationStages.Sum(x => x.playTimeTicksQuick); } }
public bool ShouldSerializesexTypes() { return sexTypes.NotNullOrEmpty(); }
public bool ShouldSerializeinteractionDefTypes() { return interactionDefTypes.NotNullOrEmpty(); }
public bool ShouldSerializeactors() { return actors.NotNullOrEmpty(); }
public bool ShouldSerializeanimationStages() { return animationStages.NotNullOrEmpty(); }
public void Initialize()
{
foreach (AnimationStage stage in animationStages)
{ stage.Initialize(); }
}
public void ValidateData()
{
sexTypes = sexTypes.Intersect(Tags.sexTypes.Concat(CustomTags.sexTypes))?.ToList();
interactionDefTypes = interactionDefTypes.Intersect(Tags.interactionDefTypes.Concat(CustomTags.interactionDefTypes))?.ToList();
}
}
}