Every new run is a scenario: the script harness, the tutorial and main galaxies as scenarios, the New Game submenu and six test arenas
A Scenario is an abstract C# class compiled with the game: Generate picks the galaxy through GalaxyStage (Main or Prelude, at the scenario's seed, the background noise drawn from the same seed), Stage places the run's first entities through ScenarioStage (Fit, Bare, Generated, Preset, Player, Place, Cargo), which collects named failures and admits nothing. RunStart generates the galaxy, the arena under Ambient and admits everything through Zone.Admit, all or nothing. The aetheria.scenario record, ScenarioShip, ScenarioEntity, RunStart.Check and the null-scenario branch are cut. New Game opens a submenu: Tutorial Galaxy and Main Galaxy, then (editor and development builds) Djinni Shakedown, Starved Reactor, Arcs, Duel, Launcher Angles and Long Haul, each with its brief. MainMenu.Launch is the one way into a new run; ActionGameManager.PendingScenario carries the scenario to StartGame once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8a0a29e0de
commit
d0782a7d14
31 changed files with 1173 additions and 611 deletions
|
|
@ -5,15 +5,12 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MessagePack;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using static CultMath.math;
|
||||
using float2 = CultMath.float2;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class MainMenu : MonoBehaviour
|
||||
{
|
||||
|
|
@ -118,45 +115,8 @@ public class MainMenu : MonoBehaviour
|
|||
_nextMenu.panel.AddButton("New Game",
|
||||
() =>
|
||||
{
|
||||
RunSave.Clear(ActionGameManager.CultCache);
|
||||
var generatorState = "Loading Database Contents";
|
||||
Action<string> setState = s => generatorState = s;
|
||||
|
||||
ShowScenarios();
|
||||
Fade(true);
|
||||
_nextMenu.panel.gameObject.SetActive(false);
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Generating Galaxy";
|
||||
Dialog.AddProperty(() => generatorState);
|
||||
Dialog.Show();
|
||||
|
||||
{
|
||||
var backgroundSettings = MessagePackSerializer.Deserialize<SectorBackgroundSettings>(
|
||||
MessagePackSerializer.Serialize(Settings.TutorialBackgroundSettings));
|
||||
int iteration = 1;
|
||||
do
|
||||
{
|
||||
backgroundSettings.NoisePosition = Random.value * 1000;
|
||||
setState($"Finding Galaxy Position: iteration {iteration++}");
|
||||
} while (backgroundSettings.CloudDensity(float2(0.5f)) < .5f);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var sector = new Galaxy(
|
||||
Settings.TutorialGenerationSettings,
|
||||
backgroundSettings,
|
||||
Settings.NameGeneratorSettings,
|
||||
ActionGameManager.CultCache,
|
||||
ActionGameManager.PlayerSettings,
|
||||
ActionGameManager.GameDataDirectory.CreateSubdirectory("Narrative"),
|
||||
Debug.Log,
|
||||
setState);
|
||||
Observable.NextFrame().Subscribe(_ =>
|
||||
{
|
||||
ActionGameManager.CurrentGalaxy = sector;
|
||||
EnterGame();
|
||||
});
|
||||
}).ContinueWith(t => Debug.LogException(t.Exception), TaskContinuationOptions.OnlyOnFaulted);
|
||||
}
|
||||
});
|
||||
_nextMenu.panel.AddButton("Settings",
|
||||
() =>
|
||||
|
|
@ -167,6 +127,72 @@ public class MainMenu : MonoBehaviour
|
|||
_nextMenu.panel.AddButton("Quit", Application.Quit);
|
||||
}
|
||||
|
||||
// New Game: every way to set up a run, each with its brief. The test arenas are listed only in editor and
|
||||
// development builds.
|
||||
private void ShowScenarios()
|
||||
{
|
||||
_nextMenu.panel.Clear();
|
||||
_nextMenu.panel.Title.text = TitleSubtitle("new game", "scenarios");
|
||||
AddScenarios(Scenarios.Modes);
|
||||
if (Debug.isDebugBuild)
|
||||
{
|
||||
_nextMenu.panel.AddSection("test arenas");
|
||||
AddScenarios(Scenarios.Tests);
|
||||
}
|
||||
_nextMenu.panel.AddButton("Back",
|
||||
() =>
|
||||
{
|
||||
ShowMain();
|
||||
Fade(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void AddScenarios(IEnumerable<Scenario> scenarios)
|
||||
{
|
||||
foreach (var scenario in scenarios)
|
||||
{
|
||||
_nextMenu.panel.AddButton(scenario.Name, () => Launch(scenario));
|
||||
_nextMenu.panel.AddProperty(() => scenario.Brief);
|
||||
}
|
||||
}
|
||||
|
||||
// The only way into a new run: clears the saved run, generates the scenario's galaxy off the main thread, and
|
||||
// enters the game, where StartGame has RunStart stage it.
|
||||
private void Launch(Scenario scenario)
|
||||
{
|
||||
RunSave.Clear(ActionGameManager.CultCache);
|
||||
var generatorState = "Loading Database Contents";
|
||||
|
||||
Fade(true);
|
||||
_nextMenu.panel.gameObject.SetActive(false);
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "Generating Galaxy";
|
||||
Dialog.AddProperty(() => generatorState);
|
||||
Dialog.Show();
|
||||
|
||||
var stage = new GalaxyStage(
|
||||
Settings.SectorGenerationSettings,
|
||||
Settings.SectorBackgroundSettings,
|
||||
Settings.TutorialGenerationSettings,
|
||||
Settings.TutorialBackgroundSettings,
|
||||
Settings.NameGeneratorSettings,
|
||||
ActionGameManager.CultCache,
|
||||
ActionGameManager.PlayerSettings,
|
||||
ActionGameManager.GameDataDirectory.CreateSubdirectory("Narrative"),
|
||||
Debug.Log,
|
||||
state => generatorState = state);
|
||||
Task.Run(() =>
|
||||
{
|
||||
var galaxy = RunStart.Generate(scenario, stage);
|
||||
Observable.NextFrame().Subscribe(_ =>
|
||||
{
|
||||
ActionGameManager.CurrentGalaxy = galaxy;
|
||||
ActionGameManager.PendingScenario = scenario;
|
||||
EnterGame();
|
||||
});
|
||||
}).ContinueWith(t => Debug.LogException(t.Exception), TaskContinuationOptions.OnlyOnFaulted);
|
||||
}
|
||||
|
||||
// The one way into the game scene. Mod ship prototypes import asynchronously at boot, so the scene waits for them,
|
||||
// and a preload that could not run at all stops here with its reason rather than in the first zone.
|
||||
private void EnterGame() => StartCoroutine(EnterGameWhenModShipsAreReady());
|
||||
|
|
|
|||
Loading…
Reference in a new issue