
TS.ItemFactoryID = 0;

function TS.CreateItemProp( item, pos, ang )

	if( not item or not TS.ItemsData[item] or not pos ) then
		return;
	end

	local ent = ents.Create( "ts2_item" );
	ent:AttachItem( item );
	ent:SetPos( pos );
	ent:SetAngles( ang or Angle( 0, 0, 0 ) );
	ent:Spawn();

	if( TS.ItemsData[item].Flags and ( string.find( TS.ItemsData[item].Flags, "c" ) or string.find( TS.ItemsData[item].Flags, "C" ) or ( string.find( TS.ItemsData[item].Flags, "W" ) ) ) ) then

		TS.ItemToContainer( ent:GetTable().ItemData );
		
		if( ent:GetTable().ItemData.FillContainer ) then
			ent:GetTable().ItemData.FillContainer( ent:GetTable().ItemData );
		end
		
	end
	
	if( ent:GetTable().ItemData.PostProcess ) then
		ent:GetTable().ItemData.PostProcess( ent:GetTable().ItemData, ent );
	end

	ent:GetTable().IFID = TS.ItemFactoryID;

	TS.ItemFactoryID = TS.ItemFactoryID + 1;
	
	return ent;

end