Right, but the point of the pain is to remind conscious me to pull my foot away. But fungi (afaik) aren’t conscious, nor can move, so what’s the evolutionary advantage to this signaling?
The Xenofungus from the video game Alpha Centauri comes to mind.
Who knows what the specific function is, maybe specific species are sensitive to the specific pressure of another species required for reproduction. In the plant example, they often use chemical signaling to repel predators (and note that plants are also "not conscious", and most are way less mobile than fungi).