
// Return if there's nothing to add on to
if (!util) then return end


/*---------------------------------------------------------
   Name:	IsValidPhysicsObject
   Params: 	<ent> <num>
   Desc:	Returns true if physics object is valid, false if not
---------------------------------------------------------*/   
function util.IsValidPhysicsObject( ent, num )

	// Make sure the entity is valid
	if ( !ent || (!ent:IsValid() && !ent:IsWorld()) ) then return false end

	// This is to stop attaching to walking NPCs.
	// Although this is possible and `works', it can severly reduce the 
	// performance of the server.. Plus they don't pay attention to constraints
	// anyway - so we're not really losing anything.
	
	local MoveType = ent:GetMoveType()
	if ( !ent:IsWorld() && MoveType != MOVETYPE_VPHYSICS ) then return false end

	local Phys = ent:GetPhysicsObjectNum( num )
	return Phys:IsValid()

end