Files
sbox-public/engine/Sandbox.Engine/Resources/Model/Model.Animation.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

33 lines
1.2 KiB
C#

namespace Sandbox;
public partial class Model
{
/// <summary>
/// Number of animations this model has.
/// </summary>
public int AnimationCount => native.GetNumAnim();
/// <summary>
/// Returns name of an animation at given animation index.
/// </summary>
/// <param name="animationIndex">Animation index to get name of, starting at 0.</param>
/// <returns>Name of the animation.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown when given index exceeds range of [0,AnimationCount-1]</exception>
public string GetAnimationName( int animationIndex )
{
if ( animationIndex < 0 || animationIndex >= AnimationCount )
throw new ArgumentOutOfRangeException( "animationIndex", $"Tried to access out of range animation index {animationIndex}, range is 0-{AnimationCount - 1}" );
return native.GetAnimationName( animationIndex );
}
private List<string> _animationNames;
public IReadOnlyList<string> AnimationNames => _animationNames ??= Enumerable.Range( 0, AnimationCount )
.Select( GetAnimationName ).ToList();
/// <summary>
/// Get the animgraph this model uses.
/// </summary>
public AnimationGraph AnimGraph => AnimationGraph.FromNative( native.GetAnimationGraph() );
}