Complete daemon-owned Terminus service loop

This commit is contained in:
Meta Vens 2026-07-13 14:36:43 +01:00
commit 6c2bcd6afb
18 changed files with 559 additions and 53 deletions

View file

@ -81,6 +81,10 @@ public sealed class AetheriaDaemonLoadoutGenerator
var cargo = PackCargo(cargoBay, availabilityFactionKey, scenarioCargo,
string.Equals(entityKind, "station", StringComparison.OrdinalIgnoreCase));
var sensorArrayCount = string.Equals(entityKind, "station", StringComparison.OrdinalIgnoreCase) ? 2 : 1;
for (var sensorIndex = 0; sensorIndex < sensorArrayCount; sensorIndex++)
TryAddFreeSpaceItem(hull, availabilityFactionKey, occupied, slots, 2, item =>
IsGear(item) && HasBehavior(item, "Sensor"));
var selectedKeys = new[] { (Role: "hull", Key: hull.ItemKey) }
.Concat(slots.Select(value => (Role: "equipment", Key: value.ItemKey)))
.Concat(cargo.Select(value => (Role: "cargo", Key: value.Item.ItemKey)));
@ -146,6 +150,28 @@ public sealed class AetheriaDaemonLoadoutGenerator
return selected.Item;
}
private AetheriaRuntimeCatalogItem? TryAddFreeSpaceItem(
AetheriaRuntimeCatalogItem hull,
string factionKey,
HashSet<(int X, int Y)> occupied,
List<AetheriaEntityItemSlot> slots,
double sizeExponent,
Func<AetheriaRuntimeCatalogItem, bool> filter)
{
var candidates = Available(factionKey)
.Where(filter)
.Select(item => (Item: item, Fit: FindFit(hull, item, occupied)))
.Where(value => value.Fit.HasValue)
.ToArray();
var selected = PickWeighted(candidates, sizeExponent, factionKey, value => value.Item);
if (selected.Item == null || !selected.Fit.HasValue)
return null;
var fit = selected.Fit.Value;
slots.Add(Slot(fit.X, fit.Y, selected.Item.ItemKey));
Reserve(occupied, selected.Item, fit.X, fit.Y, fit.Rotation);
return selected.Item;
}
private AetheriaLoadoutItemSlot[] PackCargo(
AetheriaRuntimeCatalogItem cargoBay,
string factionKey,

View file

@ -90,7 +90,7 @@ internal static class AetheriaDaemonZoneGenerator
new AetheriaDroppedPickupSnapshot
{
PickupIndex = 0,
Position = Vec3(-15, 0, -5),
Position = Vec3(-40, 0, -29),
Velocity = Vec3(0, 0, 0),
Item = new AetheriaLoadoutItem { ItemKey = "scrap-metal", Quantity = 1 }
}
@ -216,7 +216,7 @@ internal static class AetheriaDaemonZoneGenerator
var entities = new[]
{
Entity(loadouts, availabilityFactions, "Anchor Station", "station", -50, -30, 0, 0, "player", 760, keys[6], [keys[1], keys[2], keys[3], keys[4], keys[6], keys[7], keys[11]], ["repair-parts", "reactor-fuel", "drone-core"]),
Entity(loadouts, availabilityFactions, "Vanguard One", "ship", -40, -30, 10, 4, "player", 540, keys[6], [keys[0], keys[2], keys[4], keys[6], keys[7]], ["coilgun-ammo", "field-rations"]),
Entity(loadouts, availabilityFactions, "Vanguard One", "ship", -40, -30, 0, 0, "player", 540, keys[6], [keys[0], keys[2], keys[4], keys[6], keys[7]], ["coilgun-ammo", "field-rations"]),
Entity(loadouts, availabilityFactions, "Wing Two", "ship", 145, 125, -5, 7, "player", 450, keys[6], [keys[0], keys[1], keys[6], keys[8]], ["sensor-buoy", "shield-cell"]),
Entity(loadouts, availabilityFactions, "Torch Three", "ship", -235, 210, 8, -4, "player", 500, keys[7], [keys[0], keys[1], keys[7]], ["micro-missile", "coolant-pack"]),
Entity(loadouts, availabilityFactions, "Foundry Tug", "ship", 330, -155, -2, 3, "player", 390, keys[6], [keys[0], keys[1], keys[6], keys[10]], ["ore-canister", "field-rations"]),
@ -230,6 +230,13 @@ internal static class AetheriaDaemonZoneGenerator
};
foreach (var index in new[] { 1, 2, 3, 4 })
entities[index].HomeEntityKey = keys[0];
entities[1].CargoContents =
[
new AetheriaCargoBayLoadout
{
Items = Array.Empty<AetheriaLoadoutItemSlot>()
}
];
entities[2].AgentTaskCapabilities = ["attack", "defend", "explore"];
entities[3].AgentTaskCapabilities = ["attack", "defend"];
entities[4].AgentTaskCapabilities = ["mine", "haul", "tow", "explore"];

View file

@ -199,13 +199,15 @@ static async Task<AetheriaRuntimeDaemonTickResult> TickAsync(
policyRejectedCommandIds);
var terminus = string.Equals(ingressState.GameMode, AetheriaGameSessionState.TerminusMode, StringComparison.Ordinal);
var simulationClockCommands = authorizedCommands
.Where(command => command.Kind == AetheriaRuntimeDaemonCommandKinds.SetSimulationRate)
.Where(command => command.Kind == AetheriaRuntimeDaemonCommandKinds.SetSimulationRate ||
command.Kind == AetheriaRuntimeDaemonCommandKinds.AdvanceSimulationStep)
.ToArray();
if (!terminus && simulationClockCommands.Length > 0)
{
policyRejectedCommandIds.AddRange(simulationClockCommands.Select(command => command.CommandId));
authorizedCommands = authorizedCommands
.Where(command => command.Kind != AetheriaRuntimeDaemonCommandKinds.SetSimulationRate)
.Where(command => command.Kind != AetheriaRuntimeDaemonCommandKinds.SetSimulationRate &&
command.Kind != AetheriaRuntimeDaemonCommandKinds.AdvanceSimulationStep)
.ToArray();
}
else if (simulationClockCommands.Length > 0)
@ -217,7 +219,7 @@ static async Task<AetheriaRuntimeDaemonTickResult> TickAsync(
if (terminus && !advanceSimulation)
{
authorizedCommands = authorizedCommands
.Where(command => command.Kind == AetheriaRuntimeDaemonCommandKinds.SetSimulationRate)
.Where(command => !AetheriaRuntimeDaemonOperations.RequiresSimulationStep(command.Kind))
.ToArray();
}
var simulationTimeSeconds = (currentFrame?.SimulationTimeSeconds ?? 0) +
@ -369,6 +371,11 @@ static async Task ApplySimulationClockCommandsAsync(
.ReadAsync().ConfigureAwait(false) ?? new AetheriaGameSessionState();
foreach (var command in commands.OrderBy(command => command.IssuedAtUtc, StringComparer.Ordinal))
{
if (command.Kind == AetheriaRuntimeDaemonCommandKinds.AdvanceSimulationStep)
{
ingressState.SimulationStepAccumulator += 1;
continue;
}
if (AetheriaRuntimeDaemonOperations.IsSupportedSimulationRate(command.ScalarValue))
session.SimulationRate = command.ScalarValue;
}
@ -1526,10 +1533,12 @@ static async Task PublishDaemonApiDocumentsAsync(
.ConfigureAwait(false);
var gameSession = await node.MutableDocument<AetheriaGameSessionState>(AetheriaStateNode.GameSessionStateKey)
.ReadAsync().ConfigureAwait(false);
var inputCatalog = AetheriaRuntimeCatalogStore.OpenReadOnly(node.StatePath);
await node.MutableDocument<EveInputCapabilityDocument>(AetheriaRuntimeVerseRecordKeys.PilotInputCapability)
.ReplaceAsync(AetheriaRuntimeInputCapabilityDocument.FromFrame(
result.Frame,
string.Equals(gameSession?.Mode, AetheriaGameSessionState.TerminusMode, StringComparison.Ordinal)).ToEveDocument())
string.Equals(gameSession?.Mode, AetheriaGameSessionState.TerminusMode, StringComparison.Ordinal),
inputCatalog).ToEveDocument())
.ConfigureAwait(false);
var mainMenuState = await node.MutableDocument<AetheriaMainMenuState>(AetheriaStateNode.MainMenuStateKey)
.ReadAsync()
@ -2687,7 +2696,7 @@ static async Task<AetheriaRuntimeRunCheckpointCommit?> ReadRuntimeRunCheckpointA
.ToArray(),
GenerationSeed = run.GenerationSeed,
CurrentEntityKey = run.CurrentEntityKey ?? "",
Credits = 1000
Credits = 1000000
};
}