It is possible for buildings to require a resource in order to be built, the classic example being the hydro plant.
However, losing your last aluminum or your only source of aluminum (mine is pillaged, city with mine is lost etc) does not have any negative effect on the hydro plant. So in regular unmodded civ 5, it is possible for buildings to require resources for construction but they never require them for operation or maintenance. This is different than the way units are treated - where losing the strategic resource makes them fight less effectively.
So my question, as an inexperienced modder, is to what extent would it be possible to impose some kind of penalty on a building that "required" a resource that the player no longer has access to or enough of. In other words I want buildings to respond to resource shortages the same way units do. This could potentially include just nullifying all effects of the building.
Specialists?
A particularly big issue that I can imagine is, that even if with scripting you could nullify a building's yields, resource output, or whatever else, I'm sure it would be very hard to remove any specialist slots it has. Specialist slots seem like they would be another big problem.
Just Destroy the Building During Shortage?
A simple solution may be to use a script to destroy buildings that require a resource when the number of copies of the resource available fall below the amount required by the empire. The problem with this is that you need to discriminate between all the individual buildings in the empire and destroy only some of them (if you have 4 factories producing Y from X, but only 3 X, the script needs to be able to destroy only 1 factory, and somehow pick which one should be destroyed). A second, more simple problem with just destroying the buildings is that it seems like an unfair and severe way of handling the situation when you can often get a lot of resources back quickly depending on the situation (like repairing an improvement in 2 turns).
Case Study
As an example: There's a good mod from steam user Clay Matthew T that makes an "energy" resource which is created from and required by different buildings. But it doesn't do anything about the issue of the game not handling shortages realistically. If you lose the coal necessary for your city's coal plant, the plant still produces energy, buildings that require energy, in turn, continue to function just fine.
Conclusion
Solving this issue could lead to some amazing economic mods because you could have buildings with complex input/output relationships and a world economy of traded resources that emergently responds in a realistic way when a random improvement somewhere on the map is pillaged.
However, losing your last aluminum or your only source of aluminum (mine is pillaged, city with mine is lost etc) does not have any negative effect on the hydro plant. So in regular unmodded civ 5, it is possible for buildings to require resources for construction but they never require them for operation or maintenance. This is different than the way units are treated - where losing the strategic resource makes them fight less effectively.
So my question, as an inexperienced modder, is to what extent would it be possible to impose some kind of penalty on a building that "required" a resource that the player no longer has access to or enough of. In other words I want buildings to respond to resource shortages the same way units do. This could potentially include just nullifying all effects of the building.
Specialists?
A particularly big issue that I can imagine is, that even if with scripting you could nullify a building's yields, resource output, or whatever else, I'm sure it would be very hard to remove any specialist slots it has. Specialist slots seem like they would be another big problem.
Just Destroy the Building During Shortage?
A simple solution may be to use a script to destroy buildings that require a resource when the number of copies of the resource available fall below the amount required by the empire. The problem with this is that you need to discriminate between all the individual buildings in the empire and destroy only some of them (if you have 4 factories producing Y from X, but only 3 X, the script needs to be able to destroy only 1 factory, and somehow pick which one should be destroyed). A second, more simple problem with just destroying the buildings is that it seems like an unfair and severe way of handling the situation when you can often get a lot of resources back quickly depending on the situation (like repairing an improvement in 2 turns).
Case Study
As an example: There's a good mod from steam user Clay Matthew T that makes an "energy" resource which is created from and required by different buildings. But it doesn't do anything about the issue of the game not handling shortages realistically. If you lose the coal necessary for your city's coal plant, the plant still produces energy, buildings that require energy, in turn, continue to function just fine.
Conclusion
Solving this issue could lead to some amazing economic mods because you could have buildings with complex input/output relationships and a world economy of traded resources that emergently responds in a realistic way when a random improvement somewhere on the map is pillaged.