Adds a small engine extension and a resource interface. IDefinitionResource defines Title and Description properties. EngineAdditions adds an extension method on GameObject, FindNetworkRoot, that walks up the Parent chain to find the first GameObject with NetworkMode == Object and returns it, or null if the start is invalid or none found.
namespace Sandbox;
public interface IDefinitionResource
{
public string Title { get; set; }
public string Description { get; set; }
}
public static class EngineAdditions
{
extension( GameObject go )
{
public GameObject FindNetworkRoot()
{
if ( !go.IsValid() ) return null;
if ( go.NetworkMode == NetworkMode.Object ) return go;
return go.Parent?.FindNetworkRoot();
}
}
}