diff --git a/tools/blender/tests/smoke_bake.py b/tools/blender/tests/smoke_bake.py index a51c4601b..c6ed397ac 100644 --- a/tools/blender/tests/smoke_bake.py +++ b/tools/blender/tests/smoke_bake.py @@ -3,7 +3,7 @@ blender --background --factory-startup --python-use-system-env --python tools/blender/tests/smoke_bake.py Blender 5.2 is required: the tolerances below were measured on 5.2.2 (Cycles on the CPU, 256 x 256, one sample). -Environment as smoke_package.py's header says: CULTLIB_PACKAGES and SMOKE_GAME_FOLDER (a folder holding +Environment as smoke_package.py's header says: SMOKE_GAME_FOLDER (a folder holding GameData/Aetheria.cc and the published AetherDb under ModTools, no dotnet). The ship is created under /GameData/Mods/smoke.bake, which this smoke removes when it ends. @@ -39,7 +39,6 @@ import numpy REPO = Path(__file__).resolve().parents[3] FIXTURE = REPO / "tools" / "blender" / "tests" / "fixtures" / "tripo-hull.glb" -PACKAGES = os.environ.get("CULTLIB_PACKAGES") or sys.exit("Set CULTLIB_PACKAGES to CultLib's packages directory") GAME = Path(os.environ.get("SMOKE_GAME_FOLDER") or sys.exit("Set SMOKE_GAME_FOLDER to a folder holding GameData/Aetheria.cc and ModTools/AetherDb")) SHIP_ID = "smoke.bake" COLLECTION = "Smoke Bake" @@ -318,7 +317,6 @@ def main(): sys.path.insert(0, str(REPO / "tools" / "blender")) addon_utils.enable("aetheria_ships", default_set=True, handle_error=None) import aetheria_ships - aetheria_ships._brokkr_cultlib = lambda context: PACKAGES preferences = bpy.context.preferences.addons["aetheria_ships"].preferences preferences.game_folder = str(GAME) require(preferences.bake_size == 2048 and abs(preferences.bake_cage_extrusion - 0.05) < 1e-6 diff --git a/tools/blender/tests/smoke_frame.py b/tools/blender/tests/smoke_frame.py index f05650228..55879b51c 100644 --- a/tools/blender/tests/smoke_frame.py +++ b/tools/blender/tests/smoke_frame.py @@ -2,8 +2,8 @@ blender --background --factory-startup --python-use-system-env --python tools/blender/tests/smoke_frame.py -Environment as smoke_package.py's header says: CULTLIB_PACKAGES and SMOKE_GAME_FOLDER (the published AetherDb under its -ModTools, no dotnet), and msgpack importable. The ship is created under /GameData/Mods/smoke.frame, which +Environment as smoke_package.py's header says: SMOKE_GAME_FOLDER (the published AetherDb under its +ModTools, no dotnet). The ship is created under /GameData/Mods/smoke.frame, which this smoke removes when it ends. Pass 1 sends a UV sphere (1 x 0.6 x 0.4, long axis X, off the origin) through New Ship, length 10, like Djinni: nothing @@ -41,7 +41,6 @@ import bmesh import bpy REPO = Path(__file__).resolve().parents[3] -PACKAGES = os.environ.get("CULTLIB_PACKAGES") or sys.exit("Set CULTLIB_PACKAGES to CultLib's packages directory") SHIP_ID = "smoke.frame" GAME = Path(os.environ.get("SMOKE_GAME_FOLDER") or sys.exit("Set SMOKE_GAME_FOLDER to a folder holding GameData/Aetheria.cc and ModTools/AetherDb")) MODS = GAME / "GameData" / "Mods" @@ -106,9 +105,10 @@ def refused(operator, expected, what): def saved_layout(path, aetheria_ships): - shape, hardpoints, revision = aetheria_ships.ship_cc.read_layout(path, PACKAGES) - width, height, cells = shape - return width, height, {(i // height, i % height) for i, cell in enumerate(cells) if cell}, hardpoints, revision + opened = aetheria_ships._open(bpy.context, path) + width, height, cells = aetheria_ships._parse_footprint(opened["layout"]["grid"])[0] + rows = [{key: value for key, value in row.items() if key != "element"} for row in opened["layout"]["hardpoints"]] + return width, height, {(i // height, i % height) for i, cell in enumerate(cells) if cell}, rows, opened["versions"] def buffer(scene): @@ -178,7 +178,6 @@ def main(): sys.path.insert(0, str(REPO / "tools" / "blender")) addon_utils.enable("aetheria_ships", default_set=True, handle_error=None) import aetheria_ships - aetheria_ships._brokkr_cultlib = lambda context: PACKAGES bpy.context.preferences.addons["aetheria_ships"].preferences.game_folder = str(GAME) require(not (MODS / SHIP_ID).exists(), f"{MODS / SHIP_ID} exists; remove it first") path = str(MODS / SHIP_ID / "ship.cc") @@ -234,7 +233,7 @@ def main(): width, height, cells, hardpoints = buffer(scene) require((width, height) == (6, 10) and hardpoints == 0, f"The buffer is {width}x{height} with {hardpoints} hardpoints") require((0, 0) not in cells and (width // 2, height // 2) in cells, "The ellipse's cells are wrong") - require(not scene.aetheria_layout.revision, "A pending ship's buffer has a revision") + require(not scene.aetheria_layout.versions, "A pending ship's buffer has versions") origin = collection.get("aetheria.grid_origin") require(origin is not None and len(origin) == 4 and (origin[2], origin[3]) == (width, height), "aetheria.grid_origin does not carry the grid's size") @@ -269,25 +268,25 @@ def main(): refused(bpy.ops.aetheria.save_ship_layout, "AetherDb refused to create the ship", "Save with an unknown reference hull") require(not (MODS / SHIP_ID).exists(), "A refused create left the ship folder behind") collection["aetheria.pending"] = ["Smoke Frame", "Djinni"] - real = aetheria_ships.replace_layout + real = aetheria_ships._push def failing(*args, **kwargs): - raise ValueError("probe: replace_layout failed") + raise ValueError("probe: push failed") - aetheria_ships.replace_layout = failing + aetheria_ships._push = failing try: - message = refused(bpy.ops.aetheria.save_ship_layout, "probe: replace_layout failed", "Save with a failing write") + message = refused(bpy.ops.aetheria.save_ship_layout, "probe: push failed", "Save with a failing write") finally: - aetheria_ships.replace_layout = real + aetheria_ships._push = real require(not (MODS / SHIP_ID).exists(), "A failed first Save left the ship folder behind") require(collection.get("aetheria.pending") is not None, "A failed first Save cleared aetheria.pending") result, message = run(bpy.ops.aetheria.save_ship_layout) require(result == {"FINISHED"}, f"The retried Save was refused: {message}") require(collection.get("aetheria.pending") is None, "Save left aetheria.pending set") - width, height, cells, hardpoints, revision = saved_layout(path, aetheria_ships) + width, height, cells, hardpoints, versions = saved_layout(path, aetheria_ships) require((width, height, cells) == buffer(scene)[:3], "The saved .cc is not the buffer") - require(scene.aetheria_layout.revision == revision, "The buffer did not record the saved revision") - require(aetheria_ships.ship_cc.read(path, PACKAGES).ship.body[0] == SHIP_ID, "The saved file is not the ship") + require(json.loads(scene.aetheria_layout.versions) == versions, "The buffer did not record the saved versions") + require(aetheria_ships._open(bpy.context, path)["ship"] == SHIP_ID, "The saved file is not the ship") require(grid_faces() == len(cells), "Save did not redraw the Grid") refused_existing = _second_collection_refused() print("PASS 2 save creates and cleans up ok", refused_existing) @@ -431,19 +430,6 @@ def main(): require("Source Sphere" not in names and "Grid" not in names, "The GLB holds the Source or the Grid") require("the validator accepted the ship" in report and not any(name in report for name in NAMES_NOT_ECHOED), f"Package's report is not the fixed text: {report}") - # Members a later schema adds to a hardpoint row are not unsaved edits. - real_read_layout = aetheria_ships.read_layout - - def later_schema(*args, **kwargs): - shape, rows, revision = real_read_layout(*args, **kwargs) - return shape, [list(row) + [0] for row in rows], revision - - aetheria_ships.read_layout = later_schema - try: - result, message = run(bpy.ops.aetheria.package_ship) - finally: - aetheria_ships.read_layout = real_read_layout - require(result == {"FINISHED"}, f"A .cc whose rows carry a later schema's members read as unsaved edits: {message}") # A library error is the console's, not the panel's: a directory where ship.glb goes fails the exporter. glb = Path(path).with_name("ship.glb") glb.unlink() @@ -780,22 +766,24 @@ def guards_pass(aetheria_ships): del collection_a["aetheria.pending"] # A failed Save of a saved ship (a write that raises, then a .cc that changed since Load) leaves its real ship.cc. - real = aetheria_ships.replace_layout + real = aetheria_ships._push def failing(*args, **kwargs): - raise ValueError("probe: replace_layout failed") + raise ValueError("probe: push failed") - aetheria_ships.replace_layout = failing + aetheria_ships._push = failing try: - refused(bpy.ops.aetheria.save_ship_layout, "probe: replace_layout failed", "Save of a saved ship with a failing write") + refused(bpy.ops.aetheria.save_ship_layout, "probe: push failed", "Save of a saved ship with a failing write") finally: - aetheria_ships.replace_layout = real + aetheria_ships._push = real require(Path(path_a).is_file() and digest(path_a) == saved, "A failed Save deleted or changed a saved ship's ship.cc") state = bpy.context.scene.aetheria_layout - revision, state.revision = state.revision, "changed outside Blender" - refused(bpy.ops.aetheria.save_ship_layout, "changed since Load", "Save with a stale revision") - state.revision = revision - require(Path(path_a).is_file() and digest(path_a) == saved, "A stale-revision Save deleted or changed the ship.cc") + versions, armor = state.versions, state.hardpoints[0].armor + state.hardpoints[0].armor = armor + 1 # a change, so the push has a write to find stale + state.versions = json.dumps({key: "1999-01-01T00:00:00.0000000+00:00" for key in json.loads(versions)}) + refused(bpy.ops.aetheria.save_ship_layout, "changed since it was opened", "Save with a stale version") + state.versions, state.hardpoints[0].armor = versions, armor + require(Path(path_a).is_file() and digest(path_a) == saved, "A stale-version Save deleted or changed the ship.cc") # New Ship checks everything, the rasterising included, before it changes the collection: a vertical wall has # horizontal extent and no top-down area. @@ -849,16 +837,16 @@ def guards_pass(aetheria_ships): keep = MODS / GUARD_B / "keep.txt" keep.write_text("an author file") select(hull_b) - real = aetheria_ships.replace_layout + real = aetheria_ships._push def failing(*args, **kwargs): - raise ValueError("probe: replace_layout failed") + raise ValueError("probe: push failed") - aetheria_ships.replace_layout = failing + aetheria_ships._push = failing try: - refused(bpy.ops.aetheria.save_ship_layout, "probe: replace_layout failed", "Save with a failing write into an existing folder") + refused(bpy.ops.aetheria.save_ship_layout, "probe: push failed", "Save with a failing write into an existing folder") finally: - aetheria_ships.replace_layout = real + aetheria_ships._push = real require(keep.is_file(), "A failed Save deleted a file the author had in the ship folder") require(not Path(path_b).exists() and collection_b.get("aetheria.pending") is not None, "A failed Save left a half-made ship") result, message = run(bpy.ops.aetheria.save_ship_layout) diff --git a/tools/blender/tests/smoke_hull_source.py b/tools/blender/tests/smoke_hull_source.py index 68550b5f6..4314d672f 100644 --- a/tools/blender/tests/smoke_hull_source.py +++ b/tools/blender/tests/smoke_hull_source.py @@ -2,8 +2,8 @@ blender --background --factory-startup --python-use-system-env --python tools/blender/tests/smoke_hull_source.py -Environment: CULTLIB_PACKAGES and SMOKE_GAME_FOLDER as smoke_package.py's header says (the published AetherDb under -ModTools, GameData/Aetheria.cc), msgpack importable, and OpenSCAD 2026.09 or later at SMOKE_OPENSCAD (default: the add-on +Environment: SMOKE_GAME_FOLDER as smoke_package.py's header says (the published AetherDb under +ModTools, GameData/Aetheria.cc) and OpenSCAD 2026.09 or later at SMOKE_OPENSCAD (default: the add-on preference's default). SMOKE_PID_LOG, when set, receives one line per OpenSCAD process. Each ship is created under /GameData/Mods/smoke.hull.*, which this smoke removes when it ends. @@ -59,10 +59,8 @@ from pathlib import Path import addon_utils import bmesh import bpy -import msgpack REPO = Path(__file__).resolve().parents[3] -PACKAGES = os.environ.get("CULTLIB_PACKAGES") or sys.exit("Set CULTLIB_PACKAGES to CultLib's packages directory") GAME = Path(os.environ.get("SMOKE_GAME_FOLDER") or sys.exit("Set SMOKE_GAME_FOLDER to a folder holding GameData/Aetheria.cc and ModTools/AetherDb")) OPENSCAD = os.environ.get("SMOKE_OPENSCAD") PID_LOG = os.environ.get("SMOKE_PID_LOG") @@ -348,7 +346,7 @@ def one_hull(scene, number, fixture, ship_id, extent, length, rows, body, palett # Schematic lines: Build's, else hers, and never two of hers. packaged = ship_lines(ship_cc) - require(packaged and packaged[0][0] == "silhouette" and packaged[0][5] is True, f"The first line is not the silhouette: {packaged[:1]}") + require(packaged and packaged[0]["layer"] == "silhouette" and packaged[0]["cyclic"] is True, f"The first line is not the silhouette: {packaged[:1]}") kit = [row for row in packaged if row[0] != "silhouette"] drawn = [row[0] for row in packaged] require(drawn[:len(packaged) - len(kit)] == ["silhouette"] * (len(packaged) - len(kit)), "The silhouette contours are not first") @@ -363,7 +361,7 @@ def one_hull(scene, number, fixture, ship_id, extent, length, rows, body, palett result, message = run(bpy.ops.aetheria.package_ship) require(result == {"FINISHED"}, f"Package refused a ship with one Grease Pencil: {message!r}") hers = ship_lines(ship_cc) - require(len(hers) == 1 and hers[0][0] == "hers" and len(hers[0][2]) == 9, f"Her Grease Pencil did not replace the kit's lines: {hers}") + require(len(hers) == 1 and hers[0]["layer"] == "hers" and len(hers[0]["points"]) == 9, f"Her Grease Pencil did not replace the kit's lines: {hers}") second = grease_pencil(collection, "second lines", [(0, 0, 0), (2, 0, 0)]) before = ship_lines(ship_cc) for operator in (bpy.ops.aetheria.package_ship, bpy.ops.aetheria.capture_ship_lines): @@ -607,15 +605,16 @@ def clear(collection): def ship_lines(ship_path): - """The ShipAuthoring.SchematicLines rows of a ship.cc, as Package wrote them.""" - return sys.modules["aetheria_ships"].read(ship_path, PACKAGES).ship.body[sys.modules["aetheria_ships"].ship_cc.SCHEMATIC_LINES_SLOT] + """The schematic line rows of a ship.cc as open prints them, as Package wrote them.""" + return sys.modules["aetheria_ships"]._open(bpy.context, ship_path)["lines"] def same_lines(a, b, tolerance=1e-4): - """Whether two SchematicLines slots hold the same rows: layer, cyclic, colour and every point within tolerance.""" + """Whether two line lists hold the same rows: layer, cyclic, colour and every point within tolerance.""" return len(a) == len(b) and all( - x[0] == y[0] and x[5] == y[5] and len(x[2]) == len(y[2]) and approx(x[6], y[6], tolerance) - and all(abs(p - q) <= tolerance for p, q in zip(x[2], y[2])) for x, y in zip(a, b)) + x["layer"] == y["layer"] and x["cyclic"] == y["cyclic"] and len(x["points"]) == len(y["points"]) + and approx(x["color"], y["color"], tolerance) + and all(abs(p - q) <= tolerance for p, q in zip(x["points"], y["points"])) for x, y in zip(a, b)) def grease_pencil(collection, name, points): @@ -805,7 +804,7 @@ def hull_type_gate(scene): fixture, _, extent, length, rows, *_ = HULLS[0] ship_id = "smoke.hull.role" collection, box, package = make_ship(scene, fixture, ship_id, extent, length, rows) - ship_module = sys.modules["aetheria_ships.ship_cc"] + module = sys.modules["aetheria_ships"] path = str(package / "ship.cc") source = package / "hull.scad" original = source.read_text() @@ -820,20 +819,22 @@ def hull_type_gate(scene): sys.modules["aetheria_ships"].hull_source.build = recorded try: - require(ship_module.read_hull_type(path, PACKAGES) == "Ship", "New Ship did not write a Ship hull") + require(module._open(bpy.context, path)["hullType"] == "Ship", "New Ship did not write a Ship hull") select(box) result, message = run(bpy.ops.aetheria.build_hull_source) require(result == {"CANCELLED"} and "the body's proportions lie inside the language's ranges" in message, f"A Ship far wider than its language allows was built: {message!r}") print("PASS 5.1 a body wider than the language's ships is refused as Ship, on proportion") - store = ship_module.read(path, PACKAGES).store - for envelope in store.pull_all(): - if envelope.type == ship_module.HULL_SCHEMA: - values = msgpack.unpackb(envelope.payload, raw=False) - values[ship_module.HULL_TYPE_SLOT] = 1 - store.push(dataclasses.replace(envelope, payload=msgpack.packb(values, use_bin_type=True))) - require(ship_module.read_hull_type(path, PACKAGES) == "Station", "The pushed HullType did not read back as Station") + # The add-on's one hull-type reader says Station for this ship: the rest of Build reads it from there. + real_open = module._open + + def station(context, ship_path): + opened = real_open(context, ship_path) + opened["hullType"] = "Station" + return opened + + module._open = station select(box) result, message = run(bpy.ops.aetheria.build_hull_source) names = [c.name for c in judged[-1].checks] @@ -854,6 +855,7 @@ def hull_type_gate(scene): print("PASS 5.3 a Station 70 m wide is refused on the layout grid, not on proportion") finally: sys.modules["aetheria_ships"].hull_source.build = real + module._open = real_open print("HULL_TYPE_GATE_OK", flush=True) return collection @@ -866,7 +868,6 @@ def main(): import aetheria_ships global hull_source, EXECUTABLE hull_source = aetheria_ships.hull_source - aetheria_ships._brokkr_cultlib = lambda context: PACKAGES preferences = bpy.context.preferences.addons["aetheria_ships"].preferences preferences.game_folder = str(GAME) if OPENSCAD: diff --git a/tools/blender/tests/smoke_mounts.py b/tools/blender/tests/smoke_mounts.py index ee623537d..a01d172d4 100644 --- a/tools/blender/tests/smoke_mounts.py +++ b/tools/blender/tests/smoke_mounts.py @@ -3,8 +3,8 @@ Mount, and that Package moves nothing of them. blender --background --factory-startup --python-use-system-env --python tools/blender/tests/smoke_mounts.py -Environment as smoke_package.py's header says: CULTLIB_PACKAGES and SMOKE_GAME_FOLDER (the published AetherDb under its -ModTools, no dotnet), and msgpack importable. The ship is created under /GameData/Mods/smoke.mounts, which +Environment as smoke_package.py's header says: SMOKE_GAME_FOLDER (the published AetherDb under its +ModTools, no dotnet). The ship is created under /GameData/Mods/smoke.mounts, which this smoke removes when it ends. The schematic and the model are separate spaces (ruling schematic-and-model-are-separate-spaces): a row's Position is @@ -34,7 +34,6 @@ import bpy from mathutils import Vector REPO = Path(__file__).resolve().parents[3] -PACKAGES = os.environ.get("CULTLIB_PACKAGES") or sys.exit("Set CULTLIB_PACKAGES to CultLib's packages directory") SHIP_ID = "smoke.mounts" ODD_ID = "smoke.mounts.odd" # (ship id, length in cells, the source sphere's Y scale, wide, grid width parity) of passes 6 to 8; the id's mod directory @@ -271,7 +270,6 @@ def main(): sys.path.insert(0, str(REPO / "tools" / "blender")) addon_utils.enable("aetheria_ships", default_set=True, handle_error=None) import aetheria_ships - aetheria_ships._brokkr_cultlib = lambda context: PACKAGES bpy.context.preferences.addons["aetheria_ships"].preferences.game_folder = str(GAME) require(not (MODS / SHIP_ID).exists(), f"{MODS / SHIP_ID} exists; remove it first") path = str(MODS / SHIP_ID / "ship.cc") @@ -413,11 +411,26 @@ def main(): require(row(scene, "weapon.2")[3] == REVERSED and row(scene, "reactor.a") == reactor_before, "Package changed a Rotation or an internal row") require(abs(gun.rotation_euler.z - 0.3) < 1e-6, f"Package turned a hand-set yaw: {gun.rotation_euler.z}") require(abs(twin.rotation_euler.z - twin_yaw) < 1e-6, f"Package turned a mount to its row's Rotation: {twin.rotation_euler.z}") - saved = aetheria_ships.ship_cc.read_layout(path, PACKAGES)[1] - by_mount = {fields["Transform"]: fields for fields in map(aetheria_ships.ship_cc.decode_hardpoint, saved)} - require(tuple(by_mount["weapon.1"]["Position"]) == (4, 5) and tuple(by_mount["weapon.2"]["Position"]) == (1, 5) - and by_mount["weapon.2"]["Rotation"] == REVERSED and tuple(by_mount["reactor.a"]["Position"]) == (2, 2), + def saved_rows(): + return {fields["mount"]: fields for fields in aetheria_ships._open(bpy.context, path)["layout"]["hardpoints"]} + + by_mount = saved_rows() + require(tuple(by_mount["weapon.1"]["cell"]) == (4, 5) and tuple(by_mount["weapon.2"]["cell"]) == (1, 5) + and by_mount["weapon.2"]["rotation"] == REVERSED and tuple(by_mount["reactor.a"]["cell"]) == (2, 2), "The .cc does not hold what the author left") + # An element id is carried: after Load, a row moved and saved stands at its new cell under the same element. + select(sphere) + require(run(bpy.ops.aetheria.load_ship_layout)[0] == {"FINISHED"}, "Load before the element check was refused") + element = saved_rows()["weapon.1"]["element"] + require(element, "Open names no element for a saved hardpoint") + moved = next(hp for hp in scene.aetheria_layout.hardpoints if hp.mount_id == "weapon.1") + require(moved.element == element, "Load did not carry the element") + moved.x -= 1 + require(run(bpy.ops.aetheria.save_ship_layout)[0] == {"FINISHED"}, "Save of a moved row was refused") + after = saved_rows()["weapon.1"] + require(after["element"] == element and tuple(after["cell"]) == (3, 5), "A moved row did not keep its element") + moved.x += 1 + require(run(bpy.ops.aetheria.save_ship_layout)[0] == {"FINISHED"}, "Save of the restored row was refused") require([r for r in rows(scene) if r in pair_rows] == pair_rows, "The second Package moved a mirrored pair") print("PASS 3 package moves nothing ok") diff --git a/tools/blender/tests/smoke_package.py b/tools/blender/tests/smoke_package.py index 6d0322dea..8a6aca9dd 100644 --- a/tools/blender/tests/smoke_package.py +++ b/tools/blender/tests/smoke_package.py @@ -2,7 +2,7 @@ blender --background --factory-startup --python-use-system-env --python tools/blender/tests/smoke_package.py -Environment: CULTLIB_PACKAGES (CultLib's packages directory, as test_ship_cc.py) and SMOKE_GAME_FOLDER, a folder holding +Environment: SMOKE_GAME_FOLDER, a folder holding GameData/Aetheria.cc and the published AetherDb under ModTools (AetherDb.exe on Windows), which the smoke sets as the add-on's Game folder. No dotnet is needed: the add-on runs the published tool and nothing else. SMOKE_MODS names the mods directory to write into (default: a new temp directory); the package is left there so the @@ -36,7 +36,6 @@ import bpy REPO = Path(__file__).resolve().parents[3] GAME = Path(os.environ.get("SMOKE_GAME_FOLDER") or sys.exit("Set SMOKE_GAME_FOLDER to a folder holding GameData/Aetheria.cc and ModTools/AetherDb")) -PACKAGES = os.environ.get("CULTLIB_PACKAGES") or sys.exit("Set CULTLIB_PACKAGES to CultLib's packages directory") SHIP_ID = "smoke.gale" @@ -329,8 +328,6 @@ def main(): sys.path.insert(0, str(REPO / "tools" / "blender")) addon_utils.enable("aetheria_ships", default_set=True, handle_error=None) import aetheria_ships - # Brokkr is the Blender host's CultLib path provider and is not installed in a factory-startup Blender. - aetheria_ships._brokkr_cultlib = lambda context: PACKAGES bpy.context.preferences.addons["aetheria_ships"].preferences.game_folder = str(GAME) mods = Path(os.environ.get("SMOKE_MODS") or tempfile.mkdtemp(prefix="aetheria-smoke-mods-")) @@ -362,16 +359,15 @@ def main(): bpy.context.view_layer.objects.active = hull bind_cases(ship, path, mods) - ship_cc = aetheria_ships.ship_cc - _, _, revision = ship_cc.read_layout(path, PACKAGES) - def hardpoint(kind, x, mount): - return ship_cc.encode_hardpoint(Type=ship_cc.HARDPOINT_TYPE_NAMES.index(kind), Position=[x, 0], - Shape=[[1, 1, [True]]], Transform=mount, Rotation=0, Armor=0.0, FiringArc=0.0) + return {"element": "", "mount": mount, "kind": kind, "cell": [x, 0], "footprint": "#", "rotation": 0, + "armor": 0.0, "arc": 0.0} - ship_cc.replace_layout(path, PACKAGES, SHIP_ID, revision, [4, 1, [True] * 4], [ - hardpoint("Thruster", 0, "thruster"), hardpoint("Radiator", 1, "radiator"), - hardpoint("Energy", 2, "gun"), hardpoint("Reactor", 3, "reactor")]) + aetheria_ships._push(bpy.context, path, { + "ship": SHIP_ID, "versions": aetheria_ships._open(bpy.context, path)["versions"], + "layout": {"grid": "####", "hardpoints": [ + hardpoint("Thruster", 0, "thruster"), hardpoint("Radiator", 1, "radiator"), + hardpoint("Energy", 2, "gun"), hardpoint("Reactor", 3, "reactor")]}}, apply=True) objects_before = sorted(obj.name for obj in bpy.data.objects) result, report = package(aetheria_ships)