Retire the prelude and the tutorial: the cast, the scenario and the save own what they bundled

Galaxy.IsPrelude, SavedGame.IsTutorial (key 11 retired), TutorialGalaxy, TutorialGenerationSettings, its Settings.asset block and the
dead GalaxyStage/Galaxy constructor parameters (PlayerSettings, narrative directory) are gone. The rules they bundled move to their
owners: GalaxyCast.InfluenceScale (demo and test cast .5, main 1) carried by Galaxy and saved as SavedGame key 17, so a pre-cut run is
refused at Continue with a message; Scenario.EntranceStation (MainGalaxy false) decides the forced entrance station instead of the
galaxy; GalaxyStage.Cast(cast) replaces Prelude. The six arenas that read the authored cast generate DemoTerminus.Cast; Development
lists only Main Galaxy. TutorialBackgroundSettings is renamed CastBackgroundSettings in the asset YAML. Tests build their galaxy from
TestCasts.Wide and Background, the retired block's values, so every test galaxy is unchanged.

Suite at 8b2d1f544: 4 red (font credits, chunk info, trojan swarm, two-ai digest, Windows). After: the same 4, digest unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-19 20:14:26 +01:00
commit 40a5457c9e
54 changed files with 334 additions and 321 deletions

BIN
Assets/Resources/Settings.asset (Stored with Git LFS)

Binary file not shown.

View file

@ -740,8 +740,7 @@ public class ActionGameManager : MonoBehaviour
Settings.ZoneSettings,
Settings.PlanetSettings,
CurrentGalaxy,
galaxyZone,
CurrentGalaxy.IsPrelude
galaxyZone
);
galaxyZone.Contents = new Zone(ItemManager, Settings.PlanetSettings, galaxyZone.PackedContents, galaxyZone, CurrentGalaxy);
}
@ -861,7 +860,7 @@ public class ActionGameManager : MonoBehaviour
{
RunStart.GenerateArena(ItemManager, Settings.ZoneSettings, Settings.PlanetSettings, CurrentGalaxy, scenario);
PopulateLevel(CurrentGalaxy.Entrance);
return RunStart.Stage(ItemManager, Zone, scenario, Settings.StartingHullName, Settings.TutorialGenerationSettings, failures);
return RunStart.Stage(ItemManager, Zone, scenario, Settings.StartingHullName, failures);
}), failures, Debug.LogException);
if (staged == null)

View file

@ -22,8 +22,7 @@ public class GameSettings : ScriptableObject
public float MinimapAsteroidSize = 3;
public float MinimapIconSize = 1f / 32;
public float PlanetRotationSpeed = 1;
public TutorialGenerationSettings TutorialGenerationSettings;
public SectorBackgroundSettings TutorialBackgroundSettings;
public SectorBackgroundSettings CastBackgroundSettings;
public SectorBackgroundSettings SectorBackgroundSettings;
public SectorGenerationSettings SectorGenerationSettings;
public BodySettingsCollection[] BodySettingsCollections;

View file

@ -26,7 +26,10 @@ public class Galaxy
public GalaxyZone Exit { get; private set; }
public Dictionary<Faction, FactionRelationship> FactionRelationships { get; } = new Dictionary<Faction, FactionRelationship>();
private Action<string> Log { get; }
public bool IsPrelude { get; }
// How far each faction's authored InfluenceDistance reaches in this galaxy (InfluenceOf): the cast's InfluenceScale,
// 1 for a main galaxy. Carried by the save because every zone generated after Continue reads it.
public float InfluenceScale { get; }
// The run's seed, minted once by GalaxyStage.SeedFrom and carried by the save (SavedGame.Seed). It seeds
// generation, the run's item draws (RunStart) and the zone's drop dice (Zone.DropSeed).
@ -51,7 +54,9 @@ public class Galaxy
public Galaxy(CultCache cultCache, SavedGame savedGame, Action<string> log)
{
IsPrelude = savedGame.IsTutorial;
InfluenceScale = savedGame.InfluenceScale > 0
? savedGame.InfluenceScale
: throw new InvalidOperationException($"the save has no {nameof(InfluenceScale)} ({savedGame.InfluenceScale}); a run saved before InfluenceScale existed cannot be continued");
_cache = cultCache;
Log = log;
Background = savedGame.Background;
@ -112,7 +117,7 @@ public class Galaxy
uint seed)
{
_cache = cache;
IsPrelude = false;
InfluenceScale = 1;
Background = background;
Log = log;
var factions = cache.GetAll<Faction>();
@ -186,11 +191,11 @@ public class Galaxy
return _cache.GetAll<Faction>().FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase));
}
// A cast member of a prelude galaxy, by name. A name the catalog does not hold refuses the galaxy, naming the field.
// A cast member of a cast galaxy, by name. A name the catalog does not hold refuses the galaxy, naming the field.
private Faction ResolveCast(string field, string name) =>
ResolveFaction(name) ?? throw new InvalidOperationException($"cast faction {name} ({field}) is not in the catalog");
// Gives a prelude galaxy its gate: the antagonist's home is the boss zone and the exit. The only writer of Exit
// Gives a cast galaxy its gate: the antagonist's home is the boss zone and the exit. The only writer of Exit
// besides the constructors.
public void PlaceGate(Faction antagonist)
{
@ -198,23 +203,24 @@ public class Galaxy
Exit = HomeZones[antagonist];
}
// How many jumps a faction's influence reaches in this galaxy: its authored distance, halved (rounding up) in a
// prelude. Derived, never written back to the catalog's Faction, so one galaxy's generation cannot change the next.
// How many jumps a faction's influence reaches in this galaxy: its authored distance scaled by the galaxy's
// InfluenceScale (the cast decides the scale), rounding up. Derived, never written back to the catalog's Faction,
// so one galaxy's generation cannot change the next.
public int InfluenceOf(Faction faction) =>
IsPrelude ? (faction.InfluenceDistance + 1) / 2 : faction.InfluenceDistance;
(int) MathF.Ceiling(faction.InfluenceDistance * InfluenceScale);
public Galaxy(
TutorialGenerationSettings settings,
GalaxyCast cast,
SectorBackgroundSettings background,
CultCache cache,
PlayerSettings playerSettings,
DirectoryInfo narrativeDirectory,
Action<string> log,
Action<string> progressCallback,
uint seed)
{
_cache = cache;
IsPrelude = true;
InfluenceScale = cast.InfluenceScale > 0
? cast.InfluenceScale
: throw new InvalidOperationException($"the cast's {nameof(cast.InfluenceScale)} must be positive, got {cast.InfluenceScale}");
Background = background;
Log = log;
@ -223,32 +229,32 @@ public class Galaxy
var factions = new List<Faction>();
var protagonistFaction = ResolveCast(nameof(settings.ProtagonistFaction), settings.ProtagonistFaction);
var protagonistFaction = ResolveCast(nameof(cast.ProtagonistFaction), cast.ProtagonistFaction);
factions.Add(protagonistFaction);
var antagonistFaction = ResolveCast(nameof(settings.AntagonistFaction), settings.AntagonistFaction);
var antagonistFaction = ResolveCast(nameof(cast.AntagonistFaction), cast.AntagonistFaction);
factions.Add(antagonistFaction);
var bufferFaction = ResolveCast(nameof(settings.BufferFaction), settings.BufferFaction);
var bufferFaction = ResolveCast(nameof(cast.BufferFaction), cast.BufferFaction);
factions.Add(bufferFaction);
// A cast without a quest faction places no quest zone.
var questFaction = string.IsNullOrEmpty(settings.QuestFaction)
var questFaction = string.IsNullOrEmpty(cast.QuestFaction)
? null
: ResolveCast(nameof(settings.QuestFaction), settings.QuestFaction);
: ResolveCast(nameof(cast.QuestFaction), cast.QuestFaction);
if (questFaction != null) factions.Add(questFaction);
var neutralFactions = settings.NeutralFactions
.Select(name => ResolveCast(nameof(settings.NeutralFactions), name))
var neutralFactions = cast.NeutralFactions
.Select(name => ResolveCast(nameof(cast.NeutralFactions), name))
.ToArray();
factions.AddRange(neutralFactions);
Factions = factions.ToArray();
foreach (var faction in Factions) FactionRelationships[faction] = FactionRelationship.Neutral;
Zones = GenerateZones(settings.ZoneCount, ref random, progressCallback);
Zones = GenerateZones(cast.ZoneCount, ref random, progressCallback);
GenerateLinks(settings.LinkDensity, progressCallback);
GenerateLinks(cast.LinkDensity, progressCallback);
CalculateDistanceMatrix(progressCallback);
@ -302,15 +308,11 @@ public class Galaxy
CalculateFactionInfluence(progressCallback);
// No boss zone and no Exit yet (PlaceGate comes after): the prelude is one region.
BuildProvinces(settings.ProvinceZones);
// No boss zone and no Exit yet (PlaceGate comes after): a cast galaxy is one region.
BuildProvinces(cast.ProvinceZones);
NamePlaces(ref random, progressCallback);
// progressCallback?.Invoke("Weaving Narrative");
// var processor = new StoryProcessor(playerSettings, narrativeDirectory, this, ref random, Log);
// processor.ProcessStories();
progressCallback?.Invoke("Done!");
if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao
}

View file

@ -1,5 +1,4 @@
using System;
using System.IO;
using GameCult.Caching;
using MessagePack;
using static CultMath.math;
@ -13,11 +12,8 @@ public sealed class GalaxyStage
{
private readonly SectorGenerationSettings _sector;
private readonly SectorBackgroundSettings _sectorBackground;
private readonly TutorialGenerationSettings _prelude;
private readonly SectorBackgroundSettings _preludeBackground;
private readonly SectorBackgroundSettings _castBackground;
private readonly CultCache _cache;
private readonly PlayerSettings _playerSettings;
private readonly DirectoryInfo _narrativeDirectory;
private readonly Action<string> _log;
private readonly Action<string> _progress;
private readonly Func<uint> _clock;
@ -25,22 +21,16 @@ public sealed class GalaxyStage
public GalaxyStage(
SectorGenerationSettings sector,
SectorBackgroundSettings sectorBackground,
TutorialGenerationSettings prelude,
SectorBackgroundSettings preludeBackground,
SectorBackgroundSettings castBackground,
CultCache cache,
PlayerSettings playerSettings,
DirectoryInfo narrativeDirectory,
Action<string> log,
Action<string> progress = null,
Func<uint> clock = null)
{
_sector = sector;
_sectorBackground = sectorBackground;
_prelude = prelude;
_preludeBackground = preludeBackground;
_castBackground = castBackground;
_cache = cache;
_playerSettings = playerSettings;
_narrativeDirectory = narrativeDirectory;
_log = log;
_progress = progress;
_clock = clock ?? (() => (uint) (DateTime.Now.Ticks % uint.MaxValue));
@ -65,13 +55,10 @@ public sealed class GalaxyStage
return new Galaxy(_sector, background, _cache, _log, _progress, Seed);
}
// A prelude galaxy: the tutorial settings and their fixed factions, centred in dense cloud.
public Galaxy Prelude() => Prelude(_prelude);
// A prelude galaxy of the given fixed cast, centred in dense cloud.
public Galaxy Prelude(TutorialGenerationSettings cast)
// A galaxy of the given fixed cast, centred in dense cloud.
public Galaxy Cast(GalaxyCast cast)
{
var background = Copy(_preludeBackground);
var background = Copy(_castBackground);
var random = new Random(Seed);
var iteration = 1;
do
@ -79,7 +66,7 @@ public sealed class GalaxyStage
background.NoisePosition = random.NextFloat() * 1000;
_progress?.Invoke($"Finding Galaxy Position: iteration {iteration++}");
} while (background.CloudDensity(float2(.5f)) < .5f);
return new Galaxy(cast, background, _cache, _playerSettings, _narrativeDirectory, _log, _progress, Seed);
return new Galaxy(cast, background, _cache, _log, _progress, Seed);
}
private static SectorBackgroundSettings Copy(SectorBackgroundSettings settings) =>

View file

@ -27,7 +27,7 @@ public static class RunStart
{
SeedItems(itemManager, galaxy, ArenaStep);
return galaxy.Entrance.PackedContents = ZoneGenerator.GenerateZone(
itemManager, zoneSettings, planetSettings, galaxy, galaxy.Entrance, galaxy.IsPrelude, scenario.Ambient);
itemManager, zoneSettings, planetSettings, galaxy, galaxy.Entrance, scenario.EntranceStation, scenario.Ambient);
}
// Runs a start and answers whether it produced a run: null, with the reason in `failures`, when `start` throws or
@ -49,10 +49,10 @@ public static class RunStart
// with the player, a pilot for each piloted one. Returns null, with every failure listed and the arena unchanged,
// unless the whole scenario staged.
public static Staged Stage(ItemManager itemManager, Zone arena, Scenario scenario, string startingHull,
TutorialGenerationSettings tutorialGenerationSettings, List<string> failures)
List<string> failures)
{
SeedItems(itemManager, arena.Galaxy, StageStep);
var stage = new ScenarioStage(itemManager, arena, startingHull, tutorialGenerationSettings);
var stage = new ScenarioStage(itemManager, arena, startingHull);
scenario.Stage(stage);
var reported = failures.Count;
failures.AddRange(stage.Failures);

View file

@ -42,8 +42,7 @@ public class SavedGame
[Key(10)]
public SavedActionBarBinding[] ActionBarBindings;
[Key(11)]
public bool IsTutorial;
// Key(11): retired, do not reuse (a retired run-mode flag)
// Read only by a save written before Standings: its entries follow galaxy.Factions order, not Factions order, so
// Galaxy trusts it only when the two orders cannot differ (see Galaxy's save constructor).
@ -68,6 +67,11 @@ public class SavedGame
// null in a save written before it, which then reads Relationships.
[Key(16)]
public List<SavedStanding> Standings;
// Galaxy.InfluenceScale: every zone generated after Continue reads it (ZoneGenerator's factionPresence). Written only
// by RunSave.Capture and read only by Galaxy's save constructor, which refuses a save without one (0).
[Key(17)]
public float InfluenceScale;
}
[MessagePackObject]
@ -122,7 +126,7 @@ public static class RunSave
CurrentZoneEntity = currentZone.Entities.IndexOf(currentEntity),
Entrance = Array.IndexOf(galaxy.Zones, galaxy.Entrance),
Exit = Array.IndexOf(galaxy.Zones, galaxy.Exit),
IsTutorial = galaxy.IsPrelude,
InfluenceScale = galaxy.InfluenceScale,
ActionBarBindings = actionBar,
Credits = credits,
Seed = galaxy.Seed

View file

@ -22,7 +22,11 @@ public abstract class Scenario
// the scenario's conditions.
public virtual bool Ambient => true;
// Which galaxy the run is in: stage.Main() or stage.Prelude().
// True: the arena's zone always gets a generated faction station with a docking bay, whatever its seed rolls
// (ZoneGenerator). False: its stations are rolled like any other zone's.
public virtual bool EntranceStation => true;
// Which galaxy the run is in: stage.Main() or stage.Cast(cast).
public abstract Galaxy Generate(GalaxyStage stage);
// What the run starts with: exactly one stage.Player, and anything else the scenario places.

View file

@ -23,12 +23,11 @@ public sealed class ScenarioStage
private readonly HashSet<Entity> _fitted = new HashSet<Entity>();
private readonly HashSet<Entity> _cargoAuthored = new HashSet<Entity>();
internal ScenarioStage(ItemManager items, Zone arena, string startingHull, TutorialGenerationSettings tutorialGenerationSettings)
internal ScenarioStage(ItemManager items, Zone arena, string startingHull)
{
_items = items;
Arena = arena;
StartingHull = startingHull;
TutorialGenerationSettings = tutorialGenerationSettings;
Credits = items.GameplaySettings.StartingCredits;
// A design named without a product is chosen by the generator's ChooseProduct. The stage outfits with no faction,
// so every maker is reachable and the run's seed draws.
@ -38,7 +37,6 @@ public sealed class ScenarioStage
public Galaxy Galaxy => Arena.Galaxy;
public Zone Arena { get; }
public string StartingHull { get; }
public TutorialGenerationSettings TutorialGenerationSettings { get; }
// What the run starts with: the gameplay settings' starting credits unless the scenario sets another amount.
public int Credits { get; set; }

View file

@ -13,7 +13,7 @@ public sealed class AiFusedDiscipline : Scenario
public static readonly CultMath.float2 Hostile = float2(0, 700), Neutral = float2(500, 300);
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -26,7 +26,7 @@ public sealed class Arcs : Scenario
// holding every gun down. The guided launchers fire only on a lock, which that run cannot give them, so they carry the default three crates.
public const int TurretAmmoCrates = 22, PlayerAmmoCrates = 42, PlayerMissileCrates = 3;
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude();
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -17,7 +17,7 @@ public sealed class Belt : Scenario
public override uint Seed => 86;
public override bool Ambient => false;
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -33,7 +33,7 @@ public sealed class Crossing : Scenario
public const float ProjectorRange = 997f;
public static readonly CultMath.float2 Waiting = Origin + float2(0, ProjectorRange * .8f);
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -2,10 +2,10 @@ using float2 = CultMath.float2;
// The demo: one gate, one region and one boss, with a fixed cast. The Pirates are the protagonist's ostensible
// employer, Zhestokost the antagonist whose home is the boss zone and the exit, Lucent Media and Aeronautics Unlimited
// the neutrals. A prelude galaxy of that cast; the player, who is not a Pirate, flies the base Longinus.
// the neutrals. A galaxy of that cast at half influence; the player, who is not a Pirate, flies the base Longinus.
public sealed class DemoTerminus : Scenario
{
public static readonly TutorialGenerationSettings Cast = new TutorialGenerationSettings
public static readonly GalaxyCast Cast = new GalaxyCast
{
ProtagonistFaction = "Pirates",
AntagonistFaction = "Zhe",
@ -13,7 +13,8 @@ public sealed class DemoTerminus : Scenario
NeutralFactions = new[] { "Aero" },
QuestFaction = null,
ZoneCount = 64,
LinkDensity = .5f
LinkDensity = .5f,
InfluenceScale = .5f
};
public override string Name => "Terminus (Demo)";
@ -23,7 +24,7 @@ public sealed class DemoTerminus : Scenario
public override Galaxy Generate(GalaxyStage stage)
{
var galaxy = stage.Prelude(Cast);
var galaxy = stage.Cast(Cast);
galaxy.PlaceGate(galaxy.ResolveFaction(Cast.AntagonistFaction));
return galaxy;
}

View file

@ -14,7 +14,7 @@ public sealed class DjinniShakedown : Scenario
// Where the targets sit: the ballistic mount faces +z, so Ahead is inside its arc and Abeam outside it.
public static readonly float2 Ahead = new float2(0, 400), Abeam = new float2(400, 0);
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude();
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -10,7 +10,7 @@ public sealed class Duel : Scenario
public override uint Seed => 104;
public override bool Ambient => false;
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude();
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -26,7 +26,7 @@ public sealed class FusedRounds : Scenario
// The shooter is staged at this quality, so the damage its Cluster Cannon deals does not ride the item stream.
public const float StagedQuality = .6f;
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -10,7 +10,7 @@ public sealed class LauncherAngles : Scenario
public override uint Seed => 105;
public override bool Ambient => false;
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude();
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -35,7 +35,7 @@ public sealed class LockOn : Scenario
_quality = quality;
}
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -8,7 +8,7 @@ public sealed class LongHaul : Scenario
"warp, quit and Continue keep items, tier and brand; death disables Continue.";
public override uint Seed => 106;
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude();
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage) =>
stage.Player(stage.Generated(stage.StartingHull), float2.zero);

View file

@ -7,6 +7,8 @@ public sealed class MainGalaxy : Scenario
public override string Id => "main-galaxy";
public override string Brief => "The full galaxy: factions drawn at random, bosses guarding the road to the exit.";
public override bool EntranceStation => false;
public override Galaxy Generate(GalaxyStage stage) => stage.Main();
public override void Stage(ScenarioStage stage) =>

View file

@ -22,7 +22,7 @@ public sealed class Pursuit : Scenario
public override uint Seed => 111;
public override bool Ambient => false;
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -15,7 +15,7 @@ public sealed class RefusedRounds : Scenario
// The one target, ahead of the nose: inside every forward mount's arc.
public static readonly CultMath.float2 Target = float2(0, 300);
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -5,7 +5,7 @@ public static class Scenarios
{
public static readonly Scenario[] Modes = { new DemoTerminus() };
public static readonly Scenario[] Development = { new TutorialGalaxy(), new MainGalaxy() };
public static readonly Scenario[] Development = { new MainGalaxy() };
public static readonly Scenario[] Tests =
{

View file

@ -10,7 +10,7 @@ public sealed class StarvedReactor : Scenario
public override uint Seed => 102;
public override bool Ambient => false;
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude();
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -1,17 +0,0 @@
using float2 = CultMath.float2;
// New Game as it has always been: a prelude galaxy, entered in the starting hull of the protagonist faction.
public sealed class TutorialGalaxy : Scenario
{
public override string Name => "Tutorial Galaxy";
public override string Id => "tutorial-galaxy";
public override string Brief => "A small galaxy of fixed factions, entered in a ship of the protagonist faction.";
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude();
public override void Stage(ScenarioStage stage)
{
var protagonist = stage.Galaxy.ResolveFaction(stage.TutorialGenerationSettings.ProtagonistFaction);
stage.Player(stage.Generated(stage.StartingHull, protagonist), float2.zero);
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 94d688b37c5044dd9b67865c706d8918
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -14,7 +14,7 @@ public sealed class WeaponFeel : Scenario
// The one target, ahead of the nose: inside every forward mount's arc.
public static readonly CultMath.float2 Target = float2(0, 400);
public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast);
public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast);
public override void Stage(ScenarioStage stage)
{

View file

@ -94,8 +94,10 @@ public class SectorGenerationSettings
public int BossCount;
}
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
public class TutorialGenerationSettings
// The fixed cast of a galaxy a scenario generates through GalaxyStage.Cast: who plays which part, how big the galaxy is,
// and how far the factions' authored influence reaches (Galaxy.InfluenceOf). Held by the scenario that casts it; no
// asset or store holds one.
public class GalaxyCast
{
public string ProtagonistFaction;
public string AntagonistFaction;
@ -106,6 +108,8 @@ public class TutorialGenerationSettings
public int ZoneCount = 32;
// Zones per resource province (Provinces.Partition): calibration, not a gate.
public int ProvinceZones = Provinces.DefaultZonesPerProvince;
// Multiplies every faction's authored InfluenceDistance in this galaxy (rounding up); 1 leaves them as authored.
public float InfluenceScale = 1;
}
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]

View file

@ -43,7 +43,7 @@ public static class ZoneGenerator
PlanetSettings planetSettings,
Galaxy galaxy,
GalaxyZone galaxyZone,
bool isTutorial = false,
bool entranceStation = false,
bool ambient = true)
{
var pack = new ZonePack();
@ -294,15 +294,15 @@ public static class ZoneGenerator
var storyStations = galaxyZone.Locations.Where(story => story.Type == LocationType.Station).ToArray();
var stationCount = (int)(random.NextFloat() * (factionPresence + 1)) + storyStations.Length;
// Enemy count below is based on this pre-override value, so the tutorial entrance doesn't gain an enemy
// Enemy count below is based on this pre-override value, so the entrance station zone doesn't gain an enemy
// just because its station got forced.
var baseStationCount = stationCount;
// Operator ruling, 2026-09-25 (docs/locomotion-cut.md, "Tutorial station"): the entrance zone always
// gets a generated faction station with a docking bay, deterministically. Galaxy.cs halves influence and
// picks the lowest-influence unowned zone for Entrance, which otherwise rolls stationCount 0 on every
// seed. galaxy.Entrance is reference-identity, not a name comparison.
var isTutorialEntrance = isTutorial && galaxyZone == galaxy.Entrance;
if (isTutorialEntrance && stationCount < 1) stationCount = 1;
// Operator ruling, 2026-09-25 (docs/locomotion-cut.md): a scenario that declares an entrance station
// (Scenario.EntranceStation) gets a generated faction station with a docking bay in its entrance zone,
// deterministically. A cast galaxy's halved influence and its lowest-influence unowned Entrance otherwise roll
// stationCount 0 on every seed. galaxy.Entrance is reference-identity, not a name comparison.
var isEntranceStation = entranceStation && galaxyZone == galaxy.Entrance;
if (isEntranceStation && stationCount < 1) stationCount = 1;
// A station's source is a well-bearing body alone on its ring whose rail clears every massive sibling's extent (the
// sibling's support, or its Roche margin if more) and the largest reach of any station or turret hull: whatever hull
// is built there, its Lagrange orbit then sits clear of any other body.
@ -318,7 +318,7 @@ public static class ZoneGenerator
// (the rail, how far a body on it keeps others out, whether it is a station's own orbit rather than a base's)
var sources = candidates.Skip(candidates.Length / 2).Take(stationCount)
.Select(p => (orbit: orbitMap[p], extent: Extent(p), direct: false)).ToArray();
if (isTutorialEntrance && candidates.Length == 0)
if (isEntranceStation && candidates.Length == 0)
{
// The entrance gets a station whatever its bodies: it orbits a root node beyond its ring group (or, for a body, its
// whole family), never at a ring member's distance, and sits there, not at a Lagrange point.
@ -326,7 +326,7 @@ public static class ZoneGenerator
var rootNode = roots.FirstOrDefault(p => p.Children.Count > 0) ?? (roots.Count > 1 ? roots.OrderByDescending(p => p.Mass).First() : null);
if (rootNode == null)
throw new InvalidOperationException(
"The tutorial entrance zone must always get a station, but it has no candidate orbit at all -- every planet in the zone is a parentless root.");
"The entrance station zone must always get a station, but it has no candidate orbit at all -- every planet in the zone is a parentless root.");
var distance = rootNode.Empty
? (1 + GravityField.RingReach) * GravityField.Beta * rootNode.Children.Where(Massive).Min(c => c.Distance)
: Extent(rootNode);
@ -445,9 +445,9 @@ public static class ZoneGenerator
StationKinds.Choose(cache, nearestFaction, $"{seed}:station:{i}", itemManager.Log));
if (station == null)
{
if (isTutorialEntrance)
if (isEntranceStation)
throw new InvalidOperationException(
$"The tutorial entrance zone must always get a station, but {nearestFaction?.Name} has no station loadout to generate.");
$"The entrance station zone must always get a station, but {nearestFaction?.Name} has no station loadout to generate.");
continue;
}
station.Orbit = cache.RefOf(lagrangeOrbit);

View file

@ -120,9 +120,14 @@ public class MainMenu : MonoBehaviour
Debug.Log("run store has no SavedGame; Continue disabled");
_nextMenu.panel.AddButton("Continue", saved == null ? (Action) null : () =>
{
try { RunSave.RequireDesigns(cache, saved); }
Galaxy galaxy;
try
{
RunSave.RequireDesigns(cache, saved);
galaxy = new Galaxy(cache, saved, Debug.Log);
}
catch (InvalidOperationException error) { Refuse("Cannot continue this run", error.Message); return; }
ActionGameManager.CurrentGalaxy = new Galaxy(cache, saved, Debug.Log);
ActionGameManager.CurrentGalaxy = galaxy;
EnterGame();
});
}
@ -246,11 +251,8 @@ public class MainMenu : MonoBehaviour
var stage = new GalaxyStage(
Settings.SectorGenerationSettings,
Settings.SectorBackgroundSettings,
Settings.TutorialGenerationSettings,
Settings.TutorialBackgroundSettings,
Settings.CastBackgroundSettings,
ActionGameManager.CultCache,
ActionGameManager.PlayerSettings,
ActionGameManager.GameDataDirectory.CreateSubdirectory("Narrative"),
Debug.Log,
state => generatorState = state);
Task.Run(() => RunStart.Generate(scenario, stage)).ContinueWith(generation =>

View file

@ -40,10 +40,9 @@ public sealed class ChildrenWithinReachTests : IClassFixture<ChildrenWithinReach
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(catalog), AetheriaStores.CatalogTypes);
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(Path.Combine(dir, "run.cc")), AetheriaStores.RunTypes);
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
var galaxy = new Galaxy(authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"),
authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"),
cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(dir, "Narrative")), _ => { }, null, seed);
var galaxy = new Galaxy(TestCasts.Wide,
authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"),
cache, _ => { }, null, seed);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), authored.Read<GameplaySettings>("GameplaySettings"), _ => { });
var planetSettings = authored.Read<PlanetSettings>("PlanetSettings");
foreach (var galaxyZone in galaxy.Zones)
@ -51,7 +50,7 @@ public sealed class ChildrenWithinReachTests : IClassFixture<ChildrenWithinReach
Settings = authored.Read<ZoneGenerationSettings>("ZoneSettings");
tune?.Invoke(Settings);
var pack = ZoneGenerator.GenerateZone(items, Settings, planetSettings, galaxy, galaxyZone,
galaxyZone == galaxy.Entrance && galaxy.IsPrelude, false);
true, false);
foreach (var belt in pack.Planets.Select(cache.Get).OfType<AsteroidBeltData>())
{
Belts++;

View file

@ -139,6 +139,7 @@ public sealed class ConsumableSupplyTests : IDisposable
_caches.Add(cache);
var game = new SavedGame
{
InfluenceScale = 1,
Factions = new[] { maker },
Relationships = new[] { FactionRelationship.Neutral },
HomeZones = new Dictionary<int, int> { { 0, 0 } },
@ -282,8 +283,8 @@ public sealed class ConsumableSupplyTests : IDisposable
cache.Upsert(new FactionProductData { Name = "Overdrive by Maker", Design = new CultRecordRef<CraftedItemData>(overdrive.Key), Manufacturer = maker });
var authored = AuthoredSettings.Load(repo);
var galaxy = new Galaxy(authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"),
authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"), cache, new PlayerSettings(), Directory.CreateDirectory(Path.Combine(_root, "Narrative")), _ => { }, null, 1);
var galaxy = new Galaxy(TestCasts.Wide,
authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"), cache, _ => { }, null, 1);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), authored.Read<GameplaySettings>("GameplaySettings"), _ => { });
int stations = 0, ships = 0;

View file

@ -8,7 +8,7 @@ using System.Linq;
using CultMath;
using Xunit;
// The demo scenario (aetheria-release, cut demo-galaxy): a prelude galaxy of a fixed cast whose antagonist's home is the
// The demo scenario (aetheria-release, cut demo-galaxy): a galaxy of a fixed cast whose antagonist's home is the
// boss zone and the exit. The cast, the Pirates included, is in the shipped catalog.
public sealed partial class RunStartTests
{
@ -82,7 +82,7 @@ public sealed partial class RunStartTests
Assert.DoesNotContain(_cache.GetAll<Faction>(), faction => faction.Name.StartsWith("Pirates", StringComparison.Ordinal));
var refusal = Assert.Throws<InvalidOperationException>(() => DemoGalaxy(1));
Assert.Contains("Pirates", refusal.Message);
Assert.Contains(nameof(TutorialGenerationSettings.ProtagonistFaction), refusal.Message);
Assert.Contains(nameof(GalaxyCast.ProtagonistFaction), refusal.Message);
}
// The operator's ruling is that the first release is a demo: the one scenario a release build lists says so by name.
@ -144,12 +144,12 @@ public sealed partial class RunStartTests
string.Join(",", zone.AdjacentZones.Select(adjacent => Array.IndexOf(g.Zones, adjacent)).OrderBy(index => index))));
Galaxy Reference(uint seed, float density)
{
var cast = new TutorialGenerationSettings
var cast = new GalaxyCast
{
ProtagonistFaction = "Pirates", AntagonistFaction = "Zhe", BufferFaction = "Luc",
NeutralFactions = new[] { "Aero" }, QuestFaction = null, ZoneCount = 64, LinkDensity = density
NeutralFactions = new[] { "Aero" }, QuestFaction = null, ZoneCount = 64, LinkDensity = density, InfluenceScale = .5f
};
return RunStart.Generate(new Scripted(false, _ => { }, seed, galaxy => galaxy.Prelude(cast)), Inputs());
return RunStart.Generate(new Scripted(false, _ => { }, seed, stage => stage.Cast(cast)), Inputs());
}
foreach (var seed in DemoSeeds)
@ -172,50 +172,42 @@ public sealed partial class RunStartTests
// A name that resolves to nothing refuses the galaxy whichever cast field names it, and the refusal names the field.
[Theory]
[InlineData(nameof(TutorialGenerationSettings.ProtagonistFaction))]
[InlineData(nameof(TutorialGenerationSettings.AntagonistFaction))]
[InlineData(nameof(TutorialGenerationSettings.BufferFaction))]
[InlineData(nameof(TutorialGenerationSettings.QuestFaction))]
[InlineData(nameof(TutorialGenerationSettings.NeutralFactions))]
[InlineData(nameof(GalaxyCast.ProtagonistFaction))]
[InlineData(nameof(GalaxyCast.AntagonistFaction))]
[InlineData(nameof(GalaxyCast.BufferFaction))]
[InlineData(nameof(GalaxyCast.QuestFaction))]
[InlineData(nameof(GalaxyCast.NeutralFactions))]
public void AnUnresolvedCastNameRefusesTheGalaxyNamingItsField(string field)
{
var cast = new TutorialGenerationSettings
{
ProtagonistFaction = _tutorialSettings.ProtagonistFaction,
AntagonistFaction = _tutorialSettings.AntagonistFaction,
BufferFaction = _tutorialSettings.BufferFaction,
QuestFaction = _tutorialSettings.QuestFaction,
NeutralFactions = _tutorialSettings.NeutralFactions,
ZoneCount = _tutorialSettings.ZoneCount,
LinkDensity = _tutorialSettings.LinkDensity
};
typeof(TutorialGenerationSettings).GetField(field).SetValue(cast, field == nameof(cast.NeutralFactions) ? new[] { "Nonesuch" } : "Nonesuch");
var scenario = new Scripted(false, _ => { }, generate: galaxy => galaxy.Prelude(cast));
var cast = TestCasts.Wide;
typeof(GalaxyCast).GetField(field).SetValue(cast, field == nameof(cast.NeutralFactions) ? new[] { "Nonesuch" } : "Nonesuch");
var scenario = new Scripted(false, _ => { }, generate: stage => stage.Cast(cast));
var refusal = Assert.Throws<InvalidOperationException>(() => RunStart.Generate(scenario, Inputs()));
Assert.Contains(field, refusal.Message);
}
// What a release build lists under New Game is the demo alone; the tutorial and the main galaxy are listed only in
// What a release build lists under New Game is the demo alone; the main galaxy is listed only in
// editor and development builds (MainMenu.ShowScenarios), beside the test arenas.
[Fact]
public void ReleaseBuildsListOnlyTheDemo()
{
Assert.Equal(new[] { typeof(DemoTerminus) }, Scenarios.Modes.Select(scenario => scenario.GetType()));
Assert.Equal(new[] { typeof(TutorialGalaxy), typeof(MainGalaxy) }, Scenarios.Development.Select(scenario => scenario.GetType()));
Assert.Equal(new[] { typeof(MainGalaxy) }, Scenarios.Development.Select(scenario => scenario.GetType()));
}
// The tutorial is the galaxy it was before the demo: its cast, homes, entrance and ownership at a fixed seed, with
// no exit and no boss zone.
// The wide test cast at half influence is the galaxy it was before the prelude was retired: its cast, homes, entrance
// and ownership at a fixed seed, with no exit and no boss zone. Homes, entrance and owners depend on InfluenceOf, so
// an InfluenceScale of 1 or a lost halving fails it.
[Fact]
public void TutorialGalaxy_unchanged()
public void CastGalaxyAtHalfInfluenceIsUnchanged()
{
var galaxy = RunStart.Generate(new TutorialGalaxy(), Inputs(() => GalaxySeed));
Assert.Equal(TutorialSeed1, TutorialShape(galaxy));
Assert.True(galaxy.Exit == null, "the tutorial has no exit");
Assert.True(galaxy.BossZones.Count == 0, $"the tutorial has {galaxy.BossZones.Count} boss zones");
var galaxy = RunStart.Generate(new Scripted(false, _ => { }, generate: stage => stage.Cast(TestCasts.Wide)), Inputs(() => GalaxySeed));
Assert.Equal(WideCastSeed1, CastShape(galaxy));
Assert.True(galaxy.Exit == null, "a cast galaxy has no exit until its scenario places the gate");
Assert.True(galaxy.BossZones.Count == 0, $"the cast galaxy has {galaxy.BossZones.Count} boss zones");
}
private static string TutorialShape(Galaxy g) =>
private static string CastShape(Galaxy g) =>
string.Join(",", g.Factions.Select(f => f.Name)) +
" | homes " + string.Join(",", g.Factions.Select(f => g.HomeZones.TryGetValue(f, out var z) ? Array.IndexOf(g.Zones, z) : -2)) +
" | entrance " + Array.IndexOf(g.Zones, g.Entrance) +
@ -223,6 +215,6 @@ public sealed partial class RunStartTests
" | owners " + string.Join(",", g.Zones.Select(z => z.Owner == null ? "-" : z.Owner.ShortName));
// Measured at seed 1 under CultMath 0.3.0 (cultmath-unity-v0.3.0); the noise kernel changed there, which re-rolled the galaxy.
private const string TutorialSeed1 =
private const string WideCastSeed1 =
"Miss Terri’s Sugariffic Snack Company,Zhestokost,Lucent Media,Adrasteia,Aeronautics Unlimited,Finch Cybernetics | homes 3,44,40,19,0,30 | entrance 12 | zones 64 | owners AU,AU,Finch,Miss Terri's,Lucent,Zhestokost,-,Lucent,AU,AU,Lucent,Adrasteia,-,Finch,Zhestokost,-,Adrasteia,-,AU,Adrasteia,AU,Zhestokost,Miss Terri's,-,AU,Finch,Miss Terri's,-,Zhestokost,-,Finch,-,-,AU,-,-,-,-,Miss Terri's,AU,Lucent,-,Finch,-,Zhestokost,AU,-,Zhestokost,Adrasteia,Adrasteia,AU,Miss Terri's,Finch,AU,Finch,-,Lucent,Zhestokost,-,AU,Miss Terri's,Zhestokost,-,Lucent";
}

View file

@ -234,6 +234,7 @@ public sealed class FireControlCut6cTests : IDisposable
// Targeting Maker, so IsAvailable rejects Targeting Maker's products by allegiance.
var game = new SavedGame
{
InfluenceScale = 1,
Factions = new[] { maker },
Relationships = new[] { FactionRelationship.Neutral },
HomeZones = new Dictionary<int, int> { { 0, 0 } },

View file

@ -494,6 +494,7 @@ public sealed class LoadoutTests : IDisposable
var game = new SavedGame
{
InfluenceScale = 1,
Factions = Array.Empty<CultRecordRef<Faction>>(),
Relationships = Array.Empty<FactionRelationship>(),
HomeZones = new Dictionary<int, int>(),

View file

@ -830,14 +830,14 @@ public sealed partial class MiningCut3Tests : IDisposable
Galaxy galaxy;
try
{
galaxy = new Galaxy(RestoredHullsTests.TutorialGalaxySettings(), RestoredHullsTests.TutorialBackgroundSettings(),
cache, new PlayerSettings(), new DirectoryInfo(dir), _ => { }, null, seed);
galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background,
cache, _ => { }, null, seed);
}
catch (Exception) { continue; } // Galaxy's own seed-dependent flakiness (RestoredHullsTests)
var items = new ItemManager(1u, cache, new ProvenanceLedger(), GameSettings(), _ => { });
foreach (var zone in galaxy.Zones.Take(4))
{
var pack = ZoneGenerator.GenerateZone(items, RestoredHullsTests.TutorialZoneSettings(), RestoredHullsTests.AuthoredPlanetSettings(), galaxy, zone, isTutorial: zone == galaxy.Entrance);
var pack = ZoneGenerator.GenerateZone(items, RestoredHullsTests.TutorialZoneSettings(), RestoredHullsTests.AuthoredPlanetSettings(), galaxy, zone, entranceStation: zone == galaxy.Entrance);
foreach (var body in pack.Planets)
{
if (!(cache.Get(body) is AsteroidBeltData belt)) continue;
@ -874,13 +874,13 @@ public sealed partial class MiningCut3Tests : IDisposable
Galaxy galaxy;
try
{
galaxy = new Galaxy(RestoredHullsTests.TutorialGalaxySettings(), RestoredHullsTests.TutorialBackgroundSettings(),
cache, new PlayerSettings(), new DirectoryInfo(dir), _ => { }, null, seed);
galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background,
cache, _ => { }, null, seed);
}
catch (Exception) { return null; }
var items = new ItemManager(1u, cache, new ProvenanceLedger(), GameSettings(), _ => { });
return galaxy.Zones.Take(6).SelectMany(zone =>
ZoneGenerator.GenerateZone(items, RestoredHullsTests.TutorialZoneSettings(), RestoredHullsTests.AuthoredPlanetSettings(), galaxy, zone, isTutorial: zone == galaxy.Entrance)
ZoneGenerator.GenerateZone(items, RestoredHullsTests.TutorialZoneSettings(), RestoredHullsTests.AuthoredPlanetSettings(), galaxy, zone, entranceStation: zone == galaxy.Entrance)
.Planets.Select(body => cache.Get(body)).OfType<AsteroidBeltData>().Select(belt => cache.Get(belt.Kind).Name))
.ToArray();
}

View file

@ -46,6 +46,7 @@ public sealed class MiningCut5bTests : IDisposable
MiningCut5aTests.Stock(scene, kind, (ore, 1f));
var game = new SavedGame
{
InfluenceScale = 1,
Seed = 5, Factions = new CultRecordRef<Faction>[0], Relationships = new FactionRelationship[0],
HomeZones = new Dictionary<int, int>(), BossZones = new Dictionary<int, int>(), DiscoveredZones = new[] { 0 },
ActionBarBindings = new SavedActionBarBinding[0], Entrance = 0, Exit = -1
@ -222,6 +223,7 @@ public sealed class MiningCut5bTests : IDisposable
{
var game = new SavedGame
{
InfluenceScale = 1,
Factions = new CultRecordRef<Faction>[0], Relationships = new FactionRelationship[0],
HomeZones = new Dictionary<int, int>(), BossZones = new Dictionary<int, int>(), DiscoveredZones = new[] { 0 },
ActionBarBindings = new SavedActionBarBinding[0], Exit = -1

View file

@ -251,13 +251,12 @@ public sealed class OrbitsFromFieldTests : IDisposable
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(catalog), AetheriaStores.CatalogTypes);
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(Path.Combine(dir, "run.cc")), AetheriaStores.RunTypes);
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
var tutorial = authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings");
var galaxy = new Galaxy(tutorial, authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"),
cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(dir, "Narrative")), _ => { }, null, seed);
var tutorial = TestCasts.Wide;
var galaxy = new Galaxy(tutorial, authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"),
cache, _ => { }, null, seed);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), authored.Read<GameplaySettings>("GameplaySettings"), _ => { });
var pack = ZoneGenerator.GenerateZone(items, authored.Read<ZoneGenerationSettings>("ZoneSettings"), authored.Read<PlanetSettings>("PlanetSettings"), galaxy, galaxy.Entrance,
galaxy.IsPrelude, false);
true, false);
var zone = new Zone(items, authored.Read<PlanetSettings>("PlanetSettings"), pack, galaxy.Entrance, galaxy);
var hosting = zone.Planets.Values.Select(body => body.Orbit.Key).ToHashSet();

View file

@ -128,14 +128,14 @@ public sealed class OreGeographyTests : IDisposable
return reached;
}
private static Galaxy Build(CultCache cache, bool prelude, uint seed, TutorialGenerationSettings cast = null) => prelude
? new Galaxy(cast ?? Authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"), Authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"),
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed)
private static Galaxy Build(CultCache cache, bool prelude, uint seed, GalaxyCast cast = null) => prelude
? new Galaxy(cast ?? TestCasts.Wide, Authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"),
cache, _ => { }, null, seed)
: new Galaxy(Authored.Read<SectorGenerationSettings>("SectorGenerationSettings"), Authored.Read<SectorBackgroundSettings>("SectorBackgroundSettings"),
cache, _ => { }, null, seed);
// Galaxy refuses some seeds (RestoredHullsTests calls it seed-dependent flakiness); those are skipped.
private static Galaxy TryBuild(CultCache cache, bool prelude, uint seed, TutorialGenerationSettings cast = null)
private static Galaxy TryBuild(CultCache cache, bool prelude, uint seed, GalaxyCast cast = null)
{
try { return Build(cache, prelude, seed, cast); }
catch (Exception) { return null; }
@ -151,14 +151,14 @@ public sealed class OreGeographyTests : IDisposable
Enumerable.Range(1, (int) last).Select(seed => SharedGalaxy(prelude, (uint) seed)).Where(galaxy => galaxy != null);
// The demo's cast: the same fixed cast, with the province size chosen.
private static TutorialGenerationSettings Cast(int provinceZones)
private static GalaxyCast Cast(int provinceZones)
{
var cast = DemoTerminus.Cast;
return new TutorialGenerationSettings
return new GalaxyCast
{
ProtagonistFaction = cast.ProtagonistFaction, AntagonistFaction = cast.AntagonistFaction, BufferFaction = cast.BufferFaction,
NeutralFactions = cast.NeutralFactions, QuestFaction = cast.QuestFaction, ZoneCount = cast.ZoneCount, LinkDensity = cast.LinkDensity,
ProvinceZones = provinceZones
ProvinceZones = provinceZones, InfluenceScale = cast.InfluenceScale
};
}
@ -929,7 +929,7 @@ public sealed class OreGeographyTests : IDisposable
{
foreach (var zone in galaxy.Zones.Take(zones))
{
var pack = ZoneGenerator.GenerateZone(items, RestoredHullsTests.TutorialZoneSettings(), RestoredHullsTests.AuthoredPlanetSettings(), galaxy, zone, isTutorial: zone == galaxy.Entrance);
var pack = ZoneGenerator.GenerateZone(items, RestoredHullsTests.TutorialZoneSettings(), RestoredHullsTests.AuthoredPlanetSettings(), galaxy, zone, entranceStation: zone == galaxy.Entrance);
foreach (var belt in pack.Planets.Select(body => cache.Get(body)).OfType<AsteroidBeltData>())
yield return (belt, zone, pack);
}

View file

@ -30,8 +30,8 @@ public sealed class PlaceNamesTests : IDisposable
}
private static Galaxy Build(CultCache cache, bool prelude, uint seed) => prelude
? new Galaxy(Authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"), Authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"),
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed)
? new Galaxy(TestCasts.Wide, Authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"),
cache, _ => { }, null, seed)
: new Galaxy(Authored.Read<SectorGenerationSettings>("SectorGenerationSettings"), Authored.Read<SectorBackgroundSettings>("SectorBackgroundSettings"),
cache, _ => { }, null, seed);

View file

@ -128,6 +128,7 @@ public sealed class ProductChoiceTests : IDisposable
var outZ = cache.GetByName<Faction>("OutZ");
var game = new SavedGame
{
InfluenceScale = 1,
// Alpha's headquarters are in zone 0 and Zeta's in zone 1.
Factions = new[] { cache.RefOf(outA), cache.RefOf(outZ), cache.RefOf(cache.GetByName<Faction>("Alpha")), cache.RefOf(cache.GetByName<Faction>("Zeta")) },
Relationships = new[] { FactionRelationship.Neutral, FactionRelationship.Neutral, FactionRelationship.Neutral, FactionRelationship.Neutral },

View file

@ -63,8 +63,8 @@ public sealed class RestoredHullsTests
internal static CultCache OpenCatalog() => OpenReadOnlyRealCatalog(TestCatalog.Repo);
internal static CultCache OpenCatalogWithFixtures() => OpenReadOnlyRealCatalog(TestCatalog.RepoWithFixtures);
// Shared tutorial-galaxy construction settings (Assets/Resources/Settings.asset's own values), factored out
// so every test that needs a real tutorial Galaxy -- not just EntranceZoneAlwaysGetsADockedStationAcrossSeeds
// Shared cast-galaxy construction settings (Assets/Resources/Settings.asset's own values), factored out
// so every test that needs a real cast Galaxy -- not just EntranceZoneAlwaysGetsADockedStationAcrossSeeds
// -- builds it the same way instead of re-inlining the same ~20 fields.
internal static PlanetSettings AuthoredPlanetSettings() => AuthoredSettings.Load(RunStartTests.FindRepoRoot()).Read<PlanetSettings>("PlanetSettings");
@ -88,18 +88,6 @@ public sealed class RestoredHullsTests
NameData = new string[0],
};
internal static TutorialGenerationSettings TutorialGalaxySettings() => new TutorialGenerationSettings
{
ProtagonistFaction = "Miss", AntagonistFaction = "Zhe", BufferFaction = "Luc",
NeutralFactions = new[] { "Aero", "Finch" }, QuestFaction = "Adras", LinkDensity = .5f, ZoneCount = 64,
};
internal static SectorBackgroundSettings TutorialBackgroundSettings() => new SectorBackgroundSettings
{
NoiseAmplitude = 1, NoiseOffset = .3f, NoiseGain = .7f, NoiseLacunarity = 2, NoiseFrequency = .1f,
NoisePosition = 536.5106f, CloudExponent = 10, CloudAmplitude = .01f,
};
// A station's orbit is a copy of its source planet's own (Parent, Distance) (ZoneGenerator.CreateLagrangeOrbit),
// so it always matches that one planet. It matches MORE than one planet only when the source planet shares its
// distance with a sibling under the same parent -- exactly what ZoneGenerator's potentialLagrangePoints filter
@ -159,10 +147,10 @@ public sealed class RestoredHullsTests
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
for (var seed = 1u; seed <= 64u; seed++)
{
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
var galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background, cache, _ => { }, null, seed);
foreach (var zone in galaxy.Zones.Where(z => !ReferenceEquals(z, galaxy.Entrance)))
{
var orbits = ParentedPlanetOrbits(cache, ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, zone, isTutorial: false, ambient: false));
var orbits = ParentedPlanetOrbits(cache, ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, zone, entranceStation: false, ambient: false));
if (orbits.Length > 0 && !HasGenuineLagrangeCandidate(orbits)) return (seed, zone.Name);
}
}
@ -380,8 +368,8 @@ public sealed class RestoredHullsTests
public void EntranceZoneAlwaysGetsADockedStationAcrossSeeds()
{
var zoneSettings = TutorialZoneSettings();
var tutorialSettings = TutorialGalaxySettings();
var background = TutorialBackgroundSettings();
var tutorialSettings = TestCasts.Wide;
var background = TestCasts.Background;
var gameData = TestCatalog.Repo;
var sawGenuineLagrangeOrbit = false;
for (uint seed = 1; seed <= 25; seed++)
@ -390,10 +378,10 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = new Galaxy(tutorialSettings, background, cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
var galaxy = new Galaxy(tutorialSettings, background, cache, _ => { }, null, seed);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, isTutorial: true);
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, entranceStation: true);
var dockedStation = pack.Entities.OfType<OrbitalEntityPack>()
.FirstOrDefault(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station && e.DockingBays.Length > 0);
@ -413,15 +401,15 @@ public sealed class RestoredHullsTests
// Cut 1 fix batch 3 (F6, N1): a per-seed strengthening of the "across seeds" test above. That test only
// requires a genuine Lagrange orbit at least once in 25 seeds; it says nothing about a seed where a genuine
// candidate DID exist but the station landed on the widened fallback anyway (which the widening condition's
// own isTutorialEntrance-and-empty-candidates guard should make impossible). This pins the normal case
// own entranceStationEntrance-and-empty-candidates guard should make impossible). This pins the normal case
// directly, seed by seed: whenever the entrance zone actually has a genuine (non-rosette) Lagrange candidate,
// its station must be seated on one.
[Fact]
public void EntranceStationSitsOnAGenuineLagrangeOrbitWheneverOneExists()
{
var zoneSettings = TutorialZoneSettings();
var tutorialSettings = TutorialGalaxySettings();
var background = TutorialBackgroundSettings();
var tutorialSettings = TestCasts.Wide;
var background = TestCasts.Background;
var gameData = TestCatalog.Repo;
var sawGenuineCandidate = false;
for (uint seed = 1; seed <= 25; seed++)
@ -430,10 +418,10 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = new Galaxy(tutorialSettings, background, cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
var galaxy = new Galaxy(tutorialSettings, background, cache, _ => { }, null, seed);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, isTutorial: true);
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, entranceStation: true);
var planetOrbits = pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit)).Where(o => o.Parent.IsSet()).ToArray();
var hasGenuineCandidate = planetOrbits.Any(o => planetOrbits.Count(c => c.Parent.Key.Equals(o.Parent.Key) && abs(c.Distance - o.Distance) < .1f) == 1);
@ -468,7 +456,7 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed: 1u);
var galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background, cache, _ => { }, null, seed: 1u);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
var zoneSettings = TutorialZoneSettings();
@ -478,7 +466,7 @@ public sealed class RestoredHullsTests
zoneSettings.SubZoneCount = new ExponentialLerp { Exponent = 1, Minimum = 0, Maximum = 0 };
Assert.Throws<InvalidOperationException>(() =>
ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, isTutorial: true));
ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, entranceStation: true));
}
finally
{
@ -503,7 +491,7 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed: 1u);
var galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background, cache, _ => { }, null, seed: 1u);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
var zoneSettings = TutorialZoneSettings();
@ -512,7 +500,7 @@ public sealed class RestoredHullsTests
zoneSettings.SatelliteCreationProbability = 0;
zoneSettings.BinaryCreationProbability = 0;
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, isTutorial: true);
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, entranceStation: true);
var roots = pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit)).Count(o => !o.Parent.IsSet());
Assert.True(roots > 1, $"this fixture no longer produces a multi-root entrance (only {roots} root); it no longer tests the fragmented-topology case.");
@ -542,8 +530,8 @@ public sealed class RestoredHullsTests
public void EntranceStationPhaseDiffersFromEveryPlanetAtItsOwnDistanceAcrossSeeds()
{
var zoneSettings = TutorialZoneSettings();
var tutorialSettings = TutorialGalaxySettings();
var background = TutorialBackgroundSettings();
var tutorialSettings = TestCasts.Wide;
var background = TestCasts.Background;
var gameData = TestCatalog.Repo;
var checkedAny = false;
@ -553,10 +541,10 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = new Galaxy(tutorialSettings, background, cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
var galaxy = new Galaxy(tutorialSettings, background, cache, _ => { }, null, seed);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, isTutorial: true);
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, AuthoredPlanetSettings(), galaxy, galaxy.Entrance, entranceStation: true);
var dockedStation = pack.Entities.OfType<OrbitalEntityPack>()
.FirstOrDefault(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station && e.DockingBays.Length > 0);
@ -688,7 +676,7 @@ public sealed class RestoredHullsTests
// real zone from a real galaxy (e.g. one already known to have no Lagrange candidate) and make it the Entrance.
private static Galaxy BuildGalaxyWithForcedEntrance(CultCache cache, uint seed, string entranceZoneName)
{
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
var galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background, cache, _ => { }, null, seed);
var target = galaxy.Zones.Single(z => z.Name == entranceZoneName);
var factions = galaxy.Factions;
@ -715,7 +703,7 @@ public sealed class RestoredHullsTests
Relationships = factions.Select(f => galaxy.FactionRelationships[f]).ToArray(),
DiscoveredZones = Array.Empty<int>(),
Background = galaxy.Background,
IsTutorial = true,
InfluenceScale = .5f,
};
return new Galaxy(cache, game, _ => { });
}
@ -750,7 +738,7 @@ public sealed class RestoredHullsTests
var galaxy = BuildGalaxyWithForcedEntrance(cache, seed, zoneName);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, galaxy.Entrance, isTutorial: true);
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, galaxy.Entrance, entranceStation: true);
var station = pack.Entities.OfType<OrbitalEntityPack>()
.FirstOrDefault(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station && e.DockingBays.Length > 0);
@ -799,24 +787,24 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed: 1u);
var galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background, cache, _ => { }, null, seed: 1u);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
int StationCount(GalaxyZone zone, bool isTutorial) =>
ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, zone, isTutorial)
int StationCount(GalaxyZone zone, bool entranceStation) =>
ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, zone, entranceStation)
.Entities.OfType<OrbitalEntityPack>()
.Count(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station);
// (a) A non-entrance tutorial zone that naturally rolls zero stations keeps that roll under
// isTutorial: true -- the floor must not leak past the galaxy.Entrance reference check.
// The zone is chosen by its natural roll: zero stations without the tutorial floor (isTutorial: false).
var otherZone = galaxy.Zones.First(z => !ReferenceEquals(z, galaxy.Entrance) && StationCount(z, isTutorial: false) == 0);
// entranceStation: true -- the floor must not leak past the galaxy.Entrance reference check.
// The zone is chosen by its natural roll: zero stations without the tutorial floor (entranceStation: false).
var otherZone = galaxy.Zones.First(z => !ReferenceEquals(z, galaxy.Entrance) && StationCount(z, entranceStation: false) == 0);
Assert.NotSame(galaxy.Entrance, otherZone);
Assert.Equal(0, StationCount(otherZone, isTutorial: true));
Assert.Equal(0, StationCount(otherZone, entranceStation: true));
// (b) The entrance zone itself, generated for a non-tutorial game (isTutorial: false), keeps its
// natural roll too -- the floor must not leak past the isTutorial flag either.
Assert.Equal(0, StationCount(galaxy.Entrance, isTutorial: false));
// (b) The entrance zone itself, generated for a non-tutorial game (entranceStation: false), keeps its
// natural roll too -- the floor must not leak past the entranceStation flag either.
Assert.Equal(0, StationCount(galaxy.Entrance, entranceStation: false));
}
finally
{
@ -827,7 +815,7 @@ public sealed class RestoredHullsTests
// Cut 1 fix batch 2 (Soul's finding #2, baseStationCount): the entrance override raises stationCount (the
// orbit-selection floor) but must not also raise the enemyCount roll, which is keyed to baseStationCount
// (the pre-override value) precisely so the forced station doesn't buy the zone an extra enemy. Seed 1's
// entrance zone rolls baseStationCount 0 (confirmed via the isTutorial: false StationCount == 0 above) and
// entrance zone rolls baseStationCount 0 (confirmed via the entranceStation: false StationCount == 0 above) and
// the override raises stationCount to 1; this pins the resulting ship count at the value baseStationCount
// produces. It must fail if the enemy-count formula is changed to add stationCount instead (it would add a
// ship instead of zero).
@ -839,10 +827,10 @@ public sealed class RestoredHullsTests
try
{
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed: 1u);
var galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background, cache, _ => { }, null, seed: 1u);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, galaxy.Entrance, isTutorial: true);
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, galaxy.Entrance, entranceStation: true);
var stationCount = pack.Entities.OfType<OrbitalEntityPack>().Count(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station);
// Soul's finding (this cut's fix batch 3): pack.Entities.OfType<ShipPack>().Count() also counts the
// zone's neutral wanderers (ZoneGenerator.cs's own EligibleWandererFactions spawn, keyed to
@ -869,12 +857,12 @@ public sealed class RestoredHullsTests
// here by boosting one faction's presence there (HomeZone distance 0, InfluenceDistance 50, so the roll's
// floor(rand * (factionPresence+1)) is overwhelmingly likely nonzero) via the same public SavedGame round
// trip BuildGalaxyWithForcedEntrance uses, not by touching ZoneGenerator's private roll. Verified directly:
// temporarily widening every zone (dropping ZoneGenerator's isTutorialEntrance guard) turns this fixture's
// temporarily widening every zone (dropping ZoneGenerator's entranceStationEntrance guard) turns this fixture's
// station count from 0 into 2, so a natural nonzero roll really is hiding behind the empty candidate set.
// Must fail if that guard is dropped for real.
private static Galaxy BuildGalaxyWithBoostedPresence(CultCache cache, uint seed, string zoneName)
{
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
var galaxy = new Galaxy(TestCasts.Wide, TestCasts.Background, cache, _ => { }, null, seed);
var target = galaxy.Zones.Single(z => z.Name == zoneName);
var factions = galaxy.Factions;
@ -906,7 +894,7 @@ public sealed class RestoredHullsTests
Relationships = factions.Select(f => galaxy.FactionRelationships[f]).ToArray(),
DiscoveredZones = Array.Empty<int>(),
Background = galaxy.Background,
IsTutorial = true,
InfluenceScale = .5f,
};
return new Galaxy(cache, game, _ => { });
}
@ -925,7 +913,7 @@ public sealed class RestoredHullsTests
Assert.NotSame(galaxy.Entrance, zone);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), Settings(), _ => { });
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, zone, isTutorial: true);
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), AuthoredPlanetSettings(), galaxy, zone, entranceStation: true);
// Confirms this fixture still has no genuine (non-rosette) Lagrange candidate -- a regression here
// would mean the fixture no longer probes what this test claims to probe.

View file

@ -21,7 +21,7 @@ public sealed partial class RunStartTests
private ZonePack BossZonePack(Galaxy galaxy, ItemManager items, GalaxyZone zone, bool ambient = true, uint seed = 7)
{
items.Random = new CultMath.Random(seed);
return ZoneGenerator.GenerateZone(items, _zoneSettings, _planetSettings, galaxy, zone, galaxy.IsPrelude, ambient);
return ZoneGenerator.GenerateZone(items, _zoneSettings, _planetSettings, galaxy, zone, entranceStation: zone == galaxy.Entrance, ambient);
}
private Zone ZoneOf(Galaxy galaxy, GalaxyZone zone) =>

View file

@ -458,6 +458,7 @@ public sealed class RunSaveTests : IDisposable
var game = new SavedGame
{
InfluenceScale = 1,
Factions = Array.Empty<CultRecordRef<Faction>>(),
Relationships = Array.Empty<FactionRelationship>(),
HomeZones = new Dictionary<int, int>(),
@ -841,6 +842,7 @@ public sealed class RunSaveTests : IDisposable
// HomeZones lists the factions in reverse of their saved order.
private static SavedGame Game(CultCache cache, params Faction[] factions) => new SavedGame
{
InfluenceScale = 1,
Factions = factions.Select(f => cache.RefOf(f)).ToArray(),
Relationships = factions.Select(_ => FactionRelationship.Neutral).ToArray(),
HomeZones = factions.Select((_, i) => factions.Length - 1 - i).ToDictionary(i => i, _ => 0),

View file

@ -9,6 +9,7 @@ internal static class RunSeedFixture
{
var game = new SavedGame
{
InfluenceScale = 1,
Seed = seed,
Factions = new CultRecordRef<Faction>[0],
Relationships = new FactionRelationship[0],

View file

@ -79,9 +79,9 @@ public sealed partial class RunStartTests
}
[Fact]
public void APreludeNoLongerOffersEverything()
public void ACastGalaxyNoLongerOffersEverything()
{
Assert.True(_galaxy.IsPrelude);
Assert.Equal(.5f, _galaxy.InfluenceScale);
var (absentProduct, _) = AbsentMaker("AbsentToPrelude");
var generator = GeneratorFor(_galaxy, "PreludeLoner");
Assert.False(generator.IsAvailable(absentProduct));

View file

@ -17,7 +17,7 @@ using float2 = CultMath.float2;
using float3 = CultMath.float3;
// RunStart owns what a new run starts with, and Zone.Admit is the one admission into a zone (docs/scenarios-cut.md,
// 2.2 and R). Every test stages into a real arena: the entrance zone of a prelude galaxy at a fixed seed, built from a
// 2.2 and R). Every test stages into a real arena: the entrance zone of a cast galaxy at a fixed seed, built from a
// scratch copy of the catalog the game boots (TestCatalog) and the authored settings (Assets/Resources/Settings.asset).
public sealed partial class RunStartTests : IDisposable
{
@ -31,7 +31,6 @@ public sealed partial class RunStartTests : IDisposable
private readonly PlanetSettings _planetSettings;
private readonly string _startingHull;
private readonly Faction _protagonist;
private readonly TutorialGenerationSettings _tutorialSettings;
public RunStartTests()
{
@ -49,10 +48,9 @@ public sealed partial class RunStartTests : IDisposable
var authored = AuthoredSettings.Load(repo);
_zoneSettings = authored.Read<ZoneGenerationSettings>("ZoneSettings");
_planetSettings = authored.Read<PlanetSettings>("PlanetSettings");
var tutorial = _tutorialSettings = authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings");
_galaxy = new Galaxy(tutorial, authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"),
_cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(_root, "Narrative")), _ => { }, null, GalaxySeed);
var tutorial = TestCasts.Wide;
_galaxy = new Galaxy(tutorial, authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"),
_cache, _ => { }, null, GalaxySeed);
_items = new ItemManager(1u, _cache, new ProvenanceLedger(), RestoredHullsTests.PinnedFlight(authored.Read<GameplaySettings>("GameplaySettings")), _ => { });
_protagonist = _galaxy.ResolveFaction(tutorial.ProtagonistFaction);
@ -125,11 +123,11 @@ public sealed partial class RunStartTests : IDisposable
var background = authored.Read<SectorBackgroundSettings>("SectorBackgroundSettings");
var sector = authored.Read<SectorGenerationSettings>("SectorGenerationSettings");
sector.ZoneCount = 8;
var tutorial = authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings");
var tutorial = TestCasts.Wide;
var main = Assert.Throws<ArgumentOutOfRangeException>(() => new Galaxy(sector, background, _cache, _ => { }, null, 0));
var prelude = Assert.Throws<ArgumentOutOfRangeException>(() =>
new Galaxy(tutorial, background, _cache, new PlayerSettings(), new DirectoryInfo(_root), _ => { }, null, 0));
new Galaxy(tutorial, background, _cache, _ => { }, null, 0));
foreach (var refusal in new[] { main, prelude })
{
Assert.Equal("seed", refusal.ParamName);
@ -161,7 +159,7 @@ public sealed partial class RunStartTests : IDisposable
public void EveryFactionsStationsCarryOnlyGearItCanReachIncludingAHeaterAndAReactor()
{
var galaxy = MainSectorGalaxy();
Assert.False(galaxy.IsPrelude);
Assert.Equal(1f, galaxy.InfluenceScale);
var zone = Arena(true);
foreach (var faction in galaxy.Factions)
{

View file

@ -17,7 +17,7 @@ using float2 = CultMath.float2;
using float3 = CultMath.float3;
// Scenarios S2 (docs/scenarios-cut.md, R): every new run is a scenario. The fixture is RunStartTests': a scratch copy
// of the shipped catalog, the authored settings and a prelude galaxy at a fixed seed.
// of the shipped catalog, the authored settings and a cast galaxy at a fixed seed.
public sealed partial class RunStartTests
{
// A test's own scenario: a script given inline, staged into the fixture's arena or launched whole.
@ -33,7 +33,7 @@ public sealed partial class RunStartTests
_ambient = ambient;
_stage = stage;
_seed = seed;
_generate = generate ?? (galaxy => galaxy.Prelude());
_generate = generate ?? (stage => stage.Cast(TestCasts.Wide));
}
public override string Name => "Scripted";
@ -54,9 +54,8 @@ public sealed partial class RunStartTests
return new GalaxyStage(
authored.Read<SectorGenerationSettings>("SectorGenerationSettings"),
authored.Read<SectorBackgroundSettings>("SectorBackgroundSettings"),
authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"),
authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"),
_cache, new PlayerSettings(), Directory.CreateDirectory(Path.Combine(_root, "Narrative")), _ => { }, null, clock);
authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"),
_cache, _ => { }, null, clock);
}
// What MainMenu.Launch and StartGame do with a scenario: its galaxy, its arena, then staging. beforeStaging stands in
@ -67,14 +66,14 @@ public sealed partial class RunStartTests
var arena = new Zone(_items, _planetSettings, RunStart.GenerateArena(_items, _zoneSettings, _planetSettings, galaxy, scenario), galaxy.Entrance, galaxy);
beforeStaging?.Invoke();
var failures = new List<string>();
var staged = RunStart.Stage(_items, arena, scenario, _startingHull, _tutorialSettings, failures);
var staged = RunStart.Stage(_items, arena, scenario, _startingHull, failures);
return (galaxy, arena, staged, failures);
}
private RunStart.Staged Stage(Zone zone, Scenario scenario)
{
var failures = new List<string>();
var staged = RunStart.Stage(_items, zone, scenario, _startingHull, _tutorialSettings, failures);
var staged = RunStart.Stage(_items, zone, scenario, _startingHull, failures);
Assert.True(failures.Count == 0, string.Join("; ", failures));
Assert.NotNull(staged);
return staged;
@ -86,7 +85,7 @@ public sealed partial class RunStartTests
var entities = zone.Entities.ToList();
var agents = zone.Agents.ToList();
var failures = new List<string>();
Assert.Null(RunStart.Stage(_items, zone, scenario, _startingHull, _tutorialSettings, failures));
Assert.Null(RunStart.Stage(_items, zone, scenario, _startingHull, failures));
SafeAssert.Unchanged(zone, entities, agents);
return failures;
}
@ -123,26 +122,25 @@ public sealed partial class RunStartTests
Assert.Equal(1234, poor.Credits);
}
// The two game modes are what New Game did: the tutorial a prelude galaxy and a starting-hull ship of the
// protagonist faction at the entrance's origin; the main galaxy a main galaxy and a starting-hull ship there. Both
// arenas keep their generated ships.
// The two game modes are what New Game did: the demo a cast galaxy at half influence and a starting-hull ship at the
// entrance's origin; the main galaxy a main galaxy at full influence and a starting-hull ship there. Both arenas
// keep their generated ships.
[Fact]
public void ModesMatchOldNewGame()
{
Assert.Equal("Longinus", _startingHull);
var tutorial = Launch(new TutorialGalaxy(), Inputs(() => GalaxySeed));
Assert.Empty(tutorial.failures);
Assert.True(tutorial.galaxy.IsPrelude, "the tutorial is a prelude galaxy");
Assert.Equal(_startingHull, tutorial.staged.Player.HullData.Name);
Assert.Same(tutorial.galaxy.ResolveFaction(_tutorialSettings.ProtagonistFaction), tutorial.staged.Player.Faction);
Assert.Equal(float3.zero, tutorial.staged.Player.Position);
Assert.Empty(tutorial.staged.Entities);
Assert.Contains(tutorial.arena.Pack.Entities, entity => entity is ShipPack { IsPlayerShip: false });
var demo = Launch(new DemoTerminus(), Inputs(() => GalaxySeed));
Assert.Empty(demo.failures);
Assert.Equal(.5f, demo.galaxy.InfluenceScale);
Assert.Equal(_startingHull, demo.staged.Player.HullData.Name);
Assert.Equal(float3.zero, demo.staged.Player.Position);
Assert.Empty(demo.staged.Entities);
Assert.Contains(demo.arena.Pack.Entities, entity => entity is ShipPack { IsPlayerShip: false });
var main = Launch(new MainGalaxy(), Inputs(() => GalaxySeed));
Assert.Empty(main.failures);
Assert.False(main.galaxy.IsPrelude, "the main galaxy is not a prelude");
Assert.Equal(1f, main.galaxy.InfluenceScale);
Assert.Equal(_startingHull, main.staged.Player.HullData.Name);
Assert.Equal(float3.zero, main.staged.Player.Position);
Assert.Empty(main.staged.Entities);
@ -209,12 +207,12 @@ public sealed partial class RunStartTests
Assert.NotEqual(Layout(a), Layout(b));
}
// Generating a galaxy writes nothing a later one reads: a prelude leaves the catalog's faction influence as authored.
// Generating a galaxy writes nothing a later one reads: a cast galaxy leaves the catalog's faction influence as authored.
[Fact]
public void AGalaxyLeavesTheCatalogsFactionsAsAuthored()
{
var authored = _cache.GetAll<Faction>().ToDictionary(faction => faction, faction => faction.InfluenceDistance);
RunStart.Generate(new TutorialGalaxy(), Inputs());
RunStart.Generate(new DemoTerminus(), Inputs());
RunStart.Generate(new MainGalaxy(), Inputs());
Assert.All(authored, pair => Assert.Equal(pair.Value, pair.Key.InfluenceDistance));
}
@ -233,7 +231,7 @@ public sealed partial class RunStartTests
[InlineData(34u, false)]
public void EveryZoneIsLinked(uint seed, bool prelude)
{
var galaxy = RunStart.Generate(new Scripted(true, _ => { }, seed, stage => prelude ? stage.Prelude() : stage.Main()), Inputs());
var galaxy = RunStart.Generate(new Scripted(true, _ => { }, seed, stage => prelude ? stage.Cast(TestCasts.Wide) : stage.Main()), Inputs());
Assert.All(galaxy.Zones, zone => Assert.Equal(galaxy.Zones.Length, zone.Distance.Count));
var positions = galaxy.Zones.Select(zone => zone.Position).ToArray();
@ -438,7 +436,7 @@ public sealed partial class RunStartTests
public void UndockingAdmitsWithNoAgent()
{
var zone = Arena(true);
var player = Stage(zone, new TutorialGalaxy()).Player;
var player = Stage(zone, new Scripted(false, stage => stage.Player(stage.Generated(stage.StartingHull), float2(0, 0)))).Player;
var station = zone.Entities.First(entity => entity is OrbitalEntity && entity.DockingBays.Count > 0);
var agents = zone.Agents.Count;
@ -617,18 +615,69 @@ public sealed partial class RunStartTests
Assert.Empty(UnsoldAndUnplaced(runs));
}
// Whether a run is the prelude is the galaxy's fact (Galaxy.IsPrelude); a save records it with no second owner.
// How far influence reaches is the galaxy's fact (Galaxy.InfluenceScale); a save records it with no second owner, and
// a save without one (written before it existed) is refused by name rather than read as full influence.
[Fact]
public void SaveReadsPrelude()
public void InfluenceScaleRoundTripsAndOldSavesAreRefused()
{
var arena = Arena(true);
var (prelude, _) = RunSave.Capture(_cache, _galaxy, arena, null, new SavedActionBarBinding[0], 0);
Assert.True(prelude.IsTutorial);
var (demo, _) = RunSave.Capture(_cache, _galaxy, arena, null, new SavedActionBarBinding[0], 0);
Assert.Equal(.5f, demo.InfluenceScale);
var (main, _) = RunSave.Capture(_cache, MainSectorGalaxy(), arena, null, new SavedActionBarBinding[0], 0);
Assert.False(main.IsTutorial);
Assert.Equal(1f, main.InfluenceScale);
var old = Assert.Throws<InvalidOperationException>(() => new Galaxy(_cache, new SavedGame
{
Zones = demo.Zones, Factions = demo.Factions, HomeZones = demo.HomeZones, BossZones = demo.BossZones,
Entrance = demo.Entrance, Exit = demo.Exit, DiscoveredZones = demo.DiscoveredZones, Background = demo.Background,
Relationships = demo.Relationships, Standings = demo.Standings, Seed = demo.Seed,
InfluenceScale = 0,
}, _ => { }));
Assert.Contains(nameof(SavedGame.InfluenceScale), old.Message);
}
// The halving is the cast's: InfluenceOf scales a faction's authored distance by the galaxy's InfluenceScale, rounding up.
[Fact]
public void InfluenceOfMatchesTheHalving()
{
var half = _galaxy;
var full = MainSectorGalaxy();
var faction = _cache.GetAll<Faction>().First();
var authored = faction.InfluenceDistance;
try
{
for (var distance = 0; distance <= 10; distance++)
{
faction.InfluenceDistance = distance;
Assert.Equal((distance + 1) / 2, half.InfluenceOf(faction));
Assert.Equal(distance, full.InfluenceOf(faction));
}
}
finally { faction.InfluenceDistance = authored; }
}
// Whether the arena gets a forced entrance station is the scenario's declaration, not the galaxy's. At a seed whose
// natural roll is zero stations, a scenario declaring one gets a docking station and the same arena generated without
// the declaration gets none.
[Fact]
public void EntranceStationIsTheScenariosDeclaration()
{
Assert.True(new DemoTerminus().EntranceStation);
Assert.False(new MainGalaxy().EntranceStation);
var natural = ZoneGenerator.GenerateZone(_items, _zoneSettings, _planetSettings, _galaxy, _galaxy.Entrance, entranceStation: false, ambient: false);
var forced = ZoneGenerator.GenerateZone(_items, _zoneSettings, _planetSettings, _galaxy, _galaxy.Entrance, entranceStation: true, ambient: false);
Assert.Equal(0, StationsOf(natural));
Assert.True(StationsOf(forced) >= 1);
// Through RunStart, the scenario's declaration is what reaches the generator.
Assert.True(StationsOf(RunStart.GenerateArena(_items, _zoneSettings, _planetSettings, _galaxy, new DemoTerminus())) >= 1);
Assert.Equal(0, StationsOf(RunStart.GenerateArena(_items, _zoneSettings, _planetSettings, _galaxy, new MainGalaxy())));
}
private int StationsOf(ZonePack pack) =>
pack.Entities.OfType<OrbitalEntityPack>().Count(entity => (_cache.Get(entity.Hull.Data) as HullData)?.HullType == HullType.Station);
// PlayerSettings Key 2, the never-written tutorial flag, is retired: a player.cc written with it still loads, every other field intact.
[Fact]
public void OldPlayerSettingsLoad()

View file

@ -352,11 +352,10 @@ public sealed class StationKindTests : IDisposable
stock?.Invoke(w);
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
var dir = Path.Combine(_root, "galaxy" + _worlds++);
var galaxy = new Galaxy(authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"),
authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"), w.Cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(dir, "Narrative")), _ => { }, null, 3);
var galaxy = new Galaxy(TestCasts.Wide,
authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"), w.Cache, _ => { }, null, 3);
var pack = ZoneGenerator.GenerateZone(w.Items, authored.Read<ZoneGenerationSettings>("ZoneSettings"),
authored.Read<PlanetSettings>("PlanetSettings"), galaxy, galaxy.Entrance, galaxy.IsPrelude, true);
authored.Read<PlanetSettings>("PlanetSettings"), galaxy, galaxy.Entrance, true, true);
Assert.NotEmpty(pack.Entities.OfType<OrbitalEntityPack>());
return pack.Orbits.Select(orbit => w.Cache.Get(orbit)).Select(orbit => (orbit.Distance, orbit.Phase)).ToArray();
}
@ -376,11 +375,10 @@ public sealed class StationKindTests : IDisposable
foreach (var faction in new[] { w.Au, w.Zh, w.Lucent })
foreach (var kind in new[] { "mining", "shipyard", "depot", "power" }) w.Sell(faction, kind);
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
var galaxy = new Galaxy(authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"),
authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"), w.Cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(_root, "galaxy" + _worlds++, "Narrative")), _ => { }, null, 3);
var galaxy = new Galaxy(TestCasts.Wide,
authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"), w.Cache, _ => { }, null, 3);
return galaxy.Zones.Take(8).SelectMany(zone => ZoneGenerator.GenerateZone(w.Items, authored.Read<ZoneGenerationSettings>("ZoneSettings"),
authored.Read<PlanetSettings>("PlanetSettings"), galaxy, zone, zone == galaxy.Entrance && galaxy.IsPrelude, true)
authored.Read<PlanetSettings>("PlanetSettings"), galaxy, zone, true, true)
.Entities.OfType<OrbitalEntityPack>().Where(e => e.Kind.IsSet()).Select(e => e.Kind.Key.Value)).ToArray();
}
var first = Kinds();
@ -397,15 +395,14 @@ public sealed class StationKindTests : IDisposable
w.StandIn("depot", w.Lucent, "power");
w.StandIn("depot", w.Zh, "power");
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
var galaxy = new Galaxy(authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"),
authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"), w.Cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(_root, "zones", "Narrative")), _ => { }, null, 5);
var galaxy = new Galaxy(TestCasts.Wide,
authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"), w.Cache, _ => { }, null, 5);
var stations = 0;
var fallbacks = 0;
foreach (var galaxyZone in galaxy.Zones.Take(8))
{
var pack = ZoneGenerator.GenerateZone(w.Items, authored.Read<ZoneGenerationSettings>("ZoneSettings"),
authored.Read<PlanetSettings>("PlanetSettings"), galaxy, galaxyZone, galaxyZone == galaxy.Entrance && galaxy.IsPrelude, true);
authored.Read<PlanetSettings>("PlanetSettings"), galaxy, galaxyZone, true, true);
foreach (var station in pack.Entities.OfType<OrbitalEntityPack>().Where(e => w.HullOf(e).HullType == HullType.Station))
{
stations++;
@ -473,11 +470,10 @@ public sealed class StationKindTests : IDisposable
}
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
var galaxy = new Galaxy(authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"),
authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"), world.Cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(_root, "galaxy" + _worlds++, "Narrative")), _ => { }, null, 5);
var galaxy = new Galaxy(TestCasts.Wide,
authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"), world.Cache, _ => { }, null, 5);
var entrance = ZoneGenerator.GenerateZone(world.Items, authored.Read<ZoneGenerationSettings>("ZoneSettings"),
authored.Read<PlanetSettings>("PlanetSettings"), galaxy, galaxy.Entrance, galaxy.IsPrelude, true);
authored.Read<PlanetSettings>("PlanetSettings"), galaxy, galaxy.Entrance, true, true);
Assert.Contains(entrance.Entities.OfType<OrbitalEntityPack>(), e => world.HullOf(e).HullType == HullType.Station);
}

View file

@ -52,10 +52,9 @@ public sealed class StationPlacementTests : IDisposable
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(Path.Combine(dir, "run.cc")), AetheriaStores.RunTypes);
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
var settings = authored.Read<GameplaySettings>("GameplaySettings");
var galaxy = new Galaxy(authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings"),
authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"),
cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(dir, "Narrative")), _ => { }, null, seed);
var galaxy = new Galaxy(TestCasts.Wide,
authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"),
cache, _ => { }, null, seed);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), settings, _ => { });
stock?.Invoke(items);
foreach (var galaxyZone in entranceOnly ? new[] { galaxy.Entrance } : galaxy.Zones.Take(zonesPerSeed))
@ -65,7 +64,7 @@ public sealed class StationPlacementTests : IDisposable
var zoneSettings = authored.Read<ZoneGenerationSettings>("ZoneSettings");
tune?.Invoke(zoneSettings);
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, authored.Read<PlanetSettings>("PlanetSettings"), galaxy, galaxyZone,
galaxyZone == galaxy.Entrance && galaxy.IsPrelude, true);
true, true);
var zone = new Zone(items, authored.Read<PlanetSettings>("PlanetSettings"), pack, galaxyZone, galaxy);
zone.Update(.02f);
yield return new Built(seed, zone, items);

View file

@ -181,10 +181,9 @@ public sealed class SunsNeverGreenTests : IDisposable
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(catalog), AetheriaStores.CatalogTypes);
cache.AddBackingStore(new GameCult.Caching.MessagePack.SingleFileMessagePackBackingStore(Path.Combine(dir, "run.cc")), AetheriaStores.RunTypes);
var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot());
var tutorial = authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings");
var galaxy = new Galaxy(tutorial, authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings"),
cache, new PlayerSettings(),
Directory.CreateDirectory(Path.Combine(dir, "Narrative")), _ => { }, null, seed);
var tutorial = TestCasts.Wide;
var galaxy = new Galaxy(tutorial, authored.Read<SectorBackgroundSettings>("CastBackgroundSettings"),
cache, _ => { }, null, seed);
var items = new ItemManager(1u, cache, new ProvenanceLedger(), authored.Read<GameplaySettings>("GameplaySettings"), _ => { });
var zoneSettings = authored.Read<ZoneGenerationSettings>("ZoneSettings");
adjust(zoneSettings);

View file

@ -0,0 +1,18 @@
// The two fixtures every cast-galaxy test builds from: the values the retired Settings.asset block held (Miss, Zhe, Luc,
// Aero and Finch, Adras, 64 zones, half influence), so every test galaxy is what it was. A test fixture is not new
// faction material (ruling miss-terris-belongs-to-emily-r3).
internal static class TestCasts
{
internal static GalaxyCast Wide => new GalaxyCast
{
ProtagonistFaction = "Miss", AntagonistFaction = "Zhe", BufferFaction = "Luc",
NeutralFactions = new[] { "Aero", "Finch" }, QuestFaction = "Adras", LinkDensity = .5f, ZoneCount = 64,
InfluenceScale = .5f,
};
internal static SectorBackgroundSettings Background => new SectorBackgroundSettings
{
NoiseAmplitude = 1, NoiseOffset = .3f, NoiseGain = .7f, NoiseLacunarity = 2, NoiseFrequency = .1f,
NoisePosition = 536.5106f, CloudExponent = 10, CloudAmplitude = .01f,
};
}

View file

@ -560,7 +560,7 @@ public static class Program
private static int SettingsDump()
{
var authored = AuthoredSettings.Load(AetherDb.FindRoot());
authored.Dump("TutorialGenerationSettings", 2);
authored.Dump("CastBackgroundSettings", 2);
Console.WriteLine();
authored.Dump("GameplaySettings", 2);
return 0;
@ -572,15 +572,10 @@ public static class Program
{
var authored = AuthoredSettings.Load(AetherDb.FindRoot());
var tutorial = authored.Read<TutorialGenerationSettings>("TutorialGenerationSettings");
var background = authored.Read<SectorBackgroundSettings>("TutorialBackgroundSettings");
var background = authored.Read<SectorBackgroundSettings>("CastBackgroundSettings");
var zones = authored.Read<ZoneGenerationSettings>("ZoneSettings");
var gameplay = authored.Read<GameplaySettings>("GameplaySettings");
Console.WriteLine($"tutorial: protagonist {tutorial.ProtagonistFaction}, antagonist {tutorial.AntagonistFaction}, " +
$"buffer {tutorial.BufferFaction}, quest {tutorial.QuestFaction}, " +
$"neutrals [{string.Join(", ", tutorial.NeutralFactions ?? new string[0])}], " +
$"{tutorial.ZoneCount} zones, link density {tutorial.LinkDensity}");
Console.WriteLine($"background: frequency {background.NoiseFrequency}, amplitude {background.NoiseAmplitude}, " +
$"cloud exponent {background.CloudExponent}, density at centre {background.CloudDensity(new float2(.5f)):0.000}");
Console.WriteLine($"zones: sun mass {zones.SunMass}, planet mass {zones.PlanetMass}, satellite passes {zones.SatellitePasses}, " +
@ -600,8 +595,6 @@ public static class Program
else if (gameplay.Tiers.Any(t => string.IsNullOrEmpty(t.Name) || t.Quality <= 0)) missing.Add("GameplaySettings.Tiers (a tier parsed without a name or quality)");
if (gameplay.DefaultEntitySettings == null) missing.Add("GameplaySettings.DefaultEntitySettings");
if (gameplay.QualityPriceModifier == null || gameplay.QualityPriceModifier.Maximum <= 0) missing.Add("GameplaySettings.QualityPriceModifier");
if (tutorial.NeutralFactions == null || tutorial.NeutralFactions.Length != 2) missing.Add($"TutorialGenerationSettings.NeutralFactions (expected 2, got {tutorial.NeutralFactions?.Length ?? 0})");
if (string.IsNullOrEmpty(tutorial.ProtagonistFaction)) missing.Add("TutorialGenerationSettings.ProtagonistFaction");
Console.WriteLine($"\n{authored.Unplaced.Count} fields in the asset had nowhere to go");
foreach (var field in authored.Unplaced.Take(20)) Console.WriteLine($" {field}");