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 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-08 14:09:03 +02:00
commit 8b2147a5f7
4 changed files with 30 additions and 3 deletions

View file

@ -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<T>())
// 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<T>().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}");
}
}

View file

@ -2595,7 +2595,8 @@ public sealed class FireControlCut124Tests : IDisposable
{
var weapons = cache.GetAll<WeaponItemData>().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<MineLayerData>().Any()))
{
Assert.Null(w.BlastRadius);
Assert.Null(w.Fuse);

View file

@ -13,6 +13,8 @@ public sealed class MineLauncherCatalogTests
var launcher = Assert.Single(cache.GetAll<GearData>().OfType<WeaponItemData>(), item => item.Name == "Mine Launcher");
Assert.Equal(HardpointType.Launcher, launcher.HardpointType);
Assert.NotNull(launcher.Shape);
Assert.Contains(cache.GetAll<FactionProductData>(), 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);

View file

@ -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<FactionProductData>()
.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<CraftedItemData>(design),
Manufacturer = maker
});
});
Console.WriteLine($"\nAuthored \"{name}\" in Aetheria.cc");
return 0;
}