using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace OpenVIII.Battle.Dat
{
///
/// Section 3a: Model animation - Header
///
///
public struct AnimationData : IReadOnlyList
{
#region Fields
private readonly IReadOnlyList _animations;
#endregion Fields
#region Constructors
public AnimationData(BinaryReader br, long byteOffset, Skeleton skeleton) : this()
{
var cAnimations = br.ReadInt32();
IReadOnlyList pAnimations = Enumerable.Range(0, cAnimations).Select(_ => checked((uint)(byteOffset + br.ReadUInt32()))).ToList()
.AsReadOnly();
_animations = Animation.CreateInstances(br, pAnimations, skeleton);
}
#endregion Constructors
#region Properties
public int Count => _animations?.Count ?? 0;
#endregion Properties
#region Indexers
public Animation this[int index] => _animations[index];
#endregion Indexers
#region Methods
public static AnimationData CreateInstance(BinaryReader br, long byteOffset, Skeleton skeleton)
{
br.BaseStream.Seek(byteOffset, SeekOrigin.Begin);
return new AnimationData(br, byteOffset, skeleton);
}
public IEnumerator GetEnumerator() => _animations.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)_animations).GetEnumerator();
#endregion Methods
}
}