Package derives no mounts for a ship with no Ship Root, and refuses a framed one whose layout is not loaded
smoke_package's hand-tagged ship has a weapon-mount object, no Ship Root and no loaded buffer; the first mounts commit refused it. A ship with no frame has no grid to derive from, so Package leaves its rows alone as before. A framed ship with a mount and an unloaded buffer is refused with 'Load Layout first'. All commits build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a89d885c6b
commit
56129b43d5
2 changed files with 13 additions and 3 deletions
|
|
@ -399,7 +399,7 @@ def _plan_mounts(collection, state, root, path):
|
|||
"""(row, weapon-mount object, Position, yaw) for every buffer row whose Transform names a weapon-mount object: the
|
||||
Position from the object's placement, the yaw from the row's Rotation. Refuses before anything changes."""
|
||||
mounts = _mount_objects(collection)
|
||||
if not mounts:
|
||||
if not mounts or root is None: # a ship with no Ship Root has no grid to derive from: its rows are the author's
|
||||
return []
|
||||
if state.ship_id != collection["aetheria.id"] or state.ship_cc != path:
|
||||
raise ValueError("Load Layout first: the weapon mounts need this ship's layout")
|
||||
|
|
@ -407,8 +407,8 @@ def _plan_mounts(collection, state, root, path):
|
|||
if not paired:
|
||||
return []
|
||||
origin = collection.get("aetheria.grid_origin")
|
||||
if root is None or origin is None:
|
||||
raise ValueError("Rasterise first: a mount needs the ship's Ship Root and grid")
|
||||
if origin is None:
|
||||
raise ValueError("Rasterise first: a mount needs the ship's grid")
|
||||
plan = []
|
||||
for hp, obj in paired:
|
||||
if obj.parent != root:
|
||||
|
|
|
|||
|
|
@ -286,6 +286,16 @@ def main():
|
|||
by_mount = {fields["Transform"]: fields for fields in map(aetheria_ships.ship_cc.decode_hardpoint, saved)}
|
||||
require(tuple(by_mount["weapon.1"]["Position"]) == (4, 3) and by_mount["weapon.2"]["Rotation"] == REVERSED
|
||||
and tuple(by_mount["reactor.a"]["Position"]) == (2, 2), "The .cc does not hold what Package derived")
|
||||
# A framed ship whose layout buffer is not loaded cannot be derived from: Package refuses and changes nothing.
|
||||
state = scene.aetheria_layout
|
||||
ship_id, glb_before = state.ship_id, glb.read_bytes()
|
||||
state.ship_id = ""
|
||||
result, message = run(bpy.ops.aetheria.package_ship)
|
||||
require(result == {"CANCELLED"} and "Load Layout first" in scene.aetheria_package_report
|
||||
and all(name not in scene.aetheria_package_report for name in NAMES_NOT_ECHOED),
|
||||
f"Package took an unloaded layout: {scene.aetheria_package_report}")
|
||||
require(glb.read_bytes() == glb_before, "A refused Package wrote the GLB")
|
||||
state.ship_id = ship_id
|
||||
print("PASS 3 package derives ok")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue