Motivated by hydrodynamical simulations, we present results of an attempt to include more detailed gas physics within semianalytic models (SAMs) of galaxy formation, focusing on the role played by environmental effects. The main difference from previous SAMs is that we include "gravitational" heating of the intracluster medium (ICM) by the net surplus of gravitational potential energy released from gas that has been stripped from infalling satellites. Gravitational heating appears to be an efficient heating source able to prevent cooling in environments corresponding to dark matter halos more massive than M* at any given redshift because of the continued growth by mergers. The energy release by gravitational heating can match that by AGN feedback in massive galaxies and can exceed it in the most massive ones. However, there is a fundamental difference in the way the two processes operate. Gravitational heating becomes important at late times, when the peak activity of AGNs is already over, and it is very mass dependent. This mass dependency and time behavior gives the right trend to recover downsizing in the star formation rate of massive galaxies. We present a number of first-order comparisons of our model to well-established observations of galaxy properties, which can be summarized as follows. The cosmic star formation rate is reproduced well. In addition, the star formation episode of our model galaxies is a strong function of mass. Massive galaxies with M* > 1011 M☉ make most of their stars at look-back times of roughly 11 Gyr and show very low amounts of residual star formation at late times due to suppression by environmental effects. Furthermore, the luminosity function and color bimodality of the galaxy population are reproduced well.