From 8b2147a5f78ae20f94cba04dbf799a4894d12060 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 8 Oct 2026 14:09:03 +0200 Subject: [PATCH] Mine Launcher: a shape and a product that sells it; the blast-neutrality test exempts a mine layer; WireMines takes a Substance material by its path The first catalog commit left the item shapeless and unsold; this commit's mine-launcher command fixes both. The catalog blob committed before this one is superseded by the next commit. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/Editor/WireMines.cs | 6 ++++- .../FireControlCut124Tests.cs | 3 ++- .../MineLauncherCatalogTests.cs | 2 ++ tools/AetherDb/Program.cs | 22 ++++++++++++++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Editor/WireMines.cs b/Assets/Scripts/Editor/WireMines.cs index b9feee017..98b6c8857 100644 --- a/Assets/Scripts/Editor/WireMines.cs +++ b/Assets/Scripts/Editor/WireMines.cs @@ -77,9 +77,13 @@ public static class WireMines { var path = AssetDatabase.GUIDToAssetPath(guid); if (string.IsNullOrEmpty(path)) throw new System.InvalidOperationException($"No asset for guid {guid}"); - foreach (var asset in AssetDatabase.LoadAllAssetsAtPath(path).OfType()) + // A Substance archive's material is regenerated on import under another local id, so a path holding + // exactly one T is that T whatever its id. + var assets = AssetDatabase.LoadAllAssetsAtPath(path).OfType().ToArray(); + foreach (var asset in assets) if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(asset, out _, out long id) && id == fileId) return asset; + if (assets.Length == 1) return assets[0]; throw new System.InvalidOperationException($"No {typeof(T).Name} with file id {fileId} in {path}"); } } diff --git a/tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs b/tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs index c6b1bb00c..98886122b 100644 --- a/tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs +++ b/tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs @@ -2595,7 +2595,8 @@ public sealed class FireControlCut124Tests : IDisposable { var weapons = cache.GetAll().ToList(); Assert.NotEmpty(weapons); - foreach (var w in weapons) + // A mine layer is the one shipped weapon that carries a blast: its radius is the mine's (MineLauncherCatalogTests). + foreach (var w in weapons.Where(w => !w.Behaviors.OfType().Any())) { Assert.Null(w.BlastRadius); Assert.Null(w.Fuse); diff --git a/tests/Aetheria.Shared.Tests/MineLauncherCatalogTests.cs b/tests/Aetheria.Shared.Tests/MineLauncherCatalogTests.cs index 58cef185b..918963dbb 100644 --- a/tests/Aetheria.Shared.Tests/MineLauncherCatalogTests.cs +++ b/tests/Aetheria.Shared.Tests/MineLauncherCatalogTests.cs @@ -13,6 +13,8 @@ public sealed class MineLauncherCatalogTests var launcher = Assert.Single(cache.GetAll().OfType(), item => item.Name == "Mine Launcher"); Assert.Equal(HardpointType.Launcher, launcher.HardpointType); + Assert.NotNull(launcher.Shape); + Assert.Contains(cache.GetAll(), product => cache.RefOf(launcher).Key.Equals(product.Design.Key)); Assert.Equal(WeaponType.Mine, launcher.WeaponType); Assert.Equal(WeaponFuse.Proximity, launcher.Fuse); Assert.Equal(25f, launcher.BlastRadius); diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs index 4c7fa2ee9..4872e68a0 100644 --- a/tools/AetherDb/Program.cs +++ b/tools/AetherDb/Program.cs @@ -1527,6 +1527,7 @@ public static class Program { Name = name, Hardpoint = HardpointType.Launcher, + Shape = new Shape(), WeaponType = WeaponType.Mine, WeaponRange = WeaponRange.Medium, WeaponCaliber = WeaponCaliber.Medium, @@ -1567,8 +1568,27 @@ public static class Program return 0; } + // A design no product sells cannot spawn, and the shipped catalog holds none: sell it as the first + // shipped launcher is sold, by the same maker. + var launcherProducts = db.Cache.GetAll() + .Where(p => db.Cache.Get(p.Design) is WeaponItemData weapon && weapon.Hardpoint == HardpointType.Launcher) + .OrderBy(p => db.Cache.RefOf(p).Key.Value, StringComparer.Ordinal).ToArray(); + if (launcherProducts.Length == 0) throw new InvalidOperationException("No shipped launcher product names a maker for the Mine Launcher."); + var maker = launcherProducts[0].Manufacturer; + Console.WriteLine($"Sold by {db.Cache.Get(maker)?.ShortName ?? "(none)"}, as the first shipped launcher product is."); + CultRecordRefs.Validate(launcher); - db.Cache.Commit(batch => batch.Upsert(typeof(GearData), launcher)); + db.Cache.Commit(batch => + { + var design = batch.Upsert(typeof(GearData), launcher); + batch.Upsert(typeof(FactionProductData), new FactionProductData + { + Name = name, + Description = "Lays a drifting proximity mine that arms after two seconds.", + Design = new CultRecordRef(design), + Manufacturer = maker + }); + }); Console.WriteLine($"\nAuthored \"{name}\" in Aetheria.cc"); return 0; }