Merge origin/master into economy authoring command
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
dd7f40b559
33 changed files with 1329 additions and 129 deletions
41
tools/AetherDb/AutoGunsCatalog.cs
Normal file
41
tools/AetherDb/AutoGunsCatalog.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using GameCult.Caching;
|
||||
using System.Reflection;
|
||||
|
||||
// Makes the named plain guns fully automatic (ruling fire-mode-is-the-design): each one's InstantWeaponData becomes an
|
||||
// AutoWeaponData carrying every authored stat unchanged, so cadence and damage do not move. A gun that is already an
|
||||
// AutoWeapon (or any other kind) is left alone, so a rerun writes nothing. Dry run unless apply.
|
||||
public static class AutoGunsCatalog
|
||||
{
|
||||
public static readonly string[] Guns = { "Slug Rifle", "Long Slug Rifle" };
|
||||
|
||||
public static int Run(CultCache cache, bool apply, TextWriter output)
|
||||
{
|
||||
var changed = new System.Collections.Generic.List<GearData>();
|
||||
foreach (var name in Guns)
|
||||
{
|
||||
var gear = cache.GetAll<GearData>().SingleOrDefault(g => g.Name == name);
|
||||
if (gear == null) { output.WriteLine($"{name}: no such gear, skipped"); continue; }
|
||||
var index = gear.Behaviors.FindIndex(b => b.GetType() == typeof(InstantWeaponData));
|
||||
if (index < 0) { output.WriteLine($"{name}: no plain gun, kept"); continue; }
|
||||
var plain = (InstantWeaponData) gear.Behaviors[index];
|
||||
var auto = new AutoWeaponData();
|
||||
// AutoWeaponData adds no member of its own: every field of the plain gun, from every base, carries over.
|
||||
for (var type = typeof(InstantWeaponData); type != null; type = type.BaseType)
|
||||
foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
|
||||
field.SetValue(auto, field.GetValue(plain));
|
||||
gear.Behaviors[index] = auto;
|
||||
output.WriteLine($"{name}: InstantWeaponData -> AutoWeaponData (cooldown {plain.Cooldown.Max:0.###} s)");
|
||||
changed.Add(gear);
|
||||
}
|
||||
|
||||
if (!apply) { output.WriteLine("\nDry run. Pass \"apply\" to author them."); return 0; }
|
||||
if (changed.Count == 0) { output.WriteLine("Nothing to author."); return 0; }
|
||||
foreach (var gear in changed) CultRecordRefs.Validate(gear);
|
||||
cache.Commit(batch => { foreach (var gear in changed) batch.Upsert(typeof(GearData), gear, cache.RefOf(gear).Key); });
|
||||
output.WriteLine($"\nAuthored {changed.Count} guns in Aetheria.cc");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -77,9 +77,10 @@ public static class Program
|
|||
return code;
|
||||
}
|
||||
case "economy": return EconomyCommand.Run(args.Skip(1).ToArray());
|
||||
case "auto-guns": return AutoGunsCatalog.Run(AetherDb.Open(catalogWritable: args.Contains("apply")).Cache, args.Contains("apply"), Console.Out);
|
||||
case "doctrine-catalog": return DoctrineCatalog.Run(AetherDb.Open(catalogWritable: args.Contains("apply")).Cache, args.Contains("apply"), Console.Out);
|
||||
default:
|
||||
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], loadout-commit <name> <hull product> [<x>,<y>,<rotation>,<design>[@<product>]]... [--group <i>,<j>...]... [--replace] [--boss-of <faction>], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective <fraction>] [--end <multiplier>], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply], inspection-scanner [apply], minor-power-factions [apply], place-names [apply], product-lines weapons|minor-powers|gear|tiers [apply], doctrine-catalog [apply], assembly-from-maker [apply], station-kinds [hull \"<name>\" <kind>] [apply], economy report|author <batch>... [apply]");
|
||||
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], loadout-commit <name> <hull product> [<x>,<y>,<rotation>,<design>[@<product>]]... [--group <i>,<j>...]... [--replace] [--boss-of <faction>], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective <fraction>] [--end <multiplier>], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply], inspection-scanner [apply], minor-power-factions [apply], place-names [apply], product-lines weapons|minor-powers|gear|tiers [apply], doctrine-catalog [apply], auto-guns [apply], assembly-from-maker [apply], station-kinds [hull \"<name>\" <kind>] [apply], economy report|author <batch>... [apply]");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue