The large-scale penetration of renewable energy is a challenge for grid operators both at the transmission and distribution levels. Demand-side management has been gaining traction for offering new ways of controlling the balance between supply and demand of electricity that is so critical to reliable grid operations. Key questions remain as to the flexibility that different dispatchable loads can provide in real-time operations, especially since they act at very different time scales (ramp rates, cycle frequency and duration). The goal of this work is to model and understand how to design and control complex energy systems or ecosystems that interact with not one but several energy carriers such as electricity, heat and fuels; and to explore the potential of flexible energy system components that can increase the security and affordability of our energy system. Specifically, we study the optimal behavior of the Stanford campus energy system under three different California energy mixes, and under different pricing structures for both energy and carbon. This study highlights the synergies that can be gained from a district energy system that couples the supply of heating, cooling and electric power and provides key insights into the relative impacts of the carbon intensity of the electric grid and different pricing structures for carbon and energy on effective decarbonization pathways for a campus energy system.