Faction play 1: typed doctrine on Faction and one flight per faction per zone

FactionDoctrine/RoleDoctrine (Faction key 17), Flight as the only writer of
members' Target and Task, hail/grace/compliance, FollowTask/FollowState,
agent removal on Entities removal, doctrine-catalog command, FlightTests.
Not yet built or run; verification follows in later commits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-08 14:18:41 +02:00
commit 8f42265de3
24 changed files with 812 additions and 42 deletions

View file

@ -0,0 +1,69 @@
using System;
using System.IO;
using System.Linq;
using GameCult.Caching;
// Authors the starting FactionDoctrine of the four factions the demo cast uses (aetheria-release, faction-play-1).
// Tuning is a starting point; the operator adjusts it after play. A faction with no Faction record is named, not
// created: the Pirates' record is owed by follow-up pirates-catalog-record, and re-running apply writes them once it lands.
public static class DoctrineCatalog
{
private static readonly (string faction, FactionDoctrine doctrine)[] Table =
{
("Zhestokost", new FactionDoctrine
{
EngageOn = EngageOn.Trespass, Grace = 6f, Hail = "Cut thrust and hold for inspection.", ComplySpeed = 10f,
Combatant = new RoleDoctrine { RangeExponent = .05f, MinHitProbability = .05f }
}),
("Lucent Media", new FactionDoctrine
{
EngageOn = EngageOn.Detection, Grace = 2f, Hail = "You're live.",
Combatant = new RoleDoctrine { RangeExponent = .25f, MinHitProbability = .3f }
}),
("Aeronautics Unlimited", new FactionDoctrine
{
EngageOn = EngageOn.Detection,
Combatant = new RoleDoctrine { RangeExponent = .25f, MinHitProbability = .05f }
}),
("Pirates", new FactionDoctrine
{
EngageOn = EngageOn.Detection, Grace = 8f, Hail = "Drop your cargo and you can go.",
Combatant = new RoleDoctrine { RangeExponent = .5f, MinHitProbability = .15f }
}),
};
// Dry run unless apply, as the other catalog commands. The cache must be writable for apply.
public static int Run(CultCache cache, bool apply, TextWriter output)
{
var factions = cache.GetAll<Faction>().ToArray();
var changed = new System.Collections.Generic.List<Faction>();
foreach (var (name, doctrine) in Table)
{
var faction = factions.FirstOrDefault(f => string.Equals(f.Name, name, StringComparison.OrdinalIgnoreCase));
if (faction == null)
{
output.WriteLine($"{name}: no Faction record, doctrine not written");
continue;
}
output.WriteLine($"{name}: engage on {doctrine.EngageOn}, grace {doctrine.Grace:0.##}s, hail \"{doctrine.Hail}\", " +
$"comply {doctrine.ComplySpeed:0.##}, range exponent {doctrine.Combatant.RangeExponent:0.##}, " +
$"min hit {doctrine.Combatant.MinHitProbability:0.##}");
faction.Doctrine = doctrine;
changed.Add(faction);
}
if (!apply)
{
output.WriteLine("\nDry run. Pass \"apply\" to author them.");
return 0;
}
cache.Commit(batch =>
{
foreach (var faction in changed) batch.Upsert(typeof(Faction), faction, cache.RefOf(faction).Key);
});
output.WriteLine($"\nAuthored {changed.Count} doctrines in Aetheria.cc");
return 0;
}
}

View file

@ -38,8 +38,9 @@ public static class Program
case "targeting-catalog-6d": return TargetingCatalog6d(args.Contains("apply"));
case "ship-authoring": return ShipAuthoringCommands.Run(args.Skip(1).ToArray());
case "field-kinds": return FieldKindsCatalog(args.Contains("apply"));
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], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply]");
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, field-kinds [apply], doctrine-catalog [apply]");
return 1;
}
}
@ -659,7 +660,7 @@ public static class Program
{
var db = AetherDb.Open();
var products = db.Cache.GetAll<FactionProductData>().ToArray();
Console.WriteLine($"{"faction",-26} {"short",-13} {"geonames",-22} {"boss hull",-14} {"influence",-9} products");
Console.WriteLine($"{"faction",-26} {"short",-13} {"geonames",-22} {"boss hull",-14} {"influence",-9} {"doctrine",-10} products");
var broken = 0;
foreach (var faction in db.Cache.GetAll<Faction>().OrderBy(f => f.Name))
{
@ -669,7 +670,7 @@ public static class Program
? "none"
: db.Cache.Get(faction.BossHull)?.Name ?? "DANGLING";
if (geonames == "UNSET" || boss == "DANGLING") broken++;
Console.WriteLine($"{faction.Name,-26} {faction.ShortName,-13} {geonames,-22} {boss,-14} {faction.InfluenceDistance,-9} " +
Console.WriteLine($"{faction.Name,-26} {faction.ShortName,-13} {geonames,-22} {boss,-14} {faction.InfluenceDistance,-9} {(faction.Doctrine == null ? "none" : faction.Doctrine.EngageOn.ToString()),-10} " +
products.Count(p => p.Manufacturer.Key.Equals(key)));
}
Console.WriteLine($"\n{broken} factions carry a link that would break generation");