The Problem

Player construction of planetary defense structures can paradoxically result in a galaxy of defenseless independent worlds over time. This is because when a world with high-TL defenses goes independent, it often ends up with no defenses whatsoever after it reverts to its fated TL.

Players can also demolish defenses on planets undergoing civil war in order to make them easier to retake later.

Example: A player controls a TL10 world with a battlestation structure and a plasma tower structure. The world has a fated TL of 5. Under the current model, when the planet goes independent, it stops building battlestations instantly because heavy missile launchers are not available. The battlestation structure still exists. Over time the independent planet loses TL. When it drops below TL 9 the battlestation structure vanishes and when it drops below TL 8 the plasma tower structure vanishes. The end result is a TL 5 planet not building defenses.

A Solution

First, planetary defense structures should have lower-tech preceding structures defined as their destroysTo structure. This is part of an active pull request.

Optional

If not already performed, a check should be performed every time that a planet goes independent. If any structure requires a resource that the planet cannot produce as an autonomous world with its deposits, the structure should ruin to its destroysTo structure if one exists. Repeat this check on the resulting structures too (E.g. on a primordial world with battlestations, the entire satellite chain would be tried and then discarded since the only viable defenses are GDMs.) If an independent world at its fatedTL does not have any operable defense structures, it should call the worldImprovements table and build some appropriate defenses.

Included in pull request 4.

verified: the destroysTo structures get built (with timer) when manually destroyed
verified: check if destroysTo structures get built when a planet reverts due to civil war independence
in progress: check what happens when a planet drops TL while still in an empire (I would expect that high TL defense structures would get preserved, the way habitats do)