All societies rely on individual contributions to sustain public goods that benefit the entire community. A variety of mechanisms, that specify how individuals change their decisions in response to past experiences and behavioral attributes of interacting partners, have been proposed to explain how altruists are not outcompeted by selfish counterparts. A key aspect of such strategyupdate processes involves only a comparison of an individual's latest payoff with that of a randomly chosen neighbor. In reality, both the economic and social milieu often shapes cooperative behavior. We propose a new decision heuristic in social dilemmas, where the propensity of an individual to cooperate depends on the local strategy environment in which she is embedded as well as her wealth relative to that of her connected neighbors. Our decision-making model allows cooperation to be sustained and also explains the results of recent behavioral experiments on cooperation in dynamic social networks. Final cooperation levels depend only on the extent to which the strategy environment influences altruistic behaviour but is largely unaffected by network restructuring. However, the extent of wealth inequality in the community is affected by a subtle interplay between the environmental influence on a person's decision to contribute and the likelihood of reshaping community ties through breaking old and making new links, with wealth-inequality levels rising with increasing likelihood of network restructuring in some situations.