We introduce a Local Background Environment (LBE) estimator that can be measured in and around every galaxy or its dark matter subhalo in high-resolution cosmological simulations. The LBE is designed to capture the influence of environmental effects such as ram-pressure stripping on the formation and evolution of galaxies in semi-analytical models. We define the LBE directly from the particle data within an adaptive spherical shell, and devise a Gaussian mixture estimator to separate background particles from previously unidentified subhalo particles. Analyzing the LBE properties, we find that the LBE of satellite galaxies is not at rest with respect to their host halo, in contrast to typical assumptions. The orientations of the velocities of a subhalo and its LBE are well aligned in the outer infall regions of haloes, but decorrelated near halo center. Significantly, there is no abrupt change in LBE velocity or density at the halo virial radius. This suggests that stripping should also happen beyond this radius. Therefore, we use the time-evolving LBE of galaxies to develop a method to better account for ram-pressure stripping within the Munich semi-analytical model, L-Galaxies. Overall, our new approach results in a significant increase in gas stripping across cosmic time. Central galaxies, as well as satellites beyond the virial radius, can lose a significant fraction of their hot halo gas. As a result, the gas fractions and star formation rates of satellite galaxies are suppressed relative to the fiducial model, although the stellar masses and global stellar mass functions are largely unchanged.