BetterIk/SandboxBoneNode.cs

Adapter type that wraps an engine BoneCollection.Bone and exposes the IBoneNode interface for the BetterIk skeleton resolver. It delegates name and parent access to the underlying Bone and constructs parent adapters as needed.

#nullable enable

using Sandbox;
using BetterIk.Skeleton;

namespace BetterIk;

/// <summary>Thin adapter over the real engine BoneCollection.Bone, exposing just enough to
/// let BoneChainResolver walk the skeleton. No logic beyond delegation - not unit tested.</summary>
internal sealed class SandboxBoneNode : IBoneNode
{
    public SandboxBoneNode(BoneCollection.Bone bone)
    {
        Bone = bone;
    }

    public BoneCollection.Bone Bone { get; }

    public string Name => Bone.Name;

    public IBoneNode? Parent => Bone.Parent is null ? null : new SandboxBoneNode(Bone.Parent);
}