diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs index 2389297f5..767479f16 100644 --- a/tools/AetherDb/Program.cs +++ b/tools/AetherDb/Program.cs @@ -1768,37 +1768,45 @@ public static class Program return 0; } - // loot-2: pickup is a capability. The existing Tractor Beam (a Sensors-hardpoint item with no behaviours) becomes - // Tool gear whose one behaviour is Pickup, so a ship carries it in any free interior cell and Zone's pickup needs - // it. The numbers are the retired prefab's beam: range 75, beam radius 25; the grab's phase times, the spin-up - // rate and the power needed to grab are the cut's. Dry run unless passed "apply". + // loot-2: pickup is a capability. The existing Tractor Beam (a Sensors-hardpoint item with no behaviours and no price) + // becomes Tool gear whose one behaviour is Pickup, so a ship carries it in any free interior cell and Zone's pickup + // needs it, and gets the price of the cheapest gear sold today (25000), because generation offers only priced + // designs and every ship must be able to be given one. The numbers are the retired prefab's beam: range 75, beam + // radius 25; the grab's phase times, the spin-up rate and the power needed to grab are the cut's. Dry run unless + // passed "apply". private static int PickupCatalog(bool apply) { const string name = "Tractor Beam"; + const int price = 25000; var db = AetherDb.Open(catalogWritable: apply); var beam = db.Cache.GetAll().Single(gear => gear.Name == name); - if (beam.Hardpoint == HardpointType.Tool && beam.Behaviors.Count == 1 && beam.Behaviors[0] is PickupData) + if (beam.Behaviors.Count > 1 || beam.Behaviors.Count == 1 && beam.Behaviors[0] is not PickupData) + throw new InvalidOperationException($"\"{name}\" has behaviours this command does not know."); + if (beam.Hardpoint == HardpointType.Tool && beam.Behaviors.Count == 1 && beam.Price == price) { Console.WriteLine($"\"{name}\" is already authored; nothing to do."); return 0; } - if (beam.Behaviors.Count != 0) throw new InvalidOperationException($"\"{name}\" already has behaviours."); - Console.WriteLine($"\"{name}\" hardpoint {beam.Hardpoint} -> Tool, no behaviours -> one Pickup (range 75, beam radius 25, grab power .5, extend .3, envelop .2, pull .5, spin rate 2)."); + Console.WriteLine($"\"{name}\" hardpoint {beam.Hardpoint} -> Tool, {beam.Behaviors.Count} behaviours -> one Pickup (range 75, beam radius 25, grab power .5, extend .3, envelop .2, pull .5, spin rate 2), price {beam.Price} -> {price}."); if (!apply) { - Console.WriteLine("\nDry run. Pass \"apply\" to write it."); + Console.WriteLine(" +Dry run. Pass \"apply\" to write it."); return 0; } PerformanceStat Constant(float v) => new PerformanceStat { Min = v, Max = v }; beam.Hardpoint = HardpointType.Tool; - beam.Behaviors.Add(new PickupData - { - Range = Constant(75), BeamRadius = Constant(25), GrabPower = Constant(.5f), SpinRate = Constant(2), - ExtendTime = Constant(.3f), EnvelopTime = Constant(.2f), PullTime = Constant(.5f) - }); + beam.Price = price; + if (beam.Behaviors.Count == 0) + beam.Behaviors.Add(new PickupData + { + Range = Constant(75), BeamRadius = Constant(25), GrabPower = Constant(.5f), SpinRate = Constant(2), + ExtendTime = Constant(.3f), EnvelopTime = Constant(.2f), PullTime = Constant(.5f) + }); CultRecordRefs.Validate(beam); db.Cache.Commit(batch => batch.Upsert(typeof(GearData), beam, db.Cache.RefOf(beam).Key)); - Console.WriteLine($"\nWrote \"{name}\" to Aetheria.cc"); + Console.WriteLine($" +Wrote \"{name}\" to Aetheria.cc"); return 0; }