Pin the rig's slot 5 carry-through: C# slot numbers and Python replace_visual/replace_lines round trips
Tests only; builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
638856afc1
commit
7a195d2384
2 changed files with 37 additions and 0 deletions
|
|
@ -67,6 +67,15 @@ public sealed class ShipSchemaPinTests
|
|||
Assert.Equal(slot, KeyOf(typeof(ShipAnchor), members[slot]));
|
||||
}
|
||||
|
||||
// ship_cc.py edits slots 2 to 4 of a ship and the first five slots of an anchor row, and carries every later slot (replace_visual
|
||||
// by anchor Id). The rig lives in those later slots; their numbers are the contract that carry-through keeps.
|
||||
[Fact]
|
||||
public void TheRigLivesInTheSlotsPastTheOnesPythonEdits()
|
||||
{
|
||||
Assert.Equal(Integer("SCHEMATIC_LINES_SLOT") + 1, KeyOf(typeof(ShipAuthoring), nameof(ShipAuthoring.Joints)));
|
||||
Assert.Equal(Strings("ANCHOR_MEMBERS").Length, KeyOf(typeof(ShipAnchor), nameof(ShipAnchor.Joint)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PythonEnumNamesAreTheEnumsInValueOrder()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -190,6 +190,34 @@ class ReadTests(ShipFileCase):
|
|||
ship_cc.read(self.path, PACKAGES)
|
||||
|
||||
|
||||
class RigCarryThroughTests(ShipFileCase):
|
||||
"""The rig (ShipAuthoring slot 5 Joints, ShipAnchor slot 5 Joint) lies past every slot this module edits, so a save keeps it."""
|
||||
|
||||
JOINTS = [["turret", None, [0.0, 1.0, 0.0], [-30.0], [30.0]]]
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
ship = ship_body()
|
||||
ship.append(self.JOINTS)
|
||||
ship[ship_cc.ANCHORS_SLOT] = [["gun", "weapon-mount", "gun", None, 0, "turret"], ["map", "map-icon", "map", None, 0]]
|
||||
self.write(ship, hull_body())
|
||||
|
||||
def test_replace_visual_keeps_the_joints_and_each_mounts_joint_by_anchor_id(self):
|
||||
ship_cc.replace_visual(self.path, PACKAGES, "mod.skiff", "ship.glb",
|
||||
[["map", "map-icon", "map", None, 0], ["gun", "weapon-mount", "gun", None, 0]])
|
||||
ship = self.ship()
|
||||
self.assertEqual(self.JOINTS, ship[5])
|
||||
self.assertEqual([["map", "map-icon", "map", None, 0], ["gun", "weapon-mount", "gun", None, 0, "turret"]],
|
||||
ship[ship_cc.ANCHORS_SLOT])
|
||||
|
||||
def test_replace_lines_keeps_the_joints_and_the_anchor_rows(self):
|
||||
before = self.ship()
|
||||
ship_cc.replace_lines(self.path, PACKAGES, LINES)
|
||||
after = self.ship()
|
||||
self.assertEqual(self.JOINTS, after[5])
|
||||
self.assertEqual(before[ship_cc.ANCHORS_SLOT], after[ship_cc.ANCHORS_SLOT])
|
||||
|
||||
|
||||
class ReplaceLinesTests(ShipFileCase):
|
||||
def test_replaces_only_the_line_slot(self):
|
||||
new_lines = [["Detail", "Red", [0.0] * 6, [0.1, 0.1], [1.0, 1.0], True, [1.0, 0.0, 0.0, 1.0]]]
|
||||
|
|
|
|||
Loading…
Reference in a new issue