Tell apart the halves of a unit that share one skin

The ET42-026 dresses both halves in 112E-026 and the scenery tells them apart
by the model. Textures were keyed by the skin alone, so the B half became a
second A: not part of the set, and listed on its own. A shared skin now gets
the model in its id, vehicles are looked up by skin and model, and the
vehicle cache is rebuilt for the new ids.
This commit is contained in:
maj00r
2026-10-04 19:05:32 +02:00
parent 37dd038b96
commit e5c46d23ea
12 changed files with 99 additions and 30 deletions

View File

@@ -117,4 +117,34 @@ public class VehicleCatalogTests
/// <summary>Builds an entry through the real parser, for catalogue-level tests.</summary>
private static VehicleEntry ParsedEntry(string directory, params string[] lines) =>
new StarterNG.Infrastructure.Vehicles.TexturesTxtParser().Parse(directory, lines)!;
// The ET42-026: one skin for both halves, told apart by the model.
private static VehicleCatalog SharedSkinPair()
{
var files = new InMemoryFileSystem()
.WithFile(TexturesFile("pkp", "et42_v2"),
"!=e,ET42-A,ET42-B\n^2\n112E-026.mat=112E-A,ET42-A,ET42-026-A\n112E-026.mat=112E-B,ET42-B,ET42-026-B");
var installation = new TestInstallation(files);
installation.Vehicles.Load(installation.Library.Vehicles);
return installation.Library.Vehicles;
}
[Fact]
public void A_skin_shared_by_two_models_is_found_by_the_model()
{
var catalog = SharedSkinPair();
Assert.Equal("ET42-026-A", catalog.TextureFor("112E-026", "112E-A")!.TextureMini);
Assert.Equal("ET42-026-B", catalog.TextureFor("112E-026", "112E-B")!.TextureMini);
}
[Fact]
public void The_second_half_on_a_shared_skin_follows_the_first_in_its_set()
{
var catalog = SharedSkinPair();
var b = catalog.TextureFor("112E-026", "112E-B")!;
Assert.True(catalog.IsSetFollower(b));
Assert.Equal(new[] { "112E-A", "112E-B" }, catalog.ResolveSet(b)!.Select(t => t.Model));
}
}