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

41 lines
1.8 KiB
C#
Raw Normal View History

2022-09-13 05:36:34 +00:00
using System.Collections.Generic;
2022-09-19 00:07:44 +00:00
using System.Linq;
2022-09-13 05:36:34 +00:00
using System.Xml;
using System.Xml.Serialization;
2022-09-19 00:07:44 +00:00
using UnityEngine;
2022-09-13 05:36:34 +00:00
namespace RimWorldAnimationStudio
{
public class AnimationDef
{
public string defName = "Undefined";
public string label = "Undefined";
2022-10-12 05:22:29 +00:00
public bool sounds = true;
2022-09-14 05:25:58 +00:00
[XmlArray("sexTypes"), XmlArrayItem("li")] public List<string> sexTypes = new List<string>();
[XmlArray("interactionDefTypes"), XmlArrayItem("li")] public List<string> interactionDefTypes = new List<string>();
2022-09-21 21:15:25 +00:00
[XmlArray("actors"), XmlArrayItem("li")] public List<Actor> actors = new List<Actor>();
2022-09-14 05:25:58 +00:00
[XmlArray("animationStages"), XmlArrayItem("li")] public List<AnimationStage> animationStages = new List<AnimationStage>();
2022-10-14 19:00:57 +00:00
[XmlIgnore] public int animationTimeTicks { get { return animationStages.Sum(x => x.playTimeTicks); } }
[XmlIgnore] public int animationTimeTicksQuick { get { return animationStages.Sum(x => x.playTimeTicksQuick); } }
2022-09-26 04:10:41 +00:00
public bool ShouldSerializesexTypes() { return sexTypes.NotNullOrEmpty(); }
public bool ShouldSerializeinteractionDefTypes() { return interactionDefTypes.NotNullOrEmpty(); }
public bool ShouldSerializeactors() { return actors.NotNullOrEmpty(); }
public bool ShouldSerializeanimationStages() { return animationStages.NotNullOrEmpty(); }
2022-09-13 05:36:34 +00:00
public void Initialize()
{
foreach (AnimationStage stage in animationStages)
2022-10-14 19:00:57 +00:00
{ stage.Initialize(); }
2022-09-13 05:36:34 +00:00
}
2022-09-19 00:07:44 +00:00
2022-09-21 21:15:25 +00:00
public void ValidateData()
2022-09-19 00:07:44 +00:00
{
2022-09-27 05:56:35 +00:00
sexTypes = sexTypes.Intersect(Tags.sexTypes.Concat(CustomTags.sexTypes))?.ToList();
2022-09-21 21:15:25 +00:00
interactionDefTypes = interactionDefTypes.Intersect(Tags.interactionDefTypes.Concat(CustomTags.interactionDefTypes))?.ToList();
2022-09-19 00:07:44 +00:00
}
2022-09-13 05:36:34 +00:00
}
}