Welcome to the forum
Does Check engine light(CEL) come on when key is turned on?
It looks like original engine, at least a 1999 or later 3.0l Vulcan from the recessed head bolt threads in the picture.
Picture also shows excessive pinging(pre-ignition) damage, at least in that one cylinder, have to see other pistons to see if it was an engine wide issue.
That caused the pitting in the piston top and the broken off piece of piston
That much pitting had to happen over many months, did you hear Pinging/knocking noises when accelerating or going uphill?
That kind of long term damage would be audible over a long period
Google: piston damage from pinging images
So that's the cause of the engine failure, pre-ignition, and you need to know the source of that problem or it will reoccur with new engine.
Pinging is not an engine issue specifically, it can be caused by fuel mix issue, computer, MAF/O2 sensors, fuel injector, fuel pressure, spark timing, coil pack or fuel itself.
I wouldn't think dealer would know about this issue, cold engines don't show pinging usually, they start doing it after they warm up, and test drives are often done cold.
There are no tests you can do for pre-ignition damage outside of putting a camera down each spark plug hole to look for pitting, it won't show up on compression test or leak down test.
The fact that parts had been changed or work was done on a 16 year old vehicle/engine wouldn't be too much of a concern.
If dealer wants to help out then take any help you can get :)
Whatever you decide the current engine will need to come out.
If only that one piston/cylinder shows pre-ignition damage then you could just replace that piston/rings, and the head on that side, also depends on cylinder wall damage.
And check bearing clearances.
If all pistons/cylinders are showing damage then it will be a judgement call, depending on best price for used engine with heads, or rebuild yours with 2 new heads.
You can use a used 1999 and up 3.0l Vulcan engine, avoid 2003-2006 3.0l's, bad heads, it can be from a Ranger/Mazda B3000 or Ford car, but you should change the head gaskets if it is from a Ford car
You can use 1986 to 1998 3.0l as well.
Ford used these engines in many models, read here: https://en.wikipedia.org/wiki/Ford_Vulcan_engine
3.0l changes over the years seen here: Ford Ranger II 3.0 liter Engines
Flex fuel or gas only doesn't matter to engine, as you will be swapping your current upper and lower intake to the "new" engine so wiring will match up, only fuel injectors matter for flex fuel.
Also oil pan and pickup tube/screen.