it should not be possible to build on top of an existing building #224
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Done in
840f9aa.BuildingField.place()dropped a structure at the fleet centroid with no overlap check of any kind, so they could be stacked freely.It reads worse than it looks.
BuildingFielddecides which structure the fleet is standing on by testing the centroid againstinteract_radiusand returning the first match — so two structures inside one another made that a question of list order rather than of where you flew. You could fly to your workshop and open the crafter.The rule. A new structure must be at least 150 units from an existing one. That is
Building.interact_radiusitself rather than a new constant, because it is exactly the circle the ambiguity comes from. Buildings draw to a radius of roughly 60, so this leaves a visible gap rather than letting them touch. For scale: a chunk is 1200 units and a planet's landing radius is 140, so this is "fly off the thing you are standing on", not a trek.Gated in three places — the info popup (button greys out and names what is in the way),
_confirm_build, and_try_place, since the preview goes stale as the fleet keeps moving.One ordering trap. A unique structure replaces itself by demolishing the old one before placing the new one, so a placement refused afterwards would have left the player with neither. The check runs before the demolition and excludes the structure being replaced. Case D of the new test pins exactly that.
Tests.
test_building_separation.gdcovers the rule, the build path, unique-rebuild-in-place, and the destructive-ordering case. Verified in both directions — with the rule neutered it fails on the first assertion.Two existing tests encoded the old permissive behaviour and now fly clear first; neither is about placement:
test_build_info_popupbuilds every menu option from one position, so each structure blocked the nexttest_payments_use_fleet_holdbuilds a mothership on the ship lab an earlier case injects at the originNew games start with no buildings, so the first structure is unconstrained, and quests only require that a structure exists, never where — the chain is unaffected.
175/175.