k/ColliderExtension.cs
namespace Sandbox.k;

public static class ColliderExtension
{
	public static bool TryGetComponent<T>( this Collider collider, out T component, bool logError = true )
		where T : Component
	{
		component = collider.GetComponent<T>();
		var hasComponent = component != null;
		if ( !hasComponent && logError )
		{
			Log.Error( $"{typeof(T)} is missing on GameObject {collider.GameObject.Name}!" );
		}

		return hasComponent;
	}

	public static bool HasTag( this Collider collider, string tag, bool includeAncestors = true )
	{
		return collider.GameObject.Tags.Has( tag, includeAncestors );
	}
}